c4e215c27ac760c75d100338703a99009e33125c
max
  Tue Feb 6 05:28:53 2024 -0800
We got various reports that the source tree is not building on Ubuntu
anymore. Also, we got reports that there are strange issues with
binaries built on Rocky8. To get the tree to build again on Ubuntu,
and to narrow down problems on Rocky8, I'm removing a lot of the
library auto-detection code in common.mk. The code was looking for
hardcoded paths to .a files, which caused the strange linking errors on
Ubuntu: even when the correct mysql lib version was installed, the
makefile picked up an unrelated .a file and whatever was done to the
mysql config, the dynamic libs were not picked up.
This change removes most of these special cases. Most of the removals
affect only the build on very old macports versions. I left untouched
the IS_HGWDEV parts.  SSL support is not optional anymore with this
change, which hopefully affects not even builds on smartwatches and
thermostats.  Most users who want to use special library versions need
to set their PATHs such that mysql_config and similar x_config programs
return the right directories.
Macports users probably need to do something like this (HT to Markd):
export CFLAGS=-I/opt/local/include
export LDFLAGs=-L/opt/local/lib

diff --git src/inc/common.mk src/inc/common.mk
index 1c44a4c..21632d0 100644
--- src/inc/common.mk
+++ src/inc/common.mk
@@ -32,43 +32,32 @@
   IS_HGWDEV = yes
 else
   IS_HGWDEV = no
 endif
 
 # Skip freetype for conda build; not needed for utils, and the Mac build environment has
 # freetype installed but we don't want to use the system libraries because they can be
 # for a newer OSX version than the conda build target, and can be incompatible.
 ifneq (${CONDA_BUILD},1)
   FREETYPECFLAGS = $(shell freetype-config --cflags  2> /dev/null)
 
   # we use our static library on dev
   ifeq (${IS_HGWDEV},no)
     ifeq (${FREETYPELIBS},)
       ifeq ($(UNAME_S),Darwin)
-        ifneq ($(wildcard /usr/local/Cellar/freetype/2.11.0/lib/libfreetype.a),)
-          ifneq ($(wildcard /usr/local/opt/bzip2/lib/libbz2.a),)
-            FREETYPELIBS = /usr/local/Cellar/freetype/2.11.0/lib/libfreetype.a /usr/local/opt/bzip2/lib/libbz2.a
+        FREETYPELIBS =  $(shell freetype-config --libs --static 2> /dev/null )
       else
-            FREETYPELIBS = /usr/local/Cellar/freetype/2.11.0/lib/libfreetype.a -lbz2
-          endif
-        else
-          ifneq ($(wildcard /opt/local/lib/libfreetype.a),)
-            FREETYPELIBS=/opt/local/lib/libfreetype.a /opt/local/lib/libbz2.a /opt/local/lib/libbrotlidec-static.a /opt/local/lib/libbrotlienc-static.a /opt/local/lib/libbrotlicommon-static.a
-          endif
-        endif
-      endif
-      ifeq (${FREETYPELIBS},)
         FREETYPELIBS =  $(shell freetype-config --libs 2> /dev/null )
       endif
     endif
   endif
 
   ifneq (${FREETYPECFLAGS},)
   FREETYPECFLAGS += -DUSE_FREETYPE
   endif
 
   HG_INC += ${FREETYPECFLAGS}
   L += ${FREETYPELIBS}
 endif
 
 ifeq (${IS_HGWDEV},yes)
   FULLWARN = yes
@@ -77,36 +66,32 @@
 ifeq (${HOSTNAME},cirm-01)
   FULLWARN = yes
 endif
 
 ifeq (${PTHREADLIB},)
   PTHREADLIB=-lpthread
 endif
 
 # required extra library on Mac OSX
 ICONVLIB=
 
 # pthreads is required
 ifneq ($(UNAME_S),Darwin)
   L+=${PTHREADLIB}
 else
-  ifneq ($(wildcard /opt/local/lib/libiconv.a),)
-       ICONVLIB=/opt/local/lib/libiconv.a
-   else
   ICONVLIB=-liconv
 endif
-endif
 
 # autodetect UCSC installation of hal:
 ifeq (${HALDIR},)
     # ONLY on hgwdev, not any other machine here (i.e. hgcompute-01)
     ifeq (${IS_HGWDEV},yes)
       HALDIR = /hive/groups/browser/hal/build/hal.2020-12-18
       ifneq ($(wildcard ${HALDIR}),)
         ifeq (${USE_HAL},)
           USE_HAL=1
         endif
       endif
     endif
 endif
 
 ifeq (${USE_HAL},1)
