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*.h) 128 129LIBOBJ_M68K = 130ifneq (,$(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) 134endif 135 136DEP_MIPS = 137DEP_MIPS += $(wildcard arch/Mips/Mips*.inc) 138 139LIBOBJ_MIPS = 140ifneq (,$(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) 144endif 145 146 147DEP_PPC = 148DEP_PPC += $(wildcard arch/PowerPC/PPC*.inc) 149 150LIBOBJ_PPC = 151ifneq (,$(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) 155endif 156 157 158DEP_SPARC = 159DEP_SPARC += $(wildcard arch/Sparc/Sparc*.inc) 160 161LIBOBJ_SPARC = 162ifneq (,$(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) 166endif 167 168 169DEP_SYSZ = 170DEP_SYSZ += $(wildcard arch/SystemZ/SystemZ*.inc) 171 172LIBOBJ_SYSZ = 173ifneq (,$(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) 177endif 178 179 180# by default, we compile full X86 instruction sets 181X86_REDUCE = 182ifneq (,$(findstring yes,$(CAPSTONE_X86_REDUCE))) 183X86_REDUCE = _reduce 184CFLAGS += -DCAPSTONE_X86_REDUCE -Os 185endif 186 187DEP_X86 = 188DEP_X86 += arch/X86/X86GenAsmWriter$(X86_REDUCE).inc 189DEP_X86 += arch/X86/X86GenAsmWriter1$(X86_REDUCE).inc 190DEP_X86 += arch/X86/X86GenDisassemblerTables$(X86_REDUCE).inc 191DEP_X86 += arch/X86/X86GenInstrInfo$(X86_REDUCE).inc 192DEP_X86 += arch/X86/X86GenRegisterInfo.inc 193DEP_X86 += arch/X86/X86MappingInsn$(X86_REDUCE).inc 194DEP_X86 += arch/X86/X86MappingInsnOp$(X86_REDUCE).inc 195DEP_X86 += arch/X86/X86ImmSize.inc 196 197LIBOBJ_X86 = 198ifneq (,$(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 204ifeq (,$(findstring yes,$(CAPSTONE_DIET))) 205ifeq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE))) 206 LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86ATTInstPrinter.o 207endif 208endif 209 LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Mapping.o 210 LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Module.o 211endif 212 213 214DEP_XCORE = 215DEP_XCORE += $(wildcard arch/XCore/XCore*.inc) 216 217LIBOBJ_XCORE = 218ifneq (,$(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) 222endif 223 224 225DEP_TMS320C64X = 226DEP_TMS320C64X += $(wildcard arch/TMS320C64x/TMS320C64x*.inc) 227 228LIBOBJ_TMS320C64X = 229ifneq (,$(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) 233endif 234 235DEP_M680X = 236DEP_M680X += $(wildcard arch/M680X/*.inc) 237DEP_M680X += $(wildcard arch/M680X/M680X*.h) 238 239LIBOBJ_M680X = 240ifneq (,$(findstring m680x,$(CAPSTONE_ARCHS))) 241 CFLAGS += -DCAPSTONE_HAS_M680X 242 LIBSRC_M680X += $(wildcard arch/M680X/*.c) 243 LIBOBJ_M680X += $(LIBSRC_M680X:%.c=$(OBJDIR)/%.o) 244endif 245 246 247DEP_EVM = 248DEP_EVM += $(wildcard arch/EVM/EVM*.inc) 249 250LIBOBJ_EVM = 251ifneq (,$(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) 255endif 256 257 258DEP_MOS65XX = 259DEP_MOS65XX += $(wildcard arch/MOS65XX/MOS65XX*.inc) 260 261LIBOBJ_MOS65XX = 262ifneq (,$(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) 266endif 267 268 269LIBOBJ = 270LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o 271LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) 272LIBOBJ += $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X) $(LIBOBJ_EVM) $(LIBOBJ_MOS65XX) 273LIBOBJ += $(OBJDIR)/MCInst.o 274 275 276ifeq ($(PKG_EXTRA),) 277PKGCFGDIR = $(LIBDATADIR)/pkgconfig 278else 279PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig 280ifeq ($(PKGCFGDIR),) 281PKGCFGDIR = $(LIBDATADIR)/pkgconfig 282endif 283endif 284 285API_MAJOR=$(shell echo `grep -e CS_API_MAJOR include/capstone/capstone.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}') 286VERSION_EXT = 287 288IS_APPLE := $(shell $(CC) -dM -E - < /dev/null 2> /dev/null | grep __apple_build_version__ | wc -l | tr -d " ") 289ifeq ($(IS_APPLE),1) 290# on MacOS, do not build in Universal format by default 291MACOS_UNIVERSAL ?= no 292ifeq ($(MACOS_UNIVERSAL),yes) 293CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) 294LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) 295endif 296EXT = dylib 297VERSION_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) 299AR_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 302ifneq ($(HOMEBREW_CAPSTONE),1) 303ifneq ($(CAPSTONE_USE_SYS_DYN_MEM),yes) 304# remove string check because OSX kernel complains about missing symbols 305CFLAGS += -D_FORTIFY_SOURCE=0 306endif 307endif 308else 309CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) 310LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) 311$(LIBNAME)_LDFLAGS += -shared 312# Cygwin? 313IS_CYGWIN := $(shell $(CC) -dumpmachine 2>/dev/null | grep -i cygwin | wc -l) 314ifeq ($(IS_CYGWIN),1) 315EXT = dll 316AR_EXT = lib 317# Cygwin doesn't like -fPIC 318CFLAGS := $(CFLAGS:-fPIC=) 319# On Windows we need the shared library to be executable 320else 321# mingw? 322IS_MINGW := $(shell $(CC) --version 2>/dev/null | grep -i "\(mingw\|MSYS\)" | wc -l) 323ifeq ($(IS_MINGW),1) 324EXT = dll 325AR_EXT = lib 326# mingw doesn't like -fPIC either 327CFLAGS := $(CFLAGS:-fPIC=) 328# On Windows we need the shared library to be executable 329else 330# Linux, *BSD 331EXT = so 332VERSION_EXT = $(EXT).$(API_MAJOR) 333AR_EXT = a 334$(LIBNAME)_LDFLAGS += -Wl,-soname,lib$(LIBNAME).$(VERSION_EXT) 335endif 336endif 337endif 338 339ifeq ($(CAPSTONE_SHARED),yes) 340ifeq ($(IS_MINGW),1) 341LIBRARY = $(BLDIR)/$(LIBNAME).$(VERSION_EXT) 342else ifeq ($(IS_CYGWIN),1) 343LIBRARY = $(BLDIR)/$(LIBNAME).$(VERSION_EXT) 344else # *nix 345LIBRARY = $(BLDIR)/lib$(LIBNAME).$(VERSION_EXT) 346CFLAGS += -fvisibility=hidden 347endif 348endif 349 350ifeq ($(CAPSTONE_STATIC),yes) 351ifeq ($(IS_MINGW),1) 352ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) 353else ifeq ($(IS_CYGWIN),1) 354ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) 355else 356ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT) 357endif 358endif 359 360PKGCFGF = $(BLDIR)/$(LIBNAME).pc 361 362.PHONY: all clean install uninstall dist 363 364all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF) 365ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) 366 @V=$(V) CC=$(CC) $(MAKE) -C cstool 367ifndef BUILDDIR 368 $(MAKE) -C tests 369 $(MAKE) -C suite/fuzz 370else 371 $(MAKE) -C tests BUILDDIR=$(BLDIR) 372 $(MAKE) -C suite/fuzz BUILDDIR=$(BLDIR) 373endif 374 $(call install-library,$(BLDIR)/tests/) 375endif 376 377ifeq ($(CAPSTONE_SHARED),yes) 378$(LIBRARY): $(LIBOBJ) 379ifeq ($(V),0) 380 $(call log,LINK,$(@:$(BLDIR)/%=%)) 381 @$(create-library) 382else 383 $(create-library) 384endif 385endif 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 403ifeq ($(CAPSTONE_STATIC),yes) 404$(ARCHIVE): $(LIBOBJ) 405 @rm -f $(ARCHIVE) 406ifeq ($(V),0) 407 $(call log,AR,$(@:$(BLDIR)/%=%)) 408 @$(create-archive) 409else 410 $(create-archive) 411endif 412endif 413 414$(PKGCFGF): 415ifeq ($(V),0) 416 $(call log,GEN,$(@:$(BLDIR)/%=%)) 417 @$(generate-pkgcfg) 418else 419 $(generate-pkgcfg) 420endif 421 422install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY) 423 mkdir -p $(LIBDIR) 424 $(call install-library,$(LIBDIR)) 425ifeq ($(CAPSTONE_STATIC),yes) 426 $(INSTALL_DATA) $(ARCHIVE) $(LIBDIR) 427endif 428 mkdir -p $(DESTDIR)$(INCDIR)/$(LIBNAME) 429 $(INSTALL_DATA) include/capstone/*.h $(DESTDIR)$(INCDIR)/$(LIBNAME) 430 mkdir -p $(PKGCFGDIR) 431 $(INSTALL_DATA) $(PKGCFGF) $(PKGCFGDIR) 432ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) 433 mkdir -p $(BINDIR) 434 $(INSTALL_LIB) cstool/cstool $(BINDIR) 435endif 436 437uninstall: 438 rm -rf $(DESTDIR)$(INCDIR)/$(LIBNAME) 439 rm -f $(LIBDIR)/lib$(LIBNAME).* 440 rm -f $(PKGCFGDIR)/$(LIBNAME).pc 441ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) 442 rm -f $(BINDIR)/cstool 443endif 444 445clean: 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 451ifeq (,$(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) 456endif 457 458ifdef BUILDDIR 459 rm -rf $(BUILDDIR) 460endif 461 462ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) 463 $(MAKE) -C bindings/python clean 464 $(MAKE) -C bindings/java clean 465 $(MAKE) -C bindings/ocaml clean 466endif 467 468 469TAG ?= HEAD 470ifeq ($(TAG), HEAD) 471DIST_VERSION = latest 472else 473DIST_VERSION = $(TAG) 474endif 475 476dist: 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 481TESTS = test_basic test_detail test_arm test_arm64 test_m68k test_mips test_ppc test_sparc 482TESTS += test_systemz test_x86 test_xcore test_iter test_evm test_mos65xx 483TESTS += test_basic.static test_detail.static test_arm.static test_arm64.static 484TESTS += test_m68k.static test_mips.static test_ppc.static test_sparc.static 485TESTS += test_systemz.static test_x86.static test_xcore.static test_m680x.static 486TESTS += test_skipdata test_skipdata.static test_iter.static test_evm.static 487TESTS += test_mos65xx.static 488check: $(TESTS) fuzztest fuzzallcorp 489test_%: 490 ./tests/$@ > /dev/null && echo OK || echo FAILED 491 492FUZZ_INPUTS = $(shell find suite/MC -type f -name '*.cs') 493 494fuzztest: 495 ./suite/fuzz/fuzz_disasm $(FUZZ_INPUTS) 496 497fuzzallcorp: 498ifneq ($(wildcard suite/fuzz/corpus-libFuzzer-capstone_fuzz_disasmnext-latest),) 499 ./suite/fuzz/fuzz_bindisasm suite/fuzz/corpus-libFuzzer-capstone_fuzz_disasmnext-latest/ 500else 501 @echo "Skipping tests on whole corpus" 502endif 503 504$(OBJDIR)/%.o: %.c 505 @mkdir -p $(@D) 506ifeq ($(V),0) 507 $(call log,CC,$(@:$(OBJDIR)/%=%)) 508 @$(compile) 509else 510 $(compile) 511endif 512 513 514ifeq ($(CAPSTONE_SHARED),yes) 515define 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)) 521endef 522else 523define install-library 524endef 525endif 526 527 528define create-archive 529 $(AR) q $(ARCHIVE) $(LIBOBJ) 530 $(RANLIB) $(ARCHIVE) 531endef 532 533 534define create-library 535 $(CC) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY) 536endef 537 538 539define 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) 549endef 550