samples: fix Makefile for Mingw

This commit is contained in:
Nguyen Anh Quynh 2016-11-19 23:40:38 +08:00
parent c4ddf4e36b
commit 33813a0781

View file

@ -10,13 +10,15 @@ ifndef GLIB
GLIB = $(shell pkg-config --libs glib-2.0) GLIB = $(shell pkg-config --libs glib-2.0)
endif endif
LIBDIR = ..
BIN_EXT = BIN_EXT =
AR_EXT = a
# Verbose output? # Verbose output?
V ?= 0 V ?= 0
CFLAGS += -Wall -Werror -I../include CFLAGS += -Wall -Werror -I../include
LDFLAGS += -L.. -lunicorn LDFLAGS += -L$(LIBDIR) -lunicorn -lpthread -lm $(GLIB)
LDLIBS += -lpthread -lunicorn -lm $(GLIB) LDLIBS += -lpthread -lunicorn -lm $(GLIB)
ifneq ($(CROSS),) ifneq ($(CROSS),)
@ -28,6 +30,7 @@ CC = clang
CXX = clang++ CXX = clang++
AR = llvm-ar AR = llvm-ar
CFLAGS += -fsanitize=address -fno-omit-frame-pointer CFLAGS += -fsanitize=address -fno-omit-frame-pointer
LDFLAGS := -fsanitize=address ${LDFLAGS}
endif endif
# Cygwin? # Cygwin?
@ -35,10 +38,22 @@ ifneq ($(filter CYGWIN%,$(UNAME_S)),)
CFLAGS := $(CFLAGS:-fPIC=) CFLAGS := $(CFLAGS:-fPIC=)
LDLIBS += -lssp LDLIBS += -lssp
BIN_EXT = .exe BIN_EXT = .exe
AR_EXT = a
# mingw? # mingw?
else ifneq ($(filter MINGW%,$(UNAME_S)),) else ifneq ($(filter MINGW%,$(UNAME_S)),)
CFLAGS := $(CFLAGS:-fPIC=) CFLAGS := $(CFLAGS:-fPIC=)
BIN_EXT = .exe BIN_EXT = .exe
AR_EXT = lib
endif
ifeq ($(UNICORN_STATIC),yes)
ifneq ($(filter MINGW%,$(UNAME_S)),)
ARCHIVE = $(LIBDIR)/unicorn.$(AR_EXT)
else ifneq ($(filter CYGWIN%,$(UNAME_S)),)
ARCHIVE = $(LIBDIR)/libunicorn.$(AR_EXT)
else
ARCHIVE = $(LIBDIR)/libunicorn.$(AR_EXT)
endif
endif endif
.PHONY: all clean .PHONY: all clean
@ -123,7 +138,7 @@ endef
define link-static define link-static
$(CC) $< $(ARCHIVE) $(LDFLAGS_STATIC) -o $(call staticname,$@) $(CC) $< $(ARCHIVE) $(LDFLAGS) -o $(call staticname,$@)
endef endef