1- # CC=clang
2- # CXX=clang++
1+ # ########################################################################
2+ # BUILD COMMON
3+ # ########################################################################
34
45CXXFLAGS = -std=c++11 -Wall -Wno-reorder -fPIC -pie -march=native \
56 -DVERSION=$(shell cat VERSION) -Wl,-rpath=/usr/share/e9tool/lib/
@@ -38,44 +39,32 @@ E9TOOL_LIBS=\
3839 contrib/libdw/libdw.a
3940E9TOOL_CXXFLAGS =\
4041 -I src/e9tool/ -Wno-unused-function \
41- -I contrib/libdw/ \
4242 -I contrib/zydis/include/ \
4343 -I contrib/zydis/dependencies/zycore/include/
4444E9TOOL_LDFLAGS =\
4545 -Wl,--dynamic-list=src/e9tool/e9tool.syms \
46- -lpthread - ldl -lz
46+ -ldl -lz
4747
48- release : CXXFLAGS += -O2 -D NDEBUG
49- release : $(E9PATCH_OBJS )
50- $(CXX ) $(CXXFLAGS ) $(E9PATCH_OBJS ) -o e9patch
51- strip e9patch
48+ # ########################################################################
49+ # CONVENTIONAL BUILD
50+ # ########################################################################
5251
53- debug : CXXFLAGS += -O0 -g
54- debug : $(E9PATCH_OBJS )
55- $(CXX ) $(CXXFLAGS ) $(E9PATCH_OBJS ) -o e9patch
52+ all : e9tool e9patch
5653
57- sanitize : CXXFLAGS += -O0 -g -fsanitize=address
58- sanitize : $(E9PATCH_OBJS )
59- $(CXX ) $(CXXFLAGS ) $(E9PATCH_OBJS ) -o e9patch
60-
61- tool : CXXFLAGS += -O2 $(E9TOOL_CXXFLAGS )
62- tool : $(E9TOOL_OBJS ) $(E9TOOL_LIBS )
63- $(CXX ) $(CXXFLAGS ) $(E9TOOL_OBJS ) $(E9TOOL_LIBS ) -o e9tool \
64- $(E9TOOL_LDFLAGS) -Wl,-Map=output.map
54+ e9tool : CXXFLAGS += -O2 -DSYSTEM_LIBDW $(E9TOOL_CXXFLAGS )
55+ e9tool : contrib/zydis/libZydis.a $(E9TOOL_OBJS )
56+ $(CXX ) $(CXXFLAGS ) $(E9TOOL_OBJS ) contrib/zydis/libZydis.a -o e9tool \
57+ $(E9TOOL_LDFLAGS ) -ldw
6558 strip e9tool
6659
67- tool.debug : CXXFLAGS += -O0 -g $(E9TOOL_CXXFLAGS )
68- tool.debug : $(E9TOOL_OBJS ) $(E9TOOL_LIBS )
69- $(CXX ) $(CXXFLAGS ) $(E9TOOL_OBJS ) $(E9TOOL_LIBS ) -o e9tool \
70- $(E9TOOL_LDFLAGS)
71-
72- tool.sanitize : CXXFLAGS += -O0 -g -fsanitize=address $(E9TOOL_CXXFLAGS )
73- tool.sanitize : $(E9TOOL_OBJS ) $(E9TOOL_LIBS )
74- $(CXX ) $(CXXFLAGS ) $(E9TOOL_OBJS ) $(E9TOOL_LIBS ) -o e9tool \
75- $(E9TOOL_LDFLAGS)
60+ e9patch : CXXFLAGS += -O2
61+ e9patch : $(E9PATCH_OBJS )
62+ $(CXX ) $(CXXFLAGS ) $(E9PATCH_OBJS ) -o e9patch
63+ strip e9patch
7664
77- tool.clean :
78- rm -rf $(E9TOOL_OBJS ) e9tool
65+ clean :
66+ rm -rf $(E9PATCH_OBJS ) $(E9TOOL_OBJS ) e9patch e9tool \
67+ src/e9patch/e9loader.c e9loader.out e9loader.o e9loader.bin
7968
8069loader_elf :
8170 $(CXX ) -std=c++11 -Wall -fno-stack-protector -Wno-unused-function -fPIC \
@@ -99,7 +88,96 @@ contrib/zydis/libZydis.a:
9988contrib/libdw/libdw.a :
10089 (cd contrib/libdw/; make)
10190
102- clean :
103- rm -rf $(E9PATCH_OBJS ) e9patch \
104- src/e9patch/e9loader.c e9loader.out e9loader.o e9loader.bin
91+ install : all
92+ install -d " $( DESTDIR) /usr/bin"
93+ install -m 755 e9patch " $( DESTDIR) /usr/bin/e9patch"
94+ install -m 755 e9tool " $( DESTDIR) /usr/bin/e9tool"
95+ install -m 755 e9compile.sh " $( DESTDIR) /usr/bin/e9compile"
96+ sed \
97+ -e ' s/-I example/-I \/usr\/share\/e9compile\/include/g' e9compile.sh > \
98+ " $( DESTDIR) /usr/bin/e9compile"
99+ chmod 555 " $( DESTDIR) /usr/bin/e9compile"
100+ install -d " $( DESTDIR) /usr/share/doc/e9patch/"
101+ sed \
102+ -e ' s/https:\/\/github.com\/GJDuck\/e9patch\/blob\/master\/doc\/e9tool-user-guide.md/file:\/\/\/usr\/share\/doc\/e9tool\/e9tool-user-guide.html/g' \
103+ -e ' s/https:\/\/github.com\/GJDuck\/e9patch\/tree\/master\/examples/file:\/\/\/usr\/share\/e9tool\/examples/g' \
104+ doc/e9patch-programming-guide.md | markdown > \
105+ " $( DESTDIR) /usr/share/doc/e9patch/e9patch-programming-guide.html"
106+ install -m 444 LICENSE " $( DESTDIR) /usr/share/doc/e9patch/LICENSE"
107+ install -d " $( DESTDIR) /usr/share/doc/e9tool/"
108+ sed \
109+ -e 's/https :\/\/github.com\/GJDuck\/e9patch\/blob\/master\/doc\/e9patch-programming-guide.md/file:\/\/\/usr\/share\/doc\/e9patch\/e9patch-programming-guide.html/g' \
110+ doc/e9tool-user-guide.md | markdown > \
111+ "$(DESTDIR)/usr/share/doc/e9tool/e9tool-user-guide.html"
112+ install -m 444 LICENSE "$(DESTDIR)/usr/share/doc/e9tool/LICENSE"
113+ install -d "$(DESTDIR)/usr/share/e9tool/include/"
114+ install -m 444 src/e9tool/e9tool.h "$(DESTDIR)/usr/share/e9tool/include/e9tool.h"
115+ install -m 444 src/e9tool/e9plugin.h "$(DESTDIR)/usr/share/e9tool/include/e9plugin.h"
116+ install -d "$(DESTDIR)/usr/share/e9tool/examples/"
117+ install -m 444 examples/bounds.c "$(DESTDIR)/usr/share/e9tool/examples/bounds.c"
118+ sed \
119+ -e 's/.\/e9compile.sh examples\/bounds.c/e9compile \/usr\/share\/e9tool\/examples\/bounds.c/' \
120+ -e 's/\.\/e9tool/e9tool/' \
121+ examples/bounds.sh > \
122+ "$(DESTDIR)/usr/share/e9tool/examples/bounds.sh"
123+ chmod 555 "$(DESTDIR)/usr/share/e9tool/examples/bounds.sh"
124+ install -m 444 examples/cfi.c "$(DESTDIR)/usr/share/e9tool/examples/cfi.c"
125+ install -m 444 examples/count.c "$(DESTDIR)/usr/share/e9tool/examples/count.c"
126+ install -m 444 examples/cov.c "$(DESTDIR)/usr/share/e9tool/examples/cov.c"
127+ install -m 444 examples/delay.c "$(DESTDIR)/usr/share/e9tool/examples/delay.c"
128+ install -m 444 examples/hello.c "$(DESTDIR)/usr/share/e9tool/examples/hello.c"
129+ install -m 444 examples/limit.c "$(DESTDIR)/usr/share/e9tool/examples/limit.c"
130+ install -m 444 examples/nop.c "$(DESTDIR)/usr/share/e9tool/examples/nop.c"
131+ install -m 444 examples/print.c "$(DESTDIR)/usr/share/e9tool/examples/print.c"
132+ install -m 444 examples/printf.c "$(DESTDIR)/usr/share/e9tool/examples/printf.c"
133+ install -m 444 examples/skip.c "$(DESTDIR)/usr/share/e9tool/examples/skip.c"
134+ install -m 444 examples/state.c "$(DESTDIR)/usr/share/e9tool/examples/state.c"
135+ install -m 444 examples/trap.c "$(DESTDIR)/usr/share/e9tool/examples/trap.c"
136+ install -m 444 examples/win64_demo.c "$(DESTDIR)/usr/share/e9tool/examples/win64_demo.c"
137+ install -d "$(DESTDIR)/usr/share/e9tool/examples/plugins/"
138+ install -m 444 examples/plugins/example.cpp "$(DESTDIR)/usr/share/e9tool/examples/plugins/example.cpp"
139+ install -d "$(DESTDIR)/usr/share/e9compile/include/"
140+ install -m 444 examples/stdlib.c "$(DESTDIR)/usr/share/e9compile/include/stdlib.c"
141+ install -m 444 src/e9patch/e9loader.h "$(DESTDIR)/usr/share/e9compile/include/e9loader.h"
142+ install -d "$(DESTDIR)/usr/share/man/man1/"
143+ gzip --stdout doc/e9patch.1 > "$(DESTDIR)/usr/share/man/man1/e9patch.1.gz"
144+ chmod 444 "$(DESTDIR)/usr/share/man/man1/e9patch.1.gz"
145+ gzip --stdout doc/e9tool.1 > "$(DESTDIR)/usr/share/man/man1/e9tool.1.gz"
146+ chmod 444 "$(DESTDIR)/usr/share/man/man1/e9tool.1.gz"
147+ gzip --stdout doc/e9compile.1 > "$(DESTDIR)/usr/share/man/man1/e9compile.1.gz"
148+ chmod 444 "$(DESTDIR)/usr/share/man/man1/e9compile.1.gz"
149+
150+ # ########################################################################
151+ # SPECIAL BUILD
152+ # ########################################################################
153+
154+ release : CXXFLAGS += -O2 -D NDEBUG
155+ release : $(E9PATCH_OBJS )
156+ $(CXX ) $(CXXFLAGS ) $(E9PATCH_OBJS ) -o e9patch
157+ strip e9patch
158+
159+ debug : CXXFLAGS += -O0 -g
160+ debug : $(E9PATCH_OBJS )
161+ $(CXX ) $(CXXFLAGS ) $(E9PATCH_OBJS ) -o e9patch
162+
163+ sanitize : CXXFLAGS += -O0 -g -fsanitize=address
164+ sanitize : $(E9PATCH_OBJS )
165+ $(CXX ) $(CXXFLAGS ) $(E9PATCH_OBJS ) -o e9patch
166+
167+ tool : CXXFLAGS += -O2 $(E9TOOL_CXXFLAGS ) -I contrib/libdw/
168+ tool : $(E9TOOL_OBJS ) $(E9TOOL_LIBS )
169+ $(CXX ) $(CXXFLAGS ) $(E9TOOL_OBJS ) $(E9TOOL_LIBS ) -o e9tool \
170+ $(E9TOOL_LDFLAGS)
171+ strip e9tool
172+
173+ tool.debug : CXXFLAGS += -O0 -g $(E9TOOL_CXXFLAGS ) -I contrib/libdw/
174+ tool.debug : $(E9TOOL_OBJS ) $(E9TOOL_LIBS )
175+ $(CXX ) $(CXXFLAGS ) $(E9TOOL_OBJS ) $(E9TOOL_LIBS ) -o e9tool \
176+ $(E9TOOL_LDFLAGS)
177+
178+ tool.sanitize : CXXFLAGS += -O0 -g -fsanitize=address $(E9TOOL_CXXFLAGS ) \
179+ -I contrib/libdw/
180+ tool.sanitize : $(E9TOOL_OBJS ) $(E9TOOL_LIBS )
181+ $(CXX ) $(CXXFLAGS ) $(E9TOOL_OBJS ) $(E9TOOL_LIBS ) -o e9tool \
182+ $(E9TOOL_LDFLAGS)
105183
0 commit comments