Commit 924d87de authored by nagayama15's avatar nagayama15

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

parent ec7ff7bf
......@@ -5,10 +5,5 @@
README.md
LICENSE
*.a
*.so
*.o
*.ll
*.s
test_*
bin/
obj/
*.a
*.so
*.o
*.ll
*.s
test_*
bin/
obj/
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 := \
-std=c++17 \
-Wall \
-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
test:
${MAKE} -C src test
${MAKE} -C test 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:
${MAKE} -C test clean
${MAKE} -C example clean
${RM} *.so src/*/*.o src/*/*/*.o
${RM} -r bin obj
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
all:
${MAKE} -C fizzbuzz
${MAKE} -C 8cc
${MAKE} -C fizzbuzz all
# ${MAKE} -C 8cc all
test:
${MAKE} -C fizzbuzz test
${MAKE} -C 8cc test
clean:
${MAKE} -C fizzbuzz clean
${MAKE} -C 8cc clean
# ${MAKE} -C 8cc test
include ../../common.mk
SRCS := \
fizzbuzz.c
LLS := ${SRCS:.c=.ll}
LLS_0 := ${SRCS:%.c=%-0.ll}
LLS_1 := ${SRCS:%.c=%-1.ll}
LLS_2 := ${SRCS:%.c=%-2.ll}
BINS := ${LLS:.ll=} ${LLS_0:.ll=} ${LLS_1:.ll=} ${LLS_2:.ll=}
.PHONY: all test clean
LLS := ${SRCS:%.c=${OBJ_DIR}/%.ll}
LLS_0 := ${LLS:%.ll=%-0.ll}
LLS_1 := ${LLS:%.ll=%-1.ll}
LLS_2 := ${LLS:%.ll=%-2.ll}
BINS := \
${LLS:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${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}
test: ${BINS}
./fizzbuzz > fizzbuzz.txt
./fizzbuzz-0 > fizzbuzz-0.txt
./fizzbuzz-1 > fizzbuzz-1.txt
./fizzbuzz-2 > fizzbuzz-2.txt
for i in ${BINS}; \
do $$i > $$i.txt; \
done
${BINS}: ${LLS} ${LLS_0} ${LLS_1} ${LLS_2}
%.ll: %.c
${OBJ_DIR}/%.ll: %.c
@mkdir -p ${@D}
clang -emit-llvm -S -O2 -o $@ $<
%-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
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
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 $@ $<
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 := \
-std=c++17 \
-Wall \
-Wextra \
-pedantic \
-Werror \
-fPIC
TARGET := test_pass.out
SRCS := \
Test.cpp
LDFLAGS :=
include ../cxx.mk
.PHONY: all run clean
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
test: ${BIN_DIR}/${TARGET}
$<
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