Make it easier to link against libunicorn on macOS (#1195)
Adding @rpath to the install name to make it possible to link against the library without modifying it with install_name_tool. Copying both the versioned and unversioned dylibs simplifies linking.
This commit is contained in:
parent
901efc4bd4
commit
d69ebfa55c
2
Makefile
2
Makefile
@ -112,7 +112,7 @@ API_MAJOR=$(shell echo `grep -e UC_API_MAJOR include/unicorn/unicorn.h | grep -v
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
EXT = dylib
|
||||
VERSION_EXT = $(API_MAJOR).$(EXT)
|
||||
$(LIBNAME)_LDFLAGS += -dynamiclib -install_name lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR)
|
||||
$(LIBNAME)_LDFLAGS += -dynamiclib -install_name @rpath/lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR)
|
||||
AR_EXT = a
|
||||
UNICORN_CFLAGS += -fvisibility=hidden
|
||||
|
||||
|
@ -60,6 +60,7 @@ else:
|
||||
|
||||
if SYSTEM == 'darwin':
|
||||
LIBRARY_FILE = "libunicorn.dylib"
|
||||
MAC_LIBRARY_FILE = "libunicorn*.dylib"
|
||||
STATIC_LIBRARY_FILE = None
|
||||
elif SYSTEM in ('win32', 'cygwin'):
|
||||
LIBRARY_FILE = "unicorn.dll"
|
||||
@ -171,6 +172,10 @@ def build_libraries():
|
||||
|
||||
subprocess.call(cmd, env=new_env)
|
||||
|
||||
if SYSTEM == 'darwin':
|
||||
for file in glob.glob(MAC_LIBRARY_FILE):
|
||||
shutil.copy(file, LIBS_DIR, follow_symlinks=False)
|
||||
else:
|
||||
shutil.copy(LIBRARY_FILE, LIBS_DIR)
|
||||
try:
|
||||
# static library may fail to build on windows if user doesn't have visual studio installed. this is fine.
|
||||
|
Loading…
Reference in New Issue
Block a user