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