@@ -121,307 +106,134 @@
 # on hgwdev, include HAL by defaults
 ifeq (${IS_HGWDEV},yes)
    L+=${HALLIBS}
 endif
 
 ifeq (${USE_HIC},)
     USE_HIC=1
 endif
 
 ifeq (${USE_HIC},1)
     HG_DEFS+=-DUSE_HIC
 endif
 
 
 # libssl: disabled by default
-ifneq (${SSL_DIR}, "/usr/include/openssl")
-  ifneq ($(UNAME_S),Darwin)
-    ifneq ($(wildcard ${SSL_DIR}),)
-      L+=-L${SSL_DIR}/lib
-    endif
-  endif
-    HG_INC+=-I${SSL_DIR}/include
-endif
-# on hgwdev, already using the static library with mysqllient.
+#ifneq (${SSL_DIR}, "/usr/include/openssl")
+  #ifneq ($(UNAME_S),Darwin)
+    #ifneq ($(wildcard ${SSL_DIR}),)
+      #L+=-L${SSL_DIR}/lib
+    #endif
+  #endif
+    #HG_INC+=-I${SSL_DIR}/include
+#endif
+
+# on hgwdev, using the static library with mysqllient.
 ifeq (${IS_HGWDEV},yes)
    L+=/hive/groups/browser/freetype/freetype-2.10.0/objs/.libs/libfreetype.a -lbz2
    L+=/usr/lib64/libssl.a /usr/lib64/libcrypto.a -lkrb5 -lk5crypto -ldl
 else
    ifeq (${CONDA_BUILD},1)
        L+=${PREFIX}/lib/libssl.a ${PREFIX}/lib/libcrypto.a -ldl
    else
-     ifneq ($(wildcard /opt/homebrew/Cellar/openssl@3/3.0.7/lib/libssl.a),)
-         L+=/opt/homebrew/Cellar/openssl@3/3.0.7/lib/libssl.a
-     else
-       ifneq ($(wildcard /opt/local/lib/libssl.a),)
-         L+=/opt/local/lib/libssl.a
-       else
-         ifneq ($(wildcard /usr/lib/x86_64-linux-gnu/libssl.a),)
-	   L+=/usr/lib/x86_64-linux-gnu/libssl.a
-         else
-           ifneq ($(wildcard /usr/local/opt/openssl/lib/libssl.a),)
-              L+=/usr/local/opt/openssl/lib/libssl.a
-           else
-              L+=-lssl
-           endif
-         endif
-       endif
-     endif
-     ifneq ($(wildcard /opt/homebrew/Cellar/openssl@3/3.0.7/lib/libcrypto.a),)
-         L+=/opt/homebrew/Cellar/openssl@3/3.0.7/lib/libcrypto.a
-     else
-       ifneq ($(wildcard /opt/local/lib/libcrypto.a),)
-          L+=/opt/local/lib/libcrypto.a
-       else
-          ifneq ($(wildcard /usr/local/opt/openssl/lib/libcrypto.a),)
-             L+=/usr/local/opt/openssl/lib/libcrypto.a
-          else
-             L+=-lcrypto
-          endif
-       endif
-     endif
-     ifneq ($(wildcard /opt/homebrew/Cellar/zstd/1.5.2/lib/libzstd.a),)
-          L+=/opt/homebrew/Cellar/zstd/1.5.2/lib/libzstd.a
-     endif
+       L+=-lssl -lcrypto -ldl
    endif
 endif
 
 # autodetect where libm is installed
 ifeq (${MLIB},)
-  ifneq ($(wildcard /usr/lib64/libm.a),)
-      MLIB=-lm
-  endif
-endif
-ifeq (${MLIB},)
   MLIB=-lm
 endif
 
 # autodetect where png is installed
 ifeq (${PNGLIB},)
-  ifneq ($(wildcard /usr/lib64/libpng.a),)
-      PNGLIB=/usr/lib64/libpng.a
-  endif
-endif
-ifeq (${PNGLIB},)
-  ifneq ($(wildcard /usr/lib/libpng.a),)
-      PNGLIB=/usr/lib/libpng.a
-  endif
-endif
-ifeq (${PNGLIB},)
-  ifneq ($(wildcard /opt/local/lib/libpng.a),)
-      PNGLIB=/opt/local/lib/libpng.a
-  endif
-endif
-ifeq (${PNGLIB},)
-  ifneq ($(wildcard /usr/local/lib/libpng.a),)
-      PNGLIB=/usr/local/lib/libpng.a
-  endif
-endif
-ifeq (${PNGLIB},)
       PNGLIB := $(shell libpng-config --ldflags  || true)
 endif
 ifeq (${PNGLIB},)
   PNGLIB=-lpng
 endif
 ifeq (${PNGINCL},)
