Set up saner handling of sonames at build time.

This commit is contained in:
Pietro Gagliardi 2016-01-05 11:51:36 -05:00
parent a620e3921e
commit 6a15e23897
10 changed files with 38 additions and 12 deletions

View File

@ -40,6 +40,7 @@ OFILES = \
OFILES := $(OFILES:%=$(OBJDIR)/%.o)
OUT = $(OUTDIR)/$(NAME)$(SUFFIX)
OUTNOSONAME = $(OUTDIR)/$(NAME)$(LIBSUFFIX)
# TODO allow using LD
# LD is defined by default so we need a way to override the default define without blocking a user define
@ -51,6 +52,9 @@ endif
$(OUT): $(OFILES) | $(OUTDIR)
@$(reallinker) -o $(OUT) $(OFILES) $(LDFLAGS)
ifeq ($(USESSONAME),1)
@ln -s $(NAME)$(SUFFIX) $(OUTNOSONAME)
endif
@echo ====== Linked $(OUT)
.SECONDEXPANSION:

View File

@ -37,4 +37,7 @@ else
LDFLAGS += $(OUTDIR)/libui.lib
endif
# executables are not shared libraries
USESSONAME = 0
include build/GNUbase$(TOOLCHAIN).mk

View File

@ -5,7 +5,8 @@ $(error Do not run these makefiles directly.)
endif
# for GCC
SOVERSION = 0
SOVERSION0 = 0
SOVERSIONA = A
include $(OS)/GNUosspecific.mk
include common/GNUfiles.mk
@ -17,6 +18,9 @@ HFILES += \
NAME = libui
SUFFIX = $(LIBSUFFIX)
ifeq ($(USESSONAME),1)
SUFFIX = $(SONAMEEXT)
endif
ifeq ($(TOOLCHAIN),gcc)
# make every symbol hidden by default except _UI_EXTERN ones
@ -38,6 +42,10 @@ else
/D "_UI_EXTERN=__declspec(dllexport) extern"
endif
ifeq ($(USESSONAME),1)
LDFLAGS += $(SONAMEFLAG)$(NAME)$(SUFFIX)
endif
include build/GNUbase$(TOOLCHAIN).mk
# install rule is OS specific

View File

@ -28,4 +28,7 @@ else
LDFLAGS += $(OUTDIR)/libui.lib
endif
# executables are not shared libraries
USESSONAME = 0
include build/GNUbase$(TOOLCHAIN).mk

View File

@ -58,9 +58,3 @@ LDFLAGS += \
# on warning about undefined symbols:
# the gcc flags don't work with Apple's linker
# fortunately, we don't need any; Apple's linker warns about undefined symbols in -shared builds!
# flags for setting soname
# note the explicit need for @rpath
# TODO -current_version, -compatibility_version
LDFLAGS += \
-Wl,-install_name,@rpath/$(NAME).$(SOVERSION)$(SUFFIX)

View File

@ -4,3 +4,10 @@ EXESUFFIX =
LIBSUFFIX = .dylib
OSHSUFFIX = .h
TOOLCHAIN = gcc
USESSONAME = 1
SOVERSION = $(SOVERSIONA)
SONAMEEXT = .$(SOVERSION)$(LIBSUFFIX)
# note the explicit need for @rpath
# TODO -current_version, -compatibility_version
SONAMEFLAG = -Wl,-install_name,@rpath/

View File

@ -5,6 +5,9 @@ LIBSUFFIX = .so
OSHSUFFIX = .hpp
TOOLCHAIN = gcc
# TODO
USESSONAME = 0
# Force GCC 4; GCC 2 is not supported.
gccver = $(shell $(CC) --version | sed 's/-.*//g')
ifeq ($(gccver),2.95.3)

View File

@ -50,8 +50,3 @@ LDFLAGS += \
# this is not gcc-global because OS X doesn't support these flags
LDFLAGS += \
-Wl,--no-undefined -Wl,--no-allow-shlib-undefined
# flags for setting soname
# this is not gcc-global because OS X uses a different filename format
LDFLAGS += \
-Wl,-soname,$(NAME)$(SUFFIX).$(SOVERSION)

View File

@ -4,3 +4,10 @@ EXESUFFIX =
LIBSUFFIX = .so
OSHSUFFIX = .h
TOOLCHAIN = gcc
# TODO clean up all the NAMEs and SUFFIXs and NOSOSUFFIXs or whatever it was
USESSONAME = 1
SOVERSION = $(SOVERSION0)
SONAMEEXT = $(LIBSUFFIX).$(SOVERSION)
# this is not gcc-global because OS X uses a different filename format
SONAMEFLAG = -Wl,-soname,

View File

@ -4,3 +4,5 @@ EXESUFFIX = .exe
LIBSUFFIX = .dll
OSHSUFFIX = .h
TOOLCHAIN = msvc
USESSONAME = 0