This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Generate .lib files on PE platforms


MSVC needs them to link against .dll files. gcc can do without, so we
only need to do this when actually installing the files. There is a way
to generate .lib files with dlltool, but most of the time MSVC won't
cleanly link against the result, so we rather use lib.exe here.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 config/ChangeLog   |  5 +++++
 config/eu.am       | 12 ++++++++++++
 libasm/ChangeLog   |  5 +++++
 libasm/Makefile.am | 28 +++++++++++++++++++++++++---
 libdw/ChangeLog    |  5 +++++
 libdw/Makefile.am  | 28 +++++++++++++++++++++++++---
 libelf/ChangeLog   |  5 +++++
 libelf/Makefile.am | 27 ++++++++++++++++++++++++---
 8 files changed, 106 insertions(+), 9 deletions(-)

diff --git a/config/ChangeLog b/config/ChangeLog
index 0f240ea..34414a3 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-03  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* eu.am: If we're building PE binaries add a rule to build the
+	frontend .lib files using Microsofts lib.exe.
+
 2017-04-28  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* eu.am: Disable textrel_check if we're not building ELF files.
diff --git a/config/eu.am b/config/eu.am
index e692341..9603668 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -113,5 +113,17 @@ else
 textrel_check =
 endif
 
+if NATIVE_PE
+%.lib: %.def
+	case '$(host_cpu)' in \
+	i?86) \
+	  lib /machine:x86 /def:$< ;;\
+	x86_64) \
+	  lib /machine:x64 /def:$< ;;\
+	arm) \
+	  lib /machine:arm /def:$< ;;\
+	esac;
+endif
+
 print-%:
 	@echo $*=$($*)
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index 3483e4c..0155d48 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-03  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Output asm.def when linking asm.dll and create asm.lib
+	when installing.
+
 2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* asm_end.c (binary_end): Fix nesting of braces.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index c6038aa..d486db9 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -61,23 +61,45 @@ endif
 if USE_GNULIB
 libasm_so_LDLIBS += ../libgnu/libgnu.a
 endif
+if NATIVE_PE
+GEN_DEF = -Wl,--output-def=$(libasm_BARE:.dll=.def)
+CLEANFILES += $(libasm_BARE:.dll=.def)
+else
+GEN_DEF =
+endif
 
 $(libasm_BARE): libasm_pic.a libasm.map
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 		-Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
-		-Wl,--soname,$(libasm_SONAME) \
+		-Wl,--soname,$(libasm_SONAME) $(GEN_DEF) \
 		../libebl/libebl.a ../libelf/$(libelf_BARE) ../libdw/$(libdw_BARE) \
 		$(libasm_so_LDLIBS)
 	@$(textrel_check)
 	$(AM_V_at)ln -fs $@ $(libasm_SONAME)
 
-install: install-am $(libasm_BARE)
+if NATIVE_PE
+install-lib: $(libasm_BARE:.dll=.lib)
+	$(mkinstalldirs) $(DESTDIR)$(libdir)
+	$(INSTALL_PROGRAM) $< $(DESTDIR)$(libdir)/$(libasm_VERSIONED:.dll=.lib)
+	ln -fs $(libasm_VERSIONED:.dll=.lib) $(DESTDIR)$(libdir)/$(libasm_SONAME:.dll=.lib)
+	ln -fs $(libasm_SONAME:.dll=.lib) $(DESTDIR)$(libdir)/$(libasm_BARE:.dll=.lib)
+uninstall-lib:
+	rm -f $(DESTDIR)$(libdir)/$(libasm_VERSIONED:.dll=.lib)
+	rm -f $(DESTDIR)$(libdir)/$(libasm_SONAME:.dll=.lib)
+	rm -f $(DESTDIR)$(libdir)/$(libasm_BARE:.dll=.lib)
+CLEANFILES += $(libasm_BARE:.dll=.lib) $(libasm_BARE:.dll=.exp)
+else
+install-lib:
+uninstall-lib:
+endif
+
+install: install-am install-lib $(libasm_BARE)
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
 	$(INSTALL_PROGRAM) $(libasm_BARE) $(DESTDIR)$(libdir)/$(libasm_VERSIONED)
 	ln -fs $(libasm_VERSIONED) $(DESTDIR)$(libdir)/$(libasm_SONAME)
 	ln -fs $(libasm_SONAME) $(DESTDIR)$(libdir)/$(libasm_BARE)
 
-uninstall: uninstall-am
+uninstall: uninstall-am uninstall-lib
 	rm -f $(DESTDIR)$(libdir)/$(libasm_VERSIONED)
 	rm -f $(DESTDIR)$(libdir)/$(libasm_SONAME)
 	rm -f $(DESTDIR)$(libdir)/$(libasm_BARE)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 615647b..0d94ad5 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-03  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Output dw.def when linking dw.dll and create dw.lib
+	when installing.
+
 2017-02-28  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Use the predefined common library names rather than
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index aeb84dc..c6d37e9 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -103,6 +103,12 @@ PKG_RPATH = -Wl,--enable-new-dtags,-rpath,$(pkglibdir)
 else
 PKG_RPATH =
 endif
+if NATIVE_PE
+GEN_DEF = -Wl,--output-def=$(libdw_BARE:.dll=.def)
+CLEANFILES += $(libdw_BARE:.dll=.def)
+else
+GEN_DEF =
+endif
 
 libdw_pic_a_SOURCES =
 am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
