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 |
kevemueller | 82ceac5 | 2015-12-14 16:55:53 +0100 | [diff] [blame] | 23 | CC = $(CROSS)gcc |
| 24 | AR = $(CROSS)ar |
| 25 | RANLIB = $(CROSS)ranlib |
| 26 | STRIP = $(CROSS)strip |
Nguyen Anh Quynh | d80cede | 2014-01-16 21:07:59 +0800 | [diff] [blame] | 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 | 160e198 | 2015-04-09 18:28:19 +0100 | [diff] [blame] | 46 | ifeq ($(CAPSTONE_HAS_OSXKERNEL), yes) |
| 47 | CFLAGS += -DCAPSTONE_HAS_OSXKERNEL |
Pb | 2769c77 | 2015-11-06 14:44:55 +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 | 160e198 | 2015-04-09 18:28:19 +0100 | [diff] [blame] | 54 | endif |
| 55 | |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 56 | PREFIX ?= /usr |
| 57 | DESTDIR ?= |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 58 | ifndef BUILDDIR |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 59 | BLDIR = . |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 60 | OBJDIR = . |
| 61 | else |
Ole André Vadla Ravnås | 7a73439 | 2014-04-30 00:06:41 +0200 | [diff] [blame] | 62 | BLDIR = $(abspath $(BUILDDIR)) |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 63 | OBJDIR = $(BLDIR)/obj |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 64 | endif |
pancake | 91659c0 | 2015-11-08 12:05:41 +0100 | [diff] [blame] | 65 | INCDIR ?= $(PREFIX)/include |
Nguyen Anh Quynh | 9f0e6c2 | 2013-12-25 22:47:28 +0800 | [diff] [blame] | 66 | |
Nguyen Anh Quynh | 235a274 | 2014-03-29 21:09:35 +0800 | [diff] [blame] | 67 | UNAME_S := $(shell uname -s) |
Nguyen Anh Quynh | ad6cc98 | 2014-04-08 23:34:44 +0800 | [diff] [blame] | 68 | |
Nguyen Anh Quynh | 360bf1e | 2014-04-14 13:36:46 +0800 | [diff] [blame] | 69 | LIBDIRARCH ?= lib |
| 70 | # Uncomment the below line to installs x86_64 libs to lib64/ directory. |
| 71 | # Or better, pass 'LIBDIRARCH=lib64' to 'make install/uninstall' via 'make.sh'. |
| 72 | #LIBDIRARCH ?= lib64 |
pancake | 91659c0 | 2015-11-08 12:05:41 +0100 | [diff] [blame] | 73 | LIBDIR ?= $(PREFIX)/$(LIBDIRARCH) |
Nguyen Anh Quynh | f36b3f4 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 74 | BINDIR = $(PREFIX)/bin |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 75 | |
pancake | 63414a4 | 2015-02-27 17:57:53 +0100 | [diff] [blame] | 76 | LIBDATADIR ?= $(LIBDIR) |
Kamil Rytarowski | b08f461 | 2015-07-27 04:03:48 +0200 | [diff] [blame] | 77 | |
| 78 | # Don't redefine $LIBDATADIR when global environment variable |
| 79 | # USE_GENERIC_LIBDATADIR is set. This is used by the pkgsrc framework. |
| 80 | |
| 81 | ifndef USE_GENERIC_LIBDATADIR |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 82 | ifeq ($(UNAME_S), FreeBSD) |
pancake | 91659c0 | 2015-11-08 12:05:41 +0100 | [diff] [blame] | 83 | LIBDATADIR = $(PREFIX)/libdata |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 84 | endif |
Oliver Pinter | 25efded | 2014-03-23 19:10:13 +0100 | [diff] [blame] | 85 | ifeq ($(UNAME_S), DragonFly) |
pancake | 91659c0 | 2015-11-08 12:05:41 +0100 | [diff] [blame] | 86 | LIBDATADIR = $(PREFIX)/libdata |
Oliver Pinter | 25efded | 2014-03-23 19:10:13 +0100 | [diff] [blame] | 87 | endif |
Kamil Rytarowski | b08f461 | 2015-07-27 04:03:48 +0200 | [diff] [blame] | 88 | endif |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 89 | |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 90 | INSTALL_BIN ?= install |
| 91 | INSTALL_DATA ?= $(INSTALL_BIN) -m0644 |
Oliver Pinter | c5ecae5 | 2014-03-23 02:19:59 +0100 | [diff] [blame] | 92 | INSTALL_LIB ?= $(INSTALL_BIN) -m0755 |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 93 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 94 | LIBNAME = capstone |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 95 | |
Nguyen Anh Quynh | 42c6b1a | 2013-12-30 00:15:25 +0800 | [diff] [blame] | 96 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 97 | DEP_ARM = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 98 | DEP_ARM += $(wildcard arch/ARM/ARM*.inc) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 99 | |
| 100 | LIBOBJ_ARM = |
Nguyen Anh Quynh | 9cc56a3 | 2014-01-15 16:01:55 +0800 | [diff] [blame] | 101 | ifneq (,$(findstring arm,$(CAPSTONE_ARCHS))) |
| 102 | CFLAGS += -DCAPSTONE_HAS_ARM |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 103 | LIBSRC_ARM += $(wildcard arch/ARM/ARM*.c) |
| 104 | LIBOBJ_ARM += $(LIBSRC_ARM:%.c=$(OBJDIR)/%.o) |
danghvu | 02db488 | 2013-12-20 00:57:12 -0600 | [diff] [blame] | 105 | endif |
Nguyen Anh Quynh | 42c6b1a | 2013-12-30 00:15:25 +0800 | [diff] [blame] | 106 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 107 | DEP_ARM64 = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 108 | DEP_ARM64 += $(wildcard arch/AArch64/AArch64*.inc) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 109 | |
| 110 | LIBOBJ_ARM64 = |
| 111 | ifneq (,$(findstring aarch64,$(CAPSTONE_ARCHS))) |
| 112 | CFLAGS += -DCAPSTONE_HAS_ARM64 |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 113 | LIBSRC_ARM64 += $(wildcard arch/AArch64/AArch64*.c) |
| 114 | LIBOBJ_ARM64 += $(LIBSRC_ARM64:%.c=$(OBJDIR)/%.o) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 115 | endif |
| 116 | |
| 117 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 118 | DEP_M68K = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 119 | DEP_M68K += $(wildcard arch/M68K/M68K*.h) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 120 | |
| 121 | LIBOBJ_M68K = |
| 122 | ifneq (,$(findstring m68k,$(CAPSTONE_ARCHS))) |
| 123 | CFLAGS += -DCAPSTONE_HAS_M68K |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 124 | LIBSRC_M68K += $(wildcard arch/M68K/M68K*.c) |
| 125 | LIBOBJ_M68K += $(LIBSRC_M68K:%.c=$(OBJDIR)/%.o) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 126 | endif |
| 127 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 128 | DEP_MIPS = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 129 | DEP_MIPS += $(wildcard arch/Mips/Mips*.inc) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 130 | |
| 131 | LIBOBJ_MIPS = |
| 132 | ifneq (,$(findstring mips,$(CAPSTONE_ARCHS))) |
| 133 | CFLAGS += -DCAPSTONE_HAS_MIPS |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 134 | LIBSRC_MIPS += $(wildcard arch/Mips/Mips*.c) |
| 135 | LIBOBJ_MIPS += $(LIBSRC_MIPS:%.c=$(OBJDIR)/%.o) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 136 | endif |
| 137 | |
| 138 | |
| 139 | DEP_PPC = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 140 | DEP_PPC += $(wildcard arch/PowerPC/PPC*.inc) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 141 | |
| 142 | LIBOBJ_PPC = |
| 143 | ifneq (,$(findstring powerpc,$(CAPSTONE_ARCHS))) |
| 144 | CFLAGS += -DCAPSTONE_HAS_POWERPC |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 145 | LIBSRC_PPC += $(wildcard arch/PowerPC/PPC*.c) |
| 146 | LIBOBJ_PPC += $(LIBSRC_PPC:%.c=$(OBJDIR)/%.o) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 147 | endif |
| 148 | |
| 149 | |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 150 | DEP_SPARC = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 151 | DEP_SPARC += $(wildcard arch/Sparc/Sparc*.inc) |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 152 | |
| 153 | LIBOBJ_SPARC = |
| 154 | ifneq (,$(findstring sparc,$(CAPSTONE_ARCHS))) |
| 155 | CFLAGS += -DCAPSTONE_HAS_SPARC |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 156 | LIBSRC_SPARC += $(wildcard arch/Sparc/Sparc*.c) |
| 157 | LIBOBJ_SPARC += $(LIBSRC_SPARC:%.c=$(OBJDIR)/%.o) |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 158 | endif |
| 159 | |
| 160 | |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 161 | DEP_SYSZ = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 162 | DEP_SYSZ += $(wildcard arch/SystemZ/SystemZ*.inc) |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 163 | |
| 164 | LIBOBJ_SYSZ = |
| 165 | ifneq (,$(findstring systemz,$(CAPSTONE_ARCHS))) |
| 166 | CFLAGS += -DCAPSTONE_HAS_SYSZ |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 167 | LIBSRC_SYSZ += $(wildcard arch/SystemZ/SystemZ*.c) |
| 168 | LIBOBJ_SYSZ += $(LIBSRC_SYSZ:%.c=$(OBJDIR)/%.o) |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 169 | endif |
| 170 | |
| 171 | |
Nguyen Anh Quynh | 9518148 | 2014-03-25 23:20:41 +0800 | [diff] [blame] | 172 | # by default, we compile full X86 instruction sets |
Nguyen Anh Quynh | 59b5489 | 2014-03-27 10:54:44 +0800 | [diff] [blame] | 173 | X86_REDUCE = |
| 174 | ifneq (,$(findstring yes,$(CAPSTONE_X86_REDUCE))) |
| 175 | X86_REDUCE = _reduce |
Nguyen Anh Quynh | 81d930a | 2014-03-28 10:28:57 +0800 | [diff] [blame] | 176 | CFLAGS += -DCAPSTONE_X86_REDUCE -Os |
Nguyen Anh Quynh | 9518148 | 2014-03-25 23:20:41 +0800 | [diff] [blame] | 177 | endif |
| 178 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 179 | DEP_X86 = |
Nguyen Anh Quynh | 59b5489 | 2014-03-27 10:54:44 +0800 | [diff] [blame] | 180 | DEP_X86 += arch/X86/X86GenAsmWriter$(X86_REDUCE).inc |
| 181 | DEP_X86 += arch/X86/X86GenAsmWriter1$(X86_REDUCE).inc |
| 182 | DEP_X86 += arch/X86/X86GenDisassemblerTables$(X86_REDUCE).inc |
| 183 | DEP_X86 += arch/X86/X86GenInstrInfo$(X86_REDUCE).inc |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 184 | DEP_X86 += arch/X86/X86GenRegisterInfo.inc |
Nguyen Anh Quynh | 0d394aa | 2015-11-06 10:34:27 +0800 | [diff] [blame] | 185 | DEP_X86 += arch/X86/X86MappingInsn$(X86_REDUCE).inc |
| 186 | DEP_X86 += arch/X86/X86MappingInsnOp$(X86_REDUCE).inc |
| 187 | DEP_X86 += arch/X86/X86ImmSize.inc |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 188 | |
| 189 | LIBOBJ_X86 = |
| 190 | ifneq (,$(findstring x86,$(CAPSTONE_ARCHS))) |
| 191 | CFLAGS += -DCAPSTONE_HAS_X86 |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 192 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86DisassemblerDecoder.o |
| 193 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Disassembler.o |
| 194 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86IntelInstPrinter.o |
Nguyen Anh Quynh | 5068908 | 2014-05-14 12:26:53 +0800 | [diff] [blame] | 195 | # assembly syntax is irrelevant in Diet mode, when this info is suppressed |
| 196 | ifeq (,$(findstring yes,$(CAPSTONE_DIET))) |
baguette | 86e8450 | 2014-08-17 20:59:05 +0200 | [diff] [blame] | 197 | ifeq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE))) |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 198 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86ATTInstPrinter.o |
Nguyen Anh Quynh | 5068908 | 2014-05-14 12:26:53 +0800 | [diff] [blame] | 199 | endif |
baguette | 86e8450 | 2014-08-17 20:59:05 +0200 | [diff] [blame] | 200 | endif |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 201 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Mapping.o |
| 202 | LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Module.o |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 203 | endif |
| 204 | |
Nguyen Anh Quynh | c80d840 | 2014-05-26 23:02:48 +0800 | [diff] [blame] | 205 | |
| 206 | DEP_XCORE = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 207 | DEP_XCORE += $(wildcard arch/XCore/XCore*.inc) |
Nguyen Anh Quynh | c80d840 | 2014-05-26 23:02:48 +0800 | [diff] [blame] | 208 | |
| 209 | LIBOBJ_XCORE = |
| 210 | ifneq (,$(findstring xcore,$(CAPSTONE_ARCHS))) |
| 211 | CFLAGS += -DCAPSTONE_HAS_XCORE |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 212 | LIBSRC_XCORE += $(wildcard arch/XCore/XCore*.c) |
| 213 | LIBOBJ_XCORE += $(LIBSRC_XCORE:%.c=$(OBJDIR)/%.o) |
Nguyen Anh Quynh | c80d840 | 2014-05-26 23:02:48 +0800 | [diff] [blame] | 214 | endif |
| 215 | |
| 216 | |
Fotis Loukos | 0850d55 | 2016-05-03 15:52:11 +0300 | [diff] [blame] | 217 | DEP_TMS320C64X = |
Stephen | 572a4ae | 2017-10-20 16:17:30 +0100 | [diff] [blame] | 218 | DEP_TMS320C64X += $(wildcard arch/TMS320C64x/TMS320C64x*.inc) |
Fotis Loukos | 0850d55 | 2016-05-03 15:52:11 +0300 | [diff] [blame] | 219 | |
| 220 | LIBOBJ_TMS320C64X = |
| 221 | ifneq (,$(findstring tms320c64x,$(CAPSTONE_ARCHS))) |
| 222 | CFLAGS += -DCAPSTONE_HAS_TMS320C64X |
Stephen | 1ec3060 | 2017-10-21 14:47:38 +0100 | [diff] [blame] | 223 | LIBSRC_TMS320C64X += $(wildcard arch/TMS320C64x/TMS320C64x*.c) |
| 224 | LIBOBJ_TMS320C64X += $(LIBSRC_TMS320C64X:%.c=$(OBJDIR)/%.o) |
Fotis Loukos | 0850d55 | 2016-05-03 15:52:11 +0300 | [diff] [blame] | 225 | endif |
| 226 | |
Wolfgang Schwotzer | 22b4d0e | 2017-10-21 15:44:36 +0200 | [diff] [blame] | 227 | DEP_M680X = |
Nguyen Anh Quynh | d7281e9 | 2017-10-21 14:05:02 +0700 | [diff] [blame] | 228 | DEP_M680X += $(wildcard arch/M680X/*.inc) |
| 229 | DEP_M680X += $(wildcard arch/M680X/M680X*.h) |
Wolfgang Schwotzer | 22b4d0e | 2017-10-21 15:44:36 +0200 | [diff] [blame] | 230 | |
| 231 | LIBOBJ_M680X = |
| 232 | ifneq (,$(findstring m680x,$(CAPSTONE_ARCHS))) |
| 233 | CFLAGS += -DCAPSTONE_HAS_M680X |
Nguyen Anh Quynh | d7281e9 | 2017-10-21 14:05:02 +0700 | [diff] [blame] | 234 | LIBSRC_M680X += $(wildcard arch/M680X/*.c) |
| 235 | LIBOBJ_M680X += $(LIBSRC_M680X:%.c=$(OBJDIR)/%.o) |
Wolfgang Schwotzer | 22b4d0e | 2017-10-21 15:44:36 +0200 | [diff] [blame] | 236 | endif |
Fotis Loukos | 0850d55 | 2016-05-03 15:52:11 +0300 | [diff] [blame] | 237 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 238 | LIBOBJ = |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 239 | LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o |
Wolfgang Schwotzer | 22b4d0e | 2017-10-21 15:44:36 +0200 | [diff] [blame] | 240 | LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X) |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 241 | LIBOBJ += $(OBJDIR)/MCInst.o |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 242 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 243 | |
Nguyen Anh Quynh | f0677ab | 2015-05-21 12:58:38 +0800 | [diff] [blame] | 244 | ifeq ($(PKG_EXTRA),) |
| 245 | PKGCFGDIR = $(LIBDATADIR)/pkgconfig |
| 246 | else |
Nguyen Anh Quynh | af0e937 | 2014-04-12 23:10:46 +0800 | [diff] [blame] | 247 | PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig |
Nguyen Anh Quynh | d46a4f2 | 2017-04-14 18:43:06 +0800 | [diff] [blame] | 248 | ifeq ($(PKGCFGDIR),) |
| 249 | PKGCFGDIR = $(LIBDATADIR)/pkgconfig |
| 250 | endif |
Nguyen Anh Quynh | f0677ab | 2015-05-21 12:58:38 +0800 | [diff] [blame] | 251 | endif |
| 252 | |
pancake | 9c10ace | 2015-02-24 04:55:55 +0100 | [diff] [blame] | 253 | API_MAJOR=$(shell echo `grep -e CS_API_MAJOR include/capstone/capstone.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}') |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 254 | VERSION_EXT = |
Nguyen Anh Quynh | 8f856c7 | 2014-02-24 15:17:40 +0800 | [diff] [blame] | 255 | |
pancake | 5a4dabd | 2017-02-06 13:24:33 +0100 | [diff] [blame] | 256 | IS_APPLE := $(shell $(CC) -dM -E - < /dev/null 2> /dev/null | grep __apple_build_version__ | wc -l | tr -d " ") |
Ole André Vadla Ravnås | c20b049 | 2014-05-01 14:14:57 +0200 | [diff] [blame] | 257 | ifeq ($(IS_APPLE),1) |
Jonas | 7a274e2 | 2017-09-05 16:45:48 +0200 | [diff] [blame] | 258 | # on MacOS, compile in Universal format by default |
| 259 | MACOS_UNIVERSAL ?= yes |
| 260 | ifeq ($(MACOS_UNIVERSAL),yes) |
| 261 | CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
| 262 | LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
| 263 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 264 | EXT = dylib |
pancake | 2694333 | 2014-02-04 08:37:55 +0100 | [diff] [blame] | 265 | VERSION_EXT = $(API_MAJOR).$(EXT) |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 266 | $(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] | 267 | AR_EXT = a |
Nguyen Anh Quynh | e3606d9 | 2014-04-12 18:02:55 +0800 | [diff] [blame] | 268 | # 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] | 269 | # 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] | 270 | ifneq ($(HOMEBREW_CAPSTONE),1) |
Nguyen Anh Quynh | e31327d | 2014-04-29 14:25:15 +0800 | [diff] [blame] | 271 | ifneq ($(CAPSTONE_USE_SYS_DYN_MEM),yes) |
Nguyen Anh Quynh | c77cf3a | 2014-03-07 22:06:51 +0800 | [diff] [blame] | 272 | # remove string check because OSX kernel complains about missing symbols |
| 273 | CFLAGS += -D_FORTIFY_SOURCE=0 |
| 274 | endif |
Nguyen Anh Quynh | 189e83a | 2014-03-29 22:36:05 +0800 | [diff] [blame] | 275 | endif |
pancake | 02cad6e | 2013-11-27 15:38:44 +0100 | [diff] [blame] | 276 | else |
Jonas | 7a274e2 | 2017-09-05 16:45:48 +0200 | [diff] [blame] | 277 | CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
| 278 | LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch)) |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 279 | $(LIBNAME)_LDFLAGS += -shared |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 280 | # Cygwin? |
pancake | 5a4dabd | 2017-02-06 13:24:33 +0100 | [diff] [blame] | 281 | IS_CYGWIN := $(shell $(CC) -dumpmachine 2>/dev/null | grep -i cygwin | wc -l) |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 282 | ifeq ($(IS_CYGWIN),1) |
| 283 | EXT = dll |
Nguyen Anh Quynh | 76087d2 | 2014-05-14 14:53:51 +0800 | [diff] [blame] | 284 | AR_EXT = lib |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 285 | # Cygwin doesn't like -fPIC |
| 286 | CFLAGS := $(CFLAGS:-fPIC=) |
| 287 | # On Windows we need the shared library to be executable |
| 288 | else |
| 289 | # mingw? |
pancake | 5a4dabd | 2017-02-06 13:24:33 +0100 | [diff] [blame] | 290 | IS_MINGW := $(shell $(CC) --version 2>/dev/null | grep -i mingw | wc -l) |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 291 | ifeq ($(IS_MINGW),1) |
| 292 | EXT = dll |
Nguyen Anh Quynh | 76087d2 | 2014-05-14 14:53:51 +0800 | [diff] [blame] | 293 | AR_EXT = lib |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 294 | # mingw doesn't like -fPIC either |
| 295 | CFLAGS := $(CFLAGS:-fPIC=) |
| 296 | # On Windows we need the shared library to be executable |
Nguyen Anh Quynh | 4ebdd21 | 2013-12-25 23:54:45 +0800 | [diff] [blame] | 297 | else |
| 298 | # Linux, *BSD |
Nguyen Anh Quynh | c0c0d52 | 2014-03-17 17:31:33 +0800 | [diff] [blame] | 299 | EXT = so |
| 300 | VERSION_EXT = $(EXT).$(API_MAJOR) |
Nguyen Anh Quynh | 6d5381e | 2014-03-17 10:37:08 +0800 | [diff] [blame] | 301 | AR_EXT = a |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 302 | $(LIBNAME)_LDFLAGS += -Wl,-soname,lib$(LIBNAME).$(VERSION_EXT) |
Daniel Godas-Lopez | 0f7c432 | 2013-11-28 18:22:50 +0000 | [diff] [blame] | 303 | endif |
| 304 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 305 | endif |
| 306 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 307 | ifeq ($(CAPSTONE_SHARED),yes) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 308 | ifeq ($(IS_MINGW),1) |
Pranith Kumar | fbf1cd7 | 2016-04-30 12:32:59 -0400 | [diff] [blame] | 309 | LIBRARY = $(BLDIR)/$(LIBNAME).$(VERSION_EXT) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 310 | else ifeq ($(IS_CYGWIN),1) |
Pranith Kumar | fbf1cd7 | 2016-04-30 12:32:59 -0400 | [diff] [blame] | 311 | LIBRARY = $(BLDIR)/$(LIBNAME).$(VERSION_EXT) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 312 | else # *nix |
Pranith Kumar | fbf1cd7 | 2016-04-30 12:32:59 -0400 | [diff] [blame] | 313 | LIBRARY = $(BLDIR)/lib$(LIBNAME).$(VERSION_EXT) |
Hilko Bengen | e0352d6 | 2015-02-26 18:37:32 +0100 | [diff] [blame] | 314 | CFLAGS += -fvisibility=hidden |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 315 | endif |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 316 | endif |
| 317 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 318 | ifeq ($(CAPSTONE_STATIC),yes) |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 319 | ifeq ($(IS_MINGW),1) |
| 320 | ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) |
| 321 | else ifeq ($(IS_CYGWIN),1) |
| 322 | ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) |
| 323 | else |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 324 | ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 325 | endif |
Nguyen Anh Quynh | 0936b56 | 2014-06-04 00:26:33 +0800 | [diff] [blame] | 326 | endif |
| 327 | |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 328 | PKGCFGF = $(BLDIR)/$(LIBNAME).pc |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 329 | |
Nguyen Anh Quynh | 5bbbfce | 2014-02-28 10:49:46 +0800 | [diff] [blame] | 330 | .PHONY: all clean install uninstall dist |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 331 | |
Nguyen Anh Quynh | 80ff30b | 2013-12-09 00:38:44 +0800 | [diff] [blame] | 332 | all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF) |
Nguyen Anh Quynh | 794a706 | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 333 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
Adrian Herrera | 1910fd5 | 2017-06-02 15:49:10 +0200 | [diff] [blame] | 334 | @V=$(V) CC=$(CC) $(MAKE) -C cstool |
Nguyen Anh Quynh | c00bc35 | 2015-01-28 04:42:34 +0800 | [diff] [blame] | 335 | ifndef BUILDDIR |
| 336 | cd tests && $(MAKE) |
| 337 | else |
| 338 | cd tests && $(MAKE) BUILDDIR=$(BLDIR) |
| 339 | endif |
Akihiko Odaki | ec40753 | 2016-09-11 09:00:32 +0900 | [diff] [blame] | 340 | $(call install-library,$(BLDIR)/tests/) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 341 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 342 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 343 | ifeq ($(CAPSTONE_SHARED),yes) |
pancake | addb192 | 2014-02-28 02:44:07 +0100 | [diff] [blame] | 344 | $(LIBRARY): $(LIBOBJ) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 345 | ifeq ($(V),0) |
Nguyen Anh Quynh | 8c0ab86 | 2014-06-03 23:43:53 +0700 | [diff] [blame] | 346 | $(call log,LINK,$(@:$(BLDIR)/%=%)) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 347 | @$(create-library) |
| 348 | else |
| 349 | $(create-library) |
| 350 | endif |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 351 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 352 | |
Nguyen Anh Quynh | 3ba8c4d | 2016-10-23 02:09:14 +0800 | [diff] [blame] | 353 | $(LIBOBJ): config.mk *.h include/capstone/*.h |
Nguyen Anh Quynh | aeb0c40 | 2014-03-27 17:54:27 +0800 | [diff] [blame] | 354 | |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 355 | $(LIBOBJ_ARM): $(DEP_ARM) |
| 356 | $(LIBOBJ_ARM64): $(DEP_ARM64) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 357 | $(LIBOBJ_M68K): $(DEP_M68K) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 358 | $(LIBOBJ_MIPS): $(DEP_MIPS) |
| 359 | $(LIBOBJ_PPC): $(DEP_PPC) |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 360 | $(LIBOBJ_SPARC): $(DEP_SPARC) |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 361 | $(LIBOBJ_SYSZ): $(DEP_SYSZ) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 362 | $(LIBOBJ_X86): $(DEP_X86) |
Nguyen Anh Quynh | c80d840 | 2014-05-26 23:02:48 +0800 | [diff] [blame] | 363 | $(LIBOBJ_XCORE): $(DEP_XCORE) |
Fotis Loukos | 0850d55 | 2016-05-03 15:52:11 +0300 | [diff] [blame] | 364 | $(LIBOBJ_TMS320C64X): $(DEP_TMS320C64X) |
Wolfgang Schwotzer | 22b4d0e | 2017-10-21 15:44:36 +0200 | [diff] [blame] | 365 | $(LIBOBJ_M680X): $(DEP_M680X) |
Nguyen Anh Quynh | 4a328ca | 2014-02-28 23:09:04 +0800 | [diff] [blame] | 366 | |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 367 | ifeq ($(CAPSTONE_STATIC),yes) |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 368 | $(ARCHIVE): $(LIBOBJ) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 369 | @rm -f $(ARCHIVE) |
| 370 | ifeq ($(V),0) |
| 371 | $(call log,AR,$(@:$(BLDIR)/%=%)) |
| 372 | @$(create-archive) |
| 373 | else |
| 374 | $(create-archive) |
| 375 | endif |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 376 | endif |
pancake | f1cbce2 | 2013-11-27 15:31:26 +0100 | [diff] [blame] | 377 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 378 | $(PKGCFGF): |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 379 | ifeq ($(V),0) |
| 380 | $(call log,GEN,$(@:$(BLDIR)/%=%)) |
| 381 | @$(generate-pkgcfg) |
Nguyen Anh Quynh | 3ff259c | 2014-03-07 17:11:18 +0800 | [diff] [blame] | 382 | else |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 383 | $(generate-pkgcfg) |
Nguyen Anh Quynh | 3ff259c | 2014-03-07 17:11:18 +0800 | [diff] [blame] | 384 | endif |
pancake | 44ce0fb | 2013-12-03 04:11:37 +0100 | [diff] [blame] | 385 | |
pancake | ca9f1b2 | 2013-12-06 17:03:41 +0100 | [diff] [blame] | 386 | install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY) |
Nguyen Anh Quynh | ce7c9a8 | 2016-10-13 20:45:24 +0800 | [diff] [blame] | 387 | mkdir -p $(DESTDIR)$(LIBDIR) |
| 388 | $(call install-library,$(DESTDIR)$(LIBDIR)) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 389 | ifeq ($(CAPSTONE_STATIC),yes) |
Nguyen Anh Quynh | ce7c9a8 | 2016-10-13 20:45:24 +0800 | [diff] [blame] | 390 | $(INSTALL_DATA) $(ARCHIVE) $(DESTDIR)$(LIBDIR) |
Ole André Vadla Ravnås | 927fcbc | 2014-05-01 16:00:52 +0200 | [diff] [blame] | 391 | endif |
Nguyen Anh Quynh | ce7c9a8 | 2016-10-13 20:45:24 +0800 | [diff] [blame] | 392 | mkdir -p $(DESTDIR)$(INCDIR)/$(LIBNAME) |
| 393 | $(INSTALL_DATA) include/capstone/*.h $(DESTDIR)$(INCDIR)/$(LIBNAME) |
| 394 | mkdir -p $(DESTDIR)$(PKGCFGDIR) |
| 395 | $(INSTALL_DATA) $(PKGCFGF) $(DESTDIR)$(PKGCFGDIR) |
Hank Leininger | 1b4d805 | 2016-12-10 20:52:08 -0500 | [diff] [blame] | 396 | mkdir -p $(DESTDIR)$(BINDIR) |
Nguyen Anh Quynh | ce7c9a8 | 2016-10-13 20:45:24 +0800 | [diff] [blame] | 397 | $(INSTALL_LIB) cstool/cstool $(DESTDIR)$(BINDIR) |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 398 | |
| 399 | uninstall: |
Nguyen Anh Quynh | ce7c9a8 | 2016-10-13 20:45:24 +0800 | [diff] [blame] | 400 | rm -rf $(DESTDIR)$(INCDIR)/$(LIBNAME) |
| 401 | rm -f $(DESTDIR)$(LIBDIR)/lib$(LIBNAME).* |
| 402 | rm -f $(DESTDIR)$(PKGCFGDIR)/$(LIBNAME).pc |
| 403 | rm -f $(DESTDIR)$(BINDIR)/cstool |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 404 | |
| 405 | clean: |
Nguyen Anh Quynh | 5519a68 | 2014-04-29 16:24:30 +0800 | [diff] [blame] | 406 | rm -f $(LIBOBJ) |
Nguyen Anh Quynh | cbc1c03 | 2017-05-05 09:46:46 +0800 | [diff] [blame] | 407 | rm -f $(BLDIR)/lib$(LIBNAME).* $(BLDIR)/$(LIBNAME).pc |
Nguyen Anh Quynh | d63ddac | 2014-01-09 10:35:58 +0800 | [diff] [blame] | 408 | rm -f $(PKGCFGF) |
Nguyen Anh Quynh | f36b3f4 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 409 | $(MAKE) -C cstool clean |
Nguyen Tan Cong | 39fd154 | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 410 | |
Nguyen Anh Quynh | 794a706 | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 411 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
danghvu | ad66420 | 2014-05-12 14:27:38 -0500 | [diff] [blame] | 412 | cd tests && $(MAKE) clean |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 413 | rm -f $(BLDIR)/tests/lib$(LIBNAME).$(EXT) |
Nguyen Tan Cong | 39fd154 | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 414 | endif |
Nguyen Anh Quynh | 6ae472f | 2014-04-29 16:29:55 +0800 | [diff] [blame] | 415 | |
| 416 | ifdef BUILDDIR |
| 417 | rm -rf $(BUILDDIR) |
| 418 | endif |
Nguyen Anh Quynh | 5519a68 | 2014-04-29 16:24:30 +0800 | [diff] [blame] | 419 | |
Nguyen Anh Quynh | 794a706 | 2015-01-30 09:07:51 +0800 | [diff] [blame] | 420 | ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) |
danghvu | ad66420 | 2014-05-12 14:27:38 -0500 | [diff] [blame] | 421 | cd bindings/python && $(MAKE) clean |
| 422 | cd bindings/java && $(MAKE) clean |
| 423 | cd bindings/ocaml && $(MAKE) clean |
Nguyen Tan Cong | 39fd154 | 2015-01-28 00:35:44 +0700 | [diff] [blame] | 424 | endif |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 425 | |
Nguyen Anh Quynh | a580d92 | 2014-01-18 12:47:15 +0800 | [diff] [blame] | 426 | |
| 427 | TAG ?= HEAD |
| 428 | ifeq ($(TAG), HEAD) |
| 429 | DIST_VERSION = latest |
| 430 | else |
| 431 | DIST_VERSION = $(TAG) |
| 432 | endif |
| 433 | |
pancake | 35cef7f | 2014-01-18 03:42:15 +0100 | [diff] [blame] | 434 | dist: |
Nguyen Anh Quynh | 186d501 | 2014-01-22 18:46:20 +0800 | [diff] [blame] | 435 | 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] | 436 | git archive --format=zip --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).zip |
pancake | 35cef7f | 2014-01-18 03:42:15 +0100 | [diff] [blame] | 437 | |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 438 | |
Pranith Kumar | 83fb35c | 2016-02-29 22:58:57 -0500 | [diff] [blame] | 439 | TESTS = test_basic test_detail test_arm test_arm64 test_m68k test_mips test_ppc test_sparc |
Nguyen Anh Quynh | b16dc85 | 2014-11-02 08:21:34 +0800 | [diff] [blame] | 440 | TESTS += test_systemz test_x86 test_xcore test_iter |
Pranith Kumar | 83fb35c | 2016-02-29 22:58:57 -0500 | [diff] [blame] | 441 | TESTS += test_basic.static test_detail.static test_arm.static test_arm64.static |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 442 | TESTS += test_m68k.static test_mips.static test_ppc.static test_sparc.static |
Wolfgang Schwotzer | 22b4d0e | 2017-10-21 15:44:36 +0200 | [diff] [blame] | 443 | TESTS += test_systemz.static test_x86.static test_xcore.static test_m680x.static |
Nguyen Anh Quynh | b16dc85 | 2014-11-02 08:21:34 +0800 | [diff] [blame] | 444 | TESTS += test_skipdata test_skipdata.static test_iter.static |
Nguyen Anh Quynh | 984d450 | 2014-10-01 16:42:29 +0800 | [diff] [blame] | 445 | check: |
| 446 | @for t in $(TESTS); do \ |
| 447 | echo Check $$t ... ; \ |
Akihiko Odaki | ec40753 | 2016-09-11 09:00:32 +0900 | [diff] [blame] | 448 | 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] | 449 | done |
| 450 | |
Ole André Vadla Ravnås | 35f937d | 2014-04-29 09:00:34 +0200 | [diff] [blame] | 451 | $(OBJDIR)/%.o: %.c |
| 452 | @mkdir -p $(@D) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 453 | ifeq ($(V),0) |
| 454 | $(call log,CC,$(@:$(OBJDIR)/%=%)) |
| 455 | @$(compile) |
| 456 | else |
| 457 | $(compile) |
| 458 | endif |
| 459 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 460 | |
Akihiko Odaki | ec40753 | 2016-09-11 09:00:32 +0900 | [diff] [blame] | 461 | ifeq ($(CAPSTONE_SHARED),yes) |
| 462 | define install-library |
| 463 | $(INSTALL_LIB) $(LIBRARY) $1 |
| 464 | $(if $(VERSION_EXT), |
| 465 | cd $1 && \ |
| 466 | rm -f lib$(LIBNAME).$(EXT) && \ |
| 467 | ln -s lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT)) |
| 468 | endef |
| 469 | else |
| 470 | define install-library |
| 471 | endef |
| 472 | endif |
| 473 | |
| 474 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 475 | define create-archive |
| 476 | $(AR) q $(ARCHIVE) $(LIBOBJ) |
| 477 | $(RANLIB) $(ARCHIVE) |
| 478 | endef |
| 479 | |
Nguyen Anh Quynh | 58a0047 | 2014-05-01 22:53:52 +0800 | [diff] [blame] | 480 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 481 | define create-library |
danghvu | e1c7a21 | 2014-05-14 02:13:36 -0500 | [diff] [blame] | 482 | $(CC) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 483 | endef |
| 484 | |
Nguyen Anh Quynh | 58a0047 | 2014-05-01 22:53:52 +0800 | [diff] [blame] | 485 | |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 486 | define generate-pkgcfg |
Ole André Vadla Ravnås | 495a4f5 | 2015-04-23 17:55:06 +0200 | [diff] [blame] | 487 | mkdir -p $(BLDIR) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 488 | echo 'Name: capstone' > $(PKGCFGF) |
| 489 | echo 'Description: Capstone disassembly engine' >> $(PKGCFGF) |
| 490 | echo 'Version: $(PKG_VERSION)' >> $(PKGCFGF) |
| 491 | echo 'libdir=$(LIBDIR)' >> $(PKGCFGF) |
pancake | 9c10ace | 2015-02-24 04:55:55 +0100 | [diff] [blame] | 492 | echo 'includedir=$(INCDIR)' >> $(PKGCFGF) |
Ole André Vadla Ravnås | f536d40 | 2014-05-01 15:22:25 +0200 | [diff] [blame] | 493 | echo 'archive=$${libdir}/libcapstone.a' >> $(PKGCFGF) |
| 494 | echo 'Libs: -L$${libdir} -lcapstone' >> $(PKGCFGF) |
| 495 | echo 'Cflags: -I$${includedir}' >> $(PKGCFGF) |
| 496 | endef |