diff --git a/Makefile b/Makefile index 6b6b2f2..b5bbd58 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/configure b/configure index d1c281e..952a207 100755 --- a/configure +++ b/configure @@ -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 diff --git a/src/hostentdb.c b/src/hostentdb.c index 337e26c..488e983 100644 --- a/src/hostentdb.c +++ b/src/hostentdb.c @@ -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) {