@@ -119,19 +125,35 @@ $(libdw_BARE): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
 # The rpath is necessary for libebl because its $ORIGIN use will
 # not fly in a setuid executable that links in libdw.
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ -Wl,--soname,$(libdw_SONAME) \
-		-Wl,--version-script,$<,--no-undefined $(PKG_RPATH) \
+		-Wl,--version-script,$<,--no-undefined $(PKG_RPATH) $(GEN_DEF) \
 		-Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
 		-ldl -lz $(intl_LDADD) $(zip_LIBS) $(libgnu)
 	@$(textrel_check)
 	$(AM_V_at)ln -fs $@ $(libdw_SONAME)
 
-install: install-am $(libdw_BARE)
+if NATIVE_PE
+install-lib: $(libdw_BARE:.dll=.lib)
+	$(mkinstalldirs) $(DESTDIR)$(libdir)
+	$(INSTALL_PROGRAM) $< $(DESTDIR)$(libdir)/$(libdw_VERSIONED:.dll=.lib)
+	ln -fs $(libdw_VERSIONED:.dll=.lib) $(DESTDIR)$(libdir)/$(libdw_SONAME:.dll=.lib)
+	ln -fs $(libdw_SONAME:.dll=.lib) $(DESTDIR)$(libdir)/$(libdw_BARE:.dll=.lib)
+uninstall-lib:
+	rm -f $(DESTDIR)$(libdir)/$(libdw_VERSIONED:.dll=.lib)
+	rm -f $(DESTDIR)$(libdir)/$(libdw_SONAME:.dll=.lib)
+	rm -f $(DESTDIR)$(libdir)/$(libdw_BARE:.dll=.lib)
+CLEANFILES += $(libdw_BARE:.dll=.lib) $(libdw_BARE:.dll=.exp)
+else
+install-lib:
+uninstall-lib:
+endif
+
+install: install-am install-lib $(libdw_BARE)
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
 	$(INSTALL_PROGRAM) $(libdw_BARE) $(DESTDIR)$(libdir)/$(libdw_VERSIONED)
 	ln -fs $(libdw_VERSIONED) $(DESTDIR)$(libdir)/$(libdw_SONAME)
 	ln -fs $(libdw_SONAME) $(DESTDIR)$(libdir)/$(libdw_BARE)
 
-uninstall: uninstall-am
+uninstall: uninstall-am uninstall-lib
 	rm -f $(DESTDIR)$(libdir)/$(libdw_VERSIONED)
 	rm -f $(DESTDIR)$(libdir)/$(libdw_SONAME)
 	rm -f $(DESTDIR)$(libdir)/$(libdw_BARE)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index e947e19..8dfa2b7 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-03  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Output elf.def when linking elf.dll and create elf.lib
+	when installing.
+
 2017-02-28  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Use the predefined common library names rather than
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index cc31898..3286dda 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -101,21 +101,42 @@ endif
 if USE_GNULIB
 libelf_so_LDLIBS += ../libgnu/libgnu.a
 endif
+if NATIVE_PE
+GEN_DEF = -Wl,--output-def=$(libelf_BARE:.dll=.def)
+CLEANFILES += $(libelf_BARE:.dll=.def)
+else
+GEN_DEF =
+endif
 
 $(libelf_BARE): libelf_pic.a libelf.map
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 		-Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
-		-Wl,--soname,$(libelf_SONAME) $(libelf_so_LDLIBS)
+		-Wl,--soname,$(libelf_SONAME) $(GEN_DEF) $(libelf_so_LDLIBS)
 	@$(textrel_check)
 	$(AM_V_at)ln -fs $@ $(libelf_SONAME)
 
-install: install-am $(libelf_BARE)
+if NATIVE_PE
+install-lib: $(libelf_BARE:.dll=.lib)
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
+	$(INSTALL_PROGRAM) $< $(DESTDIR)$(libdir)/$(libelf_VERSIONED:.dll=.lib)
+	ln -fs $(libelf_VERSIONED:.dll=.lib) $(DESTDIR)$(libdir)/$(libelf_SONAME:.dll=.lib)
+	ln -fs $(libelf_SONAME:.dll=.lib) $(DESTDIR)$(libdir)/$(libelf_BARE:.dll=.lib)
+uninstall-lib:
+	rm -f $(DESTDIR)$(libdir)/$(libelf_VERSIONED:.dll=.lib)
+	rm -f $(DESTDIR)$(libdir)/$(libelf_SONAME:.dll=.lib)
+	rm -f $(DESTDIR)$(libdir)/$(libelf_BARE:.dll=.lib)
+CLEANFILES += $(libelf_BARE:.dll=.lib) $(libelf_BARE:.dll=.exp)
+else
+install-lib:
+uninstall-lib:
+endif
+
+install: install-am install-lib $(libelf_BARE)
 	$(INSTALL_PROGRAM) $(libelf_BARE) $(DESTDIR)$(libdir)/$(libelf_VERSIONED)
 	ln -fs $(libelf_VERSIONED) $(DESTDIR)$(libdir)/$(libelf_SONAME)
 	ln -fs $(libelf_SONAME) $(DESTDIR)$(libdir)/$(libelf_BARE)
 
-uninstall: uninstall-am
+uninstall: uninstall-am uninstall-lib
 	rm -f $(DESTDIR)$(libdir)/$(libelf_VERSIONED)
 	rm -f $(DESTDIR)$(libdir)/$(libelf_SONAME)
 	rm -f $(DESTDIR)$(libdir)/$(libelf_BARE)
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]