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 | |
Stephen | 5e184ec | 2018-05-16 16:55:44 -0700 | [diff] [blame] | 11 | OS := $(shell uname) |
| 12 | ifeq ($(OS),Darwin) |
| 13 | LIBARCHS = i386 x86_64 |
| 14 | PREFIX ?= /usr/local |
| 15 | endif |
| 16 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 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 | |
Nguyen Anh Quynh | d80cede | 2014-01-16 21:07:59 +0800 | [diff] [blame] | 23 | ifeq ($(CROSS),) |
Nguyen Anh Quynh | d80cede | 2014-01-16 21:07:59 +0800 | [diff] [blame] | 24 | RANLIB ?= ranlib |
Nguyen Anh Quynh | d80cede | 2014-01-16 21:07:59 +0800 | [diff] [blame] | 25 | else |
| 26 | CC = $(CROSS)gcc |
| 27 | AR = $(CROSS)ar |
| 28 | RANLIB = $(CROSS)ranlib |
| 29 | STRIP = $(CROSS)strip |
| 30 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 31 | |
Nguyen Anh Quynh | 77af9fb | 2014-04-29 07:11:55 +0800 | [diff] [blame] | 32 | ifneq (,$(findstring yes,$(CAPSTONE_DIET))) |
| 33 | CFLAGS ?= -Os |
| 34 | CFLAGS += -DCAPSTONE_DIET |
| 35 | else |
| 36 | CFLAGS ?= -O3 |
| 37 | endif |
| 38 | |
baguette | 86e8450 | 2014-08-17 20:59:05 +0200 | [diff] [blame] | 39 | ifneq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE))) |
| 40 | CFLAGS += -DCAPSTONE_X86_ATT_DISABLE |
| 41 | endif |
| 42 | |
Richard Henderson | 22ead3e | 2017-10-21 17:45:40 -0700 | [diff] [blame] | 43 | CFLAGS += -fPIC -Wall -Wwrite-strings -Iinclude |
Nguyen Anh Quynh | 59492c2 | 2014-01-05 23:41:31 +0800 | [diff] [blame] | 44 | |
Nguyen Anh Quynh | e31327d | 2014-04-29 14:25:15 +0800 | [diff] [blame] | 45 | ifeq ($(CAPSTONE_USE_SYS_DYN_MEM),yes) |
Nguyen Anh Quynh | 87a3f69 | 2014-05-10 19:26:32 +0800 | [diff] [blame] | 46 | CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM |
Nguyen Anh Quynh | 59492c2 | 2014-01-05 23:41:31 +0800 | [diff] [blame] | 47 | endif |
| 48 | |
reverser | bcf09f4 | 2015-04-09 18:28:19 +0100 | [diff] [blame] | 49 | ifeq ($(CAPSTONE_HAS_OSXKERNEL), yes) |
| 50 | CFLAGS += -DCAPSTONE_HAS_OSXKERNEL |
Pb | b8741bd | 2015-11-10 23:02:26 +0100 | [diff] [blame] | 51 | SDKROOT ?= $(shell xcodebuild -version -sdk macosx Path) |
| 52 | CFLAGS += -mmacosx-version-min=10.5 \ |
| 53 | -isysroot$(SDKROOT) \ |
| 54 | -I$(SDKROOT)/System/Library/Frameworks/Kernel.framework/Headers \ |
| 55 | -mkernel \ |
| 56 | -fno-builtin |
reverser | bcf09f4 | 2015-04-09 18:28:19 +0100 | [diff] [blame] | 57 | endif |
| 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) |
Jonas | 60f17f5 | 2017-09-05 16:45:48 +0200 | [diff] [blame] | 262 | # on MacOS, compile in Universal format by default |
| 263 | MACOS_UNIVERSAL ?= yes |
| 264 | ifeq ($(MACOS_UNIVERSAL),yes) |
| 265 | CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
| 266 | LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
| 267 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 268 | EXT = dylib |
pancake | 2694333 | 2014-02-04 08:37:55 +0100 | [diff] [blame] | 269 | VERSION_EXT = $(API_MAJOR).$(EXT) |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 270 | $(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] | 271 | AR_EXT = a |
Nguyen Anh Quynh | e3606d9 | 2014-04-12 18:02:55 +0800 | [diff] [blame] | 272 | # 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] | 273 | # 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] | 274 | ifneq ($(HOMEBREW_CAPSTONE),1) |
Nguyen Anh Quynh | e31327d | 2014-04-29 14:25:15 +0800 | [diff] [blame] | 275 | ifneq ($(CAPSTONE_USE_SYS_DYN_MEM),yes) |
Nguyen Anh Quynh | c77cf3a | 2014-03-07 22:06:51 +0800 | [diff] [blame] | 276 | # remove string check because OSX kernel complains about missing symbols |
| 277 | CFLAGS += -D_FORTIFY_SOURCE=0 |
| 278 | endif |
Nguyen Anh Quynh | 189e83a | 2014-03-29 22:36:05 +0800 | [diff] [blame] | 279 | endif |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 280 | else |
Jonas | 60f17f5 | 2017-09-05 16:45:48 +0200 | [diff] [blame] | 281 | CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
| 282 | LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 283 | $(LIBNAME)_LDFLAGS += -shared |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 284 | # Cygwin? |
| 285 | IS_CYGWIN := $(shell $(CC) -dumpmachine | grep -i cygwin | wc -l) |
| 286 | ifeq ($(IS_CYGWIN),1) |
| 287 | EXT = dll |
Nguyen Anh Quynh | 76087d2 | 2014-05-14 14:53:51 +0800 | [diff] [blame] | 288 | AR_EXT = lib |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 289 | # Cygwin doesn't like -fPIC |
| 290 | CFLAGS := $(CFLAGS:-fPIC=) |
| 291 | # On Windows we need the shared library to be executable |
| 292 | else |
| 293 | # mingw? |
| 294 | IS_MINGW := $(shell $(CC) --version | grep -i mingw | wc -l) |
| 295 | ifeq ($(IS_MINGW),1) |
| 296 | EXT = dll |
Nguyen Anh Quynh | 76087d2 | 2014-05-14 14:53:51 +0800 | [diff] [blame] | 297 | AR_EXT = lib |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 298 | # mingw doesn't like -fPIC either |
| 299 | CFLAGS := $(CFLAGS:-fPIC=) |
| 300 | # On Windows we need the shared library to be executable |
Nguyen Anh Quynh | 4ebdd21 | 2013-12-25 23:54:45 +0800 | [diff] [blame] | 301 | else |
| 302 | # Linux, *BSD |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 303 | EXT = so |
| 304 | VERSION_EXT = $(EXT).$(API_MAJOR) |
Nguyen Anh Quynh | 6d5381e | 2014-03-17 10:37:08 +0800 | [diff] [blame] | 305 | AR_EXT = a |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 306 | $(LIBNAME)_LDFLAGS += -Wl,-soname,lib$(LIBNAME).$(VERSION_EXT) |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 307 | endif |
| 308 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 309 | endif |
| 310 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 311 | ifeq ($(CAPSTONE_SHARED),yes) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 312 | ifeq ($(IS_MINGW),1) |
| 313 | LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT) |
| 314 | else ifeq ($(IS_CYGWIN),1) |
| 315 | LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT) |
| 316 | else # *nix |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 317 | LIBRARY = $(BLDIR)/lib$(LIBNAME).$(EXT) |
Hilko Bengen | d83bf84 | 2015-02-26 18:37:32 +0100 | [diff] [blame] | 318 | CFLAGS += -fvisibility=hidden |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 319 | endif |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 320 | endif |
| 321 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 322 | ifeq ($(CAPSTONE_STATIC),yes) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 323 | ifeq ($(IS_MINGW),1) |
| 324 | ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) |
| 325 | else ifeq ($(IS_CYGWIN),1) |
| 326 | ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) |
| 327 | else |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 328 | ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 329 | endif |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 330 | endif |
| 331 | |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 332 | PKGCFGF = $(BLDIR)/$(LIBNAME).pc |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 333 | |
Nguyen Anh Quynh | 5bbbfce | 2014-02-28 10:49:46 +0800 | [diff] [blame] | 334 | .PHONY: all clean install uninstall dist |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 335 | |
Nguyen Anh Quynh | 80ff30b | 2013-12-09 00:38:44 +0800 | [diff] [blame] | 336 | all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF) |
Nguyen Anh Quynh | 19af3ec | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 337 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
Adrian Herrera | 229593d | 2017-06-02 15:49:10 +0200 | [diff] [blame] | 338 | @V=$(V) CC=$(CC) $(MAKE) -C cstool |
Nguyen Anh Quynh | 243d41e | 2015-01-28 04:42:34 +0800 | [diff] [blame] | 339 | ifndef BUILDDIR |
Stephen | 4d38800 | 2018-05-11 20:36:10 -0700 | [diff] [blame] | 340 | $(MAKE) -C tests |
Nguyen Anh Quynh | 243d41e | 2015-01-28 04:42:34 +0800 | [diff] [blame] | 341 | else |
Stephen | 4d38800 | 2018-05-11 20:36:10 -0700 | [diff] [blame] | 342 | $(MAKE) -C tests BUILDDIR=$(BLDIR) |
Nguyen Anh Quynh | 243d41e | 2015-01-28 04:42:34 +0800 | [diff] [blame] | 343 | endif |
Akihiko Odaki | 798821f | 2016-09-03 10:54:56 +0900 | [diff] [blame] | 344 | $(call install-library,$(BLDIR)/tests/) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 345 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 346 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 347 | ifeq ($(CAPSTONE_SHARED),yes) |
pancake | addb192 | 2014-02-28 02:44:07 +0100 | [diff] [blame] | 348 | $(LIBRARY): $(LIBOBJ) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 349 | ifeq ($(V),0) |
Nguyen Anh Quynh | 8c0ab86 | 2014-06-03 23:43:53 +0700 | [diff] [blame] | 350 | $(call log,LINK,$(@:$(BLDIR)/%=%)) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 351 | @$(create-library) |
| 352 | else |
| 353 | $(create-library) |
| 354 | endif |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 355 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 356 | |
Nguyen Anh Quynh | 648b398 | 2016-10-23 02:00:47 +0800 | [diff] [blame] | 357 | $(LIBOBJ): *.h include/*.h config.mk |
Nguyen Anh Quynh | aeb0c40 | 2014-03-27 17:54:27 +0800 | [diff] [blame] | 358 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 359 | $(LIBOBJ_ARM): $(DEP_ARM) |
| 360 | $(LIBOBJ_ARM64): $(DEP_ARM64) |
| 361 | $(LIBOBJ_MIPS): $(DEP_MIPS) |
| 362 | $(LIBOBJ_PPC): $(DEP_PPC) |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 363 | $(LIBOBJ_SPARC): $(DEP_SPARC) |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 364 | $(LIBOBJ_SYSZ): $(DEP_SYSZ) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 365 | $(LIBOBJ_X86): $(DEP_X86) |
Nguyen Anh Quynh | c80d840 | 2014-05-26 23:02:48 +0800 | [diff] [blame] | 366 | $(LIBOBJ_XCORE): $(DEP_XCORE) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 367 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 368 | ifeq ($(CAPSTONE_STATIC),yes) |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 369 | $(ARCHIVE): $(LIBOBJ) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 370 | @rm -f $(ARCHIVE) |
| 371 | ifeq ($(V),0) |
| 372 | $(call log,AR,$(@:$(BLDIR)/%=%)) |
| 373 | @$(create-archive) |
| 374 | else |
| 375 | $(create-archive) |
| 376 | endif |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 377 | endif |
pancake | f1cbce2 | 2013-11-27 15:31:26 +0100 | [diff] [blame] | 378 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 379 | $(PKGCFGF): |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 380 | ifeq ($(V),0) |
| 381 | $(call log,GEN,$(@:$(BLDIR)/%=%)) |
| 382 | @$(generate-pkgcfg) |
Nguyen Anh Quynh | 3ff259c | 2014-03-07 17:11:18 +0800 | [diff] [blame] | 383 | else |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 384 | $(generate-pkgcfg) |
Nguyen Anh Quynh | 3ff259c | 2014-03-07 17:11:18 +0800 | [diff] [blame] | 385 | endif |
pancake | 44ce0fb | 2013-12-03 04:11:37 +0100 | [diff] [blame] | 386 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 387 | install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY) |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 388 | mkdir -p $(LIBDIR) |
Akihiko Odaki | 798821f | 2016-09-03 10:54:56 +0900 | [diff] [blame] | 389 | $(call install-library,$(LIBDIR)) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 390 | ifeq ($(CAPSTONE_STATIC),yes) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 391 | $(INSTALL_DATA) $(ARCHIVE) $(LIBDIR) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 392 | endif |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 393 | mkdir -p $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 3524056 | 2014-01-04 09:18:48 +0800 | [diff] [blame] | 394 | $(INSTALL_DATA) include/*.h $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 9b4b377 | 2014-04-12 18:06:54 +0800 | [diff] [blame] | 395 | mkdir -p $(PKGCFGDIR) |
| 396 | $(INSTALL_DATA) $(PKGCFGF) $(PKGCFGDIR)/ |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 397 | mkdir -p $(BINDIR) |
| 398 | $(INSTALL_LIB) cstool/cstool $(BINDIR) |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 399 | |
| 400 | uninstall: |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 401 | rm -rf $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 6d5381e | 2014-03-17 10:37:08 +0800 | [diff] [blame] | 402 | rm -f $(LIBDIR)/lib$(LIBNAME).* |
Nguyen Anh Quynh | 9b4b377 | 2014-04-12 18:06:54 +0800 | [diff] [blame] | 403 | rm -f $(PKGCFGDIR)/$(LIBNAME).pc |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 404 | rm -f $(BINDIR)/cstool |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 405 | |
| 406 | clean: |
Nguyen Anh Quynh | 5519a68 | 2014-04-29 16:24:30 +0800 | [diff] [blame] | 407 | rm -f $(LIBOBJ) |
Nguyen Anh Quynh | f4c5d5e | 2017-05-05 09:46:46 +0800 | [diff] [blame] | 408 | rm -f $(BLDIR)/lib$(LIBNAME).* $(BLDIR)/$(LIBNAME).pc |
Nguyen Anh Quynh | d63ddac | 2014-01-09 10:35:58 +0800 | [diff] [blame] | 409 | rm -f $(PKGCFGF) |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 410 | $(MAKE) -C cstool clean |
Nguyen Tan Cong | 3d6e56a | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 411 | |
Nguyen Anh Quynh | 19af3ec | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 412 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
Stephen | 4d38800 | 2018-05-11 20:36:10 -0700 | [diff] [blame] | 413 | $(MAKE) -C tests clean |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 414 | rm -f $(BLDIR)/tests/lib$(LIBNAME).$(EXT) |
Nguyen Tan Cong | 3d6e56a | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 415 | endif |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 416 | |
| 417 | ifdef BUILDDIR |
| 418 | rm -rf $(BUILDDIR) |
| 419 | endif |
Nguyen Anh Quynh | 5519a68 | 2014-04-29 16:24:30 +0800 | [diff] [blame] | 420 | |
Nguyen Anh Quynh | 19af3ec | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 421 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
Stephen | 4d38800 | 2018-05-11 20:36:10 -0700 | [diff] [blame] | 422 | $(MAKE) -C bindings/python clean |
| 423 | $(MAKE) -C bindings/java clean |
| 424 | $(MAKE) -C bindings/ocaml clean |
Nguyen Tan Cong | 3d6e56a | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 425 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 426 | |
Nguyen Anh Quynh | a580d92 | 2014-01-18 12:47:15 +0800 | [diff] [blame] | 427 | |
| 428 | TAG ?= HEAD |
| 429 | ifeq ($(TAG), HEAD) |
| 430 | DIST_VERSION = latest |
| 431 | else |
| 432 | DIST_VERSION = $(TAG) |
| 433 | endif |
| 434 | |
pancake | 35cef7f | 2014-01-18 03:42:15 +0100 | [diff] [blame] | 435 | dist: |
Nguyen Anh Quynh | 186d501 | 2014-01-22 18:46:20 +0800 | [diff] [blame] | 436 | 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] | 437 | git archive --format=zip --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).zip |
pancake | 35cef7f | 2014-01-18 03:42:15 +0100 | [diff] [blame] | 438 | |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 439 | |
Nick Briggs | ce3f0d0 | 2017-05-11 08:58:12 -0700 | [diff] [blame] | 440 | TESTS = test_basic 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] | 441 | TESTS += test_systemz test_x86 test_xcore test_iter |
Nick Briggs | ce3f0d0 | 2017-05-11 08:58:12 -0700 | [diff] [blame] | 442 | TESTS += test_basic.static test_detail.static test_arm.static test_arm64.static |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 443 | TESTS += test_mips.static test_ppc.static test_sparc.static |
| 444 | TESTS += test_systemz.static test_x86.static test_xcore.static |
Nguyen Anh Quynh | b16dc85 | 2014-11-02 08:21:34 +0800 | [diff] [blame] | 445 | TESTS += test_skipdata test_skipdata.static test_iter.static |
Stephen | 9361378 | 2018-05-25 08:59:30 -0400 | [diff] [blame] | 446 | check: $(TESTS) |
| 447 | test_%: |
| 448 | ./tests/$@ > /dev/null && echo OK || echo FAILED |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 449 | |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 450 | $(OBJDIR)/%.o: %.c |
| 451 | @mkdir -p $(@D) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 452 | ifeq ($(V),0) |
| 453 | $(call log,CC,$(@:$(OBJDIR)/%=%)) |
| 454 | @$(compile) |
| 455 | else |
| 456 | $(compile) |
| 457 | endif |
| 458 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 459 | |
Akihiko Odaki | 798821f | 2016-09-03 10:54:56 +0900 | [diff] [blame] | 460 | ifeq ($(CAPSTONE_SHARED),yes) |
| 461 | define install-library |
| 462 | $(INSTALL_LIB) $(LIBRARY) $1 |
| 463 | $(if $(VERSION_EXT), |
| 464 | cd $1 && \ |
| 465 | mv lib$(LIBNAME).$(EXT) lib$(LIBNAME).$(VERSION_EXT) && \ |
| 466 | ln -s lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT)) |
| 467 | endef |
| 468 | else |
| 469 | define install-library |
| 470 | endef |
| 471 | endif |
| 472 | |
| 473 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 474 | define create-archive |
| 475 | $(AR) q $(ARCHIVE) $(LIBOBJ) |
| 476 | $(RANLIB) $(ARCHIVE) |
| 477 | endef |
| 478 | |
Nguyen Anh Quynh | 58a0047 | 2014-05-01 22:53:52 +0800 | [diff] [blame] | 479 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 480 | define create-library |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 481 | $(CC) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 482 | endef |
| 483 | |
Nguyen Anh Quynh | 58a0047 | 2014-05-01 22:53:52 +0800 | [diff] [blame] | 484 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 485 | define generate-pkgcfg |
| 486 | echo 'Name: capstone' > $(PKGCFGF) |
| 487 | echo 'Description: Capstone disassembly engine' >> $(PKGCFGF) |
| 488 | echo 'Version: $(PKG_VERSION)' >> $(PKGCFGF) |
| 489 | echo 'libdir=$(LIBDIR)' >> $(PKGCFGF) |
Nguyen Anh Quynh | fff1307 | 2014-10-02 16:14:26 +0800 | [diff] [blame] | 490 | echo 'includedir=$(INCDIR)/capstone' >> $(PKGCFGF) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 491 | echo 'archive=$${libdir}/libcapstone.a' >> $(PKGCFGF) |
| 492 | echo 'Libs: -L$${libdir} -lcapstone' >> $(PKGCFGF) |
| 493 | echo 'Cflags: -I$${includedir}' >> $(PKGCFGF) |
| 494 | endef |