808b2080cee27e44ce67dd1c2efbf5dcdf7d3a09
hiram
  Mon Feb 26 13:39:00 2024 -0800
recovering the build on Darwin after OS upgrades no redmine

diff --git src/inc/common.mk src/inc/common.mk
index a52bc74..8a7c23f 100644
--- src/inc/common.mk
+++ src/inc/common.mk
@@ -22,30 +22,58 @@
 
 HG_DEFS=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DMACHTYPE_${MACHTYPE}
 HG_INC+=-I../inc -I../../inc -I../../../inc -I../../../../inc -I../../../../../inc -I$(kentSrc)/htslib
 
 # to check for Mac OSX Darwin specifics:
 UNAME_S := $(shell uname -s)
 # to check for builds on hgwdev
 HOSTNAME = $(shell uname -n)
 
 ifeq (${HOSTNAME},hgwdev)
   IS_HGWDEV = yes
 else
   IS_HGWDEV = no
 endif
 
+# for Darwin (Mac OSX), use static libs when they can be found
+ifeq ($(UNAME_S),Darwin)
+  ifneq ($(wildcard /opt/local/lib/libz.a),)
+    ZLIB = /opt/local/lib/libz.a
+    $(info Darwin ZLIB: ${ZLIB})
+  endif
+  ifneq ($(wildcard /opt/local/lib/libpng.a),)
+    PNGLIB = /opt/local/lib/libpng.a
+    $(info Darwin PNGLIB: ${PNGLIB})
+  endif
+  ifneq ($(wildcard /opt/local/lib/libfreetype.a),)
+    FREETYPELIBS = /opt/local/lib/libfreetype.a
+    $(info Darwin FREETYPELIBS: ${FREETYPELIBS})
+  endif
+  ifneq ($(wildcard /usr/local/opt/openssl@3/lib/libssl.a),)
+    SSLLIB = /usr/local/opt/openssl@3/lib/libssl.a
+    $(info Darwin SSLLIB: ${SSLLIB})
+  endif
+  ifneq ($(wildcard /usr/local/opt/openssl@3/lib/libcrypto.a),)
+    CRYPTOLIB = /usr/local/opt/openssl@3/lib/libcrypto.a
+    $(info Darwin CRYPTOLIB: ${CRYPTOLIB})
+  endif
+  ifneq ($(wildcard /opt/local/lib/libiconv.a),)
+    ICONVLIB = /opt/local/lib/libiconv.a
+    $(info Darwin ICONVLIB: ${ICONVLIB})
+  endif
+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)
   # Ubuntu does not have freetype-config anymore
   ifeq (${FREETYPEFLAGS},)
      FREETYPECFLAGS =  $(shell pkg-config freetype2 --cflags 2> /dev/null )
   endif
 
   # use the static library on OSX
   ifeq (${IS_HGWDEV},no)
     ifeq (${FREETYPELIBS},)
       ifeq ($(UNAME_S),Darwin)
         FREETYPELIBS =  $(shell freetype-config --libs --static 2> /dev/null )
@@ -64,39 +92,37 @@
   endif
 
   HG_INC += ${FREETYPECFLAGS}
   L += ${FREETYPELIBS}
 endif
 
 
 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
+  ifeq (${ICONVLIB},)
     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)
@@ -195,31 +221,39 @@
 
 # on hgwdev, use the static libraries
 ifeq (${IS_HGWDEV},yes)
    FULLWARN = 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
    PNGLIB=/usr/lib64/libpng.a
    PNGINCL=-I/usr/include/libpng15
    MYSQLINC=/usr/include/mysql
    MYSQLLIBS=/usr/lib64/libmysqlclient.a /usr/lib64/libssl.a /usr/lib64/libcrypto.a -lkrb5 -ldl -lz
    MYSQLLIBS += /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libstdc++.a /usr/lib64/librt.a
 else
    ifeq (${CONDA_BUILD},1)
        L+=${PREFIX}/lib/libssl.a ${PREFIX}/lib/libcrypto.a -ldl
    else
-       L+=-lssl -lcrypto -ldl
+       ifeq (${SSLLIB},)
+          L+ = -lssl
+       endif
+       ifeq (${CRYPTOLIB},)
+          L+ = -lcrypto -ldl
+       endif
+       ifeq (${DLLIB},)
+          L+ = -ldl
+       endif
    endif
 endif
 
 #global external libraries
 L += $(kentSrc)/htslib/libhts.a
 
 L+=${PNGLIB} ${MLIB} ${ZLIB} ${ICONVLIB}
 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