From c3907f9f27b3525e38d78160069c9dda423efab9 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Mon, 14 Jan 2019 15:31:46 +0000 Subject: Better linking of different NCURSESW names On Mac OS systems, the full version number is not used in the filename given to libncurses. For example for version 6.1, it is called `libncursesw.6.dylib'. So a more generic and easier to maintain and read script is now used to be able to make links for both Mac and GNU/Linux systems. In short, instead of checking if we are in Mac every time, we just set the suffixes at the start based on the machine once as variables and use those to define the links. --- reproduce/src/make/dependencies-basic.mk | 95 +++++++++++++++++--------------- 1 file changed, 50 insertions(+), 45 deletions(-) (limited to 'reproduce/src') diff --git a/reproduce/src/make/dependencies-basic.mk b/reproduce/src/make/dependencies-basic.mk index d74ac7d..80f6e1a 100644 --- a/reproduce/src/make/dependencies-basic.mk +++ b/reproduce/src/make/dependencies-basic.mk @@ -337,9 +337,9 @@ $(ilidir)/ncurses: $(tdir)/ncurses-$(ncurses-version).tar.gz \ $(ibdir)/make | $(ilidir) # Delete the library that will be installed (so we can make sure - # the build process completed afterwards). - if [ x$(on_mac_os) = xyes ]; then rm -f $(ildir)/libncursesw.dylib;\ - else rm -f $(ildir)/libncursesw.so; \ + # the build process completed afterwards and reset the links). + if [ x$(on_mac_os) = xyes ]; then rm -f $(ildir)/libncursesw*dylib;\ + else rm -f $(ildir)/libncursesw.so*; \ fi # Standard build process. @@ -365,48 +365,53 @@ $(ilidir)/ncurses: $(tdir)/ncurses-$(ncurses-version).tar.gz \ # # [1] https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/ncurses # [2] https://github.com/Homebrew/homebrew-core/blob/master/Formula/ncurses.rb - if [ x$(on_mac_os) = xyes ]; then oname=$(ildir)/libncursesw.dylib;\ - else oname=$(ildir)/libncursesw.so; \ - fi; \ - if [ -f $$oname ]; then \ - cd "$(ildir)"; \ - for lib in ncurses ncurses++ form panel menu; do \ - if [ x$(on_mac_os) = xyes ]; then \ - linkname=lib$$lib.dylib; \ - target=lib"$$lib"w.$(ncurses-version).dylib; \ - else \ - linkname=lib$$lib.so; \ - target=lib"$$lib"w.so.$(ncurses-version); \ - fi; \ - ln -fs $$target $$linkname; \ - ln -fs pkgconfig/"$$lib"w.pc pkgconfig/$$lib.pc; \ - done; \ - for lib in tic tinfo; do \ - if [ x$(on_mac_os) = xyes ]; then \ - linka=lib$$lib.dylib; \ - linkb=lib$$lib.$(ncurses-version).dylib; \ - target=libncursesw.$(ncurses-version).dylib; \ - else \ - linka=lib$$lib.so; \ - linkb=lib$$lib.so.$(ncurses-version); \ - target=libncursesw.so.$(ncurses-version); \ - fi; \ - ln -fs $$target $$linka; \ - ln -fs $$target $$linkb; \ - ln -fs pkgconfig/ncursesw.pc pkgconfig/$$lib.pc; \ - done; \ - if [ x$(on_mac_os) = xyes ]; then \ - ln -fs $$target libcurses.dylib; \ - ln -fs $$target libcursesw.dylib; \ - else \ - ln -fs $$target libcurses.so; \ - ln -fs $$target libcursesw.so; \ - fi; \ - ln -fs pkgconfig/ncursesw.pc pkgconfig/curses.pc; \ - ln -fs pkgconfig/ncursesw.pc pkgconfig/cursesw.pc; \ - echo "GNU ncurses is built and ready" > $@; \ - else \ - exit 1; \ + # + # Since we can't have comments, in the connected script, here is a + # summary: + # + # 1. We find the actual suffix of the library, from the file that + # is not a symbolic link (starting with `-' in the output of + # `ls -l'). + # + # 2. We make symbolic links to all the "ncurses", "ncurses++", + # "form", "panel" and "menu" libraries to point to their + # "wide" (character) library. + # + # 3. We make symbolic links to the "tic" and "tinfo" libraries to + # point to the same `libncursesw' library. + # + # 4. Some programs link with "curses" (not "ncurses", notice the + # starting "n"), so we'll also make links for these to point + # to the `libncursesw' library. + # + # 5. A link is made to also be able to include files from the + # `ncurses' headers. + if [ x$(on_mac_os) = xyes ]; then so="dylib"; else so="so"; fi; \ + if [ -f $(ildir)/libncursesw.$$so ]; then \ + \ + sov=$$(ls -l $(ildir)/libncursesw* \ + | awk '/^-/{print $$NF}' \ + | sed -e's|'$(ildir)/libncursesw.'||'); \ + \ + cd "$(ildir)"; \ + for lib in ncurses ncurses++ form panel menu; do \ + ln -fs lib$$lib"w".$$sov lib$$lib.$$so; \ + ln -fs pkgconfig/"$$lib"w.pc pkgconfig/$$lib.pc; \ + done; \ + for lib in tic tinfo; do \ + ln -fs libncursesw.$$sov lib$$lib.$$so; \ + ln -fs libncursesw.$$sov lib$$lib.$$sov; \ + ln -fs pkgconfig/ncursesw.pc pkgconfig/$$lib.pc; \ + done; \ + ln -fs $$target libcurses.$$so; \ + ln -fs $$target libcursesw.$$sov; \ + ln -fs pkgconfig/ncursesw.pc pkgconfig/curses.pc; \ + ln -fs pkgconfig/ncursesw.pc pkgconfig/cursesw.pc; \ + \ + ln -fs $(idir)/include/ncursesw $(idir)/include/ncurses; \ + echo "GNU ncurses is built and ready" > $@; \ + else \ + exit 1; \ fi $(ilidir)/readline: $(tdir)/readline-$(readline-version).tar.gz \ -- cgit v1.2.1