-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
97 lines (72 loc) · 2.76 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
SHELL := /bin/bash
BUILD := release
TOOLSET := gcc
build_dir := ${CURDIR}/${BUILD}/${TOOLSET}
CXX.gcc := g++
CC.gcc := gcc
LD.gcc := g++
AR.gcc := gcc-ar
CXX.gcc-8 := g++-8
CC.gcc-8 := gcc-8
LD.gcc-8 := g++-8
AR.gcc-8 := gcc-ar-8
CXX.clang := clang++
CC.clang := clang
LD.clang := clang++
AR.clang := ar
CXX := ${CXX.${TOOLSET}}
CC := ${CC.${TOOLSET}}
LD := ${LD.${TOOLSET}}
AR := ${AR.${TOOLSET}}
CXXFLAGS.gcc.debug := -Og -fstack-protector-all -fno-omit-frame-pointer # -D_GLIBCXX_DEBUG
CXXFLAGS.gcc.release := -O3 -march=native -ffast-math -DNDEBUG
CXXFLAGS.gcc := -pthread -std=gnu++17 -march=native -W{all,extra,error} -g -fmessage-length=0 ${CXXFLAGS.gcc.${BUILD}}
CXXFLAGS.gcc-8 := ${CXXFLAGS.gcc}
CFLAGS.gcc := -pthread -march=native -W{all,extra} -g -fmessage-length=0 ${CXXFLAGS.gcc.${BUILD}}
CFLAGS.gcc-8 := ${CFLAGS.gcc}
CXXFLAGS.clang.debug := -O0 -fstack-protector-all
CXXFLAGS.clang.release := -O3 -march=native -ffast-math -DNDEBUG
CXXFLAGS.clang := -pthread -std=gnu++17 -march=native -W{all,extra,error} -g -fmessage-length=0 ${CXXFLAGS.clang.${BUILD}}
CXXFLAGS := ${CXXFLAGS.${TOOLSET}}
CFLAGS := ${CFLAGS.${TOOLSET}}
CPPFLAGS :=
#LDFLAGS.gcc := -L${gcc_dir}/lib64 -Wl,-rpath=${gcc_dir}/lib64
LDFLAGS.debug :=
LDFLAGS.release :=
LDFLAGS := -fuse-ld=gold -pthread -g ${LDFLAGS.${BUILD}} ${LDFLAGS.${TOOLSET}}
LDLIBS := -lrt
COMPILE.CXX = ${CXX} -c -o $@ ${CPPFLAGS} -MD -MP ${CXXFLAGS} $(abspath $<)
COMPILE.S = ${CXX} -S -masm=intel -o- ${CPPFLAGS} ${CXXFLAGS} $(abspath $<) | c++filt > $@
PREPROCESS.CXX = ${CXX} -E -o $@ ${CPPFLAGS} ${CXXFLAGS} $(abspath $<)
COMPILE.C = ${CC} -c -o $@ ${CPPFLAGS} -MD -MP ${CFLAGS} $(abspath $<)
LINK.EXE = ${LD} -o $@ $(LDFLAGS) $(filter-out Makefile,$^) $(LDLIBS)
LINK.SO = ${LD} -shared -o $@ $(LDFLAGS) $(filter-out Makefile,$^) $(LDLIBS)
LINK.A = ${AR} rsc $@ $(filter-out Makefile,$^)
all : ${build_dir}/parse_integers_fast
${build_dir} :
mkdir -p $@
${build_dir}/parse_integers_fast : ${build_dir}/parse_integers_fast.o Makefile | ${build_dir}
$(strip ${LINK.EXE})
-include ${build_dir}/parse_integers_fast.d
${build_dir}/%.so : CXXFLAGS += -fPIC
${build_dir}/%.so : Makefile | ${build_dir}
$(strip ${LINK.SO})
${build_dir}/%.a : Makefile | ${build_dir}
$(strip ${LINK.A})
random_ints_1600000.txt :
echo 1600000 0 >$@
od --address-radix=n --read-bytes=$$((1600000*4)) --format=d4 /dev/urandom >>$@
run_parse_integers_fast : ${build_dir}/parse_integers_fast | random_ints_1600000.txt
@echo "---- running $< ----"
$<
${build_dir}/%.o : %.cc Makefile | ${build_dir}
$(strip ${COMPILE.CXX})
${build_dir}/%.o : %.c Makefile | ${build_dir}
$(strip ${COMPILE.C})
%.S : %.cc Makefile | ${build_dir}
$(strip ${COMPILE.S})
%.I : %.cc
$(strip ${PREPROCESS.CXX})
clean :
rm -rf ${build_dir}
.PHONY : clean all run_parse_integers_fast run_%