[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.
This commit is contained in:
parent
40dba09343
commit
890a33e41f
9
Makefile
9
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 @@ ifeq ($(TARGET),solaris)
|
||||
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 @@ BUILD_OPTIONS += $(call ignore_implicit,USE_LIBCRYPT)
|
||||
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
|
||||
|
10
src/auth.c
10
src/auth.c
@ -10,7 +10,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 500
|
||||
#ifdef CONFIG_HAP_CRYPT
|
||||
/* This is to have crypt() defined on Linux */
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#ifdef NEED_CRYPT_H
|
||||
/* some platforms such as Solaris need this */
|
||||
#include <crypt.h>
|
||||
#endif
|
||||
#endif /* CONFIG_HAP_CRYPT */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user