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