Commit 924d87de authored by nagayama15's avatar nagayama15

Makefileの出力ディレクトリ構造を変更

parent ec7ff7bf
...@@ -5,10 +5,5 @@ ...@@ -5,10 +5,5 @@
README.md README.md
LICENSE LICENSE
*.a bin/
*.so obj/
*.o
*.ll
*.s
test_*
*.a bin/
*.so obj/
*.o
*.ll
*.s
test_*
LLVM_INCLUDE_DIRS := $(shell llvm-config --includedir) .PHONY: all test clean
CXX := g++ all:
${MAKE} -C src all
${MAKE} -C test all
${MAKE} -C example all
CXXFLAGS := \ test:
-std=c++17 \ ${MAKE} -C src test
-Wall \ ${MAKE} -C test test
-Wextra \
-pedantic \
-Werror \
${LLVM_INCLUDE_DIRS:%=-I%} \
-fPIC \
-fno-rtti
LDFLAGS := \
$(shell llvm-config --ldflags)
.PHONY: all test example clean
all: nykk.so example
test: nykk.so
${MAKE} -C test run
${MAKE} -C example test ${MAKE} -C example test
example: nykk.so
${MAKE} -C example
nykk.so: \
src/nykk/pass/TestPass.o \
src/nykk/pass/BlockCounterPass.o \
src/nykk/pass/BlockWatermarkPass.o
src/nykk/pass/BlockWatermarkPass.o: \
src/nykk/pass/BlockWatermarkPass.cpp \
src/nykk/PermutationTable.hpp
%.so:
${CXX} ${CXXFLAGS} -shared -o $@ $^ ${LDFLAGS}
clean: clean:
${MAKE} -C test clean ${RM} -r bin obj
${MAKE} -C example clean
${RM} *.so src/*/*.o src/*/*/*.o
ROOT := $(realpath ${PWD})
CD := $(realpath ${CURDIR})
BIN_DIR := ${ROOT}/bin/${CD:${ROOT}/%=%}
OBJ_DIR := ${ROOT}/obj/${CD:${ROOT}/%=%}
.PHONY: all test clean
include ${PWD}/common.mk
LLVM_INCLUDE_DIRS := $(shell llvm-config --includedir)
CXXFLAGS := \
-std=c++17 \
-Wall \
-Wextra \
-pedantic \
-Werror \
$(addprefix -I, $(shell llvm-config --includedir)) \
-fPIC \
-fno-rtti
LDFLAGS := \
$(shell llvm-config --ldflags)
OBJS := ${SRCS:%.cpp=${OBJ_DIR}/%.o}
DEPS := ${OBJS:.o=.d}
all: ${BIN_DIR}/${TARGET}
test: ${BIN_DIR}/${TARGET}
${BIN_DIR}/${TARGET}: ${OBJS}
%.so:
@mkdir -p ${@D}
${CXX} ${CXXFLAGS} -shared -o $@ $^ ${LDFLAGS}
%.out:
@mkdir -p ${@D}
${CXX} ${CXXFLAGS} -o $@ $^ ${LDFLAGS}
${OBJ_DIR}/%.o: %.cpp
@mkdir -p ${@D}
${CXX} ${CXXFLAGS} -o $@ -c $^
.PHONY: all test clean .PHONY: all test clean
all: all:
${MAKE} -C fizzbuzz ${MAKE} -C fizzbuzz all
${MAKE} -C 8cc # ${MAKE} -C 8cc all
test: test:
${MAKE} -C fizzbuzz test ${MAKE} -C fizzbuzz test
${MAKE} -C 8cc test # ${MAKE} -C 8cc test
clean:
${MAKE} -C fizzbuzz clean
${MAKE} -C 8cc clean
include ../../common.mk
SRCS := \ SRCS := \
fizzbuzz.c fizzbuzz.c
LLS := ${SRCS:.c=.ll} LLS := ${SRCS:%.c=${OBJ_DIR}/%.ll}
LLS_0 := ${SRCS:%.c=%-0.ll} LLS_0 := ${LLS:%.ll=%-0.ll}
LLS_1 := ${SRCS:%.c=%-1.ll} LLS_1 := ${LLS:%.ll=%-1.ll}
LLS_2 := ${SRCS:%.c=%-2.ll} LLS_2 := ${LLS:%.ll=%-2.ll}
BINS := ${LLS:.ll=} ${LLS_0:.ll=} ${LLS_1:.ll=} ${LLS_2:.ll=} BINS := \
${LLS:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
.PHONY: all test clean ${LLS_0:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_1:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_2:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out}
all: ${BINS} all: ${BINS}
test: ${BINS} test: ${BINS}
./fizzbuzz > fizzbuzz.txt for i in ${BINS}; \
./fizzbuzz-0 > fizzbuzz-0.txt do $$i > $$i.txt; \
./fizzbuzz-1 > fizzbuzz-1.txt done
./fizzbuzz-2 > fizzbuzz-2.txt
${BINS}: ${LLS} ${LLS_0} ${LLS_1} ${LLS_2} ${BINS}: ${LLS} ${LLS_0} ${LLS_1} ${LLS_2}
%.ll: %.c ${OBJ_DIR}/%.ll: %.c
@mkdir -p ${@D}
clang -emit-llvm -S -O2 -o $@ $< clang -emit-llvm -S -O2 -o $@ $<
%-0.ll: %.ll %-0.ll: %.ll
opt -load=../../nykk.so -block-wm -watermark=0 -S -o $@ $< opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=0 -S -o $@ $<
%-1.ll: %.ll %-1.ll: %.ll
opt -load=../../nykk.so -block-wm -watermark=1 -S -o $@ $< opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=1 -S -o $@ $<
%-2.ll: %.ll %-2.ll: %.ll
opt -load=../../nykk.so -block-wm -watermark=2 -S -o $@ $< opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=2 -S -o $@ $<
%: %.ll ${BIN_DIR}/%.out: ${OBJ_DIR}/%.ll
@mkdir -p ${@D}
clang -o $@ $< clang -o $@ $<
clean:
${RM} ${BINS} *.ll *.txt
TARGET := nykk.so
SRCS := \
nykk/pass/BlockCounterPass.cpp \
nykk/pass/BlockWatermarkPass.cpp \
nykk/pass/TestPass.cpp
include ../cxx.mk
CXXFLAGS := \ TARGET := test_pass.out
-std=c++17 \ SRCS := \
-Wall \ Test.cpp
-Wextra \
-pedantic \
-Werror \
-fPIC
LDFLAGS := include ../cxx.mk
.PHONY: all run clean test: ${BIN_DIR}/${TARGET}
$<
all: test_pass
run: test_pass
./test_pass
test_pass: Test.o
${CXX} ${CXXFLAGS} -o $@ $^ ${LDFLAGS}
Test.o: \
Test.cpp \
TestPermutationTable.hpp \
../src/nykk/PermutationTable.hpp
clean:
${RM} test_pass *.o
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment