blob: 6e9208aa77b2dfe30ded688150d127b7fa3cee0e [file] [log] [blame]
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08001# Capstone Disassembler Engine
Nguyen Anh Quynh5311ef22015-06-03 22:21:13 +08002# By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2015
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08003
4LIB = capstone
5FLAGS = '-Wall -Wextra -Wwrite-strings'
6
Wolfgang Schwotzer22b4d0e2017-10-21 15:44:36 +02007all: arm_const.cmxa arm64_const.cmxa m680x_const.cmxa mips_const.cmxa ppc_const.cmxa sparc_const.cmxa sysz_const.cmxa x86_const.cmxa xcore_const.cmxa arm.cmxa arm64.cmxa m680x.cmxa mips.cmxa ppc.cmxa x86.cmxa sparc.cmxa systemz.cmxa xcore.cmxa capstone.cmxa test_basic.cmx test_detail.cmx test_x86.cmx test_arm.cmx test_arm64.cmx test_mips.cmx test_ppc.cmx test_sparc.cmx test_systemz.cmx test_xcore.cmx test_m680x.cmx ocaml.o
Nguyen Anh Quynh5311ef22015-06-03 22:21:13 +08008 ocamlopt -o test_basic -ccopt $(FLAGS) ocaml.o capstone.cmx test_basic.cmx -cclib -l$(LIB)
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08009 ocamlopt -o test_detail -ccopt $(FLAGS) capstone.cmx ocaml.o test_detail.cmx -cclib -l$(LIB)
Nguyen Anh Quynh586be762014-09-21 23:23:38 +080010 ocamlopt -o test_x86 -ccopt $(FLAGS) capstone.cmx ocaml.o x86.cmx x86_const.cmx test_x86.cmx -cclib -l$(LIB)
11 ocamlopt -o test_arm -ccopt $(FLAGS) capstone.cmx ocaml.o arm.cmx arm_const.cmx test_arm.cmx -cclib -l$(LIB)
12 ocamlopt -o test_arm64 -ccopt $(FLAGS) capstone.cmx ocaml.o arm64.cmx arm64_const.cmx test_arm64.cmx -cclib -l$(LIB)
13 ocamlopt -o test_mips -ccopt $(FLAGS) capstone.cmx ocaml.o mips.cmx mips_const.cmx test_mips.cmx -cclib -l$(LIB)
14 ocamlopt -o test_ppc -ccopt $(FLAGS) capstone.cmx ocaml.o ppc.cmx ppc_const.cmx test_ppc.cmx -cclib -l$(LIB)
15 ocamlopt -o test_sparc -ccopt $(FLAGS) capstone.cmx ocaml.o sparc.cmx sparc_const.cmx test_sparc.cmx -cclib -l$(LIB)
16 ocamlopt -o test_systemz -ccopt $(FLAGS) capstone.cmx ocaml.o systemz.cmx sysz_const.cmx test_systemz.cmx -cclib -l$(LIB)
17 ocamlopt -o test_xcore -ccopt $(FLAGS) capstone.cmx ocaml.o xcore.cmx xcore_const.cmx test_xcore.cmx -cclib -l$(LIB)
Wolfgang Schwotzer22b4d0e2017-10-21 15:44:36 +020018 ocamlopt -o test_m680x -ccopt $(FLAGS) capstone.cmx ocaml.o m680x.cmx m680x_const.cmx test_m680x.cmx -cclib -l$(LIB)
Guillaume Jeanneae48c972014-08-19 14:46:06 +020019
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080020
Nguyen Anh Quynh5311ef22015-06-03 22:21:13 +080021test_basic.cmx: test_basic.ml
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080022 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
23
24test_detail.cmx: test_detail.ml
25 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
26
27test_x86.cmx: test_x86.ml
28 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
29
30test_arm.cmx: test_arm.ml
31 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
32
33test_arm64.cmx: test_arm64.ml
34 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
35
36test_mips.cmx: test_mips.ml
37 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
38
Guillaume Jeanneda1c2d02014-06-30 15:59:21 +020039test_ppc.cmx: test_ppc.ml
40 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
41
Guillaume Jeanneae48c972014-08-19 14:46:06 +020042test_sparc.cmx: test_sparc.ml
43 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
44
45test_systemz.cmx: test_systemz.ml
46 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
47
48test_xcore.cmx: test_xcore.ml
49 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
50
Wolfgang Schwotzer22b4d0e2017-10-21 15:44:36 +020051test_m680x.cmx: test_m680x.ml
52 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
53
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080054ocaml.o: ocaml.c
55 ocamlc -ccopt $(FLAGS) -c $<
56
57capstone.mli: capstone.ml
58 ocamlc -ccopt $(FLAGS) -i $< > $@
59
60capstone.cmi: capstone.mli
61 ocamlc -ccopt $(FLAGS) -c $<
62
63capstone.cmx: capstone.ml capstone.cmi
64 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
65
66capstone.cmxa: capstone.cmx
67 ocamlopt -ccopt $(FLAGS) -a -o $@ $< -cclib -lsb_ocaml -cclib -l$(LIB)
68
69x86.mli: x86.ml
70 ocamlc -ccopt $(FLAGS) -i $< > $@
71
72x86.cmi: x86.mli
73 ocamlc -ccopt $(FLAGS) -c $<
74
75x86.cmx: x86.ml x86.cmi
76 ocamlopt -ccopt $(FLAGS) -c $<
77
78x86.cmxa: x86.cmx
79 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
80
Nguyen Anh Quynh586be762014-09-21 23:23:38 +080081x86_const.mli: x86_const.ml
82 ocamlc -ccopt $(FLAGS) -i $< > $@
83
84x86_const.cmi: x86_const.mli
85 ocamlc -ccopt $(FLAGS) -c $<
86
87x86_const.cmx: x86_const.ml x86_const.cmi
88 ocamlopt -ccopt $(FLAGS) -c $<
89
90x86_const.cmxa: x86_const.cmx
91 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
92
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080093arm.mli: arm.ml
94 ocamlc -ccopt $(FLAGS) -i $< > $@
95
96arm.cmi: arm.mli
97 ocamlc -ccopt $(FLAGS) -c $<
98
99arm.cmx: arm.ml arm.cmi
100 ocamlopt -ccopt $(FLAGS) -c $<
101
102arm.cmxa: arm.cmx
103 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
104
Nguyen Anh Quynh586be762014-09-21 23:23:38 +0800105arm_const.mli: arm_const.ml
106 ocamlc -ccopt $(FLAGS) -i $< > $@
107
108arm_const.cmi: arm_const.mli
109 ocamlc -ccopt $(FLAGS) -c $<
110
111arm_const.cmx: arm_const.ml arm_const.cmi
112 ocamlopt -ccopt $(FLAGS) -c $<
113
114arm_const.cmxa: arm_const.cmx
115 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
116
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800117arm64.mli: arm64.ml
118 ocamlc -ccopt $(FLAGS) -i $< > $@
119
120arm64.cmi: arm64.mli
121 ocamlc -ccopt $(FLAGS) -c $<
122
123arm64.cmx: arm64.ml arm64.cmi
124 ocamlopt -ccopt $(FLAGS) -c $<
125
126arm64.cmxa: arm64.cmx
127 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
128
Nguyen Anh Quynh586be762014-09-21 23:23:38 +0800129arm64_const.mli: arm64_const.ml
130 ocamlc -ccopt $(FLAGS) -i $< > $@
131
132arm64_const.cmi: arm64_const.mli
133 ocamlc -ccopt $(FLAGS) -c $<
134
135arm64_const.cmx: arm64_const.ml arm64_const.cmi
136 ocamlopt -ccopt $(FLAGS) -c $<
137
138arm64_const.cmxa: arm64_const.cmx
139 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
140
Wolfgang Schwotzer22b4d0e2017-10-21 15:44:36 +0200141m680x.mli: m680x.ml
142 ocamlc -ccopt $(FLAGS) -i $< > $@
143
144m680x.cmi: m680x.mli
145 ocamlc -ccopt $(FLAGS) -c $<
146
147m680x.cmx: m680x.ml m680x.cmi
148 ocamlopt -ccopt $(FLAGS) -c $<
149
150m680x.cmxa: m680x.cmx
151 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
152
153m680x_const.mli: m680x_const.ml
154 ocamlc -ccopt $(FLAGS) -i $< > $@
155
156m680x_const.cmi: m680x_const.mli
157 ocamlc -ccopt $(FLAGS) -c $<
158
159m680x_const.cmx: m680x_const.ml m680x_const.cmi
160 ocamlopt -ccopt $(FLAGS) -c $<
161
162m680x_const.cmxa: m680x_const.cmx
163 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
164
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800165mips.mli: mips.ml
166 ocamlc -ccopt $(FLAGS) -i $< > $@
167
168mips.cmi: mips.mli
169 ocamlc -ccopt $(FLAGS) -c $<
170
171mips.cmx: mips.ml mips.cmi
172 ocamlopt -ccopt $(FLAGS) -c $<
173
174mips.cmxa: mips.cmx
175 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
176
Nguyen Anh Quynh586be762014-09-21 23:23:38 +0800177mips_const.mli: mips_const.ml
178 ocamlc -ccopt $(FLAGS) -i $< > $@
179
180mips_const.cmi: mips_const.mli
181 ocamlc -ccopt $(FLAGS) -c $<
182
183mips_const.cmx: mips_const.ml mips_const.cmi
184 ocamlopt -ccopt $(FLAGS) -c $<
185
186mips_const.cmxa: mips_const.cmx
187 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
188
Guillaume Jeanneda1c2d02014-06-30 15:59:21 +0200189ppc.mli: ppc.ml
190 ocamlc -ccopt $(FLAGS) -i $< > $@
191
192ppc.cmi: ppc.mli
193 ocamlc -ccopt $(FLAGS) -c $<
194
195ppc.cmx: ppc.ml ppc.cmi
196 ocamlopt -ccopt $(FLAGS) -c $<
197
198ppc.cmxa: ppc.cmx
199 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
200
Nguyen Anh Quynh586be762014-09-21 23:23:38 +0800201ppc_const.mli: ppc_const.ml
202 ocamlc -ccopt $(FLAGS) -i $< > $@
203
204ppc_const.cmi: ppc_const.mli
205 ocamlc -ccopt $(FLAGS) -c $<
206
207ppc_const.cmx: ppc_const.ml ppc_const.cmi
208 ocamlopt -ccopt $(FLAGS) -c $<
209
210ppc_const.cmxa: ppc_const.cmx
211 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
212
Guillaume Jeanneae48c972014-08-19 14:46:06 +0200213sparc.mli: sparc.ml
214 ocamlc -ccopt $(FLAGS) -i $< > $@
215
216sparc.cmi: sparc.mli
217 ocamlc -ccopt $(FLAGS) -c $<
218
219sparc.cmx: sparc.ml sparc.cmi
220 ocamlopt -ccopt $(FLAGS) -c $<
221
222sparc.cmxa: sparc.cmx
223 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
224
Nguyen Anh Quynh586be762014-09-21 23:23:38 +0800225sparc_const.mli: sparc_const.ml
226 ocamlc -ccopt $(FLAGS) -i $< > $@
227
228sparc_const.cmi: sparc_const.mli
229 ocamlc -ccopt $(FLAGS) -c $<
230
231sparc_const.cmx: sparc_const.ml sparc_const.cmi
232 ocamlopt -ccopt $(FLAGS) -c $<
233
234sparc_const.cmxa: sparc_const.cmx
235 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
236
Guillaume Jeanneae48c972014-08-19 14:46:06 +0200237systemz.mli: systemz.ml
238 ocamlc -ccopt $(FLAGS) -i $< > $@
239
240systemz.cmi: systemz.mli
241 ocamlc -ccopt $(FLAGS) -c $<
242
243systemz.cmx: systemz.ml systemz.cmi
244 ocamlopt -ccopt $(FLAGS) -c $<
245
246systemz.cmxa: systemz.cmx
247 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
248
Nguyen Anh Quynh586be762014-09-21 23:23:38 +0800249sysz_const.mli: sysz_const.ml
250 ocamlc -ccopt $(FLAGS) -i $< > $@
251
252sysz_const.cmi: sysz_const.mli
253 ocamlc -ccopt $(FLAGS) -c $<
254
255sysz_const.cmx: sysz_const.ml sysz_const.cmi
256 ocamlopt -ccopt $(FLAGS) -c $<
257
258sysz_const.cmxa: sysz_const.cmx
259 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
260
Guillaume Jeanneae48c972014-08-19 14:46:06 +0200261xcore.mli: xcore.ml
262 ocamlc -ccopt $(FLAGS) -i $< > $@
263
264xcore.cmi: xcore.mli
265 ocamlc -ccopt $(FLAGS) -c $<
266
267xcore.cmx: xcore.ml xcore.cmi
268 ocamlopt -ccopt $(FLAGS) -c $<
269
270xcore.cmxa: xcore.cmx
271 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
272
Nguyen Anh Quynh586be762014-09-21 23:23:38 +0800273xcore_const.mli: xcore_const.ml
274 ocamlc -ccopt $(FLAGS) -i $< > $@
275
276xcore_const.cmi: xcore_const.mli
277 ocamlc -ccopt $(FLAGS) -c $<
278
279xcore_const.cmx: xcore_const.ml xcore_const.cmi
280 ocamlopt -ccopt $(FLAGS) -c $<
281
282xcore_const.cmxa: xcore_const.cmx
283 ocamlopt -ccopt $(FLAGS) -a -o $@ $<
284
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800285clean:
Wolfgang Schwotzer22b4d0e2017-10-21 15:44:36 +0200286 rm -f *.[oa] *.so *.cm[ixoa] *.cmxa *.mli test_basic test_detail test_x86 test_arm test_arm64 test_mips test_ppc test_sparc test_systemz test_xcore test_m680x
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800287
Nguyen Anh Quynh586be762014-09-21 23:23:38 +0800288gen_const:
289 cd .. && python const_generator.py ocaml
290
Wolfgang Schwotzer22b4d0e2017-10-21 15:44:36 +0200291TESTS = test_basic test_detail test_arm test_arm64 test_m680x test_mips test_ppc
Nguyen Anh Quynh984d4502014-10-01 16:42:29 +0800292TESTS += test_sparc test_systemz test_x86 test_xcore
293check:
294 @for t in $(TESTS); do \
295 echo Check $$t ... ; \
296 ./$$t > /dev/null && echo OK || echo FAILED; \
297 done
298