Update capstone
[WebKit-https.git] / Source / ThirdParty / capstone / Source / Makefile
1 # Capstone Disassembly Engine
2 # By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014
3
4 include config.mk
5 include pkgconfig.mk    # package version
6 include functions.mk
7
8 # Verbose output?
9 V ?= 0
10
11 OS := $(shell uname)
12 ifeq ($(OS),Darwin)
13 LIBARCHS ?= x86_64
14 PREFIX ?= /usr/local
15 endif
16
17 ifeq ($(PKG_EXTRA),)
18 PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR)
19 else
20 PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA)
21 endif
22
23 ifeq ($(CROSS),)
24 RANLIB ?= ranlib
25 else ifeq ($(ANDROID), 1)
26 CC = $(CROSS)/../../bin/clang
27 AR = $(CROSS)/ar
28 RANLIB = $(CROSS)/ranlib
29 STRIP = $(CROSS)/strip
30 else
31 CC = $(CROSS)gcc
32 AR = $(CROSS)ar
33 RANLIB = $(CROSS)ranlib
34 STRIP = $(CROSS)strip
35 endif
36
37 ifneq (,$(findstring yes,$(CAPSTONE_DIET)))
38 CFLAGS ?= -Os
39 CFLAGS += -DCAPSTONE_DIET
40 else
41 CFLAGS ?= -O3
42 endif
43
44 ifneq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE)))
45 CFLAGS += -DCAPSTONE_X86_ATT_DISABLE
46 endif
47
48 CFLAGS += -fPIC -Wall -Wwrite-strings -Wmissing-prototypes -Iinclude
49
50 ifeq ($(CAPSTONE_USE_SYS_DYN_MEM),yes)
51 CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
52 endif
53
54 ifeq ($(CAPSTONE_HAS_OSXKERNEL), yes)
55 CFLAGS += -DCAPSTONE_HAS_OSXKERNEL
56 SDKROOT ?= $(shell xcodebuild -version -sdk macosx Path)
57 CFLAGS += -mmacosx-version-min=10.5 \
58           -isysroot$(SDKROOT) \
59           -I$(SDKROOT)/System/Library/Frameworks/Kernel.framework/Headers \
60           -mkernel \
61           -fno-builtin
62 endif
63
64 PREFIX ?= /usr
65 DESTDIR ?=
66 ifndef BUILDDIR
67 BLDIR = .
68 OBJDIR = .
69 else
70 BLDIR = $(abspath $(BUILDDIR))
71 OBJDIR = $(BLDIR)/obj
72 endif
73 INCDIR ?= $(PREFIX)/include
74
75 UNAME_S := $(shell uname -s)
76
77 LIBDIRARCH ?= lib
78 # Uncomment the below line to installs x86_64 libs to lib64/ directory.
79 # Or better, pass 'LIBDIRARCH=lib64' to 'make install/uninstall' via 'make.sh'.
80 #LIBDIRARCH ?= lib64
81 LIBDIR = $(DESTDIR)$(PREFIX)/$(LIBDIRARCH)
82 BINDIR = $(DESTDIR)$(PREFIX)/bin
83
84 LIBDATADIR = $(LIBDIR)
85
86 # Don't redefine $LIBDATADIR when global environment variable
87 # USE_GENERIC_LIBDATADIR is set. This is used by the pkgsrc framework.
88
89 ifndef USE_GENERIC_LIBDATADIR
90 ifeq ($(UNAME_S), FreeBSD)
91 LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata
92 endif
93 ifeq ($(UNAME_S), DragonFly)
94 LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata
95 endif
96 endif
97
98 INSTALL_BIN ?= install
99 INSTALL_DATA ?= $(INSTALL_BIN) -m0644
100 INSTALL_LIB ?= $(INSTALL_BIN) -m0755
101
102 LIBNAME = capstone
103
104
105 DEP_ARM =
106 DEP_ARM += $(wildcard arch/ARM/ARM*.inc)
107
108 LIBOBJ_ARM =
109 ifneq (,$(findstring arm,$(CAPSTONE_ARCHS)))
110     CFLAGS += -DCAPSTONE_HAS_ARM
111     LIBSRC_ARM += $(wildcard arch/ARM/ARM*.c)
112     LIBOBJ_ARM += $(LIBSRC_ARM:%.c=$(OBJDIR)/%.o)
113 endif
114
115 DEP_ARM64 =
116 DEP_ARM64 += $(wildcard arch/AArch64/AArch64*.inc)
117
118 LIBOBJ_ARM64 =
119 ifneq (,$(findstring aarch64,$(CAPSTONE_ARCHS)))
120     CFLAGS += -DCAPSTONE_HAS_ARM64
121     LIBSRC_ARM64 += $(wildcard arch/AArch64/AArch64*.c)
122     LIBOBJ_ARM64 += $(LIBSRC_ARM64:%.c=$(OBJDIR)/%.o)
123 endif
124
125
126 DEP_M68K =
127 DEP_M68K += $(wildcard arch/M68K/M68K*.h)
128
129 LIBOBJ_M68K =
130 ifneq (,$(findstring m68k,$(CAPSTONE_ARCHS)))
131     CFLAGS += -DCAPSTONE_HAS_M68K
132     LIBSRC_M68K += $(wildcard arch/M68K/M68K*.c)
133     LIBOBJ_M68K += $(LIBSRC_M68K:%.c=$(OBJDIR)/%.o)
134 endif
135
136 DEP_MIPS =
137 DEP_MIPS += $(wildcard arch/Mips/Mips*.inc)
138
139 LIBOBJ_MIPS =
140 ifneq (,$(findstring mips,$(CAPSTONE_ARCHS)))
141     CFLAGS += -DCAPSTONE_HAS_MIPS
142     LIBSRC_MIPS += $(wildcard arch/Mips/Mips*.c)
143     LIBOBJ_MIPS += $(LIBSRC_MIPS:%.c=$(OBJDIR)/%.o)
144 endif
145
146
147 DEP_PPC =
148 DEP_PPC += $(wildcard arch/PowerPC/PPC*.inc)
149
150 LIBOBJ_PPC =
151 ifneq (,$(findstring powerpc,$(CAPSTONE_ARCHS)))
152     CFLAGS += -DCAPSTONE_HAS_POWERPC
153     LIBSRC_PPC += $(wildcard arch/PowerPC/PPC*.c)
154     LIBOBJ_PPC += $(LIBSRC_PPC:%.c=$(OBJDIR)/%.o)
155 endif
156
157
158 DEP_SPARC =
159 DEP_SPARC += $(wildcard arch/Sparc/Sparc*.inc)
160
161 LIBOBJ_SPARC =
162 ifneq (,$(findstring sparc,$(CAPSTONE_ARCHS)))
163     CFLAGS += -DCAPSTONE_HAS_SPARC
164     LIBSRC_SPARC += $(wildcard arch/Sparc/Sparc*.c)
165     LIBOBJ_SPARC += $(LIBSRC_SPARC:%.c=$(OBJDIR)/%.o)
166 endif
167
168
169 DEP_SYSZ =
170 DEP_SYSZ += $(wildcard arch/SystemZ/SystemZ*.inc)
171
172 LIBOBJ_SYSZ =
173 ifneq (,$(findstring systemz,$(CAPSTONE_ARCHS)))
174     CFLAGS += -DCAPSTONE_HAS_SYSZ
175     LIBSRC_SYSZ += $(wildcard arch/SystemZ/SystemZ*.c)
176     LIBOBJ_SYSZ += $(LIBSRC_SYSZ:%.c=$(OBJDIR)/%.o)
177 endif
178
179
180 # by default, we compile full X86 instruction sets
181 X86_REDUCE =
182 ifneq (,$(findstring yes,$(CAPSTONE_X86_REDUCE)))
183 X86_REDUCE = _reduce
184 CFLAGS += -DCAPSTONE_X86_REDUCE -Os
185 endif
186
187 DEP_X86 =
188 DEP_X86 += arch/X86/X86GenAsmWriter$(X86_REDUCE).inc
189 DEP_X86 += arch/X86/X86GenAsmWriter1$(X86_REDUCE).inc
190 DEP_X86 += arch/X86/X86GenDisassemblerTables$(X86_REDUCE).inc
191 DEP_X86 += arch/X86/X86GenInstrInfo$(X86_REDUCE).inc
192 DEP_X86 += arch/X86/X86GenRegisterInfo.inc
193 DEP_X86 += arch/X86/X86MappingInsn$(X86_REDUCE).inc
194 DEP_X86 += arch/X86/X86MappingInsnOp$(X86_REDUCE).inc
195 DEP_X86 += arch/X86/X86ImmSize.inc
196
197 LIBOBJ_X86 =
198 ifneq (,$(findstring x86,$(CAPSTONE_ARCHS)))
199     CFLAGS += -DCAPSTONE_HAS_X86
200     LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86DisassemblerDecoder.o
201     LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Disassembler.o
202     LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86IntelInstPrinter.o
203 # assembly syntax is irrelevant in Diet mode, when this info is suppressed
204 ifeq (,$(findstring yes,$(CAPSTONE_DIET)))
205 ifeq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE)))
206     LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86ATTInstPrinter.o
207 endif
208 endif
209     LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Mapping.o
210     LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Module.o
211 endif
212
213
214 DEP_XCORE =
215 DEP_XCORE += $(wildcard arch/XCore/XCore*.inc)
216
217 LIBOBJ_XCORE =
218 ifneq (,$(findstring xcore,$(CAPSTONE_ARCHS)))
219     CFLAGS += -DCAPSTONE_HAS_XCORE
220     LIBSRC_XCORE += $(wildcard arch/XCore/XCore*.c)
221     LIBOBJ_XCORE += $(LIBSRC_XCORE:%.c=$(OBJDIR)/%.o)
222 endif
223
224
225 DEP_TMS320C64X =
226 DEP_TMS320C64X += $(wildcard arch/TMS320C64x/TMS320C64x*.inc)
227
228 LIBOBJ_TMS320C64X =
229 ifneq (,$(findstring tms320c64x,$(CAPSTONE_ARCHS)))
230     CFLAGS += -DCAPSTONE_HAS_TMS320C64X
231     LIBSRC_TMS320C64X += $(wildcard arch/TMS320C64x/TMS320C64x*.c)
232     LIBOBJ_TMS320C64X += $(LIBSRC_TMS320C64X:%.c=$(OBJDIR)/%.o)
233 endif
234
235 DEP_M680X =
236 DEP_M680X += $(wildcard arch/M680X/*.inc)
237 DEP_M680X += $(wildcard arch/M680X/M680X*.h)
238
239 LIBOBJ_M680X =
240 ifneq (,$(findstring m680x,$(CAPSTONE_ARCHS)))
241     CFLAGS += -DCAPSTONE_HAS_M680X
242     LIBSRC_M680X += $(wildcard arch/M680X/*.c)
243     LIBOBJ_M680X += $(LIBSRC_M680X:%.c=$(OBJDIR)/%.o)
244 endif
245
246
247 DEP_EVM =
248 DEP_EVM += $(wildcard arch/EVM/EVM*.inc)
249
250 LIBOBJ_EVM =
251 ifneq (,$(findstring evm,$(CAPSTONE_ARCHS)))
252     CFLAGS += -DCAPSTONE_HAS_EVM
253     LIBSRC_EVM += $(wildcard arch/EVM/EVM*.c)
254     LIBOBJ_EVM += $(LIBSRC_EVM:%.c=$(OBJDIR)/%.o)
255 endif
256
257
258 DEP_MOS65XX =
259 DEP_MOS65XX += $(wildcard arch/MOS65XX/MOS65XX*.inc)
260
261 LIBOBJ_MOS65XX =
262 ifneq (,$(findstring mos65xx,$(CAPSTONE_ARCHS)))
263     CFLAGS += -DCAPSTONE_HAS_MOS65XX
264     LIBSRC_MOS65XX += $(wildcard arch/MOS65XX/MOS65XX*.c)
265     LIBOBJ_MOS65XX += $(LIBSRC_MOS65XX:%.c=$(OBJDIR)/%.o)
266 endif
267
268
269 LIBOBJ =
270 LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o
271 LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ)
272 LIBOBJ += $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X) $(LIBOBJ_EVM) $(LIBOBJ_MOS65XX)
273 LIBOBJ += $(OBJDIR)/MCInst.o
274
275
276 ifeq ($(PKG_EXTRA),)
277 PKGCFGDIR = $(LIBDATADIR)/pkgconfig
278 else
279 PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig
280 ifeq ($(PKGCFGDIR),)
281 PKGCFGDIR = $(LIBDATADIR)/pkgconfig
282 endif
283 endif
284
285 API_MAJOR=$(shell echo `grep -e CS_API_MAJOR include/capstone/capstone.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}')
286 VERSION_EXT =
287
288 IS_APPLE := $(shell $(CC) -dM -E - < /dev/null 2> /dev/null | grep __apple_build_version__ | wc -l | tr -d " ")
289 ifeq ($(IS_APPLE),1)
290 # on MacOS, do not build in Universal format by default
291 MACOS_UNIVERSAL ?= no
292 ifeq ($(MACOS_UNIVERSAL),yes)
293 CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
294 LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
295 endif
296 EXT = dylib
297 VERSION_EXT = $(API_MAJOR).$(EXT)
298 $(LIBNAME)_LDFLAGS += -dynamiclib -install_name lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR)
299 AR_EXT = a
300 # Homebrew wants to make sure its formula does not disable FORTIFY_SOURCE
301 # However, this is not really necessary because 'CAPSTONE_USE_SYS_DYN_MEM=yes' by default
302 ifneq ($(HOMEBREW_CAPSTONE),1)
303 ifneq ($(CAPSTONE_USE_SYS_DYN_MEM),yes)
304 # remove string check because OSX kernel complains about missing symbols
305 CFLAGS += -D_FORTIFY_SOURCE=0
306 endif
307 endif
308 else
309 CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
310 LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
311 $(LIBNAME)_LDFLAGS += -shared
312 # Cygwin?
313 IS_CYGWIN := $(shell $(CC) -dumpmachine 2>/dev/null | grep -i cygwin | wc -l)
314 ifeq ($(IS_CYGWIN),1)
315 EXT = dll
316 AR_EXT = lib
317 # Cygwin doesn't like -fPIC
318 CFLAGS := $(CFLAGS:-fPIC=)
319 # On Windows we need the shared library to be executable
320 else
321 # mingw?
322 IS_MINGW := $(shell $(CC) --version 2>/dev/null | grep -i "\(mingw\|MSYS\)" | wc -l)
323 ifeq ($(IS_MINGW),1)
324 EXT = dll
325 AR_EXT = lib
326 # mingw doesn't like -fPIC either
327 CFLAGS := $(CFLAGS:-fPIC=)
328 # On Windows we need the shared library to be executable
329 else
330 # Linux, *BSD
331 EXT = so
332 VERSION_EXT = $(EXT).$(API_MAJOR)
333 AR_EXT = a
334 $(LIBNAME)_LDFLAGS += -Wl,-soname,lib$(LIBNAME).$(VERSION_EXT)
335 endif
336 endif
337 endif
338
339 ifeq ($(CAPSTONE_SHARED),yes)
340 ifeq ($(IS_MINGW),1)
341 LIBRARY = $(BLDIR)/$(LIBNAME).$(VERSION_EXT)
342 else ifeq ($(IS_CYGWIN),1)
343 LIBRARY = $(BLDIR)/$(LIBNAME).$(VERSION_EXT)
344 else    # *nix
345 LIBRARY = $(BLDIR)/lib$(LIBNAME).$(VERSION_EXT)
346 CFLAGS += -fvisibility=hidden
347 endif
348 endif
349
350 ifeq ($(CAPSTONE_STATIC),yes)
351 ifeq ($(IS_MINGW),1)
352 ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT)
353 else ifeq ($(IS_CYGWIN),1)
354 ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT)
355 else
356 ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT)
357 endif
358 endif
359
360 PKGCFGF = $(BLDIR)/$(LIBNAME).pc
361
362 .PHONY: all clean install uninstall dist
363
364 all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF)
365 ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
366     @V=$(V) CC=$(CC) $(MAKE) -C cstool
367 ifndef BUILDDIR
368     $(MAKE) -C tests
369     $(MAKE) -C suite/fuzz
370 else
371     $(MAKE) -C tests BUILDDIR=$(BLDIR)
372     $(MAKE) -C suite/fuzz BUILDDIR=$(BLDIR)
373 endif
374     $(call install-library,$(BLDIR)/tests/)
375 endif
376
377 ifeq ($(CAPSTONE_SHARED),yes)
378 $(LIBRARY): $(LIBOBJ)
379 ifeq ($(V),0)
380     $(call log,LINK,$(@:$(BLDIR)/%=%))
381     @$(create-library)
382 else
383     $(create-library)
384 endif
385 endif
386
387 $(LIBOBJ): config.mk *.h include/capstone/*.h
388
389 $(LIBOBJ_ARM): $(DEP_ARM)
390 $(LIBOBJ_ARM64): $(DEP_ARM64)
391 $(LIBOBJ_M68K): $(DEP_M68K)
392 $(LIBOBJ_MIPS): $(DEP_MIPS)
393 $(LIBOBJ_PPC): $(DEP_PPC)
394 $(LIBOBJ_SPARC): $(DEP_SPARC)
395 $(LIBOBJ_SYSZ): $(DEP_SYSZ)
396 $(LIBOBJ_X86): $(DEP_X86)
397 $(LIBOBJ_XCORE): $(DEP_XCORE)
398 $(LIBOBJ_TMS320C64X): $(DEP_TMS320C64X)
399 $(LIBOBJ_M680X): $(DEP_M680X)
400 $(LIBOBJ_EVM): $(DEP_EVM)
401 $(LIBOBJ_MOS65XX): $(DEP_MOS65XX)
402
403 ifeq ($(CAPSTONE_STATIC),yes)
404 $(ARCHIVE): $(LIBOBJ)
405     @rm -f $(ARCHIVE)
406 ifeq ($(V),0)
407     $(call log,AR,$(@:$(BLDIR)/%=%))
408     @$(create-archive)
409 else
410     $(create-archive)
411 endif
412 endif
413
414 $(PKGCFGF):
415 ifeq ($(V),0)
416     $(call log,GEN,$(@:$(BLDIR)/%=%))
417     @$(generate-pkgcfg)
418 else
419     $(generate-pkgcfg)
420 endif
421
422 install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY)
423     mkdir -p $(LIBDIR)
424     $(call install-library,$(LIBDIR))
425 ifeq ($(CAPSTONE_STATIC),yes)
426     $(INSTALL_DATA) $(ARCHIVE) $(LIBDIR)
427 endif
428     mkdir -p $(DESTDIR)$(INCDIR)/$(LIBNAME)
429     $(INSTALL_DATA) include/capstone/*.h $(DESTDIR)$(INCDIR)/$(LIBNAME)
430     mkdir -p $(PKGCFGDIR)
431     $(INSTALL_DATA) $(PKGCFGF) $(PKGCFGDIR)
432 ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
433     mkdir -p $(BINDIR)
434     $(INSTALL_LIB) cstool/cstool $(BINDIR)
435 endif
436
437 uninstall:
438     rm -rf $(DESTDIR)$(INCDIR)/$(LIBNAME)
439     rm -f $(LIBDIR)/lib$(LIBNAME).*
440     rm -f $(PKGCFGDIR)/$(LIBNAME).pc
441 ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
442     rm -f $(BINDIR)/cstool
443 endif
444
445 clean:
446     rm -f $(LIBOBJ)
447     rm -f $(BLDIR)/lib$(LIBNAME).* $(BLDIR)/$(LIBNAME).pc
448     rm -f $(PKGCFGF)
449     [ "${ANDROID}" = "1" ] && rm -rf android-ndk-* || true
450
451 ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
452     $(MAKE) -C cstool clean
453     $(MAKE) -C tests clean
454     $(MAKE) -C suite/fuzz clean
455     rm -f $(BLDIR)/tests/lib$(LIBNAME).$(EXT)
456 endif
457
458 ifdef BUILDDIR
459     rm -rf $(BUILDDIR)
460 endif
461
462 ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
463     $(MAKE) -C bindings/python clean
464     $(MAKE) -C bindings/java clean
465     $(MAKE) -C bindings/ocaml clean
466 endif
467
468
469 TAG ?= HEAD
470 ifeq ($(TAG), HEAD)
471 DIST_VERSION = latest
472 else
473 DIST_VERSION = $(TAG)
474 endif
475
476 dist:
477     git archive --format=tar.gz --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).tgz
478     git archive --format=zip --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).zip
479
480
481 TESTS = test_basic test_detail test_arm test_arm64 test_m68k test_mips test_ppc test_sparc
482 TESTS += test_systemz test_x86 test_xcore test_iter test_evm test_mos65xx
483 TESTS += test_basic.static test_detail.static test_arm.static test_arm64.static
484 TESTS += test_m68k.static test_mips.static test_ppc.static test_sparc.static
485 TESTS += test_systemz.static test_x86.static test_xcore.static test_m680x.static
486 TESTS += test_skipdata test_skipdata.static test_iter.static test_evm.static
487 TESTS += test_mos65xx.static
488 check: $(TESTS) fuzztest fuzzallcorp
489 test_%:
490     ./tests/$@ > /dev/null && echo OK || echo FAILED
491
492 FUZZ_INPUTS = $(shell find suite/MC -type f -name '*.cs')
493
494 fuzztest:
495     ./suite/fuzz/fuzz_disasm $(FUZZ_INPUTS)
496
497 fuzzallcorp:
498 ifneq ($(wildcard suite/fuzz/corpus-libFuzzer-capstone_fuzz_disasmnext-latest),)
499     ./suite/fuzz/fuzz_bindisasm suite/fuzz/corpus-libFuzzer-capstone_fuzz_disasmnext-latest/
500 else
501     @echo "Skipping tests on whole corpus"
502 endif
503
504 $(OBJDIR)/%.o: %.c
505     @mkdir -p $(@D)
506 ifeq ($(V),0)
507     $(call log,CC,$(@:$(OBJDIR)/%=%))
508     @$(compile)
509 else
510     $(compile)
511 endif
512
513
514 ifeq ($(CAPSTONE_SHARED),yes)
515 define install-library
516     $(INSTALL_LIB) $(LIBRARY) $1
517     $(if $(VERSION_EXT),
518         cd $1 && \
519         rm -f lib$(LIBNAME).$(EXT) && \
520         ln -s lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT))
521 endef
522 else
523 define install-library
524 endef
525 endif
526
527
528 define create-archive
529     $(AR) q $(ARCHIVE) $(LIBOBJ)
530     $(RANLIB) $(ARCHIVE)
531 endef
532
533
534 define create-library
535     $(CC) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY)
536 endef
537
538
539 define generate-pkgcfg
540     mkdir -p $(BLDIR)
541     echo 'Name: capstone' > $(PKGCFGF)
542     echo 'Description: Capstone disassembly engine' >> $(PKGCFGF)
543     echo 'Version: $(PKG_VERSION)' >> $(PKGCFGF)
544     echo 'libdir=$(LIBDIR)' >> $(PKGCFGF)
545     echo 'includedir=$(INCDIR)/capstone' >> $(PKGCFGF)
546     echo 'archive=$${libdir}/libcapstone.a' >> $(PKGCFGF)
547     echo 'Libs: -L$${libdir} -lcapstone' >> $(PKGCFGF)
548     echo 'Cflags: -I$${includedir}' >> $(PKGCFGF)
549 endef