-  ifneq ($(wildcard /opt/local/include/png.h),)
-      PNGINCL=-I/opt/local/include
-  else
   PNGINCL := $(shell libpng-config --I_opts  || true)
 #       $(info using libpng-config to set PNGINCL: ${PNGINCL})
 endif
-endif
 
 # autodetect where mysql includes and libraries are installed
 # do not need to do this during 'clean' target (this is very slow for 'clean')
 ifneq ($(MAKECMDGOALS),clean)
   # on hgwdev, use the static library.
   ifeq (${IS_HGWDEV},yes)
     MYSQLINC=/usr/include/mysql
     MYSQLLIBS=/usr/lib64/libmysqlclient.a /usr/lib64/libssl.a /usr/lib64/libcrypto.a -lkrb5 -ldl -lz
   endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/lib/x86_64-linux-gnu/libmysqlclient.a),)
-	  MYSQLLIBS=/usr/lib/x86_64-linux-gnu/libmysqlclient.a -ldl
-    endif
-  endif
-  # this does *not* work on Mac OSX with the dynamic libraries
-  ifneq ($(UNAME_S),Darwin)
-    ifeq (${MYSQLLIBS},)
-      MYSQLLIBS := $(shell mysql_config --libs || true)
-#        $(info using mysql_config to set MYSQLLIBS: ${MYSQLLIBS})
-    endif
-  endif
 
+  # set MYSQL include path
   ifeq (${MYSQLINC},)
     MYSQLINC := $(shell mysql_config --include | sed -e 's/-I//' || true)
 #        $(info using mysql_config to set MYSQLINC: ${MYSQLINC})
   endif
   ifeq (${MYSQLINC},)
     ifneq ($(wildcard /usr/local/mysql/include/mysql.h),)
 	  MYSQLINC=/usr/local/mysql/include
     endif
   endif
   ifeq (${MYSQLINC},)
     ifneq ($(wildcard /usr/include/mysql/mysql.h),)
 	  MYSQLINC=/usr/include/mysql
     endif
   endif
-  ifeq (${MYSQLINC},)
-    ifneq ($(wildcard /opt/local/include/mysql57/mysql/mysql.h),)
-	  MYSQLINC=/opt/local/include/mysql57/mysql
-    endif
-  endif
-  ifeq (${MYSQLINC},)
-    ifneq ($(wildcard /opt/local/include/mysql55/mysql/mysql.h),)
-	  MYSQLINC=/opt/local/include/mysql55/mysql
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/local/Cellar/mariadb/10.9.4/lib/libmariadbclient.a),)
-         MYSQLLIBS+=/usr/local/Cellar/mariadb/10.9.4/lib/libmariadbclient.a
-    else
-      ifneq ($(wildcard /usr/local/Cellar/mariadb/10.8.3_1/lib/libmariadbclient.a),)
-           MYSQLLIBS+=/usr/local/Cellar/mariadb/10.8.3_1/lib/libmariadbclient.a
-      else
-        ifneq ($(wildcard /usr/local/Cellar/mariadb/10.6.4/lib/libmariadbclient.a),)
-           MYSQLLIBS+=/usr/local/Cellar/mariadb/10.6.4/lib/libmariadbclient.a
-        else
-          ifneq ($(wildcard /usr/local/Cellar/mariadb/10.4.12/lib/libmariadbclient.a),)
-           MYSQLLIBS+=/usr/local/Cellar/mariadb/10.4.12/lib/libmariadbclient.a
-	  endif
-        endif
-      endif
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /opt/local/lib/mysql57/mysql/libmysqlclient.a),)
-	  MYSQLLIBS=/opt/local/lib/mysql57/mysql/libmysqlclient.a
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /opt/local/lib/mysql55/mysql/libmysqlclient.a),)
-	  MYSQLLIBS=/opt/local/lib/mysql55/mysql/libmysqlclient.a
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/lib64/mysql/libmysqlclient.a),)
-	  MYSQLLIBS=/usr/lib64/mysql/libmysqlclient.a
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/local/mysql/lib/libmysqlclient.a),)
-	  MYSQLLIBS=/usr/local/mysql/lib/libmysqlclient.a
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/local/mysql/lib/libmysqlclient.a),)
-	  MYSQLLIBS=/usr/local/mysql/lib/libmysqlclient.a
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/lib64/mysql/libmysqlclient.so),)
-	  MYSQLLIBS=/usr/lib64/mysql/libmysqlclient.so
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/lib/libmysqlclient.a),)
-	  MYSQLLIBS=/usr/lib/libmysqlclient.a
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /opt/local/lib/mysql55/mysql/libmysqlclient.a),)
-	  MYSQLLIBS=/opt/local/lib/mysql55/mysql/libmysqlclient.a
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /opt/local/lib/mariadb-10.10/mysql/libmariadbclient.a),)
-        MYSQLLIBS=/opt/local/lib/mariadb-10.10/mysql/libmariadbclient.a
-    endif
-  endif
-  ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/local/Cellar/mysql/5.6.19/lib/libmysqlclient.a),)
-	  MYSQLLIBS=/usr/local/Cellar/mysql/5.6.19/lib/libmysqlclient.a
-    endif
-  endif
+
+  # this does *not* work on Mac OSX with the dynamic libraries
+  ifneq ($(UNAME_S),Darwin)
     ifeq (${MYSQLLIBS},)
