#!/bin/sh # Automate configure+make for things I build from source often. BASE_DIR=`/bin/pwd | xargs /usr/bin/basename` # GNU programs seem to support one or both of these. ISTR that it # used to be just --enable-maintainer-mode to get debugging symbols, # and then someone added --enable-debug because reasons? Hilariously, # the first hit if you google the two of them together is # https://svn.haxx.se/dev/archive-2007-03/0903.shtml, followed by # https://svn.haxx.se/dev/archive-2001-10/0387.shtml. STD_DEBUG_FLAGS="--enable-maintainer-mode --enable-debug" case ${BASE_DIR} in emacs) # If needed, run 'git clean -fdx' to get a truly pristine tree. make clean make distclean ./autogen.sh # Regarding native compilation of elisp: even with this flag, # and with the Debian packages 'gcc-12', 'libgccjit-12-dev', # 'libjansson4', and 'libjansson-dev' installed, passing the # '--with-native-compilation' flag still doesn't seem to work. # This is what the ./configure output says: # # ... # Which dumping strategy does Emacs use? pdumper # Does Emacs have native lisp compiler? no # ... # # And calling `(native-comp-available-p)' in the resultant Emacs # returns nil. I've been poking around in configure, looking at # how HAVE_NATIVE_COMP gets set, but so far I don't know why # native compilation ability isn't getting turned on. # # Oh, but later it worked with 'libgccjit-11-dev' installed, so # maybe this is solved now? We'll see. # # Regarding the X toolkit: may need 'apt-get install libgtk-3-dev'. CURRENT_BRANCH=`git branch | grep -E '^\*' | cut -d ' ' -f 2` # You could test ${CURRENT_BRANCH} here and do different things # for "master" than for release branches, when that's called for. # # To build with full debugging information and no optimizations # (which can often optimize out variables that I want to examine # while debugging), add "CFLAGS='-O0 -g3'" to the front of the # value of the 'configure' parameter below. # # The '--with-native-compilation' gets us native compilation of # Elisp. https://blog.phundrak.com/emacs-29-what-can-we-expect/ # advised the "=aot". # # I had '--with-x-toolkit=lucid' instead of '--with-x-toolkit=gtk3' # at the end of the 'make' line for a while, on the advice found in # https://www.reddit.com/r/emacs/comments/1hlj04t/\ # emacs_using_the_lucid_toolkit_is_blazingly_fast/, via # https://sachachua.com/blog/2024/12/2024-12-30-emacs-news/. # I reverted it because I didn't see any great effect, and thought # I saw maybe some minor problems with the window title bar, # draggability, etc. But it's not a clear-cut call either way. make -j`nproc` bootstrap configure="--with-native-compilation=aot --with-mailutils --with-x-toolkit=gtk3" echo "" echo "Built '`git branch | grep -E "^\* " | cut -d " " -f2`' branch." ;; hexchat) # https://hexchat.readthedocs.io/en/latest/building.html meson build -Dwith-theme-manager=true ninja -C build echo "" echo "Run 'sudo ninja -C build install' to install HexChat locally." echo "" ;; bitcoin|alt-bitcoin) make distclean ./autogen.sh # Regarding the 'autoreconf' invocation, see: # - https://github.com/apereo/mod_auth_cas/issues/97 # - https://github.com/apereo/mod_auth_cas/blob/master/README#L111 # - https://android.developreference.com/article/17551415/How+to+overcome+%E2%80%9C%27aclocal-1.15%27+is+missing+on+your+system%E2%80%9D+warning%3F autoreconf -f -i ./configure ${STD_DEBUG_FLAGS} --with-gui=qt5 --with-incompatible-bdb make -j`nproc` ;; subversion) make distclean echo "" if /bin/ls /usr/local/lib/libsvn* 1>/dev/null 2>&1; then \ echo "/usr/local/lib/libsvn* exists; remove first"; \ exit 1 fi if /bin/ls /usr/local/lib/libapr* 1>/dev/null 2>&1; then \ echo "/usr/local/lib/libapr* exists; remove first"; \ exit 1 fi if /bin/ls /usr/local/lib/libserf* 1>/dev/null 2>&1; then \ echo "/usr/local/lib/libserf* exists; remove first"; \ exit 1 fi # On 2021-09-14, I noticed that if you just run ./autogen.sh by # itself, you get errors: # # # $ ./autogen.sh # buildcheck: checking installation... # buildcheck: autoconf version 2.71 (ok) # buildcheck: autoheader version 2.71 (ok) # buildcheck: libtool version 2.4.6 (ok) # ./autogen.sh: 1: cd: can't cd to /bin/../share/aclocal # /libtool.m4 not found (try setting the LIBTOOL_M4 environment variable) # $ # # Okay, let's set LIBTOOL_M4 (based on Brane via Google results): # # $ LIBTOOL_M4=/usr/share/aclocal ./autogen.sh # buildcheck: checking installation... # buildcheck: autoconf version 2.71 (ok) # buildcheck: autoheader version 2.71 (ok) # buildcheck: libtool version 2.4.6 (ok) # Copying libtool helper: /usr/share/aclocal/libtool.m4 # Copying libtool helper: /usr/share/aclocal/ltoptions.m4 # Copying libtool helper: /usr/share/aclocal/ltsugar.m4 # Copying libtool helper: /usr/share/aclocal/ltversion.m4 # Copying libtool helper: /usr/share/aclocal/lt~obsolete.m4 # ./autogen.sh: 1: cd: can't cd to /bin/../share/libtool/build-aux # /config.guess not found (try setting the LIBTOOL_CONFIG environment variable) # $ # # Okay, that's progress. Let's set LIBTOOL_CONFIG -- that's a # little harder, because there are various directories under /usr # that contain a 'config.guess' file: # # root# find /usr -name config.guess # /usr/share/misc/config.guess # /usr/share/autoconf/build-aux/config.guess # /usr/share/libtool/build-aux/config.guess # /usr/share/automake-1.16/config.guess # /usr/share/texlive/tlpkg/installer/config.guess # root# # # For now, let's go with the /usr/share/libtool/build-aux/ one # (watch out -- there's a lot of output at the end): # # $ LIBTOOL_M4=/usr/share/aclocal LIBTOOL_CONFIG=/usr/share/libtool/build-aux ./autogen.sh # buildcheck: checking installation... # buildcheck: autoconf version 2.71 (ok) # buildcheck: autoheader version 2.71 (ok) # buildcheck: libtool version 2.4.6 (ok) # Copying libtool helper: /usr/share/aclocal/libtool.m4 # Copying libtool helper: /usr/share/aclocal/ltoptions.m4 # Copying libtool helper: /usr/share/aclocal/ltsugar.m4 # Copying libtool helper: /usr/share/aclocal/ltversion.m4 # Copying libtool helper: /usr/share/aclocal/lt~obsolete.m4 # Copying autoconf helper: /usr/share/libtool/build-aux/config.guess # Copying autoconf helper: /usr/share/libtool/build-aux/config.sub # Creating build-outputs.mk... # Creating svn_private_config.h.in... # Creating configure... # configure.ac:150: warning: The macro `AC_TRY_COMPILE' is obsolete. # configure.ac:150: You should run autoupdate. # ./lib/autoconf/general.m4:2847: AC_TRY_COMPILE is expanded from... # lib/m4sugar/m4sh.m4:699: AS_IF is expanded from... # ./lib/autoconf/libs.m4:100: AC_CHECK_LIB is expanded from... # lib/m4sugar/m4sh.m4:699: AS_IF is expanded from... # ./lib/autoconf/headers.m4:89: _AC_CHECK_HEADER_COMPILE is expanded from... # ./lib/autoconf/headers.m4:56: AC_CHECK_HEADER is expanded from... # lib/m4sugar/m4sh.m4:651: AS_FOR is expanded from... # ./lib/autoconf/headers.m4:217: AC_CHECK_HEADERS is expanded from... # build/ac-macros/serf.m4:98: SVN_SERF_PREFIX_CONFIG is expanded from... # build/ac-macros/serf.m4:48: SVN_LIB_SERF is expanded from... # configure.ac:150: the top level # configure.ac:158: warning: The macro `AC_HELP_STRING' is obsolete. # configure.ac:158: You should run autoupdate. # ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... # build/ac-macros/apr_memcache.m4:28: SVN_LIB_APR_MEMCACHE is expanded from... # configure.ac:158: the top level # configure.ac:202: warning: The macro `AC_TRY_RUN' is obsolete. # configure.ac:202: You should run autoupdate. # ./lib/autoconf/general.m4:2997: AC_TRY_RUN is expanded from... # lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from... # lib/m4sugar/m4sh.m4:699: AS_IF is expanded from... # ./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from... # ./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from... # build/ac-macros/svn-macros.m4:126: SVN_CHECK_FOR_ATOMIC_BUILTINS is expanded from... # configure.ac:202: the top level # configure.ac:382: warning: The macro `AC_HELP_STRING' is obsolete. # configure.ac:382: You should run autoupdate. # ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... # configure.ac:382: the top level # configure.ac:938: warning: The macro `AC_HEADER_STDC' is obsolete. # configure.ac:938: You should run autoupdate. # ./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from... # configure.ac:938: the top level # configure.ac:1252: warning: The macro `AC_HELP_STRING' is obsolete. # configure.ac:1252: You should run autoupdate. # ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... # configure.ac:1252: the top level # # You can run ./configure now. # # Running autogen.sh implies you are a maintainer. You may prefer # to run configure in one of the following ways: # # ./configure --enable-maintainer-mode # ./configure --disable-shared # ./configure --enable-maintainer-mode --disable-shared # ./configure --disable-optimize --enable-debug # ./configure CFLAGS='--flags-for-C' CXXFLAGS='--flags-for-C++' # # Note: If you wish to run a Subversion HTTP server, you will need # Apache 2.x. See the INSTALL file for details. # # Unh. Uh, okay? I think? That's more progress, anyway. # # For now, stick with plain ./autogen.sh, but the above are some # hints as to what we can do if the below doesn't work: LIBTOOL_M4=/usr/share/aclocal LIBTOOL_CONFIG=/usr/share/libtool/build-aux ./autogen.sh # Let's explain some of the flags here. # # * --without-apxs # # This is to avoid trying to build mod_dav_svn. You'd think # that --disable-shared would already do that, but apparently # not. Without '--without-apxs', you'll see... # # [...] # checking for Apache module support via DSO through APXS... \ # found at /usr/bin/apxs2 # checking httpd version... recent enough # checking mod_dav version... acceptable # checking whether Apache version is compatible with APR version... yes # [...] # # ...in the './configure' output, which is your first warning # sign that Subversion is going to try to build mod_dav_svn. # Then when you actually do the build, it'll fail with this # error (note: the backslashes above and below are just for # readability here): # # $ make -j`nproc` # [...] # if true ; then cd subversion/mod_dav_svn && /bin/bash \ # "/home/kfogel/src/subversion/libtool" --tag=CC --silent --mode=link \ # gcc -static -g3 -fno-omit-frame-pointer -fno-inline -pthread \ # -DSVN_DEBUG -DAP_DEBUG -rpath /usr/local/libexec \ # -avoid-version -module -shared \ # -o mod_dav_svn.la activity.lo authz.lo deadprops.lo liveprops.lo \ # lock.lo merge.lo mirror.lo mod_dav_svn.lo posts/create_txn.lo \ # reports/dated-rev.lo reports/deleted-rev.lo reports/file-revs.lo \ # reports/get-location-segments.lo reports/get-locations.lo \ # reports/get-locks.lo reports/inherited-props.lo reports/list.lo \ # reports/log.lo reports/mergeinfo.lo reports/replay.lo \ # reports/update.lo repos.lo status.lo util.lo version.lo \ # ../../subversion/libsvn_repos/libsvn_repos-1.la \ # ../../subversion/libsvn_fs/libsvn_fs-1.la \ # ../../subversion/libsvn_delta/libsvn_delta-1.la \ # ../../subversion/libsvn_subr/libsvn_subr-1.la ; \ # else echo "fake" > subversion/mod_dav_svn/mod_dav_svn.la ; fi # cd tools/server-side && /bin/bash \ # "/home/kfogel/src/subversion/libtool" \ # --tag=CC --silent --mode=link gcc -static -g3 \ # -fno-omit-frame-pointer -fno-inline -pthread \ # -DSVN_DEBUG -DAP_DEBUG -rpath /usr/local/lib \ # -o svn-populate-node-origins-index \ # svn-populate-node-origins-index.lo \ # ../../subversion/libsvn_repos/libsvn_repos-1.la \ # ../../subversion/libsvn_fs/libsvn_fs-1.la \ # ../../subversion/libsvn_subr/libsvn_subr-1.la \ # -L/usr/lib/x86_64-linux-gnu -lapr-1 # cd tools/server-side && /bin/bash \ # "/home/kfogel/src/subversion/libtool" --tag=CC --silent \ # --mode=link gcc -static -g3 -fno-omit-frame-pointer \ # -fno-inline -pthread -DSVN_DEBUG -DAP_DEBUG -rpath /usr/local/lib \ # -o svnauthz svnauthz.lo \ # ../../subversion/libsvn_repos/libsvn_repos-1.la \ # ../../subversion/libsvn_fs/libsvn_fs-1.la \ # ../../subversion/libsvn_subr/libsvn_subr-1.la \ # -L/usr/lib/x86_64-linux-gnu -lapr-1 # cd tools/server-side && /bin/bash \ # "/home/kfogel/src/subversion/libtool" --tag=CC --silent \ # --mode=link gcc -static -g3 -fno-omit-frame-pointer \ # -fno-inline -pthread -DSVN_DEBUG -DAP_DEBUG \ # -rpath /usr/local/lib \ # -o svnauthz-validate svnauthz.lo \ # ../../subversion/libsvn_repos/libsvn_repos-1.la \ # ../../subversion/libsvn_fs/libsvn_fs-1.la \ # ../../subversion/libsvn_subr/libsvn_subr-1.la \ # -L/usr/lib/x86_64-linux-gnu -lapr-1 # libtool: error: cannot find name of object for 'activity.lo' # make: \ # *** [build-outputs.mk:846: subversion/mod_dav_svn/mod_dav_svn.la] Error 1 # make: *** Waiting for unfinished jobs.... # $ # # "libtool: error: cannot find name of object for 'activity.lo'" # is an error that doesn't get a lot of search engine hits, # which is one reason I've taken the trouble to spell it out # here in a sentence that is awkardly-phrased as a result of # being careful to not divide the error across comment lines :-). # # Anyway, it seems to result from trying to build mod_dav_svn # when you're not actually going to link dynamically against # Apache HTTPD. If you add '--without-apxs' then the problem # goes away. So do that. # # * --with-serf # # On an up-to-date Debian GNU/Linux 'testing' distro as of # 2021-02-13, I would seem to have recent-enough versions of # Serf installed to build Subversion with support for the # HTTP/HTTPS RA ("repository access") module: # # $ dpkg --status libserf-1-1 # Package: libserf-1-1 # Status: install ok installed # Priority: optional # Section: libs # Installed-Size: 154 # Maintainer: James McCoy # Architecture: amd64 # Multi-Arch: same # Source: serf # Version: 1.3.9-10 # Depends: libapr1 (>= 1.4.8-2~), libaprutil1 (>= 1.2.7+dfsg), libc6 (>= 2.14), libgssapi-krb5-2 (>= 1.17), libssl1.1 (>= 1.1.0), zlib1g (>= 1:1.1.4) # Description: high-performance asynchronous HTTP client library # serf library is a C-based HTTP client library built upon the Apache # Portable Runtime (APR) library. It multiplexes connections, running the # read/write communication asynchronously. Memory copies and # transformations are kept to a minimum to provide high performance # operation. # Homepage: https://serf.apache.org/ # $ dpkg --status libserf-dev # Package: libserf-dev # Status: install ok installed # Priority: optional # Section: libdevel # Installed-Size: 387 # Maintainer: James McCoy # Architecture: amd64 # Multi-Arch: same # Source: serf # Version: 1.3.9-10 # Depends: libapr1-dev, libaprutil1-dev, libserf-1-1 (= 1.3.9-10), libssl-dev # Description: high-performance asynchronous HTTP client library headers # serf library is a C-based HTTP client library built upon the Apache # Portable Runtime (APR) library. It multiplexes connections, running the # read/write communication asynchronously. Memory copies and # transformations are kept to a minimum to provide high performance # operation. # . # This package contains development headers for serf. # Homepage: https://serf.apache.org/ # $ # # And yet when I configure Subversion for build (without # passing '--with-serf', because I would normally rely on the # Subversion build process's default inclusion of Serf support # if Serf is auto-detected during the configure step anyway) # then somehow Serf is detected as being 1.3.1 instead of # 1.3.9 (and since 1.3.1 < 1.3.4, it is not used): # # configure: serf library configuration via pkg-config # checking for serf-2 library... no # checking for serf-1 library... yes # checking serf library version... 1.3.1 # checking serf version is suitable... no # configure: WARNING: Serf version too old: need 1.3.4 # checking was serf enabled... no # # An appropriate version of serf could not be found, so libsvn_ra_serf # will not be built. If you want to build libsvn_ra_serf, please # install serf 1.3.4 or newer. # # Now, despite the confusing Debian naming convention of # 'libserf-1-1', it is very clear that the installed Serf is # 1.3.9. Not only is that what 'dpkg' output says, it's what # /usr/include/serf-1/serf.h says: # # #define SERF_MAJOR_VERSION 1 # #define SERF_MINOR_VERSION 3 # #define SERF_PATCH_VERSION 9 # # So what's going on? Do I accidentally have some much older # version of libserf installed somewhere else? Or is the # configure process misreading the Serf version? Well, those # are good questions. Right now, though, I'd just like to make # sure that my Subversion build fails if it can't get the # HTTP/HTTPS RA module, and the way to do that is to pass # '--with-serf' explicitly. That tells configure that we want # & expect to have Serf, and that therefore there should be an # error if it's (apparently) not available. # # I did do some further shaving of that yak, though. Here's # what I've got so far (as of 2021-02-13): there seems to be a # known thing where pkg-config reports Serf as being a lower # version number than it really is. This line in configure... # # SERF_VERSION=`$PKG_CONFIG $serf_pc_arg --modversion` # # ...translates to this pkg-config command... # # /usr/bin/pkg-config serf-1 --modversion # # ...which for some reason gives the answer "1.3.1". The post # https://serverfault.com/questions/873921/serf-1-3-9-compiles-as-1-3-0 # is the closest thing I've found to an explanation or # workaround, and I've not finished digging in to it yet. Also # https://svn.haxx.se/users/archive-2019-05/0025.shtml may be # worth a look -- indeed, pointing out the serverfault post in # that svn-users thread might be a constructive thing to do. # # It looks like the problem may be an OpenSSL/LibreSSL # difference that then affects Serf that then affects # Subversion. If I have to start building Serf instead of # getting it from Debian, I will, but that'd suck. # # Just in case the Internet disappears, this is the patch to # start from for patching test/server/test_sslserver.c in Serf # (apparently look somewhere around current line 30): # # diff --git a/buckets/ssl_buckets.c b/buckets/ssl_buckets.c # index b01e535..6fadb0c 100644 # --- a/buckets/ssl_buckets.c # +++ b/buckets/ssl_buckets.c # @@ -1156,7 +1156,7 @@ static void init_ssl_libraries(void) # } # #endif # # -#ifdef USE_OPENSSL_1_1_API # +#if defined(USE_OPENSSL_1_1_API) && !defined(LIBRESSL_VERSION_NUMBER) # OPENSSL_malloc_init(); # #else # CRYPTO_malloc_init(); if [ ! -f /usr/local/lib/libserf-2* ]; then echo "ERROR: Go build and install Apache Serf first:" >&2 echo "" >&2 echo " $ pushd ~/src" >&2 echo " $ svn co https://svn.apache.org/repos/asf/serf/trunk serf" >&2 echo " $ cd serf" >&2 echo " $ scons" >&2 echo " $ sudo scons install" >&2 echo " $ popd" >&2 echo "" >&2 echo " (See http://serf.apache.org/download for more information.)" >&2 echo "" >&2 fi # This may still fail, with errors like # # $ makeit # [...] # checking for kf5-config... no # configure: error: cannot find kf5-config # make: *** No targets specified and no makefile found. Stop. # $ # # or perhaps: # # $ makeit # [...] # checking for kf5-config... /bin/kf5-config # checking for KWallet... no # configure: error: cannot find KWallet # make: *** No targets specified and no makefile found. Stop. # $ # # At such times, you'll be glad to know about commands like: # # $ apt-cache showsrc subversion # <...shows all dependency packages, among other things!...> # # $ apt source subversion # <...downloads pkg maintainer's sources, which includes their # configuration commands tucked away somewhere...> # # Partly through the above commands, I discovered the package(s) # that got me past the "cannot find Kwallet" configuration error. # To get through both errors, you'll need all of them -- while # 'libkf5kdelibs4support5-bin' seems to have been enough to fix # the 'kf5-config' problem, getting past the 'KWallet' problem # required all of the others (see also my 2021-12-16 IRC chat # with sabor in #svn-dev on Libera): # # - libkf5kdelibs4support5-bin # - libpam-kwallet5 # - libkf5wallet-dev # - libkf5wayland-dev # - libkf5doctools-dev # - kwalletcli # - libkf5coreaddons-dev # - libkf5i18n-dev ./configure --enable-maintainer-mode --without-apxs --with-serf --with-gpg_agent --with-kwallet make -j`nproc` ;; apr) scons scons check echo "" echo "Now do 'scons install'." echo "" ;; interstellar-probe) make distclean ./autogen.sh ./configure ${STD_DEBUG_FLAGS} --with-ansible --made-you-look make -j`nproc` ;; *) echo "Generic GNU-style build..." if [ -f ./autogen.sh ]; then ./autogen.sh; fi ./configure ${STD_DEBUG_FLAGS} make -j`nproc` ;; esac