Nguyen Anh Quynh | f7ff8f6 | 2016-10-11 16:50:51 +0800 | [diff] [blame] | 1 | # Makefile for Cstool of Capstone Disassembly Engine |
echotyh | 6239a98 | 2016-10-10 15:16:56 +0800 | [diff] [blame] | 2 | |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 3 | include ../functions.mk |
4 | |||||
YUHANG TANG | abc28b5 | 2016-10-14 17:29:56 +0800 | [diff] [blame] | 5 | .PHONY: clean all |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 6 | |
Nguyen Anh Quynh | ef2c5f2 | 2016-10-10 23:25:21 +0800 | [diff] [blame] | 7 | LIBNAME = capstone |
8 | |||||
Zach Riggle | 8f813d4 | 2017-08-28 19:23:03 -0500 | [diff] [blame] | 9 | CFLAGS += -I../include |
10 | LDFLAGS += -O3 -Wall -L.. -l$(LIBNAME) | ||||
Nguyen Anh Quynh | a169963 | 2016-10-10 23:07:39 +0800 | [diff] [blame] | 11 | |
YUHANG TANG | abc28b5 | 2016-10-14 17:29:56 +0800 | [diff] [blame] | 12 | TARGET = cstool |
13 | SOURCES := $(wildcard *.c) | ||||
14 | OBJECTS := $(SOURCES:.c=.o) | ||||
15 | |||||
Adrian Herrera | 229593d | 2017-06-02 15:49:10 +0200 | [diff] [blame] | 16 | LIBCAPSTONE = libcapstone.a |
Nguyen Anh Quynh | b6c4c3f | 2017-05-25 23:10:19 +0800 | [diff] [blame] | 17 | |
18 | IS_CYGWIN := $(shell $(CC) -dumpmachine 2>/dev/null | grep -i cygwin | wc -l) | ||||
19 | ifeq ($(IS_CYGWIN),1) | ||||
Adrian Herrera | 229593d | 2017-06-02 15:49:10 +0200 | [diff] [blame] | 20 | LIBCAPSTONE = capstone.lib |
Nguyen Anh Quynh | b6c4c3f | 2017-05-25 23:10:19 +0800 | [diff] [blame] | 21 | else |
22 | IS_MINGW := $(shell $(CC) --version 2>/dev/null | grep -i mingw | wc -l) | ||||
23 | ifeq ($(IS_MINGW),1) | ||||
Adrian Herrera | 229593d | 2017-06-02 15:49:10 +0200 | [diff] [blame] | 24 | LIBCAPSTONE = capstone.lib |
Nguyen Anh Quynh | b6c4c3f | 2017-05-25 23:10:19 +0800 | [diff] [blame] | 25 | endif |
26 | endif | ||||
27 | |||||
YUHANG TANG | abc28b5 | 2016-10-14 17:29:56 +0800 | [diff] [blame] | 28 | all: $(TARGET) |
29 | |||||
Adrian Herrera | 229593d | 2017-06-02 15:49:10 +0200 | [diff] [blame] | 30 | $(TARGET): ../$(LIBCAPSTONE) $(OBJECTS) |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 31 | ifeq ($(V),0) |
32 | $(call log,LINK,$@) | ||||
YUHANG TANG | abc28b5 | 2016-10-14 17:29:56 +0800 | [diff] [blame] | 33 | @${CC} $(OBJECTS) $(LDFLAGS) -o $@ |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 34 | else |
YUHANG TANG | abc28b5 | 2016-10-14 17:29:56 +0800 | [diff] [blame] | 35 | ${CC} $(OBJECTS) $(LDFLAGS) -o $@ |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 36 | endif |
37 | |||||
38 | clean: | ||||
Nguyen Anh Quynh | c86e78f | 2016-11-08 10:56:18 +0800 | [diff] [blame] | 39 | ${RM} -rf *.o $(TARGET) |
echotyh | 6239a98 | 2016-10-10 15:16:56 +0800 | [diff] [blame] | 40 | |
41 | %.o: %.c | ||||
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 42 | ifeq ($(V),0) |
43 | $(call log,CC,$@) | ||||
Nguyen Anh Quynh | a169963 | 2016-10-10 23:07:39 +0800 | [diff] [blame] | 44 | @${CC} $(CFLAGS) -c $< -o $@ |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 45 | else |
Nguyen Anh Quynh | a169963 | 2016-10-10 23:07:39 +0800 | [diff] [blame] | 46 | ${CC} $(CFLAGS) -c $< -o $@ |
Nguyen Anh Quynh | 3460327 | 2016-10-10 22:54:16 +0800 | [diff] [blame] | 47 | endif |