1 # Makefile for Cstool of Capstone Disassembly Engine 2 3 include ../functions.mk 4 5 .PHONY: clean all 6 7 LIBNAME = capstone 8 9 CFLAGS += -I../include 10 LDFLAGS += -O3 -Wall -L.. -l$(LIBNAME) 11 12 TARGET = cstool 13 SOURCES := $(wildcard *.c) 14 OBJECTS := $(SOURCES:.c=.o) 15 16 LIBCAPSTONE = libcapstone.a 17 18 IS_CYGWIN := $(shell $(CC) -dumpmachine 2>/dev/null | grep -i cygwin | wc -l) 19 ifeq ($(IS_CYGWIN),1) 20 LIBCAPSTONE = capstone.lib 21 else 22 IS_MINGW := $(shell $(CC) --version 2>/dev/null | grep -i mingw | wc -l) 23 ifeq ($(IS_MINGW),1) 24 LIBCAPSTONE = capstone.lib 25 endif 26 endif 27 28 all: $(TARGET) 29 30 $(TARGET): ../$(LIBCAPSTONE) $(OBJECTS) 31 ifeq ($(V),0) 32 $(call log,LINK,$@) 33 @${CC} $(OBJECTS) $(LDFLAGS) -o $@ 34 else 35 ${CC} $(OBJECTS) $(LDFLAGS) -o $@ 36 endif 37 38 clean: 39 ${RM} -rf *.o $(TARGET) 40 41 %.o: %.c 42 ifeq ($(V),0) 43 $(call log,CC,$@) 44 @${CC} $(CFLAGS) -c $< -o $@ 45 else 46 ${CC} $(CFLAGS) -c $< -o $@ 47 endif 48