Add configure check for gettext(3).
authorRoy Marples <roy@marples.name>
Tue, 2 Sep 2014 10:04:49 +0000 (10:04 +0000)
committerRoy Marples <roy@marples.name>
Tue, 2 Sep 2014 10:04:49 +0000 (10:04 +0000)
configure
src/libdhcpcd/Makefile
src/libdhcpcd/dhcpcd.c

index 80c2b4f88273567a12e574f46b26a4d171bc30c3..7279906913bbac98476a4cff5fcec7999579518c 100755 (executable)
--- a/configure
+++ b/configure
@@ -237,6 +237,32 @@ fi
 XCC="$CC `$SED -n -e 's/CPPLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
 XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
 
+if [ -z "$GETTEXT" ]; then
+       printf "Testing for gettext ... "
+       cat <<EOF >_gettext.c
+#include <libintl.h>
+int main(void) {
+       gettext("foo");
+       return 0;
+}
+EOF
+       LIB_INTL=
+       if $XCC _gettext.c -o _gettext 2>/dev/null; then
+               GETTEXT=yes
+       elif $XCC _gettext.c -o _gettext -lintl 2>/dev/null; then
+               GETTEXT="yes (-lintl)"
+               LIB_INTL=-lintl
+       else
+               GETTEXT=no
+       fi
+       echo "$GETTEXT"
+       rm -f _gettext.c _gettext
+fi
+if [ "$GETTEXT" != no ]; then
+       echo "#define HAS_GETTEXT" >>$CONFIG_H
+       echo "LIB_INTL= $LIB_INTL" >>$CONFIG_MK
+fi
+
 if [ -z "$STRLCPY" ]; then
        printf "Testing for strlcpy ... "
        cat <<EOF >_strlcpy.c
@@ -287,7 +313,7 @@ echo "LIB_DHCPCD=   $x" >>$CONFIG_MK
 
 # Due to our use of pkg-config, pass --as-needed to ld so we only link
 # what we actually need.
-echo "LDADD+=  -Wl,--as-needed" >>$CONFIG_MK
+echo "LDADD+=          -Wl,--as-needed" >>$CONFIG_MK
 
 UI=
 if [ "$WITH_GTK" = yes -o -z "$WITH_GTK" ]; then
index 162377a8d4f177b7775bc3982e2d55b9417f0613..4deacdb451bb3589c4819b0534503c88944862cd 100644 (file)
@@ -7,6 +7,7 @@ TOPDIR=         ../..
 include ${TOPDIR}/iconfig.mk
 
 CPPFLAGS+=     -I${TOPDIR}
+LDADD+=                ${LIB_INTL}
 
 # Don't install
 LIBINSTALL=    ${LIB_DHCPCD_INSTALL}
index 7c79e8c0fd323681ecbdb9ccedd2f0c1a229b75c..a86a05c93f0feda358a21d2f9dc4488e49067edd 100644 (file)
 #include "config.h"
 #include "dhcpcd.h"
 
+#ifdef HAS_GETTEXT
+#include <libintl.h>
 #define _ gettext
+#else
+#define _(a) (a)
+#endif
 
 #ifndef SUN_LEN
 #define SUN_LEN(su) \