Merge bf7b4611c4
into d28f4df8e2
commit
4179fae8ad
5
Makefile
5
Makefile
|
@ -22,7 +22,7 @@ LOBJS = src/nameinfo.o src/version.o \
|
|||
|
||||
GENH = src/version.h
|
||||
|
||||
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe
|
||||
CFLAGS += -Wall -O0 -g -std=c99 -pipe
|
||||
NO_AS_NEEDED = -Wl,--no-as-needed
|
||||
LIBDL = -ldl
|
||||
LDFLAGS = -fPIC $(NO_AS_NEEDED) $(LIBDL) -lpthread
|
||||
|
@ -30,6 +30,7 @@ INC =
|
|||
PIC = -fPIC
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
SOCKET_LIBS =
|
||||
|
||||
LDSO_SUFFIX = so
|
||||
LD_SET_SONAME = -Wl,-soname=
|
||||
|
@ -82,7 +83,7 @@ src/version.o: src/version.h
|
|||
|
||||
$(LDSO_PATHNAME): $(LOBJS)
|
||||
$(CC) $(LDFLAGS) $(LD_SET_SONAME)$(LDSO_PATHNAME) $(USER_LDFLAGS) \
|
||||
-shared -o $@ $(LOBJS)
|
||||
-shared -o $@ $(LOBJS) $(SOCKET_LIBS)
|
||||
|
||||
$(ALL_TOOLS): $(OBJS)
|
||||
$(CC) src/main.o src/common.o $(USER_LDFLAGS) -o $(PXCHAINS)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
prefix=/usr/local
|
||||
OUR_CPPFLAGS=
|
||||
C99_CFLAGS="-std=c99"
|
||||
|
||||
# Get a temporary filename
|
||||
i=0
|
||||
|
@ -30,11 +31,19 @@ isopenbsd() {
|
|||
uname -s | grep OpenBSD >/dev/null
|
||||
}
|
||||
|
||||
issolaris() {
|
||||
[ "`uname -s`" = SunOS ]
|
||||
}
|
||||
|
||||
isgnuld() {
|
||||
ld --version 2> /dev/null | grep -Fq GNU
|
||||
}
|
||||
|
||||
check_compile() {
|
||||
printf "checking %s ... " "$1"
|
||||
printf "$3" > "$tmpc"
|
||||
local res=0
|
||||
$CC $OUR_CPPFLAGS $CPPFLAGS $2 $CFLAGS -c "$tmpc" -o /dev/null >/dev/null 2>&1 \
|
||||
$CC $OUR_CPPFLAGS $CPPFLAGS $2 $C99_CFLAGS $CFLAGS -c "$tmpc" -o /dev/null >/dev/null 2>&1 \
|
||||
|| res=1
|
||||
test x$res = x0 && \
|
||||
{ printf "yes\n" ; test x"$2" = x || OUR_CPPFLAGS="$OUR_CPPFLAGS $2" ; } \
|
||||
|
@ -45,7 +54,7 @@ check_compile() {
|
|||
check_define() {
|
||||
printf "checking whether \$CC defines %s ... " "$1"
|
||||
local res=1
|
||||
$CC $OUR_CPPFLAGS $CPPFLAGS $CFLAGS -dM -E - </dev/null | grep "$1" >/dev/null && res=0
|
||||
$CC $OUR_CPPFLAGS $CPPFLAGS $C99_CFLAGS $CFLAGS -dM -E - </dev/null | grep "$1" >/dev/null && res=0
|
||||
test x$res = x0 && printf "yes\n" || printf "no\n"
|
||||
return $res
|
||||
}
|
||||
|
@ -54,7 +63,7 @@ check_compile_run() {
|
|||
printf "checking %s ... " "$1"
|
||||
printf "$2" > "$tmpc"
|
||||
local res=0
|
||||
$CC $OUR_CPPFLAGS $CPPFLAGS $CFLAGS "$tmpc" -o "$tmpc".out >/dev/null 2>&1 \
|
||||
$CC $OUR_CPPFLAGS $CPPFLAGS $C99_CFLAGS $CFLAGS "$tmpc" -o "$tmpc".out >/dev/null 2>&1 \
|
||||
|| res=1
|
||||
test x$res = x0 && { "$tmpc".out || res=1 ; }
|
||||
rm -f "$tmpc".out
|
||||
|
@ -133,13 +142,26 @@ if [ -z "$CC" ] ; then
|
|||
CC=cc
|
||||
fi
|
||||
|
||||
check_compile 'whether netinet/in.h defines s6_addr16' "" \
|
||||
'#include <netinet/in.h>\nint main(int a, char**c){struct in6_addr x={.s6_addr32[0]=a};return x.s6_addr16[0]; }' \
|
||||
|| {
|
||||
check_compile 'whether netinet/in.h defines __u6_addr.__u6_addr16' \
|
||||
'-Ds6_addr16=__u6_addr.__u6_addr16 -Ds6_addr32=__u6_addr.__u6_addr32' \
|
||||
'#include <netinet/in.h>\nint main(int a, char**c){struct in6_addr x={.s6_addr32[0]=a};return x.s6_addr16[0]; }'
|
||||
}
|
||||
check_compile "whether fine to define _GNU_SOURCE" "-D_GNU_SOURCE" \
|
||||
'#include <unistd.h>\nint main() { return 0; }'
|
||||
|
||||
for i in 700 600; do
|
||||
check_compile "whether _XOPEN_SOURCE=$i is suitable for C99 mode" "-D_XOPEN_SOURCE=$i" "#include <unistd.h>" && break
|
||||
done
|
||||
|
||||
for i in 16 32; do
|
||||
check_compile "whether netinet/in.h defines s6_addr$i" "" \
|
||||
'#include <netinet/in.h>\nint main(int a, char**c){'"struct in6_addr x={.s6_addr$i[0]=a};return x.s6_addr$i[0];"' }' \
|
||||
|| {
|
||||
check_compile "whether netinet/in.h defines __u6_addr.__u6_addr$i" \
|
||||
"-Ds6_addr$i=__u6_addr.__u6_addr$i" \
|
||||
'#include <netinet/in.h>\nint main(int a, char**c){'"struct in6_addr x={.s6_addr$i[0]=a};return x.s6_addr$i[0];"' }' || \
|
||||
check_compile "whether netinet/in.h defines _S6_un._S6_u$i" \
|
||||
"-Ds6_addr$i=_S6_un._S6_u$i" \
|
||||
'#include <netinet/in.h>\nint main(int a, char**c){'"struct in6_addr x={.s6_addr$i[0]=a};return x.s6_addr$i[0];"' }' || \
|
||||
OUR_CPPFLAGS="$OUR_CPPFLAGS -DNO_S6_ADDR$i"
|
||||
}
|
||||
done
|
||||
|
||||
check_define __OpenBSD__ && \
|
||||
check_compile_run 'whether OpenBSDs fclose() (illegally) calls close()' \
|
||||
|
@ -174,6 +196,13 @@ elif isbsd ; then
|
|||
echo "CFLAGS+=-DIS_BSD">>config.mak
|
||||
isopenbsd && echo "CFLAGS+=-DIS_OPENBSD">>config.mak
|
||||
make_cmd=gmake
|
||||
elif issolaris; then
|
||||
echo "CFLAGS+=-DIS_SOLARIS -D__EXTENSIONS__" >> config.mak
|
||||
if ! isgnuld; then
|
||||
echo "NO_AS_NEEDED=" >> config.mak
|
||||
echo "LD_SET_SONAME=-Wl,-h," >> config.mak
|
||||
fi
|
||||
echo "SOCKET_LIBS=-lsocket -lnsl" >> config.mak
|
||||
fi
|
||||
|
||||
echo "Done, now run $make_cmd && $make_cmd install"
|
||||
|
|
|
@ -787,8 +787,8 @@ void proxy_freeaddrinfo(struct addrinfo *res) {
|
|||
free(res);
|
||||
}
|
||||
|
||||
#if defined(IS_MAC) || defined(IS_OPENBSD)
|
||||
#ifdef IS_OPENBSD /* OpenBSD has its own incompatible getservbyname_r */
|
||||
#if defined(IS_MAC) || defined(IS_OPENBSD) || defined(IS_SOLARIS)
|
||||
#if defined(IS_OPENBSD) || defined(IS_SOLARIS) /* OpenBSD and Solaris has its own incompatible getservbyname_r */
|
||||
#define getservbyname_r mygetservbyname_r
|
||||
#endif
|
||||
/* getservbyname on mac is using thread local storage, so we dont need mutex
|
||||
|
|
|
@ -330,7 +330,11 @@ int close(int fd) {
|
|||
}
|
||||
static int is_v4inv6(const struct in6_addr *a) {
|
||||
return a->s6_addr32[0] == 0 && a->s6_addr32[1] == 0 &&
|
||||
#ifdef NO_S6_ADDR16
|
||||
a->s6_addr[8] == 0 && a->s6_addr[9] == 0 && a->s6_addr[10] == 0xff && a->s6_addr[11] == 0xff;
|
||||
#else
|
||||
a->s6_addr16[4] == 0 && a->s6_addr16[5] == 0xffff;
|
||||
#endif
|
||||
}
|
||||
int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
||||
INIT();
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#undef _XOPEN_SOURCE
|
||||
#ifndef _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE 700
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
|
Loading…
Reference in New Issue