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 | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 6 | |
Nguyen Anh Quynh | d80cede | 2014-01-16 21:07:59 +0800 | [diff] [blame] | 7 | ifeq ($(CROSS),) |
| 8 | CC ?= cc |
| 9 | AR ?= ar |
| 10 | RANLIB ?= ranlib |
| 11 | STRIP ?= strip |
| 12 | else |
| 13 | CC = $(CROSS)gcc |
| 14 | AR = $(CROSS)ar |
| 15 | RANLIB = $(CROSS)ranlib |
| 16 | STRIP = $(CROSS)strip |
| 17 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 18 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 19 | CFLAGS += -fPIC -O3 -Wall -Iinclude |
Nguyen Anh Quynh | 59492c2 | 2014-01-05 23:41:31 +0800 | [diff] [blame] | 20 | |
| 21 | ifeq ($(USE_SYS_DYN_MEM),yes) |
| 22 | CFLAGS += -DUSE_SYS_DYN_MEM |
| 23 | endif |
| 24 | |
Nguyen Anh Quynh | 901631e | 2014-03-27 17:14:57 +0800 | [diff] [blame] | 25 | ifneq (,$(findstring yes,$(CAPSTONE_DIET))) |
Nguyen Anh Quynh | 81d930a | 2014-03-28 10:28:57 +0800 | [diff] [blame] | 26 | CFLAGS += -DCAPSTONE_DIET -Os |
Nguyen Anh Quynh | 901631e | 2014-03-27 17:14:57 +0800 | [diff] [blame] | 27 | endif |
| 28 | |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 29 | PREFIX ?= /usr |
| 30 | DESTDIR ?= |
| 31 | INCDIR = $(DESTDIR)$(PREFIX)/include |
Nguyen Anh Quynh | 9f0e6c2 | 2013-12-25 22:47:28 +0800 | [diff] [blame] | 32 | |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 33 | LIBDIR = $(DESTDIR)$(PREFIX)/lib |
Nguyen Anh Quynh | 9f0e6c2 | 2013-12-25 22:47:28 +0800 | [diff] [blame] | 34 | # on x86_64, we might have /usr/lib64 directory instead of /usr/lib |
Nguyen Anh Quynh | 2844cc5 | 2014-03-05 23:49:14 +0800 | [diff] [blame] | 35 | UNAME_M := $(shell uname -m) |
Nguyen Anh Quynh | 235a274 | 2014-03-29 21:09:35 +0800 | [diff] [blame] | 36 | UNAME_S := $(shell uname -s) |
Nguyen Anh Quynh | 2844cc5 | 2014-03-05 23:49:14 +0800 | [diff] [blame] | 37 | ifeq ($(UNAME_M), x86_64) |
Nguyen Anh Quynh | c0b63dc | 2014-01-01 21:40:49 +0800 | [diff] [blame] | 38 | ifeq (,$(wildcard $(LIBDIR))) |
Nguyen Anh Quynh | 1d44753 | 2014-03-29 05:48:12 -0700 | [diff] [blame] | 39 | ifneq ($(UNAME_S), Darwin) |
Nguyen Anh Quynh | c0b63dc | 2014-01-01 21:40:49 +0800 | [diff] [blame] | 40 | LIBDIR = $(DESTDIR)$(PREFIX)/lib64 |
Nguyen Anh Quynh | c0b63dc | 2014-01-01 21:40:49 +0800 | [diff] [blame] | 41 | endif |
Nguyen Anh Quynh | 9f0e6c2 | 2013-12-25 22:47:28 +0800 | [diff] [blame] | 42 | endif |
Nguyen Anh Quynh | 1d44753 | 2014-03-29 05:48:12 -0700 | [diff] [blame] | 43 | endif |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 44 | |
Nguyen Anh Quynh | 927b2ad | 2014-03-30 22:25:16 +0800 | [diff] [blame] | 45 | ifneq ($(UNAME_S),Darwin) |
| 46 | LDFLAGS += -shared |
| 47 | endif |
| 48 | |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 49 | LIBDATADIR = $(LIBDIR) |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 50 | ifeq ($(UNAME_S), FreeBSD) |
| 51 | LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 52 | endif |
Oliver Pinter | 25efded | 2014-03-23 19:10:13 +0100 | [diff] [blame] | 53 | ifeq ($(UNAME_S), DragonFly) |
| 54 | LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata |
| 55 | endif |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 56 | |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 57 | INSTALL_BIN ?= install |
| 58 | INSTALL_DATA ?= $(INSTALL_BIN) -m0644 |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 59 | INSTALL_LIB ?= $(INSTALL_BIN) -m0755 |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 60 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 61 | LIBNAME = capstone |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 62 | |
Nguyen Anh Quynh | 42c6b1a | 2013-12-30 00:15:25 +0800 | [diff] [blame] | 63 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 64 | DEP_ARM = |
| 65 | DEP_ARM += arch/ARM/ARMGenAsmWriter.inc |
| 66 | DEP_ARM += arch/ARM/ARMGenDisassemblerTables.inc |
| 67 | DEP_ARM += arch/ARM/ARMGenInstrInfo.inc |
| 68 | DEP_ARM += arch/ARM/ARMGenRegisterInfo.inc |
| 69 | DEP_ARM += arch/ARM/ARMGenSubtargetInfo.inc |
| 70 | |
| 71 | LIBOBJ_ARM = |
Nguyen Anh Quynh | 9cc56a3 | 2014-01-15 16:01:55 +0800 | [diff] [blame] | 72 | ifneq (,$(findstring arm,$(CAPSTONE_ARCHS))) |
| 73 | CFLAGS += -DCAPSTONE_HAS_ARM |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 74 | LIBOBJ_ARM += arch/ARM/ARMDisassembler.o |
| 75 | LIBOBJ_ARM += arch/ARM/ARMInstPrinter.o |
| 76 | LIBOBJ_ARM += arch/ARM/ARMMapping.o |
| 77 | LIBOBJ_ARM += arch/ARM/ARMModule.o |
danghvu | 02db488 | 2013-12-20 00:57:12 -0600 | [diff] [blame] | 78 | endif |
Nguyen Anh Quynh | 42c6b1a | 2013-12-30 00:15:25 +0800 | [diff] [blame] | 79 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 80 | DEP_ARM64 = |
| 81 | DEP_ARM64 += arch/AArch64/AArch64GenAsmWriter.inc |
| 82 | DEP_ARM64 += arch/AArch64/AArch64GenInstrInfo.inc |
| 83 | DEP_ARM64 += arch/AArch64/AArch64GenSubtargetInfo.inc |
| 84 | DEP_ARM64 += arch/AArch64/AArch64GenDisassemblerTables.inc |
| 85 | DEP_ARM64 += arch/AArch64/AArch64GenRegisterInfo.inc |
| 86 | |
| 87 | LIBOBJ_ARM64 = |
| 88 | ifneq (,$(findstring aarch64,$(CAPSTONE_ARCHS))) |
| 89 | CFLAGS += -DCAPSTONE_HAS_ARM64 |
| 90 | LIBOBJ_ARM64 += arch/AArch64/AArch64BaseInfo.o |
| 91 | LIBOBJ_ARM64 += arch/AArch64/AArch64Disassembler.o |
| 92 | LIBOBJ_ARM64 += arch/AArch64/AArch64InstPrinter.o |
| 93 | LIBOBJ_ARM64 += arch/AArch64/AArch64Mapping.o |
| 94 | LIBOBJ_ARM64 += arch/AArch64/AArch64Module.o |
| 95 | endif |
| 96 | |
| 97 | |
| 98 | DEP_MIPS = |
| 99 | DEP_MIPS += arch/Mips/MipsGenAsmWriter.inc |
| 100 | DEP_MIPS += arch/Mips/MipsGenDisassemblerTables.inc |
| 101 | DEP_MIPS += arch/Mips/MipsGenInstrInfo.inc |
| 102 | DEP_MIPS += arch/Mips/MipsGenRegisterInfo.inc |
| 103 | DEP_MIPS += arch/Mips/MipsGenSubtargetInfo.inc |
| 104 | |
| 105 | LIBOBJ_MIPS = |
| 106 | ifneq (,$(findstring mips,$(CAPSTONE_ARCHS))) |
| 107 | CFLAGS += -DCAPSTONE_HAS_MIPS |
| 108 | LIBOBJ_MIPS += arch/Mips/MipsDisassembler.o |
| 109 | LIBOBJ_MIPS += arch/Mips/MipsInstPrinter.o |
| 110 | LIBOBJ_MIPS += arch/Mips/MipsMapping.o |
| 111 | LIBOBJ_MIPS += arch/Mips/MipsModule.o |
| 112 | endif |
| 113 | |
| 114 | |
| 115 | DEP_PPC = |
| 116 | DEP_PPC += arch/PowerPC/PPCGenAsmWriter.inc |
| 117 | DEP_PPC += arch/PowerPC/PPCGenInstrInfo.inc |
| 118 | DEP_PPC += arch/PowerPC/PPCGenSubtargetInfo.inc |
| 119 | DEP_PPC += arch/PowerPC/PPCGenDisassemblerTables.inc |
| 120 | DEP_PPC += arch/PowerPC/PPCGenRegisterInfo.inc |
| 121 | |
| 122 | LIBOBJ_PPC = |
| 123 | ifneq (,$(findstring powerpc,$(CAPSTONE_ARCHS))) |
| 124 | CFLAGS += -DCAPSTONE_HAS_POWERPC |
| 125 | LIBOBJ_PPC += arch/PowerPC/PPCDisassembler.o |
| 126 | LIBOBJ_PPC += arch/PowerPC/PPCInstPrinter.o |
| 127 | LIBOBJ_PPC += arch/PowerPC/PPCMapping.o |
| 128 | LIBOBJ_PPC += arch/PowerPC/PPCModule.o |
| 129 | endif |
| 130 | |
| 131 | |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 132 | DEP_SPARC = |
| 133 | DEP_SPARC += arch/Sparc/SparcGenAsmWriter.inc |
| 134 | DEP_SPARC += arch/Sparc/SparcGenInstrInfo.inc |
| 135 | DEP_SPARC += arch/Sparc/SparcGenSubtargetInfo.inc |
| 136 | DEP_SPARC += arch/Sparc/SparcGenDisassemblerTables.inc |
| 137 | DEP_SPARC += arch/Sparc/SparcGenRegisterInfo.inc |
| 138 | |
| 139 | LIBOBJ_SPARC = |
| 140 | ifneq (,$(findstring sparc,$(CAPSTONE_ARCHS))) |
| 141 | CFLAGS += -DCAPSTONE_HAS_SPARC |
| 142 | LIBOBJ_SPARC += arch/Sparc/SparcDisassembler.o |
| 143 | LIBOBJ_SPARC += arch/Sparc/SparcInstPrinter.o |
| 144 | LIBOBJ_SPARC += arch/Sparc/SparcMapping.o |
| 145 | LIBOBJ_SPARC += arch/Sparc/SparcModule.o |
| 146 | endif |
| 147 | |
| 148 | |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 149 | DEP_SYSZ = |
| 150 | DEP_SYSZ += arch/SystemZ/SystemZGenAsmWriter.inc |
| 151 | DEP_SYSZ += arch/SystemZ/SystemZGenInstrInfo.inc |
| 152 | DEP_SYSZ += arch/SystemZ/SystemZGenSubtargetInfo.inc |
| 153 | DEP_SYSZ += arch/SystemZ/SystemZGenDisassemblerTables.inc |
| 154 | DEP_SYSZ += arch/SystemZ/SystemZGenRegisterInfo.inc |
| 155 | |
| 156 | LIBOBJ_SYSZ = |
| 157 | ifneq (,$(findstring systemz,$(CAPSTONE_ARCHS))) |
| 158 | CFLAGS += -DCAPSTONE_HAS_SYSZ |
| 159 | LIBOBJ_SYSZ += arch/SystemZ/SystemZDisassembler.o |
| 160 | LIBOBJ_SYSZ += arch/SystemZ/SystemZInstPrinter.o |
| 161 | LIBOBJ_SYSZ += arch/SystemZ/SystemZMapping.o |
| 162 | LIBOBJ_SYSZ += arch/SystemZ/SystemZModule.o |
| 163 | LIBOBJ_SYSZ += arch/SystemZ/SystemZMCTargetDesc.o |
| 164 | endif |
| 165 | |
| 166 | |
Nguyen Anh Quynh | 9518148 | 2014-03-25 23:20:41 +0800 | [diff] [blame] | 167 | # by default, we compile full X86 instruction sets |
Nguyen Anh Quynh | 59b5489 | 2014-03-27 10:54:44 +0800 | [diff] [blame] | 168 | X86_REDUCE = |
| 169 | ifneq (,$(findstring yes,$(CAPSTONE_X86_REDUCE))) |
| 170 | X86_REDUCE = _reduce |
Nguyen Anh Quynh | 81d930a | 2014-03-28 10:28:57 +0800 | [diff] [blame] | 171 | CFLAGS += -DCAPSTONE_X86_REDUCE -Os |
Nguyen Anh Quynh | 9518148 | 2014-03-25 23:20:41 +0800 | [diff] [blame] | 172 | endif |
| 173 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 174 | DEP_X86 = |
Nguyen Anh Quynh | 59b5489 | 2014-03-27 10:54:44 +0800 | [diff] [blame] | 175 | DEP_X86 += arch/X86/X86GenAsmWriter$(X86_REDUCE).inc |
| 176 | DEP_X86 += arch/X86/X86GenAsmWriter1$(X86_REDUCE).inc |
| 177 | DEP_X86 += arch/X86/X86GenDisassemblerTables$(X86_REDUCE).inc |
| 178 | DEP_X86 += arch/X86/X86GenInstrInfo$(X86_REDUCE).inc |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 179 | DEP_X86 += arch/X86/X86GenRegisterInfo.inc |
| 180 | |
| 181 | LIBOBJ_X86 = |
| 182 | ifneq (,$(findstring x86,$(CAPSTONE_ARCHS))) |
| 183 | CFLAGS += -DCAPSTONE_HAS_X86 |
| 184 | LIBOBJ_X86 += arch/X86/X86DisassemblerDecoder.o |
| 185 | LIBOBJ_X86 += arch/X86/X86Disassembler.o |
| 186 | LIBOBJ_X86 += arch/X86/X86IntelInstPrinter.o |
| 187 | LIBOBJ_X86 += arch/X86/X86ATTInstPrinter.o |
| 188 | LIBOBJ_X86 += arch/X86/X86Mapping.o |
| 189 | LIBOBJ_X86 += arch/X86/X86Module.o |
| 190 | endif |
| 191 | |
| 192 | LIBOBJ = |
| 193 | LIBOBJ += cs.o utils.o SStream.o MCInstrDesc.o MCRegisterInfo.o |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 194 | LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_X86) |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 195 | LIBOBJ += MCInst.o |
| 196 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 197 | |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 198 | PKGCFCGDIR = $(LIBDATADIR)/pkgconfig |
Nguyen Anh Quynh | 315f02d | 2014-03-25 06:43:19 +0800 | [diff] [blame] | 199 | 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] | 200 | VERSION_EXT = |
Nguyen Anh Quynh | 8f856c7 | 2014-02-24 15:17:40 +0800 | [diff] [blame] | 201 | |
Nguyen Anh Quynh | 5e107ab | 2013-12-31 23:38:28 +0800 | [diff] [blame] | 202 | # OSX? |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 203 | ifeq ($(UNAME_S),Darwin) |
| 204 | EXT = dylib |
pancake | 2694333 | 2014-02-04 08:37:55 +0100 | [diff] [blame] | 205 | VERSION_EXT = $(API_MAJOR).$(EXT) |
Nguyen Anh Quynh | 719e9da | 2014-03-30 22:29:03 +0800 | [diff] [blame] | 206 | 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] | 207 | AR_EXT = a |
Nguyen Anh Quynh | 189e83a | 2014-03-29 22:36:05 +0800 | [diff] [blame] | 208 | ifneq ($(HOMEBREW_CAPSTONE),1) |
Nguyen Anh Quynh | c77cf3a | 2014-03-07 22:06:51 +0800 | [diff] [blame] | 209 | ifneq ($(USE_SYS_DYN_MEM),yes) |
| 210 | # remove string check because OSX kernel complains about missing symbols |
| 211 | CFLAGS += -D_FORTIFY_SOURCE=0 |
| 212 | endif |
Nguyen Anh Quynh | 8f856c7 | 2014-02-24 15:17:40 +0800 | [diff] [blame] | 213 | # By default, suppose that Brew is installed & use Brew path for pkgconfig file |
| 214 | PKGCFCGDIR = /usr/local/lib/pkgconfig |
| 215 | # is Macport installed instead? |
Nguyen Anh Quynh | 2b63b07 | 2014-02-24 15:26:20 +0800 | [diff] [blame] | 216 | ifneq (,$(wildcard /opt/local/bin/port)) |
Nguyen Anh Quynh | 8f856c7 | 2014-02-24 15:17:40 +0800 | [diff] [blame] | 217 | # then correct the path for pkgconfig file |
| 218 | PKGCFCGDIR = /opt/local/lib/pkgconfig |
| 219 | endif |
Nguyen Anh Quynh | 189e83a | 2014-03-29 22:36:05 +0800 | [diff] [blame] | 220 | endif |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 221 | else |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 222 | # Cygwin? |
| 223 | IS_CYGWIN := $(shell $(CC) -dumpmachine | grep -i cygwin | wc -l) |
| 224 | ifeq ($(IS_CYGWIN),1) |
| 225 | EXT = dll |
| 226 | AR_EXT = dll.a |
| 227 | # Cygwin doesn't like -fPIC |
| 228 | CFLAGS := $(CFLAGS:-fPIC=) |
| 229 | # On Windows we need the shared library to be executable |
| 230 | else |
| 231 | # mingw? |
| 232 | IS_MINGW := $(shell $(CC) --version | grep -i mingw | wc -l) |
| 233 | ifeq ($(IS_MINGW),1) |
| 234 | EXT = dll |
| 235 | AR_EXT = dll.a |
| 236 | # mingw doesn't like -fPIC either |
| 237 | CFLAGS := $(CFLAGS:-fPIC=) |
| 238 | # On Windows we need the shared library to be executable |
Nguyen Anh Quynh | 4ebdd21 | 2013-12-25 23:54:45 +0800 | [diff] [blame] | 239 | else |
| 240 | # Linux, *BSD |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 241 | EXT = so |
| 242 | VERSION_EXT = $(EXT).$(API_MAJOR) |
Nguyen Anh Quynh | 6d5381e | 2014-03-17 10:37:08 +0800 | [diff] [blame] | 243 | AR_EXT = a |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 244 | LDFLAGS += -Wl,-soname,lib$(LIBNAME).$(VERSION_EXT) |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 245 | endif |
| 246 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 247 | endif |
| 248 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 249 | LIBRARY = lib$(LIBNAME).$(EXT) |
| 250 | ARCHIVE = lib$(LIBNAME).$(AR_EXT) |
| 251 | PKGCFGF = $(LIBNAME).pc |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 252 | |
Nguyen Anh Quynh | 5bbbfce | 2014-02-28 10:49:46 +0800 | [diff] [blame] | 253 | .PHONY: all clean install uninstall dist |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 254 | |
Nguyen Anh Quynh | 80ff30b | 2013-12-09 00:38:44 +0800 | [diff] [blame] | 255 | all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF) |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 256 | $(MAKE) -C tests |
| 257 | $(INSTALL_DATA) lib$(LIBNAME).$(EXT) tests |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 258 | |
pancake | addb192 | 2014-02-28 02:44:07 +0100 | [diff] [blame] | 259 | $(LIBRARY): $(LIBOBJ) |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 260 | $(CC) $(LDFLAGS) $(LIBOBJ) -o $(LIBRARY) |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 261 | |
Nguyen Anh Quynh | aeb0c40 | 2014-03-27 17:54:27 +0800 | [diff] [blame] | 262 | $(LIBOBJ): config.mk |
| 263 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 264 | $(LIBOBJ_ARM): $(DEP_ARM) |
| 265 | $(LIBOBJ_ARM64): $(DEP_ARM64) |
| 266 | $(LIBOBJ_MIPS): $(DEP_MIPS) |
| 267 | $(LIBOBJ_PPC): $(DEP_PPC) |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 268 | $(LIBOBJ_SPARC): $(DEP_SPARC) |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 269 | $(LIBOBJ_SYSZ): $(DEP_SYSZ) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 270 | $(LIBOBJ_X86): $(DEP_X86) |
| 271 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 272 | $(ARCHIVE): $(LIBOBJ) |
| 273 | rm -f $(ARCHIVE) |
| 274 | $(AR) q $(ARCHIVE) $(LIBOBJ) |
| 275 | $(RANLIB) $(ARCHIVE) |
pancake | f1cbce2 | 2013-11-27 15:31:26 +0100 | [diff] [blame] | 276 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 277 | $(PKGCFGF): |
Nguyen Anh Quynh | 0655fe4 | 2013-12-22 13:23:20 +0800 | [diff] [blame] | 278 | echo 'Name: capstone' > $(PKGCFGF) |
Nguyen Anh Quynh | 296a231 | 2014-03-05 23:50:41 +0800 | [diff] [blame] | 279 | echo 'Description: Capstone disassembly engine' >> $(PKGCFGF) |
Nguyen Anh Quynh | 3ff259c | 2014-03-07 17:11:18 +0800 | [diff] [blame] | 280 | ifeq ($(PKG_EXTRA),) |
| 281 | echo 'Version: $(PKG_MAJOR).$(PKG_MINOR)' >> $(PKGCFGF) |
| 282 | else |
| 283 | echo 'Version: $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA)' >> $(PKGCFGF) |
| 284 | endif |
Nguyen Anh Quynh | 0655fe4 | 2013-12-22 13:23:20 +0800 | [diff] [blame] | 285 | echo 'libdir=$(LIBDIR)' >> $(PKGCFGF) |
| 286 | echo 'includedir=$(PREFIX)/include/capstone' >> $(PKGCFGF) |
| 287 | echo 'archive=$${libdir}/libcapstone.a' >> $(PKGCFGF) |
| 288 | echo 'Libs: -L$${libdir} -lcapstone' >> $(PKGCFGF) |
| 289 | echo 'Cflags: -I$${includedir}' >> $(PKGCFGF) |
pancake | 44ce0fb | 2013-12-03 04:11:37 +0100 | [diff] [blame] | 290 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 291 | install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY) |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 292 | mkdir -p $(LIBDIR) |
Nguyen Anh Quynh | 7df338c | 2014-03-18 09:28:48 +0800 | [diff] [blame] | 293 | # remove potential broken old libs |
| 294 | rm -f $(LIBDIR)/lib$(LIBNAME).* |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 295 | $(INSTALL_LIB) lib$(LIBNAME).$(EXT) $(LIBDIR) |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 296 | ifneq ($(VERSION_EXT),) |
pancake | e030e18 | 2014-02-04 08:36:22 +0100 | [diff] [blame] | 297 | cd $(LIBDIR) && \ |
| 298 | mv lib$(LIBNAME).$(EXT) lib$(LIBNAME).$(VERSION_EXT) && \ |
| 299 | ln -s lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT) |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 300 | endif |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 301 | $(INSTALL_DATA) lib$(LIBNAME).$(AR_EXT) $(LIBDIR) |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 302 | mkdir -p $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 3524056 | 2014-01-04 09:18:48 +0800 | [diff] [blame] | 303 | $(INSTALL_DATA) include/*.h $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 8f856c7 | 2014-02-24 15:17:40 +0800 | [diff] [blame] | 304 | mkdir -p $(PKGCFCGDIR) |
| 305 | $(INSTALL_DATA) $(PKGCFGF) $(PKGCFCGDIR)/ |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 306 | |
| 307 | uninstall: |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 308 | rm -rf $(INCDIR)/$(LIBNAME) |
Nguyen Anh Quynh | 6d5381e | 2014-03-17 10:37:08 +0800 | [diff] [blame] | 309 | rm -f $(LIBDIR)/lib$(LIBNAME).* |
Nguyen Anh Quynh | 8f856c7 | 2014-02-24 15:17:40 +0800 | [diff] [blame] | 310 | rm -f $(PKGCFCGDIR)/$(LIBNAME).pc |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 311 | |
| 312 | clean: |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 313 | rm -f $(LIBOBJ) lib$(LIBNAME).* |
Nguyen Anh Quynh | d63ddac | 2014-01-09 10:35:58 +0800 | [diff] [blame] | 314 | rm -f $(PKGCFGF) |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 315 | $(MAKE) -C bindings/python clean |
danghvu | 7545b9b | 2013-11-28 10:18:02 -0600 | [diff] [blame] | 316 | $(MAKE) -C bindings/java clean |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 317 | $(MAKE) -C bindings/ocaml clean |
| 318 | $(MAKE) -C tests clean |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 319 | |
Nguyen Anh Quynh | a580d92 | 2014-01-18 12:47:15 +0800 | [diff] [blame] | 320 | |
| 321 | TAG ?= HEAD |
| 322 | ifeq ($(TAG), HEAD) |
| 323 | DIST_VERSION = latest |
| 324 | else |
| 325 | DIST_VERSION = $(TAG) |
| 326 | endif |
| 327 | |
pancake | 35cef7f | 2014-01-18 03:42:15 +0100 | [diff] [blame] | 328 | dist: |
Nguyen Anh Quynh | 186d501 | 2014-01-22 18:46:20 +0800 | [diff] [blame] | 329 | 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] | 330 | git archive --format=zip --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).zip |
pancake | 35cef7f | 2014-01-18 03:42:15 +0100 | [diff] [blame] | 331 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 332 | .c.o: |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 333 | $(CC) $(CFLAGS) -c $< -o $@ |