forked from ariadne/libucontext
Allow building on Darwin/arm64
Changes: 1. `-soname` should be `-install_name` on Darwin 2. Version suffix should placed before extension suffix (libucontext.so.1 -> libucontext.1.dylib) 3. Check for architecture specific include directory, and include it while building 4. `EXPORT_UNPREFIXED` macro shouldn't be set since Darwin don't support aliases 5. Choose correct subdir for arm64 6. Use `-dynamiclib` instead of `-shared` on Darwin for adding version info (`-current_version` and `-compatibility_version`)arm_linker_fix
parent
b1b4fe9665
commit
6ddefbbbb4
35
Makefile
35
Makefile
|
@ -13,13 +13,21 @@ endif
|
|||
ifeq ($(ARCH),$(filter $(ARCH),armv7l))
|
||||
override ARCH = arm
|
||||
endif
|
||||
ifeq ($(ARCH),$(filter $(ARCH),arm64))
|
||||
override ARCH = aarch64
|
||||
endif
|
||||
|
||||
LIBDIR := /lib
|
||||
INCLUDEDIR := /usr/include
|
||||
PKGCONFIGDIR := /usr/lib/pkgconfig
|
||||
CFLAGS := -ggdb3 -O2 -Wall
|
||||
CPPFLAGS := -Iinclude -Iarch/${ARCH} -Iarch/common
|
||||
ifneq ($(shell uname),Darwin)
|
||||
EXPORT_UNPREFIXED := yes
|
||||
else
|
||||
# Darwin does not support aliases
|
||||
EXPORT_UNPREFIXED := no
|
||||
endif
|
||||
FREESTANDING := no
|
||||
|
||||
ifeq ($(FREESTANDING),yes)
|
||||
|
@ -34,13 +42,30 @@ endif
|
|||
LIBUCONTEXT_C_SRC = $(wildcard arch/${ARCH}/*.c)
|
||||
LIBUCONTEXT_S_SRC = $(wildcard arch/${ARCH}/*.S)
|
||||
|
||||
ifeq ($(shell test -d arch/${ARCH}/include; echo $?),0)
|
||||
CPPFLAGS += -Iarch/${ARCH}/include
|
||||
endif
|
||||
|
||||
LIBUCONTEXT_VERSION := $(shell head -n 1 VERSION)
|
||||
LIBUCONTEXT_OBJ = ${LIBUCONTEXT_C_SRC:.c=.o} ${LIBUCONTEXT_S_SRC:.S=.o}
|
||||
LIBUCONTEXT_SOVERSION = 1
|
||||
ifeq ($(shell uname),Darwin)
|
||||
LIBUCONTEXT_NAME = libucontext.dylib
|
||||
LIBUCONTEXT_SONAME = libucontext.${LIBUCONTEXT_SOVERSION}.dylib
|
||||
LIBUCONTEXT_POSIX_NAME = libucontext_posix.dylib
|
||||
LIBUCONTEXT_POSIX_SONAME = libucontext_posix.${LIBUCONTEXT_SOVERSION}.dylib
|
||||
LIBUCONTEXT_LINKER_FLAGS = -Wl,-dynamiclib,-install_name,${LIBUCONTEXT_SONAME},-current_version,${LIBUCONTEXT_SOVERSION},-compatibility_version,${LIBUCONTEXT_SOVERSION}
|
||||
LIBUCONTEXT_POSIX_LINKER_FLAGS = -Wl,-dynamiclib,-install_name,${LIBUCONTEXT_POSIX_SONAME},-current_version,${LIBUCONTEXT_SOVERSION},-compatibility_version,${LIBUCONTEXT_SOVERSION}
|
||||
else
|
||||
LIBUCONTEXT_NAME = libucontext.so
|
||||
LIBUCONTEXT_SONAME = libucontext.so.${LIBUCONTEXT_SOVERSION}
|
||||
LIBUCONTEXT_POSIX_NAME = libucontext_posix.so
|
||||
LIBUCONTEXT_POSIX_SONAME = libucontext_posix.so.${LIBUCONTEXT_SOVERSION}
|
||||
LIBUCONTEXT_LINKER_FLAGS = -Wl,-shared,-soname,${LIBUCONTEXT_SONAME}
|
||||
LIBUCONTEXT_POSIX_LINKER_FLAGS = -Wl,-shared,-soname,${LIBUCONTEXT_POSIX_SONAME}
|
||||
endif
|
||||
LIBUCONTEXT_STATIC_NAME = libucontext.a
|
||||
LIBUCONTEXT_PC = libucontext.pc
|
||||
LIBUCONTEXT_SONAME = libucontext.so.${LIBUCONTEXT_SOVERSION}
|
||||
LIBUCONTEXT_PATH = ${LIBDIR}/${LIBUCONTEXT_SONAME}
|
||||
LIBUCONTEXT_STATIC_PATH = ${LIBDIR}/${LIBUCONTEXT_STATIC_NAME}
|
||||
LIBUCONTEXT_HEADERS = \
|
||||
|
@ -48,11 +73,9 @@ LIBUCONTEXT_HEADERS = \
|
|||
include/libucontext/bits.h
|
||||
LIBUCONTEXT_EXAMPLES = \
|
||||
examples/cooperative_threading
|
||||
LIBUCONTEXT_POSIX_NAME = libucontext_posix.so
|
||||
LIBUCONTEXT_POSIX_STATIC_NAME = libucontext_posix.a
|
||||
LIBUCONTEXT_POSIX_C_SRC = libucontext_posix.c
|
||||
LIBUCONTEXT_POSIX_OBJ = ${LIBUCONTEXT_POSIX_C_SRC:.c=.o}
|
||||
LIBUCONTEXT_POSIX_SONAME = libucontext_posix.so.${LIBUCONTEXT_SOVERSION}
|
||||
LIBUCONTEXT_POSIX_PATH = ${LIBDIR}/${LIBUCONTEXT_POSIX_SONAME}
|
||||
LIBUCONTEXT_POSIX_STATIC_PATH = ${LIBDIR}/${LIBUCONTEXT_POSIX_STATIC_NAME}
|
||||
|
||||
|
@ -64,8 +87,7 @@ endif
|
|||
all: ${LIBUCONTEXT_SONAME} ${LIBUCONTEXT_STATIC_NAME} ${LIBUCONTEXT_POSIX_NAME} ${LIBUCONTEXT_POSIX_STATIC_NAME} ${LIBUCONTEXT_PC}
|
||||
|
||||
${LIBUCONTEXT_POSIX_NAME}: ${LIBUCONTEXT_NAME} ${LIBUCONTEXT_POSIX_OBJ}
|
||||
$(CC) -fPIC -o ${LIBUCONTEXT_POSIX_NAME} -Wl,-soname,${LIBUCONTEXT_POSIX_SONAME} \
|
||||
-shared ${LIBUCONTEXT_POSIX_OBJ} ${LDFLAGS}
|
||||
$(CC) -fPIC -o ${LIBUCONTEXT_POSIX_NAME} ${LIBUCONTEXT_POSIX_LINKER_FLAGS} ${LIBUCONTEXT_POSIX_OBJ} ${LDFLAGS}
|
||||
|
||||
${LIBUCONTEXT_POSIX_STATIC_NAME}: ${LIBUCONTEXT_STATIC_NAME} ${LIBUCONTEXT_POSIX_OBJ}
|
||||
$(AR) rcs ${LIBUCONTEXT_POSIX_STATIC_NAME} ${LIBUCONTEXT_POSIX_OBJ}
|
||||
|
@ -77,8 +99,7 @@ ${LIBUCONTEXT_STATIC_NAME}: ${LIBUCONTEXT_HEADERS} ${LIBUCONTEXT_OBJ}
|
|||
$(AR) rcs ${LIBUCONTEXT_STATIC_NAME} ${LIBUCONTEXT_OBJ}
|
||||
|
||||
${LIBUCONTEXT_NAME}: ${LIBUCONTEXT_HEADERS} ${LIBUCONTEXT_OBJ}
|
||||
$(CC) -fPIC -o ${LIBUCONTEXT_NAME} -Wl,-soname,${LIBUCONTEXT_SONAME} \
|
||||
-shared ${LIBUCONTEXT_OBJ} ${LDFLAGS}
|
||||
$(CC) -fPIC -o ${LIBUCONTEXT_NAME} ${LIBUCONTEXT_LINKER_FLAGS} ${LIBUCONTEXT_OBJ} ${LDFLAGS}
|
||||
|
||||
${LIBUCONTEXT_SONAME}: ${LIBUCONTEXT_NAME}
|
||||
ln -sf ${LIBUCONTEXT_NAME} ${LIBUCONTEXT_SONAME}
|
||||
|
|
Loading…
Reference in New Issue