62934fae49d85ac9d7f53032bbbd0d7553f7a1c5
hiram
  Mon Aug 13 10:57:55 2018 -0700
ordering difficulties with libm refs #21876

diff --git src/inc/common.mk src/inc/common.mk
index 1d1b18b..01d996a 100644
--- src/inc/common.mk
+++ src/inc/common.mk
@@ -126,31 +126,31 @@
 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=-lssl -lcrypto /usr/lib64/libmysqlclient.a -lkrb5
+    MYSQLLIBS=-lssl -lcrypto /usr/lib64/libmysqlclient.a ${ZLIB} -lkrb5
   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
 
   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),)
@@ -249,31 +249,31 @@
 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} ${ZLIB} ${MLIB}
+L+=${PNGLIB} ${MLIB} ${ZLIB}
 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)