2015-08-21 10:04:50 +03:00
|
|
|
# Unicorn Emulator Engine
|
|
|
|
# By Dang Hoang Vu <dang.hvu -at- gmail.com>, 2015
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: all clean install uninstall dist header
|
|
|
|
|
|
|
|
include config.mk
|
|
|
|
include pkgconfig.mk # package version
|
|
|
|
|
|
|
|
LIBNAME = unicorn
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
UNAME_S := $(shell uname -s)
|
2015-08-21 10:04:50 +03:00
|
|
|
|
2016-11-07 21:52:05 +03:00
|
|
|
GENOBJ = $(shell find qemu/$(1) -name "*.o" 2>/dev/null)
|
2015-08-21 10:04:50 +03:00
|
|
|
|
|
|
|
ifneq (,$(findstring x86,$(UNICORN_ARCHS)))
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,x86_64-softmmu)
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_X86
|
|
|
|
UNICORN_TARGETS += x86_64-softmmu,
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring arm,$(UNICORN_ARCHS)))
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,arm-softmmu)
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_ARM
|
|
|
|
UNICORN_TARGETS += arm-softmmu,
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring m68k,$(UNICORN_ARCHS)))
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,m68k-softmmu)
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_M68K
|
|
|
|
UNICORN_TARGETS += m68k-softmmu,
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring aarch64,$(UNICORN_ARCHS)))
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,aarch64-softmmu)
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_ARM64
|
|
|
|
UNICORN_TARGETS += aarch64-softmmu,
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring mips,$(UNICORN_ARCHS)))
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,mips-softmmu)
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,mipsel-softmmu)
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,mips64-softmmu)
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,mips64el-softmmu)
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_MIPS
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_MIPSEL
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_MIPS64
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_MIPS64EL
|
|
|
|
UNICORN_TARGETS += mips-softmmu,
|
|
|
|
UNICORN_TARGETS += mipsel-softmmu,
|
|
|
|
UNICORN_TARGETS += mips64-softmmu,
|
|
|
|
UNICORN_TARGETS += mips64el-softmmu,
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring sparc,$(UNICORN_ARCHS)))
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,sparc-softmmu)
|
|
|
|
UC_TARGET_OBJ += $(call GENOBJ,sparc64-softmmu)
|
|
|
|
UNICORN_CFLAGS += -DUNICORN_HAS_SPARC
|
|
|
|
UNICORN_TARGETS += sparc-softmmu,sparc64-softmmu,
|
|
|
|
endif
|
|
|
|
|
|
|
|
UNICORN_CFLAGS += -fPIC
|
|
|
|
|
|
|
|
# Verbose output?
|
|
|
|
V ?= 0
|
|
|
|
|
|
|
|
ifeq ($(UNICORN_DEBUG),yes)
|
|
|
|
CFLAGS += -g
|
2015-10-19 03:47:19 +03:00
|
|
|
else
|
|
|
|
CFLAGS += -O3
|
2016-10-29 02:31:52 +03:00
|
|
|
UNICORN_QEMU_FLAGS += --disable-debug-info
|
2015-08-21 10:04:50 +03:00
|
|
|
endif
|
|
|
|
|
2016-04-21 01:38:27 +03:00
|
|
|
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
|
|
|
|
|
2015-08-21 10:04:50 +03:00
|
|
|
ifeq ($(CROSS),)
|
|
|
|
CC ?= cc
|
|
|
|
AR ?= ar
|
|
|
|
RANLIB ?= ranlib
|
|
|
|
STRIP ?= strip
|
|
|
|
else
|
2015-12-20 05:05:04 +03:00
|
|
|
CC = $(CROSS)-gcc
|
|
|
|
AR = $(CROSS)-ar
|
|
|
|
RANLIB = $(CROSS)-ranlib
|
|
|
|
STRIP = $(CROSS)-strip
|
|
|
|
GLIB = "-L/usr/$(CROSS)/lib/ -lglib-2.0"
|
2015-08-21 10:04:50 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Find GLIB
|
|
|
|
ifndef GLIB
|
|
|
|
GLIB = `pkg-config --libs glib-2.0`
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(PKG_EXTRA),)
|
|
|
|
PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR)
|
|
|
|
else
|
|
|
|
PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA)
|
|
|
|
endif
|
|
|
|
|
|
|
|
API_MAJOR=$(shell echo `grep -e UC_API_MAJOR include/unicorn/unicorn.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}')
|
|
|
|
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
# Apple?
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
2015-08-21 10:04:50 +03:00
|
|
|
EXT = dylib
|
|
|
|
VERSION_EXT = $(API_MAJOR).$(EXT)
|
2015-10-16 17:03:24 +03:00
|
|
|
$(LIBNAME)_LDFLAGS += -dynamiclib -install_name lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR)
|
2015-08-21 10:04:50 +03:00
|
|
|
AR_EXT = a
|
|
|
|
UNICORN_CFLAGS += -fvisibility=hidden
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
|
2016-07-15 11:34:16 +03:00
|
|
|
ifeq ($(MACOS_UNIVERSAL),yes)
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
$(LIBNAME)_LDFLAGS += -m32 -arch i386 -m64 -arch x86_64
|
2016-07-15 09:12:30 +03:00
|
|
|
UNICORN_CFLAGS += -m32 -arch i386 -m64 -arch x86_64
|
2016-07-15 11:34:16 +03:00
|
|
|
endif
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
|
2015-08-21 10:04:50 +03:00
|
|
|
# Cygwin?
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
else ifneq ($(filter CYGWIN%,$(UNAME_S)),)
|
2015-08-21 10:04:50 +03:00
|
|
|
EXT = dll
|
2015-12-17 08:20:57 +03:00
|
|
|
AR_EXT = a
|
2015-08-21 10:04:50 +03:00
|
|
|
BIN_EXT = .exe
|
2015-12-17 08:20:57 +03:00
|
|
|
UNICORN_CFLAGS := $(UNICORN_CFLAGS:-fPIC=)
|
|
|
|
#UNICORN_QEMU_FLAGS += --disable-stack-protector
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
|
2015-08-21 10:04:50 +03:00
|
|
|
# mingw?
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
else ifneq ($(filter MINGW%,$(UNAME_S)),)
|
2015-08-21 10:04:50 +03:00
|
|
|
EXT = dll
|
|
|
|
AR_EXT = lib
|
|
|
|
BIN_EXT = .exe
|
2016-10-29 02:31:52 +03:00
|
|
|
UNICORN_QEMU_FLAGS += --disable-stack-protector
|
|
|
|
UNICORN_CFLAGS := $(UNICORN_CFLAGS:-fPIC=)
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
|
|
|
|
# Linux, Darwin
|
2015-08-21 10:04:50 +03:00
|
|
|
else
|
|
|
|
EXT = so
|
|
|
|
VERSION_EXT = $(EXT).$(API_MAJOR)
|
|
|
|
AR_EXT = a
|
2015-12-28 20:11:37 +03:00
|
|
|
$(LIBNAME)_LDFLAGS += -Wl,-Bsymbolic-functions,-soname,lib$(LIBNAME).$(VERSION_EXT)
|
2016-04-27 11:32:30 +03:00
|
|
|
UNICORN_CFLAGS += -fvisibility=hidden
|
2015-08-21 10:04:50 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(UNICORN_SHARED),yes)
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
ifneq ($(filter MINGW%,$(UNAME_S)),)
|
2016-10-29 02:31:52 +03:00
|
|
|
LIBRARY = $(LIBNAME).$(EXT)
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
else ifneq ($(filter CYGWIN%,$(UNAME_S)),)
|
2016-10-29 02:31:52 +03:00
|
|
|
LIBRARY = cyg$(LIBNAME).$(EXT)
|
|
|
|
LIBRARY_DLLA = lib$(LIBNAME).$(EXT).$(AR_EXT)
|
2015-12-17 08:20:57 +03:00
|
|
|
$(LIBNAME)_LDFLAGS += -Wl,--out-implib=$(LIBRARY_DLLA)
|
|
|
|
$(LIBNAME)_LDFLAGS += -lssp
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
# Linux, Darwin
|
|
|
|
else
|
2016-10-29 02:31:52 +03:00
|
|
|
LIBRARY = lib$(LIBNAME).$(VERSION_EXT)
|
|
|
|
LIBRARY_SYMLINK = lib$(LIBNAME).$(EXT)
|
2015-08-21 10:04:50 +03:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(UNICORN_STATIC),yes)
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
ifneq ($(filter MINGW%,$(UNAME_S)),)
|
2016-10-29 02:31:52 +03:00
|
|
|
ARCHIVE = $(LIBNAME).$(AR_EXT)
|
|
|
|
# Cygwin, Linux, Darwin
|
2015-08-21 10:04:50 +03:00
|
|
|
else
|
2016-10-29 02:31:52 +03:00
|
|
|
ARCHIVE = lib$(LIBNAME).$(AR_EXT)
|
2015-08-21 10:04:50 +03:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
INSTALL_BIN ?= install
|
|
|
|
INSTALL_DATA ?= $(INSTALL_BIN) -m0644
|
|
|
|
INSTALL_LIB ?= $(INSTALL_BIN) -m0755
|
|
|
|
PKGCFGF = $(LIBNAME).pc
|
|
|
|
PREFIX ?= /usr
|
|
|
|
DESTDIR ?=
|
|
|
|
|
|
|
|
LIBDIRARCH ?= lib
|
|
|
|
# Uncomment the below line to installs x86_64 libs to lib64/ directory.
|
|
|
|
# Or better, pass 'LIBDIRARCH=lib64' to 'make install/uninstall' via 'make.sh'.
|
|
|
|
#LIBDIRARCH ?= lib64
|
|
|
|
|
2015-11-10 13:47:19 +03:00
|
|
|
LIBDIR ?= $(PREFIX)/$(LIBDIRARCH)
|
|
|
|
INCDIR ?= $(PREFIX)/include
|
2015-12-17 08:20:57 +03:00
|
|
|
BINDIR ?= $(PREFIX)/bin
|
2015-08-21 10:04:50 +03:00
|
|
|
|
|
|
|
LIBDATADIR ?= $(LIBDIR)
|
|
|
|
|
|
|
|
# Don't redefine $LIBDATADIR when global environment variable
|
|
|
|
# USE_GENERIC_LIBDATADIR is set. This is used by the pkgsrc framework.
|
|
|
|
|
|
|
|
ifndef USE_GENERIC_LIBDATADIR
|
|
|
|
ifeq ($(UNAME_S), FreeBSD)
|
2016-12-17 10:25:06 +03:00
|
|
|
LIBDATADIR = $(PREFIX)/libdata
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
else ifeq ($(UNAME_S), DragonFly)
|
2016-12-17 10:25:06 +03:00
|
|
|
LIBDATADIR = $(PREFIX)/libdata
|
2015-08-21 10:04:50 +03:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(PKG_EXTRA),)
|
|
|
|
PKGCFGDIR = $(LIBDATADIR)/pkgconfig
|
|
|
|
else
|
|
|
|
PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig
|
|
|
|
endif
|
|
|
|
|
2016-11-07 21:52:05 +03:00
|
|
|
$(LIBNAME)_LDFLAGS += $(GLIB) -lm
|
|
|
|
|
2016-10-29 02:31:52 +03:00
|
|
|
.PHONY: all
|
|
|
|
all: unicorn
|
|
|
|
$(MAKE) -C samples
|
2015-08-21 10:04:50 +03:00
|
|
|
|
2016-11-11 19:40:22 +03:00
|
|
|
qemu/config-host.h-timestamp:
|
2015-08-21 10:04:50 +03:00
|
|
|
cd qemu && \
|
2016-04-21 01:38:27 +03:00
|
|
|
./configure --cc="${CC}" --extra-cflags="$(UNICORN_CFLAGS)" --target-list="$(UNICORN_TARGETS)" ${UNICORN_QEMU_FLAGS}
|
2015-08-21 10:04:50 +03:00
|
|
|
printf "$(UNICORN_ARCHS)" > config.log
|
2016-10-29 02:31:52 +03:00
|
|
|
$(MAKE) -C qemu -j 4
|
2016-11-07 21:52:05 +03:00
|
|
|
$(eval UC_TARGET_OBJ += $$(wildcard qemu/util/*.o) $$(wildcard qemu/*.o) $$(wildcard qemu/qom/*.o) $$(wildcard qemu/hw/core/*.o) $$(wildcard qemu/qapi/*.o) $$(wildcard qemu/qobject/*.o))
|
2015-08-21 10:04:50 +03:00
|
|
|
|
2016-11-07 21:52:05 +03:00
|
|
|
unicorn: $(LIBRARY) $(ARCHIVE)
|
2015-08-21 10:04:50 +03:00
|
|
|
|
2016-11-11 19:40:22 +03:00
|
|
|
$(LIBRARY): qemu/config-host.h-timestamp uc.o list.o
|
2016-11-19 12:20:05 +03:00
|
|
|
ifeq ($(UNICORN_SHARED),yes)
|
|
|
|
ifeq ($(V),0)
|
|
|
|
$(call log,GEN,$(LIBRARY))
|
|
|
|
@$(CC) $(CFLAGS) -shared $(UC_TARGET_OBJ) uc.o list.o -o $(LIBRARY) $($(LIBNAME)_LDFLAGS)
|
|
|
|
@-ln -sf $(LIBRARY) $(LIBRARY_SYMLINK)
|
|
|
|
else
|
2016-11-07 21:52:05 +03:00
|
|
|
$(CC) $(CFLAGS) -shared $(UC_TARGET_OBJ) uc.o list.o -o $(LIBRARY) $($(LIBNAME)_LDFLAGS)
|
|
|
|
-ln -sf $(LIBRARY) $(LIBRARY_SYMLINK)
|
2016-11-19 12:20:05 +03:00
|
|
|
endif
|
|
|
|
endif
|
2015-08-21 10:04:50 +03:00
|
|
|
|
2016-11-11 19:40:22 +03:00
|
|
|
$(ARCHIVE): qemu/config-host.h-timestamp uc.o list.o
|
2016-11-19 12:20:05 +03:00
|
|
|
ifeq ($(UNICORN_STATIC),yes)
|
|
|
|
ifeq ($(V),0)
|
|
|
|
$(call log,GEN,$(ARCHIVE))
|
|
|
|
@$(AR) q $(ARCHIVE) $(UC_TARGET_OBJ) uc.o list.o
|
|
|
|
@$(RANLIB) $(ARCHIVE)
|
|
|
|
else
|
2016-11-07 21:52:05 +03:00
|
|
|
$(AR) q $(ARCHIVE) $(UC_TARGET_OBJ) uc.o list.o
|
2016-10-29 02:31:52 +03:00
|
|
|
$(RANLIB) $(ARCHIVE)
|
2016-11-19 12:20:05 +03:00
|
|
|
endif
|
|
|
|
endif
|
2015-08-21 10:04:50 +03:00
|
|
|
|
|
|
|
$(PKGCFGF):
|
|
|
|
$(generate-pkgcfg)
|
|
|
|
|
2015-09-21 04:39:35 +03:00
|
|
|
.PHONY: test
|
|
|
|
test: all
|
2015-09-22 04:47:45 +03:00
|
|
|
$(MAKE) -C tests/unit test
|
2016-11-07 21:52:05 +03:00
|
|
|
$(MAKE) -C tests/regress test
|
2016-10-29 02:31:52 +03:00
|
|
|
$(MAKE) -C bindings test
|
2015-09-21 04:39:35 +03:00
|
|
|
|
2016-11-11 19:40:22 +03:00
|
|
|
install: qemu/config-host.h-timestamp $(PKGCFGF)
|
2015-12-17 08:20:57 +03:00
|
|
|
mkdir -p $(DESTDIR)$(LIBDIR)
|
2015-08-21 10:04:50 +03:00
|
|
|
ifeq ($(UNICORN_SHARED),yes)
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
ifneq ($(filter CYGWIN%,$(UNAME_S)),)
|
2015-12-17 08:20:57 +03:00
|
|
|
$(INSTALL_LIB) $(LIBRARY) $(DESTDIR)$(BINDIR)
|
|
|
|
$(INSTALL_DATA) $(LIBRARY_DLLA) $(DESTDIR)$(LIBDIR)
|
|
|
|
else
|
|
|
|
$(INSTALL_LIB) $(LIBRARY) $(DESTDIR)$(LIBDIR)
|
|
|
|
endif
|
2015-08-21 10:04:50 +03:00
|
|
|
ifneq ($(VERSION_EXT),)
|
2015-12-17 08:20:57 +03:00
|
|
|
cd $(DESTDIR)$(LIBDIR) && \
|
2015-10-25 04:44:01 +03:00
|
|
|
ln -sf lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT)
|
2015-08-21 10:04:50 +03:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifeq ($(UNICORN_STATIC),yes)
|
2015-12-17 08:20:57 +03:00
|
|
|
$(INSTALL_DATA) $(ARCHIVE) $(DESTDIR)$(LIBDIR)
|
2015-08-21 10:04:50 +03:00
|
|
|
endif
|
2015-12-17 08:20:57 +03:00
|
|
|
mkdir -p $(DESTDIR)$(INCDIR)/$(LIBNAME)
|
|
|
|
$(INSTALL_DATA) include/unicorn/*.h $(DESTDIR)$(INCDIR)/$(LIBNAME)
|
|
|
|
mkdir -p $(DESTDIR)$(PKGCFGDIR)
|
|
|
|
$(INSTALL_DATA) $(PKGCFGF) $(DESTDIR)$(PKGCFGDIR)/
|
2015-08-21 10:04:50 +03:00
|
|
|
|
|
|
|
|
|
|
|
TAG ?= HEAD
|
|
|
|
ifeq ($(TAG), HEAD)
|
|
|
|
DIST_VERSION = latest
|
|
|
|
else
|
|
|
|
DIST_VERSION = $(TAG)
|
|
|
|
endif
|
|
|
|
|
2016-11-11 19:40:22 +03:00
|
|
|
bindings: qemu/config-host.h-timestamp
|
Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-21 19:21:10 +03:00
|
|
|
$(MAKE) -C bindings build
|
|
|
|
$(MAKE) -C bindings samples
|
|
|
|
|
2015-08-21 10:04:50 +03:00
|
|
|
dist:
|
|
|
|
git archive --format=tar.gz --prefix=unicorn-$(DIST_VERSION)/ $(TAG) > unicorn-$(DIST_VERSION).tgz
|
|
|
|
git archive --format=zip --prefix=unicorn-$(DIST_VERSION)/ $(TAG) > unicorn-$(DIST_VERSION).zip
|
|
|
|
|
|
|
|
|
2016-12-21 20:12:10 +03:00
|
|
|
# run "make header" whenever qemu/header_gen.py is modified
|
2016-10-29 02:31:52 +03:00
|
|
|
header:
|
2015-08-21 10:04:50 +03:00
|
|
|
$(eval TARGETS := m68k arm aarch64 mips mipsel mips64 mips64el\
|
|
|
|
powerpc sparc sparc64 x86_64)
|
|
|
|
$(foreach var,$(TARGETS),\
|
|
|
|
$(shell python qemu/header_gen.py $(var) > qemu/$(var).h;))
|
|
|
|
@echo "Generated headers for $(TARGETS)."
|
|
|
|
|
2015-08-24 04:57:01 +03:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -rf $(INCDIR)/$(LIBNAME)
|
|
|
|
rm -f $(LIBDIR)/lib$(LIBNAME).*
|
2015-12-17 08:20:57 +03:00
|
|
|
rm -f $(BINDIR)/cyg$(LIBNAME).*
|
2015-08-24 04:57:01 +03:00
|
|
|
rm -f $(PKGCFGDIR)/$(LIBNAME).pc
|
|
|
|
|
|
|
|
|
2015-08-21 10:04:50 +03:00
|
|
|
clean:
|
|
|
|
$(MAKE) -C qemu clean
|
|
|
|
rm -rf *.d *.o
|
2015-12-17 08:20:57 +03:00
|
|
|
rm -rf lib$(LIBNAME)* $(LIBNAME)*.lib $(LIBNAME)*.dll cyg$(LIBNAME)*.dll
|
2016-10-29 02:31:52 +03:00
|
|
|
$(MAKE) -C samples clean
|
2015-09-22 05:04:20 +03:00
|
|
|
$(MAKE) -C tests/unit clean
|
2015-08-21 10:04:50 +03:00
|
|
|
|
|
|
|
|
|
|
|
define generate-pkgcfg
|
|
|
|
echo 'Name: unicorn' > $(PKGCFGF)
|
|
|
|
echo 'Description: Unicorn emulator engine' >> $(PKGCFGF)
|
|
|
|
echo 'Version: $(PKG_VERSION)' >> $(PKGCFGF)
|
|
|
|
echo 'libdir=$(LIBDIR)' >> $(PKGCFGF)
|
|
|
|
echo 'includedir=$(INCDIR)' >> $(PKGCFGF)
|
|
|
|
echo 'archive=$${libdir}/libunicorn.a' >> $(PKGCFGF)
|
|
|
|
echo 'Libs: -L$${libdir} -lunicorn' >> $(PKGCFGF)
|
|
|
|
echo 'Cflags: -I$${includedir}' >> $(PKGCFGF)
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
define log
|
|
|
|
@printf " %-7s %s\n" "$(1)" "$(2)"
|
|
|
|
endef
|
|
|
|
|