Nguyen Anh Quynh | 296a231 | 2014-03-05 23:50:41 +0800 | [diff] [blame] | 1 | # Capstone Disassembly Engine |
Nguyen Anh Quynh | 1ed8bb6 | 2014-03-10 23:14:30 -0700 | [diff] [blame] | 2 | # By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 |
Nguyen Anh Quynh | 5e107ab | 2013-12-31 23:38:28 +0800 | [diff] [blame] | 3 | |
danghvu | 6f52bf9 | 2013-12-19 22:43:01 -0600 | [diff] [blame] | 4 | include config.mk |
Nguyen Anh Quynh | 3ff259c | 2014-03-07 17:11:18 +0800 | [diff] [blame] | 5 | include pkgconfig.mk # package version |
Nguyen Anh Quynh | 58a0047 | 2014-05-01 22:53:52 +0800 | [diff] [blame] | 6 | include functions.mk |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 7 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 8 | # Verbose output? |
| 9 | V ?= 0 |
| 10 | |
| 11 | ifeq ($(PKG_EXTRA),) |
| 12 | PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR) |
| 13 | else |
| 14 | PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) |
| 15 | endif |
| 16 | |
Nguyen Anh Quynh | d80cede | 2014-01-16 21:07:59 +0800 | [diff] [blame] | 17 | ifeq ($(CROSS),) |
| 18 | CC ?= cc |
| 19 | AR ?= ar |
| 20 | RANLIB ?= ranlib |
| 21 | STRIP ?= strip |
| 22 | else |
| 23 | CC = $(CROSS)gcc |
| 24 | AR = $(CROSS)ar |
| 25 | RANLIB = $(CROSS)ranlib |
| 26 | STRIP = $(CROSS)strip |
| 27 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 28 | |
Nguyen Anh Quynh | 77af9fb | 2014-04-29 07:11:55 +0800 | [diff] [blame] | 29 | ifneq (,$(findstring yes,$(CAPSTONE_DIET))) |
| 30 | CFLAGS ?= -Os |
| 31 | CFLAGS += -DCAPSTONE_DIET |
| 32 | else |
| 33 | CFLAGS ?= -O3 |
| 34 | endif |
| 35 | |
baguette | 86e8450 | 2014-08-17 20:59:05 +0200 | [diff] [blame] | 36 | ifneq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE))) |
| 37 | CFLAGS += -DCAPSTONE_X86_ATT_DISABLE |
| 38 | endif |
| 39 | |
Nguyen Anh Quynh | 77af9fb | 2014-04-29 07:11:55 +0800 | [diff] [blame] | 40 | CFLAGS += -fPIC -Wall -Iinclude |
Nguyen Anh Quynh | 59492c2 | 2014-01-05 23:41:31 +0800 | [diff] [blame] | 41 | |
Nguyen Anh Quynh | e31327d | 2014-04-29 14:25:15 +0800 | [diff] [blame] | 42 | ifeq ($(CAPSTONE_USE_SYS_DYN_MEM),yes) |
Nguyen Anh Quynh | 87a3f69 | 2014-05-10 19:26:32 +0800 | [diff] [blame] | 43 | CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM |
Nguyen Anh Quynh | 59492c2 | 2014-01-05 23:41:31 +0800 | [diff] [blame] | 44 | endif |
| 45 | |
reverser | bcf09f4 | 2015-04-09 18:28:19 +0100 | [diff] [blame] | 46 | ifeq ($(CAPSTONE_HAS_OSXKERNEL), yes) |
| 47 | CFLAGS += -DCAPSTONE_HAS_OSXKERNEL |
Pb | b8741bd | 2015-11-10 23:02:26 +0100 | [diff] [blame] | 48 | SDKROOT ?= $(shell xcodebuild -version -sdk macosx Path) |
| 49 | CFLAGS += -mmacosx-version-min=10.5 \ |
| 50 | -isysroot$(SDKROOT) \ |
| 51 | -I$(SDKROOT)/System/Library/Frameworks/Kernel.framework/Headers \ |
| 52 | -mkernel \ |
| 53 | -fno-builtin |
reverser | bcf09f4 | 2015-04-09 18:28:19 +0100 | [diff] [blame] | 54 | endif |
| 55 | |
Ole André Vadla Ravnås | 6583f06 | 2014-07-04 23:09:19 +0200 | [diff] [blame] | 56 | CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
Ole André Vadla Ravnås | b202b91 | 2014-07-04 23:38:20 +0200 | [diff] [blame] | 57 | LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
Ole André Vadla Ravnås | 6583f06 | 2014-07-04 23:09:19 +0200 | [diff] [blame] | 58 | |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 59 | PREFIX ?= /usr |
| 60 | DESTDIR ?= |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 61 | ifndef BUILDDIR |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 62 | BLDIR = . |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 63 | OBJDIR = . |
| 64 | else |
Ole André Vadla Ravnås | 7a73439 | 2014-04-30 00:06:41 +0200 | [diff] [blame] | 65 | BLDIR = $(abspath $(BUILDDIR)) |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 66 | OBJDIR = $(BLDIR)/obj |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 67 | endif |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 68 | INCDIR = $(DESTDIR)$(PREFIX)/include |
Nguyen Anh Quynh | 9f0e6c2 | 2013-12-25 22:47:28 +0800 | [diff] [blame] | 69 | |
Nguyen Anh Quynh | 235a274 | 2014-03-29 21:09:35 +0800 | [diff] [blame] | 70 | UNAME_S := $(shell uname -s) |
Nguyen Anh Quynh | ad6cc98 | 2014-04-08 23:34:44 +0800 | [diff] [blame] | 71 | |
Nguyen Anh Quynh | 360bf1e | 2014-04-14 13:36:46 +0800 | [diff] [blame] | 72 | LIBDIRARCH ?= lib |
| 73 | # Uncomment the below line to installs x86_64 libs to lib64/ directory. |
| 74 | # Or better, pass 'LIBDIRARCH=lib64' to 'make install/uninstall' via 'make.sh'. |
| 75 | #LIBDIRARCH ?= lib64 |
| 76 | LIBDIR = $(DESTDIR)$(PREFIX)/$(LIBDIRARCH) |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame^] | 77 | BINDIR = $(DESTDIR)$(PREFIX)/bin |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 78 | |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 79 | LIBDATADIR = $(LIBDIR) |
Kamil Rytarowski | 453b41a | 2015-07-27 04:03:48 +0200 | [diff] [blame] | 80 | |
| 81 | # Don't redefine $LIBDATADIR when global environment variable |
| 82 | # USE_GENERIC_LIBDATADIR is set. This is used by the pkgsrc framework. |
| 83 | |
| 84 | ifndef USE_GENERIC_LIBDATADIR |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 85 | ifeq ($(UNAME_S), FreeBSD) |
| 86 | LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 87 | endif |
Oliver Pinter | 25efded | 2014-03-23 19:10:13 +0100 | [diff] [blame] | 88 | ifeq ($(UNAME_S), DragonFly) |
| 89 | LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata |
| 90 | endif |
Kamil Rytarowski | 453b41a | 2015-07-27 04:03:48 +0200 | [diff] [blame] | 91 | endif |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 92 | |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 93 | INSTALL_BIN ?= install |
| 94 | INSTALL_DATA ?= $(INSTALL_BIN) -m0644 |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 95 | INSTALL_LIB ?= $(INSTALL_BIN) -m0755 |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 96 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 97 | LIBNAME = capstone |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 98 | |
Nguyen Anh Quynh | 42c6b1a | 2013-12-30 00:15:25 +0800 | [diff] [blame] | 99 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 100 | DEP_ARM = |
| 101 | DEP_ARM += arch/ARM/ARMGenAsmWriter.inc |
| 102 | DEP_ARM += arch/ARM/ARMGenDisassemblerTables.inc |
| 103 | DEP_ARM += arch/ARM/ARMGenInstrInfo.inc |
| 104 | DEP_ARM += arch/ARM/ARMGenRegisterInfo.inc |
| 105 | DEP_ARM += arch/ARM/ARMGenSubtargetInfo.inc |
| 106 | |
| 107 | LIBOBJ_ARM = |
Nguyen Anh Quynh | 9cc56a3 | 2014-01-15 16:01:55 +0800 | [diff] [blame] | 108 | ifneq (,$(findstring arm,$(CAPSTONE_ARCHS))) |
| 109 | CFLAGS += -DCAPSTONE_HAS_ARM |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 110 | LIBOBJ_ARM += $(OBJDIR)/arch/ARM/ARMDisassembler.o |
| 111 | LIBOBJ_ARM += $(OBJDIR)/arch/ARM/ARMInstPrinter.o |
| 112 | LIBOBJ_ARM += $(OBJDIR)/arch/ARM/ARMMapping.o |
| 113 | LIBOBJ_ARM += $(OBJDIR)/arch/ARM/ARMModule.o |
danghvu | 02db488 | 2013-12-20 00:57:12 -0600 | [diff] [blame] | 114 | endif |
Nguyen Anh Quynh | 42c6b1a | 2013-12-30 00:15:25 +0800 | [diff] [blame] | 115 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 116 | DEP_ARM64 = |
| 117 | DEP_ARM64 += arch/AArch64/AArch64GenAsmWriter.inc |
| 118 | DEP_ARM64 += arch/AArch64/AArch64GenInstrInfo.inc |
| 119 | DEP_ARM64 += arch/AArch64/AArch64GenSubtargetInfo.inc |
| 120 | DEP_ARM64 += arch/AArch64/AArch64GenDisassemblerTables.inc |
| 121 | DEP_ARM64 += arch/AArch64/AArch64GenRegisterInfo.inc |
| 122 | |
| 123 | LIBOBJ_ARM64 = |
| 124 | ifneq (,$(findstring aarch64,$(CAPSTONE_ARCHS))) |
| 125 | CFLAGS += -DCAPSTONE_HAS_ARM64 |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 126 | LIBOBJ_ARM64 += $(OBJDIR)/arch/AArch64/AArch64BaseInfo.o |
| 127 | LIBOBJ_ARM64 += $(OBJDIR)/arch/AArch64/AArch64Disassembler.o |
| 128 | LIBOBJ_ARM64 += $(OBJDIR)/arch/AArch64/AArch64InstPrinter.o |
| 129 | LIBOBJ_ARM64 += $(OBJDIR)/arch/AArch64/AArch64Mapping.o |
| 130 | LIBOBJ_ARM64 += $(OBJDIR)/arch/AArch64/AArch64Module.o |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 131 | endif |
| 132 | |
| 133 | |
| 134 | DEP_MIPS = |
| 135 | DEP_MIPS += arch/Mips/MipsGenAsmWriter.inc |
| 136 | DEP_MIPS += arch/Mips/MipsGenDisassemblerTables.inc |
| 137 | DEP_MIPS += arch/Mips/MipsGenInstrInfo.inc |
| 138 | DEP_MIPS += arch/Mips/MipsGenRegisterInfo.inc |
| 139 | DEP_MIPS += arch/Mips/MipsGenSubtargetInfo.inc |
| 140 | |
| 141 | LIBOBJ_MIPS = |
| 142 | ifneq (,$(findstring mips,$(CAPSTONE_ARCHS))) |
| 143 | CFLAGS += -DCAPSTONE_HAS_MIPS |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 144 | LIBOBJ_MIPS += $(OBJDIR)/arch/Mips/MipsDisassembler.o |
| 145 | LIBOBJ_MIPS += $(OBJDIR)/arch/Mips/MipsInstPrinter.o |
| 146 | LIBOBJ_MIPS += $(OBJDIR)/arch/Mips/MipsMapping.o |
| 147 | LIBOBJ_MIPS += $(OBJDIR)/arch/Mips/MipsModule.o |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 148 | endif |
| 149 | |
| 150 | |
| 151 | DEP_PPC = |
| 152 | DEP_PPC += arch/PowerPC/PPCGenAsmWriter.inc |
| 153 | DEP_PPC += arch/PowerPC/PPCGenInstrInfo.inc |
| 154 | DEP_PPC += arch/PowerPC/PPCGenSubtargetInfo.inc |
| 155 | DEP_PPC += arch/PowerPC/PPCGenDisassemblerTables.inc |
| 156 | DEP_PPC += arch/PowerPC/PPCGenRegisterInfo.inc |
| 157 | |
| 158 | LIBOBJ_PPC = |
| 159 | ifneq (,$(findstring powerpc,$(CAPSTONE_ARCHS))) |
| 160 | CFLAGS += -DCAPSTONE_HAS_POWERPC |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 161 | LIBOBJ_PPC += $(OBJDIR)/arch/PowerPC/PPCDisassembler.o |
| 162 | LIBOBJ_PPC += $(OBJDIR)/arch/PowerPC/PPCInstPrinter.o |
| 163 | LIBOBJ_PPC += $(OBJDIR)/arch/PowerPC/PPCMapping.o |
| 164 | LIBOBJ_PPC += $(OBJDIR)/arch/PowerPC/PPCModule.o |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 165 | endif |
| 166 | |
| 167 | |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 168 | DEP_SPARC = |
| 169 | DEP_SPARC += arch/Sparc/SparcGenAsmWriter.inc |
| 170 | DEP_SPARC += arch/Sparc/SparcGenInstrInfo.inc |
| 171 | DEP_SPARC += arch/Sparc/SparcGenSubtargetInfo.inc |
| 172 | DEP_SPARC += arch/Sparc/SparcGenDisassemblerTables.inc |
| 173 | DEP_SPARC += arch/Sparc/SparcGenRegisterInfo.inc |
| 174 | |
| 175 | LIBOBJ_SPARC = |
| 176 | ifneq (,$(findstring sparc,$(CAPSTONE_ARCHS))) |
| 177 | CFLAGS += -DCAPSTONE_HAS_SPARC |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 178 | LIBOBJ_SPARC += $(OBJDIR)/arch/Sparc/SparcDisassembler.o |
| 179 | LIBOBJ_SPARC += $(OBJDIR)/arch/Sparc/SparcInstPrinter.o |
| 180 | LIBOBJ_SPARC += $(OBJDIR)/arch/Sparc/SparcMapping.o |
| 181 | LIBOBJ_SPARC += $(OBJDIR)/arch/Sparc/SparcModule.o |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 182 | endif |
| 183 | |
| 184 | |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 185 | DEP_SYSZ = |
| 186 | DEP_SYSZ += arch/SystemZ/SystemZGenAsmWriter.inc |
| 187 | DEP_SYSZ += arch/SystemZ/SystemZGenInstrInfo.inc |
| 188 | DEP_SYSZ += arch/SystemZ/SystemZGenSubtargetInfo.inc |
| 189 | DEP_SYSZ += arch/SystemZ/SystemZGenDisassemblerTables.inc |
| 190 | DEP_SYSZ += arch/SystemZ/SystemZGenRegisterInfo.inc |
| 191 | |
| 192 | LIBOBJ_SYSZ = |
| 193 | ifneq (,$(findstring systemz,$(CAPSTONE_ARCHS))) |
| 194 | CFLAGS += -DCAPSTONE_HAS_SYSZ |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 195 | LIBOBJ_SYSZ += $(OBJDIR)/arch/SystemZ/SystemZDisassembler.o |
| 196 | LIBOBJ_SYSZ += $(OBJDIR)/arch/SystemZ/SystemZInstPrinter.o |
| 197 | LIBOBJ_SYSZ += $(OBJDIR)/arch/SystemZ/SystemZMapping.o |
| 198 | LIBOBJ_SYSZ += $(OBJDIR)/arch/SystemZ/SystemZModule.o |
| 199 | LIBOBJ_SYSZ += $(OBJDIR)/arch/SystemZ/SystemZMCTargetDesc.o |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 200 | endif |
| 201 | |
| 202 | |
Nguyen Anh Quynh | 9518148 | 2014-03-25 23:20:41 +0800 | [diff] [blame] | 203 | # by default, we compile full X86 instruction sets |
Nguyen Anh Quynh | 59b5489 | 2014-03-27 10:54:44 +0800 | [diff] [blame] | 204 | X86_REDUCE = |
| 205 | ifneq (,$(findstring yes,$(CAPSTONE_X86_REDUCE))) |
| 206 | X86_REDUCE = _reduce |
Nguyen Anh Quynh | 81d930a | 2014-03-28 10:28:57 +0800 | [diff] [blame] | 207 | CFLAGS += -DCAPSTONE_X86_REDUCE -Os |
Nguyen Anh Quynh | 9518148 | 2014-03-25 23:20:41 +0800 | [diff] [blame] | 208 | endif |
| 209 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 210 | DEP_X86 = |
Nguyen Anh Quynh | 59b5489 | 2014-03-27 10:54:44 +0800 | [diff] [blame] | 211 | DEP_X86 += arch/X86/X86GenAsmWriter$(X86_REDUCE).inc |
| 212 | DEP_X86 += arch/X86/X86GenAsmWriter1$(X86_REDUCE).inc |
| 213 | DEP_X86 += arch/X86/X86GenDisassemblerTables$(X86_REDUCE).inc |
| 214 | DEP_X86 += arch/X86/X86GenInstrInfo$(X86_REDUCE).inc |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 215 | DEP_X86 += arch/X86/X86GenRegisterInfo.inc |
| 216 | |
| 217 | LIBOBJ_X86 = |
| 218 | ifneq (,$(findstring x86,$(CAPSTONE_ARCHS))) |
| 219 | CFLAGS += -DCAPSTONE_HAS_X86 |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 220 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86DisassemblerDecoder.o |
| 221 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Disassembler.o |
| 222 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86IntelInstPrinter.o |
Nguyen Anh Quynh | 5068908 | 2014-05-14 12:26:53 +0800 | [diff] [blame] | 223 | # assembly syntax is irrelevant in Diet mode, when this info is suppressed |
| 224 | ifeq (,$(findstring yes,$(CAPSTONE_DIET))) |
baguette | 86e8450 | 2014-08-17 20:59:05 +0200 | [diff] [blame] | 225 | ifeq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE))) |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 226 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86ATTInstPrinter.o |
Nguyen Anh Quynh | 5068908 | 2014-05-14 12:26:53 +0800 | [diff] [blame] | 227 | endif |
baguette | 86e8450 | 2014-08-17 20:59:05 +0200 | [diff] [blame] | 228 | endif |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 229 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Mapping.o |
| 230 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Module.o |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 231 | endif |
| 232 | |
Nguyen Anh Quynh | c80d840 | 2014-05-26 23:02:48 +0800 | [diff] [blame] | 233 | |
| 234 | DEP_XCORE = |
| 235 | DEP_XCORE += arch/XCore/XCoreGenAsmWriter.inc |
| 236 | DEP_XCORE += arch/XCore/XCoreGenInstrInfo.inc |
| 237 | DEP_XCORE += arch/XCore/XCoreGenDisassemblerTables.inc |
| 238 | DEP_XCORE += arch/XCore/XCoreGenRegisterInfo.inc |
| 239 | |
| 240 | LIBOBJ_XCORE = |
| 241 | ifneq (,$(findstring xcore,$(CAPSTONE_ARCHS))) |
| 242 | CFLAGS += -DCAPSTONE_HAS_XCORE |
| 243 | LIBOBJ_XCORE += $(OBJDIR)/arch/XCore/XCoreDisassembler.o |
| 244 | LIBOBJ_XCORE += $(OBJDIR)/arch/XCore/XCoreInstPrinter.o |
| 245 | LIBOBJ_XCORE += $(OBJDIR)/arch/XCore/XCoreMapping.o |
| 246 | LIBOBJ_XCORE += $(OBJDIR)/arch/XCore/XCoreModule.o |
| 247 | endif |
| 248 | |
| 249 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 250 | LIBOBJ = |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 251 | LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o |
Nguyen Anh Quynh | c80d840 | 2014-05-26 23:02:48 +0800 | [diff] [blame] | 252 | LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_X86) $(LIBOBJ_XCORE) |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 253 | LIBOBJ += $(OBJDIR)/MCInst.o |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 254 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 255 | |
Nguyen Anh Quynh | af0e937 | 2014-04-12 23:10:46 +0800 | [diff] [blame] | 256 | PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig |
Nguyen Anh Quynh | 315f02d | 2014-03-25 06:43:19 +0800 | [diff] [blame] | 257 | API_MAJOR=$(shell echo `grep -e CS_API_MAJOR include/capstone.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}') |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 258 | VERSION_EXT = |
Nguyen Anh Quynh | 8f856c7 | 2014-02-24 15:17:40 +0800 | [diff] [blame] | 259 | |
Ron Pinz | d086384 | 2015-12-16 11:46:00 -0500 | [diff] [blame] | 260 | IS_APPLE := $(shell $(CC) -dM -E - < /dev/null | grep -cm 1 -e __apple_build_version__ -e __APPLE_CC__) |
Ole André Vadla Ravnås | c20b049 | 2014-05-01 14:14:57 +0200 | [diff] [blame] | 261 | ifeq ($(IS_APPLE),1) |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 262 | EXT = dylib |
pancake | 2694333 | 2014-02-04 08:37:55 +0100 | [diff] [blame] | 263 | VERSION_EXT = $(API_MAJOR).$(EXT) |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 264 | $(LIBNAME)_LDFLAGS += -dynamiclib -install_name lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR) |
Nguyen Anh Quynh | 4ebdd21 | 2013-12-25 23:54:45 +0800 | [diff] [blame] | 265 | AR_EXT = a |
Nguyen Anh Quynh | e3606d9 | 2014-04-12 18:02:55 +0800 | [diff] [blame] | 266 | # Homebrew wants to make sure its formula does not disable FORTIFY_SOURCE |
Nguyen Anh Quynh | e31327d | 2014-04-29 14:25:15 +0800 | [diff] [blame] | 267 | # However, this is not really necessary because 'CAPSTONE_USE_SYS_DYN_MEM=yes' by default |
Nguyen Anh Quynh | 189e83a | 2014-03-29 22:36:05 +0800 | [diff] [blame] | 268 | ifneq ($(HOMEBREW_CAPSTONE),1) |
Nguyen Anh Quynh | e31327d | 2014-04-29 14:25:15 +0800 | [diff] [blame] | 269 | ifneq ($(CAPSTONE_USE_SYS_DYN_MEM),yes) |
Nguyen Anh Quynh | c77cf3a | 2014-03-07 22:06:51 +0800 | [diff] [blame] | 270 | # remove string check because OSX kernel complains about missing symbols |
| 271 | CFLAGS += -D_FORTIFY_SOURCE=0 |
| 272 | endif |
Nguyen Anh Quynh | 189e83a | 2014-03-29 22:36:05 +0800 | [diff] [blame] | 273 | endif |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 274 | else |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 275 | $(LIBNAME)_LDFLAGS += -shared |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 276 | # Cygwin? |
| 277 | IS_CYGWIN := $(shell $(CC) -dumpmachine | grep -i cygwin | wc -l) |
| 278 | ifeq ($(IS_CYGWIN),1) |
| 279 | EXT = dll |
Nguyen Anh Quynh | 76087d2 | 2014-05-14 14:53:51 +0800 | [diff] [blame] | 280 | AR_EXT = lib |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 281 | # Cygwin doesn't like -fPIC |
| 282 | CFLAGS := $(CFLAGS:-fPIC=) |
| 283 | # On Windows we need the shared library to be executable |
| 284 | else |
| 285 | # mingw? |
| 286 | IS_MINGW := $(shell $(CC) --version | grep -i mingw | wc -l) |
| 287 | ifeq ($(IS_MINGW),1) |
| 288 | EXT = dll |
Nguyen Anh Quynh | 76087d2 | 2014-05-14 14:53:51 +0800 | [diff] [blame] | 289 | AR_EXT = lib |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 290 | # mingw doesn't like -fPIC either |
| 291 | CFLAGS := $(CFLAGS:-fPIC=) |
| 292 | # On Windows we need the shared library to be executable |
Nguyen Anh Quynh | 4ebdd21 | 2013-12-25 23:54:45 +0800 | [diff] [blame] | 293 | else |
| 294 | # Linux, *BSD |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 295 | EXT = so |
| 296 | VERSION_EXT = $(EXT).$(API_MAJOR) |
Nguyen Anh Quynh | 6d5381e | 2014-03-17 10:37:08 +0800 | [diff] [blame] | 297 | AR_EXT = a |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 298 | $(LIBNAME)_LDFLAGS += -Wl,-soname,lib$(LIBNAME).$(VERSION_EXT) |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 299 | endif |
| 300 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 301 | endif |
| 302 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 303 | ifeq ($(CAPSTONE_SHARED),yes) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 304 | ifeq ($(IS_MINGW),1) |
| 305 | LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT) |
| 306 | else ifeq ($(IS_CYGWIN),1) |
| 307 | LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT) |
| 308 | else # *nix |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 309 | LIBRARY = $(BLDIR)/lib$(LIBNAME).$(EXT) |
Hilko Bengen | d83bf84 | 2015-02-26 18:37:32 +0100 | [diff] [blame] | 310 | CFLAGS += -fvisibility=hidden |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 311 | endif |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 312 | endif |
| 313 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 314 | ifeq ($(CAPSTONE_STATIC),yes) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 315 | ifeq ($(IS_MINGW),1) |
| 316 | ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) |
| 317 | else ifeq ($(IS_CYGWIN),1) |
| 318 | ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) |
| 319 | else |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 320 | ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 321 | endif |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 322 | endif |
| 323 | |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 324 | PKGCFGF = $(BLDIR)/$(LIBNAME).pc |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 325 | |
Nguyen Anh Quynh | 5bbbfce | 2014-02-28 10:49:46 +0800 | [diff] [blame] | 326 | .PHONY: all clean install uninstall dist |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 327 | |
Nguyen Anh Quynh | 80ff30b | 2013-12-09 00:38:44 +0800 | [diff] [blame] | 328 | all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF) |
Nguyen Anh Quynh | 19af3ec | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 329 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame^] | 330 | @V=$(V) $(MAKE) -C cstool |
Nguyen Anh Quynh | 243d41e | 2015-01-28 04:42:34 +0800 | [diff] [blame] | 331 | ifndef BUILDDIR |
| 332 | cd tests && $(MAKE) |
| 333 | else |
| 334 | cd tests && $(MAKE) BUILDDIR=$(BLDIR) |
| 335 | endif |
Akihiko Odaki | 798821f | 2016-09-03 10:54:56 +0900 | [diff] [blame] | 336 | $(call install-library,$(BLDIR)/tests/) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 337 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 338 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 339 | ifeq ($(CAPSTONE_SHARED),yes) |
pancake | addb192 | 2014-02-28 02:44:07 +0100 | [diff] [blame] | 340 | $(LIBRARY): $(LIBOBJ) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 341 | ifeq ($(V),0) |
Nguyen Anh Quynh | 8c0ab86 | 2014-06-03 23:43:53 +0700 | [diff] [blame] | 342 | $(call log,LINK,$(@:$(BLDIR)/%=%)) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 343 | @$(create-library) |
| 344 | else |
| 345 | $(create-library) |
| 346 | endif |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 347 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 348 | |
Nguyen Anh Quynh | aeb0c40 | 2014-03-27 17:54:27 +0800 | [diff] [blame] | 349 | $(LIBOBJ): config.mk |
| 350 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 351 | $(LIBOBJ_ARM): $(DEP_ARM) |
| 352 | $(LIBOBJ_ARM64): $(DEP_ARM64) |
| 353 | $(LIBOBJ_MIPS): $(DEP_MIPS) |
| 354 | $(LIBOBJ_PPC): $(DEP_PPC) |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 355 | $(LIBOBJ_SPARC): $(DEP_SPARC) |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 356 | $(LIBOBJ_SYSZ): $(DEP_SYSZ) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 357 | $(LIBOBJ_X86): $(DEP_X86) |
Nguyen Anh Quynh | c80d840 | 2014-05-26 23:02:48 +0800 | [diff] [blame] | 358 | $(LIBOBJ_XCORE): $(DEP_XCORE) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 359 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 360 | ifeq ($(CAPSTONE_STATIC),yes) |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 361 | $(ARCHIVE): $(LIBOBJ) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 362 | @rm -f $(ARCHIVE) |
| 363 | ifeq ($(V),0) |
| 364 | $(call log,AR,$(@:$(BLDIR)/%=%)) |
| 365 | @$(create-archive) |
| 366 | else |
| 367 | $(create-archive) |
| 368 | endif |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 369 | endif |
pancake | f1cbce2 | 2013-11-27 15:31:26 +0100 | [diff] [blame] | 370 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 371 | $(PKGCFGF): |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 372 | ifeq ($(V),0) |
| 373 | $(call log,GEN,$(@:$(BLDIR)/%=%)) |
| 374 | @$(generate-pkgcfg) |
Nguyen Anh Quynh | 3ff259c | 2014-03-07 17:11:18 +0800 | [diff] [blame] | 375 | else |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 376 | $(generate-pkgcfg) |
Nguyen Anh Quynh | 3ff259c | 2014-03-07 17:11:18 +0800 | [diff] [blame] | 377 | endif |
pancake | 44ce0fb | 2013-12-03 04:11:37 +0100 | [diff] [blame] | 378 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 379 | install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY) |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 380 | mkdir -p $(LIBDIR) |
Akihiko Odaki | 798821f | 2016-09-03 10:54:56 +0900 | [diff] [blame] | 381 | $(call install-library,$(LIBDIR)) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 382 | ifeq ($(CAPSTONE_STATIC),yes) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 383 | $(INSTALL_DATA) $(ARCHIVE) $(LIBDIR) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 384 | endif |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 385 | mkdir -p $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 3524056 | 2014-01-04 09:18:48 +0800 | [diff] [blame] | 386 | $(INSTALL_DATA) include/*.h $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 9b4b377 | 2014-04-12 18:06:54 +0800 | [diff] [blame] | 387 | mkdir -p $(PKGCFGDIR) |
| 388 | $(INSTALL_DATA) $(PKGCFGF) $(PKGCFGDIR)/ |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame^] | 389 | mkdir -p $(BINDIR) |
| 390 | $(INSTALL_LIB) cstool/cstool $(BINDIR) |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 391 | |
| 392 | uninstall: |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 393 | rm -rf $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 6d5381e | 2014-03-17 10:37:08 +0800 | [diff] [blame] | 394 | rm -f $(LIBDIR)/lib$(LIBNAME).* |
Nguyen Anh Quynh | 9b4b377 | 2014-04-12 18:06:54 +0800 | [diff] [blame] | 395 | rm -f $(PKGCFGDIR)/$(LIBNAME).pc |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame^] | 396 | rm -f $(BINDIR)/cstool |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 397 | |
| 398 | clean: |
Nguyen Anh Quynh | 5519a68 | 2014-04-29 16:24:30 +0800 | [diff] [blame] | 399 | rm -f $(LIBOBJ) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 400 | rm -f $(BLDIR)/lib$(LIBNAME).* $(BLDIR)/$(LIBNAME).* |
Nguyen Anh Quynh | d63ddac | 2014-01-09 10:35:58 +0800 | [diff] [blame] | 401 | rm -f $(PKGCFGF) |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame^] | 402 | $(MAKE) -C cstool clean |
Nguyen Tan Cong | 3d6e56a | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 403 | |
Nguyen Anh Quynh | 19af3ec | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 404 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
danghvu | ad66420 | 2014-05-12 14:27:38 -0500 | [diff] [blame] | 405 | cd tests && $(MAKE) clean |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 406 | rm -f $(BLDIR)/tests/lib$(LIBNAME).$(EXT) |
Nguyen Tan Cong | 3d6e56a | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 407 | endif |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 408 | |
| 409 | ifdef BUILDDIR |
| 410 | rm -rf $(BUILDDIR) |
| 411 | endif |
Nguyen Anh Quynh | 5519a68 | 2014-04-29 16:24:30 +0800 | [diff] [blame] | 412 | |
Nguyen Anh Quynh | 19af3ec | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 413 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
danghvu | ad66420 | 2014-05-12 14:27:38 -0500 | [diff] [blame] | 414 | cd bindings/python && $(MAKE) clean |
| 415 | cd bindings/java && $(MAKE) clean |
| 416 | cd bindings/ocaml && $(MAKE) clean |
Nguyen Tan Cong | 3d6e56a | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 417 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 418 | |
Nguyen Anh Quynh | a580d92 | 2014-01-18 12:47:15 +0800 | [diff] [blame] | 419 | |
| 420 | TAG ?= HEAD |
| 421 | ifeq ($(TAG), HEAD) |
| 422 | DIST_VERSION = latest |
| 423 | else |
| 424 | DIST_VERSION = $(TAG) |
| 425 | endif |
| 426 | |
pancake | 35cef7f | 2014-01-18 03:42:15 +0100 | [diff] [blame] | 427 | dist: |
Nguyen Anh Quynh | 186d501 | 2014-01-22 18:46:20 +0800 | [diff] [blame] | 428 | git archive --format=tar.gz --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).tgz |
Nguyen Anh Quynh | f4f7253 | 2014-03-11 12:29:16 +0800 | [diff] [blame] | 429 | git archive --format=zip --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).zip |
pancake | 35cef7f | 2014-01-18 03:42:15 +0100 | [diff] [blame] | 430 | |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 431 | |
| 432 | TESTS = test test_detail test_arm test_arm64 test_mips test_ppc test_sparc |
Nguyen Anh Quynh | b16dc85 | 2014-11-02 08:21:34 +0800 | [diff] [blame] | 433 | TESTS += test_systemz test_x86 test_xcore test_iter |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 434 | TESTS += test.static test_detail.static test_arm.static test_arm64.static |
| 435 | TESTS += test_mips.static test_ppc.static test_sparc.static |
| 436 | TESTS += test_systemz.static test_x86.static test_xcore.static |
Nguyen Anh Quynh | b16dc85 | 2014-11-02 08:21:34 +0800 | [diff] [blame] | 437 | TESTS += test_skipdata test_skipdata.static test_iter.static |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 438 | check: |
| 439 | @for t in $(TESTS); do \ |
| 440 | echo Check $$t ... ; \ |
Akihiko Odaki | 798821f | 2016-09-03 10:54:56 +0900 | [diff] [blame] | 441 | LD_LIBRARY_PATH=./tests ./tests/$$t > /dev/null && echo OK || echo FAILED; \ |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 442 | done |
| 443 | |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 444 | $(OBJDIR)/%.o: %.c |
| 445 | @mkdir -p $(@D) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 446 | ifeq ($(V),0) |
| 447 | $(call log,CC,$(@:$(OBJDIR)/%=%)) |
| 448 | @$(compile) |
| 449 | else |
| 450 | $(compile) |
| 451 | endif |
| 452 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 453 | |
Akihiko Odaki | 798821f | 2016-09-03 10:54:56 +0900 | [diff] [blame] | 454 | ifeq ($(CAPSTONE_SHARED),yes) |
| 455 | define install-library |
| 456 | $(INSTALL_LIB) $(LIBRARY) $1 |
| 457 | $(if $(VERSION_EXT), |
| 458 | cd $1 && \ |
| 459 | mv lib$(LIBNAME).$(EXT) lib$(LIBNAME).$(VERSION_EXT) && \ |
| 460 | ln -s lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT)) |
| 461 | endef |
| 462 | else |
| 463 | define install-library |
| 464 | endef |
| 465 | endif |
| 466 | |
| 467 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 468 | define create-archive |
| 469 | $(AR) q $(ARCHIVE) $(LIBOBJ) |
| 470 | $(RANLIB) $(ARCHIVE) |
| 471 | endef |
| 472 | |
Nguyen Anh Quynh | 58a0047 | 2014-05-01 22:53:52 +0800 | [diff] [blame] | 473 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 474 | define create-library |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 475 | $(CC) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 476 | endef |
| 477 | |
Nguyen Anh Quynh | 58a0047 | 2014-05-01 22:53:52 +0800 | [diff] [blame] | 478 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 479 | define generate-pkgcfg |
| 480 | echo 'Name: capstone' > $(PKGCFGF) |
| 481 | echo 'Description: Capstone disassembly engine' >> $(PKGCFGF) |
| 482 | echo 'Version: $(PKG_VERSION)' >> $(PKGCFGF) |
| 483 | echo 'libdir=$(LIBDIR)' >> $(PKGCFGF) |
Nguyen Anh Quynh | fff1307 | 2014-10-02 16:14:26 +0800 | [diff] [blame] | 484 | echo 'includedir=$(INCDIR)/capstone' >> $(PKGCFGF) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 485 | echo 'archive=$${libdir}/libcapstone.a' >> $(PKGCFGF) |
| 486 | echo 'Libs: -L$${libdir} -lcapstone' >> $(PKGCFGF) |
| 487 | echo 'Cflags: -I$${includedir}' >> $(PKGCFGF) |
| 488 | endef |