From 62b445308e0e28999bcfc89cad0fd68082066438 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Sat, 4 Apr 2020 23:38:25 +0100 Subject: The build of M4 and XLSX I/O on macOS has been fixed Until now, the M4 that was built on macOS had internal problems (as discussed in #1): it would simply print `Abort trap: 6' in the output and abort. After looking at the build of Homebrew, I noticed that they apply a patch (correct one line) to fix this problem. To be able to apply that patch on macOS systems, I had fully open up the build recipe of M4 and atleast on the testing system, it was built successfully. Also, after successfully building M4, and thus Autoconf and thus Minizip, we were able to build XLSX I/O on a macOS and found out that the internal library's full address wasn't being put in the libraries and executables. With this commit, we now use macOS's `install_name_tool' to correct the positions of the two `libxlsxio_*' libraries in all its executables. --- reproduce/software/make/basic.mk | 28 ++++++++++++++++++++++++++-- reproduce/software/make/high-level.mk | 13 ++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/reproduce/software/make/basic.mk b/reproduce/software/make/basic.mk index 212c738..47a01a3 100644 --- a/reproduce/software/make/basic.mk +++ b/reproduce/software/make/basic.mk @@ -1002,10 +1002,34 @@ $(ibidir)/libbsd: | $(ibidir)/coreutils \ $(call gbuild, libbsd-$(libbsd-version), static,,V=1) \ && echo "Libbsd $(libbsd-version)" > $@ -$(ibidir)/m4: | $(ibidir)/coreutils \ +# We need to apply a patch to the M4 source to be used properly on macOS. +# The patch [1] was inspired by Homebrew's build instructions [1]. +# +# [1] https://raw.githubusercontent.com/macports/macports-ports/edf0ee1e2cf/devel/m4/files/secure_snprintf.patch +# [2] https://github.com/Homebrew/homebrew-core/blob/master/Formula/m4.rb +$(ibidir)/m4: | $(ibidir)/sed \ $(ibidir)/texinfo \ + $(ibidir)/coreutils \ $(tdir)/m4-$(m4-version).tar.gz - $(call gbuild, m4-$(m4-version), static,,V=1) \ + cd $(ddir); \ + unpackdir=m4-$(m4-version); \ + rm -rf $$unpackdir \ + && if ! tar xf $(word 1,$(filter $(tdir)/%,$|)); then \ + echo; echo "Tar error"; exit 1; \ + fi \ + && cd $$unpackdir \ + && if [ x$(on_mac_os) = xyes ]; then \ + sed -i -e's|if !(((__GLIBC__ > 2|if !defined(__APPLE__) \&\& !(((__GLIBC__ > 2|' lib/vasnprintf.c; \ + fi \ + && sed -i -e's|\#\! /bin/sh|\#\! $(ibdir)/bash|' \ + -e's|\#\!/bin/sh|\#\! $(ibdir)/bash|' \ + configure \ + && ./configure --prefix=$(idir) SHELL=$(ibdir)/bash \ + LDFLAGS="$(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)" \ + && make SHELL=$(ibdir)/bash V=1 -j$(numthreads) \ + && make SHELL=$(ibdir)/bash V=1 install \ + && cd .. \ + && rm -rf $$unpackdir \ && echo "GNU M4 $(m4-version)" > $@ # Metastore is used (through a Git hook) to restore the source modification diff --git a/reproduce/software/make/high-level.mk b/reproduce/software/make/high-level.mk index b9b291f..605ca74 100644 --- a/reproduce/software/make/high-level.mk +++ b/reproduce/software/make/high-level.mk @@ -1197,10 +1197,17 @@ $(ibidir)/xlsxio: $(ibidir)/cmake \ -DMINIZIP_DIR:PATH=$(idir) \ -DMINIZIP_LIBRARIES=$(idir) \ -DMINIZIP_INCLUDE_DIRS=$(iidir)) \ - && if [ "x$(on_mac_os)" != xyes ]; then \ - echo "Adding RPATH to the XLSX I/O executables..."; \ + && echo "Correcting internal linking of XLSX I/O executables..." \ + && if [ "x$(on_mac_os)" = xyes ]; then \ + for f in $(ibdir)/xlsxio_* $(ildir)/libxlsxio_*.dylib; do \ + install_name_tool -change libxlsxio_read.dylib \ + $(ildir)/libxlsxio_read.dylib $$f; \ + install_name_tool -change libxlsxio_write.dylib \ + $(ildir)/libxlsxio_write.dylib $$f; \ + done; \ + else \ for f in $(ibdir)/xlsxio_* $(ildir)/libxlsxio_*.so; do \ - patchelf --set-rpath $(ildir) $$f; \ + patchelf --set-rpath $(ildir) $$f; \ done; \ fi \ && echo "Deleting XLSX I/O example files..." \ -- cgit v1.2.1