[BUILD] fix platform-dependant build issues related to crypt()
Holger Just and Ross West reported build issues on FreeBSD and
Solaris that were initially caused by the definition of
_XOPEN_SOURCE at the top of auth.c, which was required on Linux
to avoid a build warning.
Krzysztof Oledzki found that using _GNU_SOURCE instead also worked
on Linux and did not cause any issue on several versions of FreeBSD.
Solaris still reported a warning this time, which was fixed by
including <crypt.h>, which itself is not present on FreeBSD nor on
all Linux toolchains.
So by adding a new build option (NEED_CRYPT_H), we can get Solaris
to get crypt() working and stop complaining at the same time, without
impacting other platforms.
This fix was tested at least on several linux toolchains (at least
uclibc, glibc 2.2.5, 2.3.6 and 2.7), on FreeBSD 4 to 8, Solaris 8
(which needs crypt.h), and AIX 5.3 (without crypt.h).
Every time it builds without a warning.
diff --git a/Makefile b/Makefile
index 022731d..4c13355 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,8 @@
# USE_TPROXY : enable transparent proxy. Automatic.
# USE_LINUX_TPROXY : enable full transparent proxy (need kernel patch).
# USE_LINUX_SPLICE : enable kernel 2.6 splicing (broken on old kernels)
+# USE_LIBCRYPT : enable crypted passwords using -lcrypt
+# USE_CRYPT_H : set it if your system requires including crypt.h
#
# Options can be forced by specifying "USE_xxx=1" or can be disabled by using
# "USE_xxx=" (empty string).
@@ -208,6 +210,8 @@
TARGET_CFLAGS = -fomit-frame-pointer -DFD_SETSIZE=65536 -D_REENTRANT
TARGET_LDFLAGS = -lnsl -lsocket
USE_TPROXY = implicit
+ USE_LIBCRYPT = implicit
+ USE_CRYPT_H = implicit
else
ifeq ($(TARGET),freebsd)
# This is for FreeBSD
@@ -336,6 +340,11 @@
OPTIONS_LDFLAGS += -lcrypt
endif
+ifneq ($(USE_CRYPT_H),)
+OPTIONS_CFLAGS += -DNEED_CRYPT_H
+BUILD_OPTIONS += $(call ignore_implicit,USE_CRYPT_H)
+endif
+
ifneq ($(USE_POLL),)
OPTIONS_CFLAGS += -DENABLE_POLL
OPTIONS_OBJS += src/ev_poll.o