1# Capstone Disassembler Engine 2# By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> 3 4LIB = capstone 5FLAGS = '-Wall -Wextra -Wwrite-strings' 6 7all: arm_const.cmxa arm64_const.cmxa mips_const.cmxa ppc_const.cmxa sparc_const.cmxa sysz_const.cmxa x86_const.cmxa xcore_const.cmxa arm.cmxa arm64.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 ocaml.o 8 ocamlopt -o test_basic -ccopt $(FLAGS) ocaml.o capstone.cmx test_basic.cmx -cclib -l$(LIB) 9 ocamlopt -o test_detail -ccopt $(FLAGS) capstone.cmx ocaml.o test_detail.cmx -cclib -l$(LIB) 10 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) 18 19 20test_basic.cmx: test_basic.ml 21 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 22 23test_detail.cmx: test_detail.ml 24 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 25 26test_x86.cmx: test_x86.ml 27 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 28 29test_arm.cmx: test_arm.ml 30 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 31 32test_arm64.cmx: test_arm64.ml 33 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 34 35test_mips.cmx: test_mips.ml 36 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 37 38test_ppc.cmx: test_ppc.ml 39 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 40 41test_sparc.cmx: test_sparc.ml 42 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 43 44test_systemz.cmx: test_systemz.ml 45 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 46 47test_xcore.cmx: test_xcore.ml 48 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 49 50ocaml.o: ocaml.c 51 ocamlc -ccopt $(FLAGS) -c $< 52 53capstone.mli: capstone.ml 54 ocamlc -ccopt $(FLAGS) -i $< > $@ 55 56capstone.cmi: capstone.mli 57 ocamlc -ccopt $(FLAGS) -c $< 58 59capstone.cmx: capstone.ml capstone.cmi 60 ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB) 61 62capstone.cmxa: capstone.cmx 63 ocamlopt -ccopt $(FLAGS) -a -o $@ $< -cclib -lsb_ocaml -cclib -l$(LIB) 64 65x86.mli: x86.ml 66 ocamlc -ccopt $(FLAGS) -i $< > $@ 67 68x86.cmi: x86.mli 69 ocamlc -ccopt $(FLAGS) -c $< 70 71x86.cmx: x86.ml x86.cmi 72 ocamlopt -ccopt $(FLAGS) -c $< 73 74x86.cmxa: x86.cmx 75 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 76 77x86_const.mli: x86_const.ml 78 ocamlc -ccopt $(FLAGS) -i $< > $@ 79 80x86_const.cmi: x86_const.mli 81 ocamlc -ccopt $(FLAGS) -c $< 82 83x86_const.cmx: x86_const.ml x86_const.cmi 84 ocamlopt -ccopt $(FLAGS) -c $< 85 86x86_const.cmxa: x86_const.cmx 87 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 88 89arm.mli: arm.ml 90 ocamlc -ccopt $(FLAGS) -i $< > $@ 91 92arm.cmi: arm.mli 93 ocamlc -ccopt $(FLAGS) -c $< 94 95arm.cmx: arm.ml arm.cmi 96 ocamlopt -ccopt $(FLAGS) -c $< 97 98arm.cmxa: arm.cmx 99 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 100 101arm_const.mli: arm_const.ml 102 ocamlc -ccopt $(FLAGS) -i $< > $@ 103 104arm_const.cmi: arm_const.mli 105 ocamlc -ccopt $(FLAGS) -c $< 106 107arm_const.cmx: arm_const.ml arm_const.cmi 108 ocamlopt -ccopt $(FLAGS) -c $< 109 110arm_const.cmxa: arm_const.cmx 111 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 112 113arm64.mli: arm64.ml 114 ocamlc -ccopt $(FLAGS) -i $< > $@ 115 116arm64.cmi: arm64.mli 117 ocamlc -ccopt $(FLAGS) -c $< 118 119arm64.cmx: arm64.ml arm64.cmi 120 ocamlopt -ccopt $(FLAGS) -c $< 121 122arm64.cmxa: arm64.cmx 123 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 124 125arm64_const.mli: arm64_const.ml 126 ocamlc -ccopt $(FLAGS) -i $< > $@ 127 128arm64_const.cmi: arm64_const.mli 129 ocamlc -ccopt $(FLAGS) -c $< 130 131arm64_const.cmx: arm64_const.ml arm64_const.cmi 132 ocamlopt -ccopt $(FLAGS) -c $< 133 134arm64_const.cmxa: arm64_const.cmx 135 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 136 137mips.mli: mips.ml 138 ocamlc -ccopt $(FLAGS) -i $< > $@ 139 140mips.cmi: mips.mli 141 ocamlc -ccopt $(FLAGS) -c $< 142 143mips.cmx: mips.ml mips.cmi 144 ocamlopt -ccopt $(FLAGS) -c $< 145 146mips.cmxa: mips.cmx 147 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 148 149mips_const.mli: mips_const.ml 150 ocamlc -ccopt $(FLAGS) -i $< > $@ 151 152mips_const.cmi: mips_const.mli 153 ocamlc -ccopt $(FLAGS) -c $< 154 155mips_const.cmx: mips_const.ml mips_const.cmi 156 ocamlopt -ccopt $(FLAGS) -c $< 157 158mips_const.cmxa: mips_const.cmx 159 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 160 161ppc.mli: ppc.ml 162 ocamlc -ccopt $(FLAGS) -i $< > $@ 163 164ppc.cmi: ppc.mli 165 ocamlc -ccopt $(FLAGS) -c $< 166 167ppc.cmx: ppc.ml ppc.cmi 168 ocamlopt -ccopt $(FLAGS) -c $< 169 170ppc.cmxa: ppc.cmx 171 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 172 173ppc_const.mli: ppc_const.ml 174 ocamlc -ccopt $(FLAGS) -i $< > $@ 175 176ppc_const.cmi: ppc_const.mli 177 ocamlc -ccopt $(FLAGS) -c $< 178 179ppc_const.cmx: ppc_const.ml ppc_const.cmi 180 ocamlopt -ccopt $(FLAGS) -c $< 181 182ppc_const.cmxa: ppc_const.cmx 183 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 184 185sparc.mli: sparc.ml 186 ocamlc -ccopt $(FLAGS) -i $< > $@ 187 188sparc.cmi: sparc.mli 189 ocamlc -ccopt $(FLAGS) -c $< 190 191sparc.cmx: sparc.ml sparc.cmi 192 ocamlopt -ccopt $(FLAGS) -c $< 193 194sparc.cmxa: sparc.cmx 195 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 196 197sparc_const.mli: sparc_const.ml 198 ocamlc -ccopt $(FLAGS) -i $< > $@ 199 200sparc_const.cmi: sparc_const.mli 201 ocamlc -ccopt $(FLAGS) -c $< 202 203sparc_const.cmx: sparc_const.ml sparc_const.cmi 204 ocamlopt -ccopt $(FLAGS) -c $< 205 206sparc_const.cmxa: sparc_const.cmx 207 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 208 209systemz.mli: systemz.ml 210 ocamlc -ccopt $(FLAGS) -i $< > $@ 211 212systemz.cmi: systemz.mli 213 ocamlc -ccopt $(FLAGS) -c $< 214 215systemz.cmx: systemz.ml systemz.cmi 216 ocamlopt -ccopt $(FLAGS) -c $< 217 218systemz.cmxa: systemz.cmx 219 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 220 221sysz_const.mli: sysz_const.ml 222 ocamlc -ccopt $(FLAGS) -i $< > $@ 223 224sysz_const.cmi: sysz_const.mli 225 ocamlc -ccopt $(FLAGS) -c $< 226 227sysz_const.cmx: sysz_const.ml sysz_const.cmi 228 ocamlopt -ccopt $(FLAGS) -c $< 229 230sysz_const.cmxa: sysz_const.cmx 231 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 232 233xcore.mli: xcore.ml 234 ocamlc -ccopt $(FLAGS) -i $< > $@ 235 236xcore.cmi: xcore.mli 237 ocamlc -ccopt $(FLAGS) -c $< 238 239xcore.cmx: xcore.ml xcore.cmi 240 ocamlopt -ccopt $(FLAGS) -c $< 241 242xcore.cmxa: xcore.cmx 243 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 244 245xcore_const.mli: xcore_const.ml 246 ocamlc -ccopt $(FLAGS) -i $< > $@ 247 248xcore_const.cmi: xcore_const.mli 249 ocamlc -ccopt $(FLAGS) -c $< 250 251xcore_const.cmx: xcore_const.ml xcore_const.cmi 252 ocamlopt -ccopt $(FLAGS) -c $< 253 254xcore_const.cmxa: xcore_const.cmx 255 ocamlopt -ccopt $(FLAGS) -a -o $@ $< 256 257clean: 258 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 259 260gen_const: 261 cd .. && python const_generator.py ocaml 262 263TESTS = test_basic test_detail test_arm test_arm64 test_mips test_ppc 264TESTS += test_sparc test_systemz test_x86 test_xcore 265check: 266 @for t in $(TESTS); do \ 267 echo Check $$t ... ; \ 268 ./$$t > /dev/null && echo OK || echo FAILED; \ 269 done 270 271