From 22f72496d973ccbe12ff239fee876e59cf090c94 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 9 Apr 2005 16:10:09 +0000 Subject: [PATCH] Adapt the build of the network libraries to the different target platforms. If we compile for Haiku we don't want select for example as we have it in libroot, but we need it under R5. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12275 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/network/libbind/DEVNOTES | 11 ++++----- src/kits/network/libbind/Jamfile | 9 +++++-- src/kits/network/libbind/irs/gai_strerror.c | 2 +- src/kits/network/libbind/port_after.h | 10 ++++---- src/kits/network/libbind/port_before.h | 2 +- src/kits/network/libnet/Jamfile | 26 ++++++++++++++++----- src/kits/network/libnet/networks | 2 +- src/kits/network/libnet/poll.c | 5 ++-- src/kits/network/libnet/resolv.conf | 2 +- src/kits/network/libnet/select.c | 2 +- src/kits/network/libnetapi/Jamfile | 13 +++++++++-- src/kits/network/libsocket/Jamfile | 19 +++++++++++---- src/kits/network/libsocket/select.c | 2 +- 13 files changed, 72 insertions(+), 33 deletions(-) diff --git a/src/kits/network/libbind/DEVNOTES b/src/kits/network/libbind/DEVNOTES index a7caa439a3..353a895c46 100644 --- a/src/kits/network/libbind/DEVNOTES +++ b/src/kits/network/libbind/DEVNOTES @@ -1,19 +1,18 @@ -BIND 9.2.3 ported to OpenBeOS +BIND 9.2.3 ported to Haiku -This file contains important information for developers who want to port BIND to OpenBeOS. +This file contains important information for developers who want to port BIND to Haiku. I created config.h, port_before.h, and port_after.h with the BIND configure script and fixed some mistakes that the script made. Our private folder are: - headers (some headers are not defined in OpenBeOS) - src (functions that are not part of OpenBeOS, e.g.: strsep) + headers (some headers are not defined in Haiku) + src (functions that are not part of Haiku, e.g.: strsep) Porting issues: BIND wants to include sys/un.h and utmp.h. We do not have these, so I put empty headers into the private headers folder. strsep() is not defined although we #define NEED_STRSEP in port_after.h. I put it in our private src folder. - OpenBeOS defines pselect(), but we turned NEEDS_PSELECT in port_after.h on because it is not present in BeOS. - As long as we do not have a working kernel this should be #define'd. When we can do a real OpenBeOS port we should #undef it again. + Haiku defines pselect(), we turn on NEEDS_PSELECT in port_after.h only if we compile for BeOS. Added sources for compatibility: src/res_resultcodes.c: BONE's host command wants _res_resultcodes to be defined diff --git a/src/kits/network/libbind/Jamfile b/src/kits/network/libbind/Jamfile index 5059eda184..db63370329 100644 --- a/src/kits/network/libbind/Jamfile +++ b/src/kits/network/libbind/Jamfile @@ -28,6 +28,12 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) resolv ] ; SubDirCcFlags $(defines) ; SubDirC++Flags $(defines) ; } + +if ( $(TARGET_PLATFORM) = haiku ) { + PLATFORM_LIBS = libroot.so libbe.so ; +} else { + PLATFORM_LIBS = root be ; +} SharedLibrary "bind" : # dst @@ -176,8 +182,7 @@ SharedLibrary "bind" : ; LinkSharedOSLibs libbind.so : - root - be # BeOS defines syslog in libbe.so + $(PLATFORM_LIBS) libsocket.so libnet.so # for gethostname() ; diff --git a/src/kits/network/libbind/irs/gai_strerror.c b/src/kits/network/libbind/irs/gai_strerror.c index 3e803dbcb8..0db2bdc8c2 100644 --- a/src/kits/network/libbind/irs/gai_strerror.c +++ b/src/kits/network/libbind/irs/gai_strerror.c @@ -63,7 +63,7 @@ gai_strerror(int ecode) { #ifdef DO_PTHREADS if (!once) { - // OpenBeOS compatibility: this is a function call, thus it must be + // Haiku compatibility: this is a function call, thus it must be // initialized here and not at when allocating 'lock' lock = PTHREAD_MUTEX_INITIALIZER; diff --git a/src/kits/network/libbind/port_after.h b/src/kits/network/libbind/port_after.h index 06af4c581a..facb6a2fc4 100644 --- a/src/kits/network/libbind/port_after.h +++ b/src/kits/network/libbind/port_after.h @@ -9,17 +9,19 @@ #include #endif -// OpenBeOS does not have these error codes +// Haiku does not have these error codes #define ETOOMANYREFS B_ERROR -// OpenBeOS fd_set has 'bits' instead of 'fds_bits' +// Haiku fd_set has 'bits' instead of 'fds_bits' #define fds_bits bits -// OpenBeOS does have pselect, but as long as we compile for BeOS we turn this on +// Haiku does have pselect, turn this on only when we're not compiling Haiku +#ifndef __HAIKU__ #define NEED_PSELECT 1 #define pselect isc__pselect +#endif -// OpenBeOS has problems with datagram sockets +// Haiku has problems with datagram sockets // #define CANNOT_CONNECT_DGRAM 1 #define HAVE_SA_LEN 1 diff --git a/src/kits/network/libbind/port_before.h b/src/kits/network/libbind/port_before.h index c725b7a125..54930a7fd1 100644 --- a/src/kits/network/libbind/port_before.h +++ b/src/kits/network/libbind/port_before.h @@ -19,7 +19,7 @@ struct timezone; /* silence warning */ #undef BSD_COMP -// OpenBeOS pthread support +// Haiku pthread support #define DO_PTHREADS 1 #include diff --git a/src/kits/network/libnet/Jamfile b/src/kits/network/libnet/Jamfile index e059c3234d..20fd0eb55a 100644 --- a/src/kits/network/libnet/Jamfile +++ b/src/kits/network/libnet/Jamfile @@ -7,8 +7,10 @@ UsePrivateHeaders net ; # Default libs include BeOS R5 libnet.so, something we don't want here! LINKFLAGS on libnet.so = [ on libnet.so return $(LINKFLAGS) ] -nodefaultlibs ; - local defines = BUILDING_R5_LIBNET ; - if $(BONE_VERSION) { + local defines ; + if ( $(TARGET_PLATFORM) = r5 ) { + defines += BUILDING_R5_LIBNET ; + } else if ( $(TARGET_PLATFORM) = bone ) { defines += BONE_VERSION ; } defines = [ FDefines $(defines) ] ; @@ -18,10 +20,22 @@ UsePrivateHeaders net ; Depends libnet.so : install_network_etc_files ; +if ( $(TARGET_PLATFORM) = r5 ) { + PLATFORM_SOURCES = + socket.c + select.c + poll.c + ; + PLATFORM_LIBS = ; +} else { + # under Haiku and BONE we don't need the above + # because they are in libsocket.so or libroot.so + PLATFORM_SOURCES = ; + PLATFORM_LIBS = libsocket.so ; +} + SharedLibrary net : - socket.c - select.c - poll.c + $(PLATFORM_SOURCES) compat.c arc4random.c base64.c @@ -59,7 +73,7 @@ SharedLibrary net : res_send.c sethostent.c - : libroot.so + : libroot.so $(PLATFORM_LIBS) ; OBOSInstall install_network_etc_files : [ FDirName $(OBOS_ETC_DIR) ] : diff --git a/src/kits/network/libnet/networks b/src/kits/network/libnet/networks index 305cc1a7c4..0c3d0ace1e 100644 --- a/src/kits/network/libnet/networks +++ b/src/kits/network/libnet/networks @@ -1,4 +1,4 @@ -# OpenBeOS /etc/networks +# Haiku /etc/networks # # Internet networks (from nic.ddn.mil) diff --git a/src/kits/network/libnet/poll.c b/src/kits/network/libnet/poll.c index b0b881e1ec..e95311ec1d 100644 --- a/src/kits/network/libnet/poll.c +++ b/src/kits/network/libnet/poll.c @@ -1,8 +1,8 @@ #include #include -#include "sys/select.h" +#include -#include "poll.h" +#include // ------------------------------- int poll(struct pollfd *fds, nfds_t numfds, int timeout) @@ -58,4 +58,3 @@ int poll(struct pollfd *fds, nfds_t numfds, int timeout) return rc; } - diff --git a/src/kits/network/libnet/resolv.conf b/src/kits/network/libnet/resolv.conf index 50cf809cfd..1368c853f5 100644 --- a/src/kits/network/libnet/resolv.conf +++ b/src/kits/network/libnet/resolv.conf @@ -1,4 +1,4 @@ -# resolv.conf for OpenBeOS +# resolv.conf for Haiku # # We lookup in the /etc/hosts file first, then we do a bind lookup lookup file bind diff --git a/src/kits/network/libnet/select.c b/src/kits/network/libnet/select.c index f32ea873ab..94ba531abd 100644 --- a/src/kits/network/libnet/select.c +++ b/src/kits/network/libnet/select.c @@ -177,4 +177,4 @@ error: return n; } -#endif +#endif // !BONE_VERSION diff --git a/src/kits/network/libnetapi/Jamfile b/src/kits/network/libnetapi/Jamfile index dce460a15e..55f44f8429 100644 --- a/src/kits/network/libnetapi/Jamfile +++ b/src/kits/network/libnetapi/Jamfile @@ -2,14 +2,23 @@ SubDir OBOS_TOP src kits network libnetapi ; UsePrivateHeaders net ; -SubDirC++Flags -DBUILDING_R5_LIBNET ; +{ + if ( $(TARGET_PLATFORM) = r5 ) { + defines = [ FDefines BUILDING_R5_LIBNET ] ; + SubDirCcFlags $(defines) ; + SubDirC++Flags $(defines) ; + PLATFORM_LIBS = ; + } else { + PLATFORM_LIBS = libsocket.so ; + } +} SharedLibrary netapi : NetEndpoint.cpp NetAddress.cpp NetBuffer.cpp NetDebug.cpp - : be libnet.so + : be libnet.so $(PLATFORM_LIBS) ; # Installation -- in the test directory for the time being diff --git a/src/kits/network/libsocket/Jamfile b/src/kits/network/libsocket/Jamfile index a28cf6bcc3..63f9335bac 100644 --- a/src/kits/network/libsocket/Jamfile +++ b/src/kits/network/libsocket/Jamfile @@ -5,9 +5,11 @@ UsePrivateHeaders net ; { # Default libs include BeOS R5 libnet.so, something we don't want here! LINKFLAGS on libsocket.so = [ on libsocket.so return $(LINKFLAGS) ] -nodefaultlibs ; - + local defines ; - if $(BONE_VERSION) { + if ( $(TARGET_PLATFORM) = r5 ) { + defines += BUILDING_R5_LIBNET ; + } else if ( $(TARGET_PLATFORM) = bone ) { defines += BONE_VERSION ; } defines = [ FDefines $(defines) ] ; @@ -15,10 +17,19 @@ UsePrivateHeaders net ; SubDirC++Flags $(defines) ; } +if ( $(TARGET_PLATFORM) = bone ) { + PLATFORM_SOURCES = + select.c + ; +} else { + # under Haiku we don't need the above + # because it's in libroot.so + PLATFORM_SOURCES = ; +} + SharedLibrary socket : socket.c - select.c - + $(PLATFORM_SOURCES) : root ; diff --git a/src/kits/network/libsocket/select.c b/src/kits/network/libsocket/select.c index 6ae6aec382..ebe601e519 100644 --- a/src/kits/network/libsocket/select.c +++ b/src/kits/network/libsocket/select.c @@ -176,4 +176,4 @@ error: return n; } -#endif +#endif // !BONE_VERSION