From 1f5b18a8949ecfc942dac4c71f2358b955bde2fe Mon Sep 17 00:00:00 2001 From: midipix Date: Apr 24 2016 21:06:32 +0000 Subject: build system: PE targets: added import library version support. --- diff --git a/Makefile.in b/Makefile.in index 869b090..0957e32 100644 --- a/Makefile.in +++ b/Makefile.in @@ -71,6 +71,8 @@ include $(PROJECT_DIR)/sysinfo/toolchain/$(TOOLCHAIN).mk include $(PROJECT_DIR)/project/defs.mk include $(PROJECT_DIR)/project/version.mk +include $(PROJECT_DIR)/project/custom.mk + include $(PROJECT_DIR)/project/tree.mk include $(PROJECT_DIR)/project/depends.mk include $(PROJECT_DIR)/project/headers.mk @@ -112,7 +114,7 @@ install-headers:shared static mkdir -p $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE) cp $(API_HEADERS) $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE) -install-shared: shared install-lib install-soname install-solink +install-shared: shared install-lib install-soname install-solink install-implib install-lib: shared mkdir -p $(DESTDIR)$(LIBDIR) @@ -128,7 +130,7 @@ install-app: app install-app-extras -shared: shared-lib shared-soname shared-solink +shared: shared-lib shared-soname shared-solink implib static: static-lib @@ -140,8 +142,6 @@ shared-solink: shared-lib $(SHARED_SOLINK) static-lib: static-objs $(STATIC_LIB) -shared-implib: shared-lib - default-app: version.tag static $(DEFAULT_APP) $(APP) @@ -198,7 +198,7 @@ version.tag: $(GIT_REFERENCE_DIR) distclean: clean rm -f Makefile -clean: +clean: clean-implib rm -f tree.tag rm -f dirs.tag rm -f host.tag @@ -210,7 +210,6 @@ clean: rm -f $(SHARED_SONAME) rm -f $(SHARED_SOLINK) rm -f $(STATIC_LIB) - rm -f $(SHARED_IMPLIB) rm -f $(APP) rm -f $(DEFAULT_APP) rm -f $(SHARED_APP) @@ -320,11 +319,14 @@ clean: .PHONY: all install shared static app .display \ - shared-objs shared-lib shared-implib \ + shared-objs shared-lib \ static-objs static-lib \ default-app shared-app static-app \ - install-shared install-static install-implib \ + install-shared install-static \ install-headers install-app \ - clean distclean version \ + clean distclean clean-implib version \ .display-project .display-env .display-tools .display-flags \ - .display-pe .display-elf .display-dirs .display-build + .display-pe .display-elf .display-dirs .display-build \ + implib implib-ver implib-soname implib-solink \ + install-implib install-implib-ver \ + install-implib-soname install-implib-solink diff --git a/project/custom.mk b/project/custom.mk new file mode 100644 index 0000000..3a30273 --- /dev/null +++ b/project/custom.mk @@ -0,0 +1,3 @@ +ifeq ($(OS_BINFMT),PE) +include $(PROJECT_DIR)/sysinfo/os/pe.mk +endif diff --git a/project/defs.mk b/project/defs.mk index 5a5d60b..e80bd59 100644 --- a/project/defs.mk +++ b/project/defs.mk @@ -14,6 +14,8 @@ APP_OBJS = $(APP_SRCS:.c=.o) SHARED_OBJS = $(COMMON_LOBJS) $(ARCH_LOBJS) STATIC_OBJS = $(COMMON_OBJS) $(ARCH_OBJS) +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) @@ -22,8 +24,15 @@ 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) +IMP_DEF = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_XYZ)$(OS_LIBDEF_EXT) +IMP_VER = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_XYZ)$(OS_IMPLIB_EXT) +IMP_SONAME = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_SONAME)$(OS_IMPLIB_EXT) +IMP_SOLINK = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_IMPLIB_EXT) + +IMPLIB_DEF = lib/$(IMP_DEF) +IMPLIB_VER = lib/$(IMP_VER) +IMPLIB_SONAME = lib/$(IMP_SONAME) +IMPLIB_SOLINK = lib/$(IMP_SOLINK) APP = bin/$(OS_APP_PREFIX)$(NICKNAME)$(OS_APP_SUFFIX) DEFAULT_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-default$(OS_APP_SUFFIX) @@ -45,6 +54,7 @@ LDFLAGS_SHARED = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ LDFLAGS_SHARED += -Wl,-soname LDFLAGS_SHARED += -Wl,$(DSO_SONAME) +LDFLAGS_SHARED += $(LDFLAGS_IMPLIB) LDFLAGS_APP = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ diff --git a/sysinfo/os/any-os.mk b/sysinfo/os/any-os.mk index c052f31..cf8ec00 100644 --- a/sysinfo/os/any-os.mk +++ b/sysinfo/os/any-os.mk @@ -7,5 +7,6 @@ OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a OS_SONAME = symlink +OS_BINFMT = ELF -.PHONY: $(SHARED_IMPLIB) +.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK) diff --git a/sysinfo/os/bsd.mk b/sysinfo/os/bsd.mk index 694c54f..6e8fac0 100644 --- a/sysinfo/os/bsd.mk +++ b/sysinfo/os/bsd.mk @@ -7,5 +7,6 @@ OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a OS_SONAME = symlink +OS_BINFMT = ELF -.PHONY: $(SHARED_IMPLIB) +.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK) diff --git a/sysinfo/os/darwin.mk b/sysinfo/os/darwin.mk index 7ccdfde..5a0b99e 100644 --- a/sysinfo/os/darwin.mk +++ b/sysinfo/os/darwin.mk @@ -7,7 +7,8 @@ OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a OS_SONAME = symlink +OS_BINFMT = MACHO CFLAGS_OS += -D_DARWIN_C_SOURCE -.PHONY: $(SHARED_IMPLIB) +.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK) diff --git a/sysinfo/os/linux.mk b/sysinfo/os/linux.mk index e2dcd2e..082026b 100644 --- a/sysinfo/os/linux.mk +++ b/sysinfo/os/linux.mk @@ -7,5 +7,6 @@ OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a OS_SONAME = symlink +OS_BINFMT = ELF -.PHONY: $(SHARED_IMPLIB) +.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK) diff --git a/sysinfo/os/midipix.mk b/sysinfo/os/midipix.mk index 098ac68..d99b249 100644 --- a/sysinfo/os/midipix.mk +++ b/sysinfo/os/midipix.mk @@ -7,9 +7,4 @@ OS_IMPLIB_EXT = .lib.a OS_LIBDEF_EXT = .so.def OS_ARCHIVE_EXT = .a OS_SONAME = copy - -LDFLAGS_CONFIG += -mout-implib - -install-implib: shared-implib - mkdir -p $(DESTDIR)$(LIBDIR) - cp $(SHARED_IMPLIB) $(DESTDIR)$(LIBDIR) +OS_BINFMT = PE \ No newline at end of file diff --git a/sysinfo/os/mingw.mk b/sysinfo/os/mingw.mk index a40239f..6ade8d5 100644 --- a/sysinfo/os/mingw.mk +++ b/sysinfo/os/mingw.mk @@ -7,10 +7,6 @@ OS_IMPLIB_EXT = .dll.a OS_LIBDEF_EXT = .def OS_ARCHIVE_EXT = .a OS_SONAME = copy +OS_BINFMT = PE CFLAGS_PIC = -LDFLAGS_CONFIG += -Wl,--out-implib,$(SHARED_IMPLIB) - -install-implib: shared-implib - mkdir -p $(DESTDIR)$(LIBDIR) - cp $(SHARED_IMPLIB) $(DESTDIR)$(LIBDIR) diff --git a/sysinfo/os/pe.mk b/sysinfo/os/pe.mk new file mode 100644 index 0000000..0b50df2 --- /dev/null +++ b/sysinfo/os/pe.mk @@ -0,0 +1,48 @@ +LDFLAGS_IMPLIB += -Wl,--output-def +LDFLAGS_IMPLIB += -Wl,$(IMPLIB_DEF) + +implib: implib-ver implib-soname implib-solink + +implib-ver: shared-lib $(IMPLIB_VER) + +implib-soname: shared-lib $(IMPLIB_SONAME) + +implib-solink: shared-lib $(IMPLIB_SOLINK) + +$(IMPLIB_DEF): shared-lib + +$(IMPLIB_VER): $(IMPLIB_DEF) + $(DLLTOOL) -l $(IMPLIB_VER) -d $(IMPLIB_DEF) -D $(DSO_VER) + +$(IMPLIB_SONAME): $(IMPLIB_DEF) + $(DLLTOOL) -l $(IMPLIB_SONAME) -d $(IMPLIB_DEF) -D $(DSO_SONAME) + +$(IMPLIB_SOLINK): $(IMPLIB_SONAME) + rm -f $(IMPLIB_SOLINK).tmp + ln -s $(IMP_SONAME) $(IMPLIB_SOLINK).tmp + mv $(IMPLIB_SOLINK).tmp $(IMPLIB_SOLINK) + +install-implib: install-implib-ver \ + install-implib-soname \ + install-implib-solink + +install-implib-ver: implib-ver + mkdir -p $(DESTDIR)$(LIBDIR) + cp $(IMPLIB_VER) $(DESTDIR)$(LIBDIR) + +install-implib-soname: implib-soname + mkdir -p $(DESTDIR)$(LIBDIR) + cp $(IMPLIB_SONAME) $(DESTDIR)$(LIBDIR) + +install-implib-solink: implib-soname + mkdir -p $(DESTDIR)$(LIBDIR) + rm -f $@.tmp + ln -s $(IMP_SONAME) $@.tmp + mv $@.tmp $(DESTDIR)$(LIBDIR)/$(IMP_SOLINK) + +clean-implib: + rm -f $(SHARED_LIB) + rm -f $(IMPLIB_DEF) + rm -f $(IMPLIB_VER) + rm -f $(IMPLIB_SONAME) + rm -f $(IMPLIB_SOLINK) diff --git a/sysinfo/toolchain/binutils.mk b/sysinfo/toolchain/binutils.mk index a29ac0c..3232915 100644 --- a/sysinfo/toolchain/binutils.mk +++ b/sysinfo/toolchain/binutils.mk @@ -15,3 +15,4 @@ CXXFILT = $(CROSS_COMPILE)c++filt ELFEDIT = $(CROSS_COMPILE)elfedit OBJCOPY = $(CROSS_COMPILE)objcopy READELF = $(CROSS_COMPILE)readelf +DLLTOOL = $(CROSS_COMPILE)dlltool diff --git a/sysinfo/toolchain/llvm.mk b/sysinfo/toolchain/llvm.mk index 3c805a8..65b5396 100644 --- a/sysinfo/toolchain/llvm.mk +++ b/sysinfo/toolchain/llvm.mk @@ -15,3 +15,4 @@ CXXFILT = $(CROSS_COMPILE)c++filt ELFEDIT = $(CROSS_COMPILE)elfedit OBJCOPY = $(CROSS_COMPILE)objcopy READELF = $(CROSS_COMPILE)readelf +DLLTOOL = $(CROSS_COMPILE)dlltool