Selaa lähdekoodia

db_mysql: use mysql_config to detect include and libs

Daniel-Constantin Mierla 14 vuotta sitten
vanhempi
commit
54306955b4
1 muutettua tiedostoa jossa 25 lisäystä ja 5 poistoa
  1. 25 5
      modules/db_mysql/Makefile

+ 25 - 5
modules/db_mysql/Makefile

@@ -6,18 +6,38 @@ include ../../Makefile.defs
 auto_gen=
 NAME=db_mysql.so
 
-# mysql.h locations (freebsd,openbsd  solaris)
-DEFS +=-DSER_MOD_INTERFACE -I$(LOCALBASE)/include -I$(LOCALBASE)/include/mysql \
+DEFS +=-DSER_MOD_INTERFACE
+
+# set CROSS_COMPILE to true if you want to skip
+# the autodetection
+# CROSS_COMPILE=true
+
+ifeq ($(CROSS_COMPILE),)
+MYSQLCFG=$(shell which mysql_config)
+endif
+
+ifneq ($(MYSQLCFG),)
+
+	# use autodetection
+	DEFS += $(shell $(MYSQLCFG) --include | sed 's/\(-I.*\)\/mysql/\1/g' )
+	LIBS = $(shell $(MYSQLCFG) --libs)
+
+else
+
+	# mysql.h locations (freebsd,openbsd  solaris)
+	DEFS +=-DSER_MOD_INTERFACE -I$(LOCALBASE)/include \
+		-I$(LOCALBASE)/include/mysql \
 		-I$(LOCALBASE)/mysql/include \
 		-I/usr/include/mysql
 
-# libmysqlclient locations on RH/Suse, Solaris /OpenBSD, FreeBSD
-# (Debian does the right thing and puts it in /usr/lib)
-LIBS=-L/usr/lib/mysql -L$(LOCALBASE)/lib -L$(LOCALBASE)/lib/mysql \
+	# libmysqlclient locations on RH/Suse, Solaris /OpenBSD, FreeBSD
+	# (Debian does the right thing and puts it in /usr/lib)
+	LIBS=-L/usr/lib/mysql -L$(LOCALBASE)/lib -L$(LOCALBASE)/lib/mysql \
 		-L$(LOCALBASE)/mysql/lib/mysql/ \
 		-L$(LOCALBASE)/mysql/lib \
 		-L/usr/lib64/mysql \
 		-lmysqlclient -lz
+endif
 
 SERLIBPATH=../../lib
 SER_LIBS=$(SERLIBPATH)/srdb2/srdb2 $(SERLIBPATH)/srdb1/srdb1