-    ifneq ($(wildcard /usr/local/Cellar/mysql/5.6.16/lib/libmysqlclient.a),)
-	  MYSQLLIBS=/usr/local/Cellar/mysql/5.6.16/lib/libmysqlclient.a
+      MYSQLLIBS := $(shell mysql_config --libs || true)
+#        $(info using mysql_config to set MYSQLLIBS: ${MYSQLLIBS})
     endif
   endif
   ifeq ($(findstring src/hg/,${CURDIR}),src/hg/)
     ifeq (${MYSQLINC},)
         $(error can not find installed mysql development system)
     endif
   endif
     # last resort, hoping the compiler can find it in standard locations
   ifeq (${MYSQLLIBS},)
       MYSQLLIBS="-lmysqlclient"
   endif
 endif
 
 # $(info have MYSQLINC: ${MYSQLINC})
 # $(info have MYSQLLIBS: ${MYSQLLIBS})
 
 # OK to add -lstdc++ to all MYSQLLIBS just in case it is
 #    MySQL version 5.6 libraries, but no 'librt' on Mac OSX
 ifeq (${IS_HGWDEV},yes)
   MYSQLLIBS += /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libstdc++.a /usr/lib64/librt.a
 else
   ifeq ($(UNAME_S),Darwin)
     MYSQLLIBS += -lstdc++
   else
     MYSQLLIBS += -lstdc++ -lrt
   endif
 endif
 
 ifeq (${ZLIB},)
   ZLIB=-lz
-  ifneq ($(wildcard /opt/local/lib/libz.a),)
-    ZLIB=/opt/local/lib/libz.a
-  endif
-  ifneq ($(wildcard /usr/lib64/libz.a),)
-    ZLIB=/usr/lib64/libz.a
-  endif
 endif
 
 #global external libraries
 L += $(kentSrc)/htslib/libhts.a
 
 L+=${PNGLIB} ${MLIB} ${ZLIB} ${ICONVLIB}
-ifneq ($(wildcard /usr/local/Cellar/mariadb/10.9.4/include/mysql/mysql.h),)
-    HG_INC+=-I/usr/local/Cellar/mariadb/10.9.4/include/mysql
-else
-  ifneq ($(wildcard /usr/local/Cellar/mariadb/10.8.3_1/include/mysql/mysql.h),)
-      HG_INC+=-I/usr/local/Cellar/mariadb/10.8.3_1/include/mysql
-  else
-    ifneq ($(wildcard /usr/local/Cellar/mariadb/10.6.4/include/mysql/mysql.h),)
-      HG_INC+=-I/usr/local/Cellar/mariadb/10.6.4/include/mysql
-    else
-      ifneq ($(wildcard /usr/local/Cellar/mariadb/10.4.12/include/mysql/mysql.h),)
-        HG_INC+=-I/usr/local/Cellar/mariadb/10.4.12/include/mysql
-      endif
-    endif
-  endif
-endif
-ifneq ($(wildcard /opt/homebrew/Cellar/openssl@3/3.0.7/include/openssl/hmac.h),)
-    HG_INC+=-I/opt/homebrew/Cellar/openssl@3/3.0.7/include
-else
-  ifneq ($(wildcard /usr/local/opt/openssl/include/openssl/hmac.h),)
-    HG_INC+=-I/usr/local/opt/openssl/include
-  endif
-endif
 HG_INC+=${PNGINCL}
 
 # pass through COREDUMP
 ifneq (${COREDUMP},)
     HG_DEFS+=-DCOREDUMP
 endif
 
 # autodetect UCSC additional source code with password for some external tracks on gbib
 GBIBDIR = /hive/groups/browser/gbib/
 ifneq ($(wildcard ${GBIBDIR}/*.c),)
   HG_DEFS+=-DUSE_GBIB_PWD
   HG_INC += -I${GBIBDIR}
 endif
 
 SYS = $(shell uname -s)