52c2741cc86ddc2ab4e279c1607cb431f6188e42
hiram
  Tue Oct 15 09:58:01 2013 -0700
now using mysql_config to find MYSQLINC and MYSQLLIBS refs #11899 #9149
diff --git src/inc/common.mk src/inc/common.mk
index 15f7f7d..443e474 100644
--- src/inc/common.mk
+++ src/inc/common.mk
@@ -66,31 +66,40 @@
 endif
 ifeq (${PNGLIB},)
   ifneq ($(wildcard /opt/local/lib/libpng.a),)
       PNGLIB=/opt/local/lib/libpng.a
   endif
 endif
 ifeq (${PNGLIB},)
   PNGLIB=-lpng
 endif
 ifeq (${PNGINCL},)
   ifneq ($(wildcard /opt/local/include/png.h),)
       PNGINCL=-I/opt/local/include
   endif
 endif
 
-# autodetect where libmysql is installed
+# autodetect where mysql includes and libraries are installed
+ifeq (${MYSQLINC},)
+  MYSQLINC := $(shell mysql_config --include | sed -e 's/-I//' || true)
+#  $(info using mysql_config to set MYSQLINC: ${MYSQLINC})
+endif
+ifeq (${MYSQLLIBS},)
+  MYSQLLIBS := $(shell mysql_config --libs || true)
+#  $(info using mysql_config to set MYSQLLIBS: ${MYSQLLIBS})
+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/mysql55/mysql/mysql.h),)
       MYSQLINC=/opt/local/include/mysql55/mysql
   endif
 endif
@@ -122,30 +131,33 @@
 ifeq (${MYSQLLIBS},)
   ifneq ($(wildcard /opt/local/lib/mysql55/mysql/libmysqlclient.a),)
       MYSQLLIBS=/opt/local/lib/mysql55/mysql/libmysqlclient.a
   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
 
+# $(info have MYSQLINC: ${MYSQLINC})
+# $(info have MYSQLLIBS: ${MYSQLLIBS})
+
 UNAME_S := $(shell uname -s)
 
 # OK to add -lstdc++ to all MYSQLLIBS just in case it is
 #    MySQL version 5.6 libraries, but no 'librt' on Mac OSX
 ifeq ($(UNAME_S),Darwin)
   MYSQLLIBS += -lstdc++
 else
   MYSQLLIBS += -lstdc++ -lrt
 endif
 
 L+=${PNGLIB}
 HG_INC+=${PNGINCL}
 
 # 32-bit color enabled by default
 ifneq (${COLOR32},0)