Makefile: Fix shared library building on various OSes
Versioned for OS not in (Windows, Android), and create a .dll.a implib on Windows
This commit is contained in:
parent
e1262a9ac9
commit
3f69873c99
29
Makefile
29
Makefile
@ -54,6 +54,7 @@ CFLAGS += -fsanitize=address
|
||||
LDFLAGS += -fsanitize=address
|
||||
endif
|
||||
|
||||
SHAREDLIBVERSION=0
|
||||
include $(SRC_PATH)build/platform-$(OS).mk
|
||||
|
||||
|
||||
@ -179,33 +180,41 @@ endif
|
||||
endif
|
||||
|
||||
ifneq (ios, $(OS))
|
||||
libraries: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX)
|
||||
libraries: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER)
|
||||
else
|
||||
libraries: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX)
|
||||
endif
|
||||
|
||||
LIBRARIES += $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX)
|
||||
LIBRARIES += $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER)
|
||||
|
||||
$(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX): $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
|
||||
$(QUIET)rm -f $@
|
||||
$(QUIET_AR)$(AR) $(AR_OPTS) $+
|
||||
|
||||
$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX): $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
|
||||
$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER): $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
|
||||
$(QUIET)rm -f $@
|
||||
$(QUIET_CXX)$(CXX) $(SHARED) $(CXX_LINK_O) $+ $(LDFLAGS) $(SHLDFLAGS)
|
||||
if [ "$(SHAREDLIBSUFFIXVER)" != "$(SHAREDLIBSUFFIX)" ]; then \
|
||||
ln -sfn $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER) \
|
||||
$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX); \
|
||||
fi
|
||||
|
||||
ifeq ($(HAVE_GMP_API),Yes)
|
||||
plugin: $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX)
|
||||
LIBRARIES += $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX)
|
||||
plugin: $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIXVER)
|
||||
LIBRARIES += $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIXVER)
|
||||
else
|
||||
plugin:
|
||||
@echo "./gmp-api : No such file or directory."
|
||||
@echo "You do not have gmp-api. Run make gmp-bootstrap to get the gmp-api headers."
|
||||
endif
|
||||
|
||||
$(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX): $(MODULE_OBJS) $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
|
||||
$(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIXVER): $(MODULE_OBJS) $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
|
||||
$(QUIET)rm -f $@
|
||||
$(QUIET_CXX)$(CXX) $(SHARED) $(CXX_LINK_O) $+ $(LDFLAGS) $(SHLDFLAGS) $(MODULE_LDFLAGS)
|
||||
if [ "$(SHAREDLIBSUFFIXVER)" != "$(SHAREDLIBSUFFIX)" ]; then \
|
||||
ln -sfn $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIXVER) \
|
||||
$(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX); \
|
||||
fi
|
||||
|
||||
$(PROJECT_NAME).pc: $(PROJECT_NAME).pc.in
|
||||
@sed -e 's;@prefix@;$(PREFIX);' -e 's;@VERSION@;$(VERSION);' < $(PROJECT_NAME).pc.in > $(PROJECT_NAME).pc
|
||||
@ -220,7 +229,15 @@ install-static: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) install-headers
|
||||
|
||||
install-shared: $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) install-headers $(PROJECT_NAME).pc
|
||||
mkdir -p $(PREFIX)/lib
|
||||
mkdir -p $(PREFIX)/bin
|
||||
install -m 755 $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) $(PREFIX)/lib
|
||||
if [ -L $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) ]; then \
|
||||
cp -a $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) $(SHAREDLIB_DIR); \
|
||||
fi
|
||||
if [ -f $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX).a ]; then \
|
||||
install -m 644 $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX).a \
|
||||
$(PREFIX)/lib; \
|
||||
fi
|
||||
mkdir -p $(PREFIX)/lib/pkgconfig
|
||||
install -m 444 $(PROJECT_NAME).pc $(PREFIX)/lib/pkgconfig
|
||||
ifneq ($(EXTRA_LIBRARY),)
|
||||
|
@ -1,6 +1,10 @@
|
||||
ARCH = arm
|
||||
include $(SRC_PATH)build/arch.mk
|
||||
SHAREDLIB_DIR = $(PREFIX)/lib
|
||||
SHAREDLIBSUFFIX = so
|
||||
# Android APK/JARs expect libraries to be unversioned
|
||||
SHAREDLIBSUFFIXVER=$(SHAREDLIBSUFFIX)
|
||||
SHLDFLAGS =
|
||||
NDKLEVEL = 12
|
||||
ifeq ($(ARCH), arm)
|
||||
ifneq ($(APP_ABI), armeabi)
|
||||
|
@ -1,5 +1,10 @@
|
||||
include $(SRC_PATH)build/arch.mk
|
||||
SHAREDLIB_DIR = $(PREFIX)/lib
|
||||
SHAREDLIBSUFFIX = dylib
|
||||
SHAREDLIBSUFFIXVER=$(SHAREDLIBVERSION).$(SHAREDLIBSUFFIX)
|
||||
SHLDFLAGS = -dynamiclib -twolevel_namespace -undefined dynamic_lookup \
|
||||
-fno-common -headerpad_max_install_names -install_name \
|
||||
$(SHAREDLIB_DIR)/$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER)
|
||||
SHARED = -dynamiclib
|
||||
CFLAGS += -Wall -fPIC -MMD -MP
|
||||
LDFLAGS += -lpthread
|
||||
|
@ -1,5 +1,8 @@
|
||||
include $(SRC_PATH)build/arch.mk
|
||||
SHAREDLIB_DIR = $(PREFIX)/lib
|
||||
SHAREDLIBSUFFIX = so
|
||||
SHAREDLIBSUFFIXVER=$(SHAREDLIBSUFFIX).$(SHAREDLIBVERSION)
|
||||
SHLDFLAGS = -Wl,-soname,$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER)
|
||||
CFLAGS += -fPIC
|
||||
LDFLAGS += -lpthread
|
||||
ifeq ($(ASM_ARCH), x86)
|
||||
|
@ -1,5 +1,8 @@
|
||||
include $(SRC_PATH)build/arch.mk
|
||||
SHAREDLIB_DIR = $(PREFIX)/lib
|
||||
SHAREDLIBSUFFIX = so
|
||||
SHAREDLIBSUFFIXVER=$(SHAREDLIBSUFFIX).$(SHAREDLIBVERSION)
|
||||
SHLDFLAGS = -Wl,-soname,$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER)
|
||||
CFLAGS += -Wall -fno-strict-aliasing -fPIC -MMD -MP
|
||||
LDFLAGS += -lpthread
|
||||
ifeq ($(ASM_ARCH), x86)
|
||||
|
@ -1,5 +1,8 @@
|
||||
include $(SRC_PATH)build/x86-common.mk
|
||||
SHAREDLIB_DIR = $(PREFIX)/bin
|
||||
SHAREDLIBSUFFIX = dll
|
||||
SHAREDLIBSUFFIXVER=$(SHAREDLIBSUFFIX)
|
||||
SHLDFLAGS = -Wl,--out-implib,$(LIBPREFIX)$(PROJECT_NAME).dll.a
|
||||
CFLAGS += -MMD -MP
|
||||
LDFLAGS +=
|
||||
ifeq ($(ENABLE64BIT), Yes)
|
||||
|
Loading…
Reference in New Issue
Block a user