FreeBSD support

This commit is contained in:
rofl0r 2012-12-25 19:08:05 +01:00
parent be4efc0fd5
commit 5526afb56d
3 changed files with 15 additions and 2 deletions

View File

@ -22,7 +22,8 @@ LOBJS = src/nameinfo.o \
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe
NO_AS_NEEDED = -Wl,--no-as-needed
LDFLAGS = -shared -fPIC $(NO_AS_NEEDED) -ldl -lpthread
LIBDL = -ldl
LDFLAGS = -shared -fPIC $(NO_AS_NEEDED) $(LIBDL) -lpthread
INC =
PIC = -fPIC
AR = $(CROSS_COMPILE)ar

9
configure vendored
View File

@ -34,7 +34,11 @@ parsearg() {
}
ismac() {
uname -s | grep Darwin
uname -s | grep Darwin >/dev/null
}
isbsd() {
uname -s | grep BSD >/dev/null
}
while true ; do
@ -83,6 +87,9 @@ if ismac ; then
echo MAC_CFLAGS+=-DIS_MAC=1>>config.mak
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
echo INSTALL_FLAGS=-m>>config.mak
elif isbsd ; then
echo LIBDL=>>config.mak
echo "CFLAGS+=-DIS_BSD">>config.mak
fi
echo done, now run make \&\& make install

View File

@ -28,11 +28,16 @@ static void hdb_add(struct hostent_list* hl, char* host, ip_type ip) {
}
static void hdb_fill(struct hostent_list *hl) {
#ifndef IS_BSD
struct hostent* hp;
while((hp = gethostent()))
if(hp->h_addrtype == AF_INET && hp->h_length == sizeof(in_addr_t)) {
hdb_add(hl, hp->h_name, (ip_type) { .as_int = *((in_addr_t*)(hp->h_addr_list[0])) });
}
#else
/* FreeBSD hangs on gethostent(). since this feature is not crucial, we just do nothing */
(void) hl;
#endif
}
void hdb_init(struct hostent_list *hl) {