diff options
author | midipix <writeonce@midipix.org> | 2016-04-24 12:52:34 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-04-24 17:06:30 -0400 |
commit | 513c5c3ce6d8fd3878759398748638a1937f54d4 (patch) | |
tree | dfe0aa09efe308f0bca099398fb59a4729692ea0 | |
parent | 71e74382b35dccf28d0beaac49bd15c837ba8949 (diff) | |
download | slibtool-513c5c3ce6d8fd3878759398748638a1937f54d4.tar.bz2 slibtool-513c5c3ce6d8fd3878759398748638a1937f54d4.tar.xz |
build system: added library version support.
-rw-r--r-- | Makefile.in | 18 | ||||
-rw-r--r-- | project/defs.mk | 17 | ||||
-rw-r--r-- | project/version.mk | 42 | ||||
-rw-r--r-- | sysinfo/os/any-os.mk | 1 | ||||
-rw-r--r-- | sysinfo/os/bsd.mk | 1 | ||||
-rw-r--r-- | sysinfo/os/darwin.mk | 1 | ||||
-rw-r--r-- | sysinfo/os/linux.mk | 1 | ||||
-rw-r--r-- | sysinfo/os/midipix.mk | 1 | ||||
-rw-r--r-- | sysinfo/os/mingw.mk | 1 |
9 files changed, 76 insertions, 7 deletions
diff --git a/Makefile.in b/Makefile.in index 3776f57..869b090 100644 --- a/Makefile.in +++ b/Makefile.in @@ -70,6 +70,7 @@ include $(PROJECT_DIR)/sysinfo/compiler/$(COMPILER).mk include $(PROJECT_DIR)/sysinfo/toolchain/$(TOOLCHAIN).mk include $(PROJECT_DIR)/project/defs.mk +include $(PROJECT_DIR)/project/version.mk include $(PROJECT_DIR)/project/tree.mk include $(PROJECT_DIR)/project/depends.mk include $(PROJECT_DIR)/project/headers.mk @@ -89,7 +90,7 @@ src/%.lo: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag dirs.tag src/%.o: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag dirs.tag $(CC) -c -o $@ $< $(CFLAGS_STATIC) -lib/%$(OS_LIB_SUFFIX): +lib/%$(OS_LIB_SUFFIX)$(VER_XYZ): $(CC) -shared -o $@ $^ $(LDFLAGS_SHARED) lib/%$(OS_ARCHIVE_EXT): @@ -105,13 +106,15 @@ install: install-libs install-headers install-app install-extras app: default-app -install-libs: install-shared install-static install-implib install-libs-extras +install-libs: install-shared install-static install-libs-extras install-headers:shared static mkdir -p $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE) cp $(API_HEADERS) $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE) -install-shared: shared install-implib +install-shared: shared install-lib install-soname install-solink + +install-lib: shared mkdir -p $(DESTDIR)$(LIBDIR) cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR) @@ -125,12 +128,16 @@ install-app: app install-app-extras -shared: shared-lib shared-implib +shared: shared-lib shared-soname shared-solink static: static-lib shared-lib: shared-objs $(SHARED_LIB) +shared-soname: shared-lib $(SHARED_SONAME) + +shared-solink: shared-lib $(SHARED_SOLINK) + static-lib: static-objs $(STATIC_LIB) shared-implib: shared-lib @@ -200,6 +207,8 @@ clean: rm -f $(STATIC_OBJS) rm -f $(APP_OBJS) rm -f $(SHARED_LIB) + rm -f $(SHARED_SONAME) + rm -f $(SHARED_SOLINK) rm -f $(STATIC_LIB) rm -f $(SHARED_IMPLIB) rm -f $(APP) @@ -256,6 +265,7 @@ clean: .display-flags: @echo CFLAGS_DEBUG:' '$(CFLAGS_DEBUG) @echo CFLAGS_COMMON:' '$(CFLAGS_COMMON) + @echo CFLAGS_VERSION:' '$(CFLAGS_VERSION) @echo CFLAGS_CMDLINE:' '$(CFLAGS_CMDLINE) @echo CFLAGS_CONFIG:' '$(CFLAGS_CONFIG) @echo CFLAGS_SYSROOT:' '$(CFLAGS_SYSROOT) diff --git a/project/defs.mk b/project/defs.mk index f182b87..5a5d60b 100644 --- a/project/defs.mk +++ b/project/defs.mk @@ -14,9 +14,16 @@ APP_OBJS = $(APP_SRCS:.c=.o) SHARED_OBJS = $(COMMON_LOBJS) $(ARCH_LOBJS) STATIC_OBJS = $(COMMON_OBJS) $(ARCH_OBJS) -SHARED_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX) -STATIC_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_ARCHIVE_EXT) +DSO_VER = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX)$(VER_XYZ) +DSO_SONAME = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX)$(VER_SONAME) +DSO_SOLINK = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX) + +SHARED_LIB = lib/$(DSO_VER) +SHARED_SONAME = lib/$(DSO_SONAME) +SHARED_SOLINK = lib/$(DSO_SOLINK) + SHARED_IMPLIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_IMPLIB_EXT) +STATIC_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_ARCHIVE_EXT) APP = bin/$(OS_APP_PREFIX)$(NICKNAME)$(OS_APP_SUFFIX) DEFAULT_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-default$(OS_APP_SUFFIX) @@ -25,7 +32,8 @@ STATIC_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-static$(OS_APP_SUFFIX) CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_CONFIG) $(CFLAGS_SYSROOT) \ $(CFLAGS_COMMON) $(CFLAGS_CMDLINE) $(CFLAGS_HOST) \ - $(CFLAGS_PATH) $(CFLAGS_OS) $(CFLAGS_SITE) + $(CFLAGS_PATH) $(CFLAGS_OS) $(CFLAGS_SITE) \ + $(CFLAGS_VERSION) CFLAGS_SHARED = $(CFLAGS) $(CFLAGS_PIC) $(CFLAGS_SHARED_ATTR) CFLAGS_STATIC = $(CFLAGS) $(CFLAGS_OBJ) $(CFLAGS_STATIC_ATTR) @@ -35,6 +43,9 @@ LDFLAGS_SHARED = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ $(LDFLAGS_PATH) $(SHARED_LIB_DEPS) $(LDFLAGS_LAST) +LDFLAGS_SHARED += -Wl,-soname +LDFLAGS_SHARED += -Wl,$(DSO_SONAME) + LDFLAGS_APP = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ $(LDFLAGS_PATH) $(SHARED_APP_DEPS) $(LDFLAGS_LAST) diff --git a/project/version.mk b/project/version.mk new file mode 100644 index 0000000..1d58cf3 --- /dev/null +++ b/project/version.mk @@ -0,0 +1,42 @@ +include $(PROJECT_DIR)/project/tagver.mk + +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_MAJOR=$(VER_MAJOR) +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_MINOR=$(VER_MINOR) +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_PATCH=$(VER_PATCH) + +VER_XYZ = .$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) +VER_SONAME = .$(VER_MAJOR) + +# libfoo.so (common) +install-solink: install-lib + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $(DESTDIR)$(LIBDIR)/$(DSO_SOLINK) + +$(SHARED_SOLINK): $(SHARED_LIB) + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $@ + +# libfoo.so.x (symlink) +ifeq ($(OS_SONAME),symlink) +$(SHARED_SONAME): $(SHARED_LIB) + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $@ + +install-soname: install-lib + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $(DESTDIR)$(LIBDIR)/$(DSO_SONAME) +endif + + +# libfoo.so.x (copy) +ifeq ($(OS_SONAME),copy) +install-soname: install-lib + cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR)/$(DSO_SONAME) + +$(SHARED_SONAME): $(SHARED_LIB) + cp $(SHARED_LIB) $(SHARED_SONAME) +endif diff --git a/sysinfo/os/any-os.mk b/sysinfo/os/any-os.mk index 0aa0a75..c052f31 100644 --- a/sysinfo/os/any-os.mk +++ b/sysinfo/os/any-os.mk @@ -6,5 +6,6 @@ OS_LIB_SUFFIX = .so OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a +OS_SONAME = symlink .PHONY: $(SHARED_IMPLIB) diff --git a/sysinfo/os/bsd.mk b/sysinfo/os/bsd.mk index 1b29c90..694c54f 100644 --- a/sysinfo/os/bsd.mk +++ b/sysinfo/os/bsd.mk @@ -6,5 +6,6 @@ OS_LIB_SUFFIX = .so OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a +OS_SONAME = symlink .PHONY: $(SHARED_IMPLIB) diff --git a/sysinfo/os/darwin.mk b/sysinfo/os/darwin.mk index f16b1f1..7ccdfde 100644 --- a/sysinfo/os/darwin.mk +++ b/sysinfo/os/darwin.mk @@ -6,6 +6,7 @@ OS_LIB_SUFFIX = .dylib OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a +OS_SONAME = symlink CFLAGS_OS += -D_DARWIN_C_SOURCE diff --git a/sysinfo/os/linux.mk b/sysinfo/os/linux.mk index 2bd6329..e2dcd2e 100644 --- a/sysinfo/os/linux.mk +++ b/sysinfo/os/linux.mk @@ -6,5 +6,6 @@ OS_LIB_SUFFIX = .so OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a +OS_SONAME = symlink .PHONY: $(SHARED_IMPLIB) diff --git a/sysinfo/os/midipix.mk b/sysinfo/os/midipix.mk index d1cc534..098ac68 100644 --- a/sysinfo/os/midipix.mk +++ b/sysinfo/os/midipix.mk @@ -6,6 +6,7 @@ OS_LIB_SUFFIX = .so OS_IMPLIB_EXT = .lib.a OS_LIBDEF_EXT = .so.def OS_ARCHIVE_EXT = .a +OS_SONAME = copy LDFLAGS_CONFIG += -mout-implib diff --git a/sysinfo/os/mingw.mk b/sysinfo/os/mingw.mk index be3c106..a40239f 100644 --- a/sysinfo/os/mingw.mk +++ b/sysinfo/os/mingw.mk @@ -6,6 +6,7 @@ OS_LIB_SUFFIX = .dll OS_IMPLIB_EXT = .dll.a OS_LIBDEF_EXT = .def OS_ARCHIVE_EXT = .a +OS_SONAME = copy CFLAGS_PIC = LDFLAGS_CONFIG += -Wl,--out-implib,$(SHARED_IMPLIB) |