blob: 3457cc66a92260faff8811518e1f9e193e5c1361 [file] [log] [blame]
Nguyen Anh Quynhf7ff8f62016-10-11 16:50:51 +08001# Makefile for Cstool of Capstone Disassembly Engine
echotyh6239a982016-10-10 15:16:56 +08002
Nguyen Anh Quynh34603272016-10-10 22:54:16 +08003include ../functions.mk
4
YUHANG TANGabc28b52016-10-14 17:29:56 +08005.PHONY: clean all
Nguyen Anh Quynh34603272016-10-10 22:54:16 +08006
Nguyen Anh Quynhef2c5f22016-10-10 23:25:21 +08007LIBNAME = capstone
8
Zach Riggle8f813d42017-08-28 19:23:03 -05009CFLAGS += -I../include
10LDFLAGS += -O3 -Wall -L.. -l$(LIBNAME)
Nguyen Anh Quynha1699632016-10-10 23:07:39 +080011
YUHANG TANGabc28b52016-10-14 17:29:56 +080012TARGET = cstool
13SOURCES := $(wildcard *.c)
14OBJECTS := $(SOURCES:.c=.o)
15
Adrian Herrera229593d2017-06-02 15:49:10 +020016LIBCAPSTONE = libcapstone.a
Nguyen Anh Quynhb6c4c3f2017-05-25 23:10:19 +080017
18IS_CYGWIN := $(shell $(CC) -dumpmachine 2>/dev/null | grep -i cygwin | wc -l)
19ifeq ($(IS_CYGWIN),1)
Adrian Herrera229593d2017-06-02 15:49:10 +020020LIBCAPSTONE = capstone.lib
Nguyen Anh Quynhb6c4c3f2017-05-25 23:10:19 +080021else
22IS_MINGW := $(shell $(CC) --version 2>/dev/null | grep -i mingw | wc -l)
23ifeq ($(IS_MINGW),1)
Adrian Herrera229593d2017-06-02 15:49:10 +020024LIBCAPSTONE = capstone.lib
Nguyen Anh Quynhb6c4c3f2017-05-25 23:10:19 +080025endif
26endif
27
YUHANG TANGabc28b52016-10-14 17:29:56 +080028all: $(TARGET)
29
Adrian Herrera229593d2017-06-02 15:49:10 +020030$(TARGET): ../$(LIBCAPSTONE) $(OBJECTS)
Nguyen Anh Quynh34603272016-10-10 22:54:16 +080031ifeq ($(V),0)
32 $(call log,LINK,$@)
YUHANG TANGabc28b52016-10-14 17:29:56 +080033 @${CC} $(OBJECTS) $(LDFLAGS) -o $@
Nguyen Anh Quynh34603272016-10-10 22:54:16 +080034else
YUHANG TANGabc28b52016-10-14 17:29:56 +080035 ${CC} $(OBJECTS) $(LDFLAGS) -o $@
Nguyen Anh Quynh34603272016-10-10 22:54:16 +080036endif
37
38clean:
Nguyen Anh Quynhc86e78f2016-11-08 10:56:18 +080039 ${RM} -rf *.o $(TARGET)
echotyh6239a982016-10-10 15:16:56 +080040
41%.o: %.c
Nguyen Anh Quynh34603272016-10-10 22:54:16 +080042ifeq ($(V),0)
43 $(call log,CC,$@)
Nguyen Anh Quynha1699632016-10-10 23:07:39 +080044 @${CC} $(CFLAGS) -c $< -o $@
Nguyen Anh Quynh34603272016-10-10 22:54:16 +080045else
Nguyen Anh Quynha1699632016-10-10 23:07:39 +080046 ${CC} $(CFLAGS) -c $< -o $@
Nguyen Anh Quynh34603272016-10-10 22:54:16 +080047endif