From 6a15e23897aba1858340b625168c358abf94b0b3 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 5 Jan 2016 11:51:36 -0500 Subject: [PATCH] Set up saner handling of sonames at build time. --- build/GNUbasegcc.mk | 4 ++++ build/GNUmakefile.example | 3 +++ build/GNUmakefile.libui | 10 +++++++++- build/GNUmakefile.test | 3 +++ darwin/GNUfiles.mk | 6 ------ darwin/GNUosspecific.mk | 7 +++++++ haiku/GNUosspecific.mk | 3 +++ unix/GNUfiles.mk | 5 ----- unix/GNUosspecific.mk | 7 +++++++ windows/GNUosspecific.mk | 2 ++ 10 files changed, 38 insertions(+), 12 deletions(-) diff --git a/build/GNUbasegcc.mk b/build/GNUbasegcc.mk index cb1ee524..552394e0 100644 --- a/build/GNUbasegcc.mk +++ b/build/GNUbasegcc.mk @@ -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: diff --git a/build/GNUmakefile.example b/build/GNUmakefile.example index fab16e2b..daf36cce 100644 --- a/build/GNUmakefile.example +++ b/build/GNUmakefile.example @@ -37,4 +37,7 @@ else LDFLAGS += $(OUTDIR)/libui.lib endif +# executables are not shared libraries +USESSONAME = 0 + include build/GNUbase$(TOOLCHAIN).mk diff --git a/build/GNUmakefile.libui b/build/GNUmakefile.libui index f9ff61a8..cf61bc6a 100644 --- a/build/GNUmakefile.libui +++ b/build/GNUmakefile.libui @@ -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 diff --git a/build/GNUmakefile.test b/build/GNUmakefile.test index 3e2e9099..6b992021 100644 --- a/build/GNUmakefile.test +++ b/build/GNUmakefile.test @@ -28,4 +28,7 @@ else LDFLAGS += $(OUTDIR)/libui.lib endif +# executables are not shared libraries +USESSONAME = 0 + include build/GNUbase$(TOOLCHAIN).mk diff --git a/darwin/GNUfiles.mk b/darwin/GNUfiles.mk index 02c533eb..108a8d30 100644 --- a/darwin/GNUfiles.mk +++ b/darwin/GNUfiles.mk @@ -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) diff --git a/darwin/GNUosspecific.mk b/darwin/GNUosspecific.mk index f5a27474..39acdaa4 100644 --- a/darwin/GNUosspecific.mk +++ b/darwin/GNUosspecific.mk @@ -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/ diff --git a/haiku/GNUosspecific.mk b/haiku/GNUosspecific.mk index 8bc66e4c..e178f48d 100644 --- a/haiku/GNUosspecific.mk +++ b/haiku/GNUosspecific.mk @@ -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) diff --git a/unix/GNUfiles.mk b/unix/GNUfiles.mk index 4861bab4..49ac9fef 100644 --- a/unix/GNUfiles.mk +++ b/unix/GNUfiles.mk @@ -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) diff --git a/unix/GNUosspecific.mk b/unix/GNUosspecific.mk index 980690ae..b5fa75e5 100644 --- a/unix/GNUosspecific.mk +++ b/unix/GNUosspecific.mk @@ -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, \ No newline at end of file diff --git a/windows/GNUosspecific.mk b/windows/GNUosspecific.mk index ae31a330..a4da078f 100644 --- a/windows/GNUosspecific.mk +++ b/windows/GNUosspecific.mk @@ -4,3 +4,5 @@ EXESUFFIX = .exe LIBSUFFIX = .dll OSHSUFFIX = .h TOOLCHAIN = msvc + +USESSONAME = 0