Skip to content

Commit 5526afb

Browse files
committed
FreeBSD support
1 parent be4efc0 commit 5526afb

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ LOBJS = src/nameinfo.o \
2222

2323
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe
2424
NO_AS_NEEDED = -Wl,--no-as-needed
25-
LDFLAGS = -shared -fPIC $(NO_AS_NEEDED) -ldl -lpthread
25+
LIBDL = -ldl
26+
LDFLAGS = -shared -fPIC $(NO_AS_NEEDED) $(LIBDL) -lpthread
2627
INC =
2728
PIC = -fPIC
2829
AR = $(CROSS_COMPILE)ar

configure

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ parsearg() {
3434
}
3535

3636
ismac() {
37-
uname -s | grep Darwin
37+
uname -s | grep Darwin >/dev/null
38+
}
39+
40+
isbsd() {
41+
uname -s | grep BSD >/dev/null
3842
}
3943

4044
while true ; do
@@ -83,6 +87,9 @@ if ismac ; then
8387
echo MAC_CFLAGS+=-DIS_MAC=1>>config.mak
8488
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
8589
echo INSTALL_FLAGS=-m>>config.mak
90+
elif isbsd ; then
91+
echo LIBDL=>>config.mak
92+
echo "CFLAGS+=-DIS_BSD">>config.mak
8693
fi
8794

8895
echo done, now run make \&\& make install

src/hostentdb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ static void hdb_add(struct hostent_list* hl, char* host, ip_type ip) {
2828
}
2929

3030
static void hdb_fill(struct hostent_list *hl) {
31+
#ifndef IS_BSD
3132
struct hostent* hp;
3233
while((hp = gethostent()))
3334
if(hp->h_addrtype == AF_INET && hp->h_length == sizeof(in_addr_t)) {
3435
hdb_add(hl, hp->h_name, (ip_type) { .as_int = *((in_addr_t*)(hp->h_addr_list[0])) });
3536
}
37+
#else
38+
/* FreeBSD hangs on gethostent(). since this feature is not crucial, we just do nothing */
39+
(void) hl;
40+
#endif
3641
}
3742

3843
void hdb_init(struct hostent_list *hl) {

0 commit comments

Comments
 (0)