summaryrefslogtreecommitdiffstats
path: root/debian/patches/Improve-cross-compile-support.patch
blob: 708336f79775dca8ced0e979f3c1f970247343b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
From: Helmut Grohne <helmut@subdivi.de>
Date: Tue, 5 Jan 2021 22:25:00 +0100
Subject: Improve cross-compile support

The check for the signedness of size_t really doesn't have to be run as
that is a compile time property.

Beyond that, dovecot uses mysql_config. I've looked into that and
mysql_config is unfixably broken during cross builds. It will not be
fixed. Instead, please use pkg-config. My patch implements that with a
fallback to mysql_config to avoid breaking other users.

Last but not least, src/lib-lua/Makefile.am adds $(LUA_LIBS) to
libdovecot_lua_la_DEPENDENCIES. As it happens, LUA_LIBS contains a -L
flag and when that flag shows up in a dependency, make gives up. I have
no clue why one would add LUA_LIBS to DEPENDENCIES as it already is
being correctly added to LIBADD. My patch suggests to quite simply drop
that.
---
 m4/want_mysql.m4        | 54 ++++++++++++++++++++++++-------------------------
 src/lib-lua/Makefile.am |  4 +---
 2 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/m4/want_mysql.m4 b/m4/want_mysql.m4
index 98e6f93..425bcdd 100644
--- a/m4/want_mysql.m4
+++ b/m4/want_mysql.m4
@@ -1,26 +1,28 @@
 AC_DEFUN([DOVECOT_WANT_MYSQL], [
   have_mysql=no
-  if test $want_mysql != no; then
-    AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, mysql_config, NO)
-    if test $MYSQL_CONFIG = NO; then
-  	# based on code from PHP
-  	MYSQL_LIBS="-lmysqlclient -lz -lm"
-  	for i in /usr /usr/local /usr/local/mysql; do
-  		for j in include include/mysql ""; do
-  			if test -r "$i/$j/mysql.h"; then
-  				MYSQL_INCLUDE="-I$i/$j"
-  			fi
-  		done
-  		for j in lib lib/mysql lib64 lib64/mysql ""; do
-  			if test -f "$i/$j/libmysqlclient.so" || test -f "$i/$j/libmysqlclient.a"; then
-  				MYSQL_LIBS="-L$i/$j -lmysqlclient -lz -lm"
-  			fi
-  		done
-  	done
-    else
-      MYSQL_INCLUDE="`$MYSQL_CONFIG --include`"
-      MYSQL_LIBS="`$MYSQL_CONFIG --libs`"
-    fi
+    AS_IF([test $want_mysql != no],[
+    PKG_CHECK_MODULES([MYSQL],[mysqlclient],,[
+      AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, mysql_config, NO)
+      if test $MYSQL_CONFIG = NO; then
+    	# based on code from PHP
+    	MYSQL_LIBS="-lmysqlclient -lz -lm"
+    	for i in /usr /usr/local /usr/local/mysql; do
+    		for j in include include/mysql ""; do
+    			if test -r "$i/$j/mysql.h"; then
+    				MYSQL_CFLAGS="-I$i/$j"
+    			fi
+    		done
+    		for j in lib lib/mysql lib64 lib64/mysql ""; do
+    			if test -f "$i/$j/libmysqlclient.so" || test -f "$i/$j/libmysqlclient.a"; then
+    				MYSQL_LIBS="-L$i/$j -lmysqlclient -lz -lm"
+    			fi
+    		done
+    	done
+      else
+        MYSQL_CFLAGS="`$MYSQL_CONFIG --include`"
+        MYSQL_LIBS="`$MYSQL_CONFIG --libs`"
+      fi
+    ])
   
     old_LIBS=$LIBS
     if test "$MYSQL_LIBS" != ""; then
@@ -31,14 +33,10 @@ AC_DEFUN([DOVECOT_WANT_MYSQL], [
     LIBS="$LIBS -lz -lm"
     AC_CHECK_LIB(mysqlclient, mysql_init, [
   		old_CPPFLAGS=$CPPFLAGS
-  		if test "$MYSQL_INCLUDE" != ""; then
-  			CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"
+  		if test "$MYSQL_CFLAGS" != ""; then
+  			CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
   		fi
   		AC_CHECK_HEADER(mysql.h, [
-  			if test "$MYSQL_INCLUDE" != ""; then
-  				MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_INCLUDE"
-  			fi
-  
   			AC_CHECK_LIB(mysqlclient, mysql_ssl_set, [
   				AC_DEFINE(HAVE_MYSQL_SSL,, [Define if your MySQL library has SSL functions])
   				if test "x$have_openssl" = "yes"; then
@@ -85,5 +83,5 @@ AC_DEFUN([DOVECOT_WANT_MYSQL], [
       MYSQL_CFLAGS=
     fi
     LIBS=$old_LIBS
-  fi
+  ])
 ])
diff --git a/src/lib-lua/Makefile.am b/src/lib-lua/Makefile.am
index 20ce311..7d44e89 100644
--- a/src/lib-lua/Makefile.am
+++ b/src/lib-lua/Makefile.am
@@ -24,9 +24,7 @@ test_programs += test-dict-lua
 endif
 
 # Note: the only things this lib should depend on are libdovecot and lua.
-libdovecot_lua_la_DEPENDENCIES = \
-	../lib-dovecot/libdovecot.la \
-	$(LIBDICT_LUA)
+libdovecot_lua_la_DEPENDENCIES = ../lib-dovecot/libdovecot.la
 libdovecot_lua_la_LIBADD = \
 	../lib-dovecot/libdovecot.la \
 	$(LIBDICT_LUA) \