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