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