diff --git a/Makefile b/Makefile index f4551eb9..c329c023 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,29 @@ UNAME_S := $(shell uname -s) # If you want to use 16 job threads, use "-j16". SMP_MFLAGS := -j4 +ifeq ($(UNICORN_ASAN),yes) +CC = clang -fsanitize=address -fno-omit-frame-pointer +CXX = clang++ -fsanitize=address -fno-omit-frame-pointer +AR = llvm-ar +LDFLAGS := -fsanitize=address ${LDFLAGS} +endif + +ifeq ($(CROSS),) +CC ?= cc +AR ?= ar +RANLIB ?= ranlib +STRIP ?= strip +else +CC = $(CROSS)-gcc +AR = $(CROSS)-ar +RANLIB = $(CROSS)-ranlib +STRIP = $(CROSS)-strip +endif + +IS_WIN32 = $(shell $(CC) -dM -E - < /dev/null | grep '_WIN32'; \ + if [ $$? = 0 ]; then echo yes; \ + else echo no; fi) + UC_GET_OBJ = $(shell for i in \ $$(grep '$(1)' $(2) | \ grep '\.o' | cut -d '=' -f 2); do \ @@ -31,7 +54,11 @@ UC_TARGET_OBJ += $(call UC_GET_OBJ,obj-,qemu/qapi/Makefile.objs, qemu/qapi/) UC_TARGET_OBJ += $(call UC_GET_OBJ,obj-,qemu/qobject/Makefile.objs, qemu/qobject/) UC_TARGET_OBJ += $(call UC_GET_OBJ,obj-,qemu/qom/Makefile.objs, qemu/qom/) UC_TARGET_OBJ += $(call UC_GET_OBJ,obj-y,qemu/util/Makefile.objs, qemu/util/) +ifeq ($(IS_WIN32),yes) +UC_TARGET_OBJ += $(call UC_GET_OBJ,obj-$$(CONFIG_WIN32),qemu/util/Makefile.objs, qemu/util/) +else UC_TARGET_OBJ += $(call UC_GET_OBJ,obj-$$(CONFIG_POSIX),qemu/util/Makefile.objs, qemu/util/) +endif UC_TARGET_OBJ_X86 = $(call UC_GET_OBJ,obj-,qemu/Makefile.target, qemu/x86_64-softmmu/) UC_TARGET_OBJ_X86 += $(call UC_GET_OBJ,obj-,qemu/hw/i386/Makefile.objs, qemu/x86_64-softmmu/hw/i386/) @@ -142,25 +169,6 @@ CFLAGS += -O3 UNICORN_QEMU_FLAGS += --disable-debug-info endif -ifeq ($(UNICORN_ASAN),yes) -CC = clang -fsanitize=address -fno-omit-frame-pointer -CXX = clang++ -fsanitize=address -fno-omit-frame-pointer -AR = llvm-ar -LDFLAGS := -fsanitize=address ${LDFLAGS} -endif - -ifeq ($(CROSS),) -CC ?= cc -AR ?= ar -RANLIB ?= ranlib -STRIP ?= strip -else -CC = $(CROSS)-gcc -AR = $(CROSS)-ar -RANLIB = $(CROSS)-ranlib -STRIP = $(CROSS)-strip -endif - ifeq ($(PKG_EXTRA),) PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR) else