FreeBSD build platform support. Original patches courtesy of

Samuel Rodriguez Perez, somewhat hacked by myself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19392 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2006-11-29 18:08:00 +00:00
parent 67491d2adc
commit 69b1f76d66
10 changed files with 241 additions and 176 deletions
+12 -3
View File
@@ -294,7 +294,7 @@ HOST_UNARFLAGS ?= x ;
# check the host platform compatibility # check the host platform compatibility
SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host : linux freebsd ; SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host : linux freebsd ;
if $(HOST_PLATFORM) = linux { if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd {
# don't use lex: otherwise rc will not work correctly # don't use lex: otherwise rc will not work correctly
if $(LEX) = lex { if $(LEX) = lex {
LEX = flex ; LEX = flex ;
@@ -422,6 +422,11 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
HOST_LIBSUPC++ = supc++ ; HOST_LIBSUPC++ = supc++ ;
} }
# Unlike glibc FreeBSD's libc doesn't have built-in regex support.
if $(HOST_PLATFORM) = freebsd {
HOST_LIBROOT += /usr/lib/libgnuregex.so ;
}
# The BeOS compilers define __INTEL__ respectively __POWERPC__. On the # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the
# build platform we need to make sure, this is also defined. # build platform we need to make sure, this is also defined.
if $(HOST_CPU) = x86 { if $(HOST_CPU) = x86 {
@@ -449,7 +454,7 @@ if $(METROWERKS) {
HOST_BE_API_HEADERS = ; HOST_BE_API_HEADERS = ;
HOST_BE_API_CCFLAGS = ; HOST_BE_API_CCFLAGS = ;
HOST_BE_API_C++FLAGS = ; HOST_BE_API_C++FLAGS = ;
if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
HOST_BE_API_HEADERS = HOST_BE_API_HEADERS =
[ FDirName $(HAIKU_TOP) headers build ] [ FDirName $(HAIKU_TOP) headers build ]
@@ -465,6 +470,10 @@ if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ; HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ;
} }
# Add directory with system headers we need when building something for the host
# platform, e.g. containing missing POSIX/GNU headers.
HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host $(HOST_PLATFORM) ] ;
#pragma mark - #pragma mark -
@@ -655,7 +664,7 @@ CC = bad-cc ;
C++ = bad-c++ ; C++ = bad-c++ ;
LINK = bad-link ; LINK = bad-link ;
# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() # Allow compiling unit tests on Zeta. Instead of fixing the PostMessage()
# issues, they deprecated that nice function. This will enable it again: # issues, they deprecated that nice function. This will enable it again:
C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ;
# Same for buggy find_directory threadsafety fixes # Same for buggy find_directory threadsafety fixes
+1 -1
View File
@@ -25,7 +25,7 @@ extern ssize_t read_pos(int fd, off_t pos, void *buffer, size_t count);
extern ssize_t write_pos(int fd, off_t pos, const void *buffer,size_t count); extern ssize_t write_pos(int fd, off_t pos, const void *buffer,size_t count);
// There's no O_NOTRAVERSE under Linux, but there's a O_NOFOLLOW, which // There's no O_NOTRAVERSE under Linux and FreeBSD, but there's a O_NOFOLLOW, which
// means something different (open() fails when the file is a symlink), but // means something different (open() fails when the file is a symlink), but
// we can abuse this flag for our purposes (we filter it in libroot). // we can abuse this flag for our purposes (we filter it in libroot).
#ifndef O_NOTRAVERSE #ifndef O_NOTRAVERSE
+14
View File
@@ -0,0 +1,14 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_FREEBSD_ENDIAN
#define _HAIKU_BUILD_COMPATIBILITY_FREEBSD_ENDIAN
// There's no <endian.h> in FreeBSD, but <sys/endian.h>. And the macro naming
// differs.
#include <sys/endian.h>
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
#define __BIG_ENDIAN _BIG_ENDIAN
#define __PDP_ENDIAN _PDP_ENDIAN
#define BYTE_ORDER _BYTE_ORDER
#endif // _HAIKU_BUILD_COMPATIBILITY_FREEBSD_ENDIAN
+8
View File
@@ -0,0 +1,8 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_FREEBSD_REGEX
#define _HAIKU_BUILD_COMPATIBILITY_FREEBSD_REGEX
// There's no <regex.h> in FreeBSD, but <gnu/regex.h>.
#include <gnu/regex.h>
#endif // _HAIKU_BUILD_COMPATIBILITY_FREEBSD_REGEX
+166 -158
View File
@@ -1,158 +1,166 @@
#define BUILDING_HAIKU_ERROR_MAPPER 1 #define BUILDING_HAIKU_ERROR_MAPPER 1
#include <BeOSBuildCompatibility.h> #include <BeOSBuildCompatibility.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <map> #include <map>
using namespace std; using namespace std;
static map<int, int> sToHaikuErrorMap; static map<int, int> sToHaikuErrorMap;
static map<int, int> sToHostErrorMap; static map<int, int> sToHostErrorMap;
static bool sErrorMapsInitialized = false; static bool sErrorMapsInitialized = false;
// init_error_map // init_error_map
static void static void
init_error_map() init_error_map()
{ {
if (sErrorMapsInitialized) if (sErrorMapsInitialized)
return; return;
#define ADD_ERROR(error) \ #define ADD_ERROR(error) \
sToHaikuErrorMap[error] = HAIKU_##error; \ sToHaikuErrorMap[error] = HAIKU_##error; \
sToHostErrorMap[HAIKU_##error] = error; sToHostErrorMap[HAIKU_##error] = error;
ADD_ERROR(E2BIG); ADD_ERROR(E2BIG);
ADD_ERROR(ECHILD); ADD_ERROR(ECHILD);
ADD_ERROR(EDEADLK); ADD_ERROR(EDEADLK);
ADD_ERROR(EFBIG); ADD_ERROR(EFBIG);
ADD_ERROR(EMLINK); ADD_ERROR(EMLINK);
ADD_ERROR(ENFILE); ADD_ERROR(ENFILE);
ADD_ERROR(ENODEV); ADD_ERROR(ENODEV);
ADD_ERROR(ENOLCK); ADD_ERROR(ENOLCK);
ADD_ERROR(ENOSYS); ADD_ERROR(ENOSYS);
ADD_ERROR(ENOTTY); ADD_ERROR(ENOTTY);
ADD_ERROR(ENXIO); ADD_ERROR(ENXIO);
ADD_ERROR(ESPIPE); ADD_ERROR(ESPIPE);
ADD_ERROR(ESRCH); ADD_ERROR(ESRCH);
#ifdef EFPOS #ifdef EFPOS
ADD_ERROR(EFPOS); ADD_ERROR(EFPOS);
#endif #endif
#ifdef ESIGPARM #ifdef ESIGPARM
ADD_ERROR(ESIGPARM); ADD_ERROR(ESIGPARM);
#endif #endif
ADD_ERROR(EDOM); ADD_ERROR(EDOM);
ADD_ERROR(ERANGE); ADD_ERROR(ERANGE);
ADD_ERROR(EPROTOTYPE); ADD_ERROR(EPROTOTYPE);
ADD_ERROR(EPROTONOSUPPORT); ADD_ERROR(EPROTONOSUPPORT);
ADD_ERROR(EPFNOSUPPORT); ADD_ERROR(EPFNOSUPPORT);
ADD_ERROR(EAFNOSUPPORT); ADD_ERROR(EAFNOSUPPORT);
ADD_ERROR(EADDRINUSE); ADD_ERROR(EADDRINUSE);
ADD_ERROR(EADDRNOTAVAIL); ADD_ERROR(EADDRNOTAVAIL);
ADD_ERROR(ENETDOWN); ADD_ERROR(ENETDOWN);
ADD_ERROR(ENETUNREACH); ADD_ERROR(ENETUNREACH);
ADD_ERROR(ENETRESET); ADD_ERROR(ENETRESET);
ADD_ERROR(ECONNABORTED); ADD_ERROR(ECONNABORTED);
ADD_ERROR(ECONNRESET); ADD_ERROR(ECONNRESET);
ADD_ERROR(EISCONN); ADD_ERROR(EISCONN);
ADD_ERROR(ENOTCONN); ADD_ERROR(ENOTCONN);
ADD_ERROR(ESHUTDOWN); ADD_ERROR(ESHUTDOWN);
ADD_ERROR(ECONNREFUSED); ADD_ERROR(ECONNREFUSED);
ADD_ERROR(EHOSTUNREACH); ADD_ERROR(EHOSTUNREACH);
ADD_ERROR(ENOPROTOOPT); ADD_ERROR(ENOPROTOOPT);
ADD_ERROR(ENOBUFS); ADD_ERROR(ENOBUFS);
ADD_ERROR(EINPROGRESS); ADD_ERROR(EINPROGRESS);
ADD_ERROR(EALREADY); ADD_ERROR(EALREADY);
ADD_ERROR(EILSEQ); ADD_ERROR(EILSEQ);
ADD_ERROR(ENOMSG); ADD_ERROR(ENOMSG);
ADD_ERROR(ESTALE); ADD_ERROR(ESTALE);
ADD_ERROR(EOVERFLOW); ADD_ERROR(EOVERFLOW);
ADD_ERROR(EMSGSIZE); ADD_ERROR(EMSGSIZE);
ADD_ERROR(EOPNOTSUPP); ADD_ERROR(EOPNOTSUPP);
ADD_ERROR(ENOTSOCK); ADD_ERROR(ENOTSOCK);
ADD_ERROR(EHOSTDOWN); ADD_ERROR(EHOSTDOWN);
ADD_ERROR(EBADMSG); ADD_ERROR(EBADMSG);
ADD_ERROR(ECANCELED); ADD_ERROR(ECANCELED);
ADD_ERROR(EDESTADDRREQ); ADD_ERROR(EDESTADDRREQ);
ADD_ERROR(EDQUOT); ADD_ERROR(EDQUOT);
ADD_ERROR(EIDRM); ADD_ERROR(EIDRM);
ADD_ERROR(EMULTIHOP); ADD_ERROR(EMULTIHOP);
ADD_ERROR(ENODATA); #ifdef ENODATA
ADD_ERROR(ENOLINK); ADD_ERROR(ENODATA);
ADD_ERROR(ENOSR); #endif
ADD_ERROR(ENOSTR); ADD_ERROR(ENOLINK);
ADD_ERROR(ENOTSUP); #ifdef ENOSR
ADD_ERROR(EPROTO); ADD_ERROR(ENOSR);
ADD_ERROR(ETIME); #endif
ADD_ERROR(ETXTBSY); #ifdef ENOSTR
ADD_ERROR(ENOMEM); ADD_ERROR(ENOSTR);
ADD_ERROR(EACCES); #endif
ADD_ERROR(EINTR); ADD_ERROR(ENOTSUP);
ADD_ERROR(EIO); ADD_ERROR(EPROTO);
ADD_ERROR(EBUSY); #ifdef ETIME
ADD_ERROR(EFAULT); ADD_ERROR(ETIME);
ADD_ERROR(ETIMEDOUT); #endif
ADD_ERROR(EAGAIN); ADD_ERROR(ETXTBSY);
ADD_ERROR(EWOULDBLOCK); ADD_ERROR(ENOMEM);
ADD_ERROR(EBADF); ADD_ERROR(EACCES);
ADD_ERROR(EEXIST); ADD_ERROR(EINTR);
ADD_ERROR(EINVAL); ADD_ERROR(EIO);
ADD_ERROR(ENAMETOOLONG); ADD_ERROR(EBUSY);
ADD_ERROR(ENOENT); ADD_ERROR(EFAULT);
ADD_ERROR(EPERM); ADD_ERROR(ETIMEDOUT);
ADD_ERROR(ENOTDIR); ADD_ERROR(EAGAIN);
ADD_ERROR(EISDIR); ADD_ERROR(EWOULDBLOCK);
ADD_ERROR(ENOTEMPTY); ADD_ERROR(EBADF);
ADD_ERROR(ENOSPC); ADD_ERROR(EEXIST);
ADD_ERROR(EROFS); ADD_ERROR(EINVAL);
ADD_ERROR(EMFILE); ADD_ERROR(ENAMETOOLONG);
ADD_ERROR(EXDEV); ADD_ERROR(ENOENT);
ADD_ERROR(ELOOP); ADD_ERROR(EPERM);
ADD_ERROR(ENOEXEC); ADD_ERROR(ENOTDIR);
ADD_ERROR(EPIPE); ADD_ERROR(EISDIR);
ADD_ERROR(ENOTEMPTY);
sErrorMapsInitialized = true; ADD_ERROR(ENOSPC);
} ADD_ERROR(EROFS);
ADD_ERROR(EMFILE);
// to_host_error ADD_ERROR(EXDEV);
static int ADD_ERROR(ELOOP);
to_host_error(int error) ADD_ERROR(ENOEXEC);
{ ADD_ERROR(EPIPE);
init_error_map();
sErrorMapsInitialized = true;
map<int, int>::iterator it = sToHostErrorMap.find(error); }
return (it != sToHostErrorMap.end() ? it->second : error);
} // to_host_error
static int
// to_haiku_error to_host_error(int error)
static int {
to_haiku_error(int error) init_error_map();
{
init_error_map(); map<int, int>::iterator it = sToHostErrorMap.find(error);
return (it != sToHostErrorMap.end() ? it->second : error);
map<int, int>::iterator it = sToHaikuErrorMap.find(error); }
if (it != sToHaikuErrorMap.end())
return it->second; // to_haiku_error
static int
return (error > 0 ? -error : error); to_haiku_error(int error)
} {
init_error_map();
// _haiku_build_strerror
char * map<int, int>::iterator it = sToHaikuErrorMap.find(error);
_haiku_build_strerror(int errnum) if (it != sToHaikuErrorMap.end())
{ return it->second;
return strerror(to_host_error(errnum));
} return (error > 0 ? -error : error);
}
// _haiku_build_errno
int * // _haiku_build_strerror
_haiku_build_errno() char *
{ _haiku_build_strerror(int errnum)
static int localErrno = 0; {
localErrno = to_haiku_error(errno); return strerror(to_host_error(errnum));
return &localErrno; }
}
// _haiku_build_errno
int *
_haiku_build_errno()
{
static int localErrno = 0;
localErrno = to_haiku_error(errno);
return &localErrno;
}
+3 -3
View File
@@ -15,7 +15,7 @@ rule ISAPnPHeaderGen
actions ISAPnPHeaderGen1 actions ISAPnPHeaderGen1
{ {
grep '^PNP[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] ' $(2[1]) | awk -f $(2[2]) > $(1) ; grep '^PNP[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] ' $(2[1]) | gawk -f $(2[2]) > $(1) ;
} }
ISAPnPHeaderGen [ FGristFiles isapnpids.h ] : isapnp_devids.txt : devlist2h.awk ; ISAPnPHeaderGen [ FGristFiles isapnpids.h ] : isapnp_devids.txt : devlist2h.awk ;
@@ -33,7 +33,7 @@ rule USBHeaderGen
actions USBHeaderGen1 actions USBHeaderGen1
{ {
awk -v HEADERFILE=$(1[1]) -v DATAFILE=$(1[2]) -f $(2[2]) $(2[1]) gawk -v HEADERFILE=$(1[1]) -v DATAFILE=$(1[2]) -f $(2[2]) $(2[1])
} }
USBHeaderGen [ FGristFiles usbdevs.h usbdevs_data.h ] : usbdevs : usb_devlist2h.awk ; USBHeaderGen [ FGristFiles usbdevs.h usbdevs_data.h ] : usbdevs : usb_devlist2h.awk ;
@@ -51,7 +51,7 @@ rule PCIHeaderGen
actions PCIHeaderGen1 actions PCIHeaderGen1
{ {
awk -v HEADERFILE=$(1) -f $(2[2]) $(2[1]) gawk -v HEADERFILE=$(1) -f $(2[2]) $(2[1])
} }
PCIHeaderGen [ FGristFiles pcihdr.h ] : pci.ids : pci-header.awk ; PCIHeaderGen [ FGristFiles pcihdr.h ] : pci.ids : pci-header.awk ;
@@ -6,7 +6,7 @@
and some versions of Unix). To further avoid complications I've also and some versions of Unix). To further avoid complications I've also
hidden the stat and dirent structs since those vary even more widely. hidden the stat and dirent structs since those vary even more widely.
THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED
OR IMPLIED. YOU MAY USE THIS CODE AND FREELY DISTRIBUTE IT FOR OR IMPLIED. YOU MAY USE THIS CODE AND FREELY DISTRIBUTE IT FOR
NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED. NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED.
@@ -14,8 +14,8 @@
Dominic Giampaolo Dominic Giampaolo
[email protected] [email protected]
*/ */
#ifndef _COMPAT_H #ifndef _COMPAT_H
#define _COMPAT_H #define _COMPAT_H
@@ -51,6 +51,19 @@ typedef struct iovec iovec;
# include <image.h> /* for a few typedefs */ # include <image.h> /* for a few typedefs */
# include <Drivers.h> /* for various ioctl structs, etc */ # include <Drivers.h> /* for various ioctl structs, etc */
# include <iovec.h> /* because we're boneheads sometimes */ # include <iovec.h> /* because we're boneheads sometimes */
#elif HAIKU_HOST_PLATFORM_FREEBSD
/* BSD Compilant stat.h */
# define __BSD_VISIBLE 1
#undef __XSI_VISIBLE
# define __XSI_VISIBLE 1
/* for mknod */
# define __POSIX_VISIBLE 200112
/* for S_ISLNK, S_ISSOCK and lstat */
# include <sys/stat.h>
# include <sys/uio.h>
# include <image.h> /* for a few typedefs */
# include <Drivers.h> /* for various ioctl structs, etc */
typedef unsigned long ulong;
#else #else
# include <sys/uio.h> # include <sys/uio.h>
# include <image.h> /* for a few typedefs */ # include <image.h> /* for a few typedefs */
@@ -55,8 +55,12 @@ static error_entry sErrors[] = {
{ FS_ENXIO, ENXIO }, { FS_ENXIO, ENXIO },
{ FS_ESPIPE, ESPIPE }, { FS_ESPIPE, ESPIPE },
{ FS_ESRCH, ESRCH }, { FS_ESRCH, ESRCH },
// { FS_EFPOS, EFPOS }, #ifdef EFPOS
// { FS_ESIGPARM, ESIGPARM }, { FS_EFPOS, EFPOS },
#endif
#ifdef ESIGPARM
{ FS_ESIGPARM, ESIGPARM },
#endif
{ FS_EDOM, EDOM }, { FS_EDOM, EDOM },
{ FS_ERANGE, ERANGE }, { FS_ERANGE, ERANGE },
{ FS_EPROTOTYPE, EPROTOTYPE }, { FS_EPROTOTYPE, EPROTOTYPE },
@@ -93,13 +97,21 @@ static error_entry sErrors[] = {
{ FS_EDQUOT, EDQUOT }, { FS_EDQUOT, EDQUOT },
{ FS_EIDRM, EIDRM }, { FS_EIDRM, EIDRM },
{ FS_EMULTIHOP, EMULTIHOP }, { FS_EMULTIHOP, EMULTIHOP },
{ FS_ENODATA, ENODATA }, #ifdef ENODATA
{ FS_ENODATA, ENODATA },
#endif
{ FS_ENOLINK, ENOLINK }, { FS_ENOLINK, ENOLINK },
{ FS_ENOSR, ENOSR }, #ifdef ENOSR
{ FS_ENOSTR, ENOSTR }, { FS_ENOSR, ENOSR },
#endif
#ifdef ENOSTR
{ FS_ENOSTR, ENOSTR },
#endif
{ FS_ENOTSUP, ENOTSUP }, { FS_ENOTSUP, ENOTSUP },
{ FS_EPROTO, EPROTO }, { FS_EPROTO, EPROTO },
{ FS_ETIME, ETIME }, #ifdef ETIME
{ FS_ETIME, ETIME },
#endif
{ FS_ETXTBSY, ETXTBSY }, { FS_ETXTBSY, ETXTBSY },
{ FS_ENOMEM, ENOMEM }, { FS_ENOMEM, ENOMEM },
@@ -121,7 +121,8 @@ get_external_command(const char *prompt, char *input, int len)
} }
// get the len of the command // get the len of the command
int commandLen = strnlen(message.command, sizeof(message.command)) + 1; message.command[sizeof(message.command) - 1] = '\0';
int commandLen = strlen(message.command) + 1;
if (commandLen <= 1) { if (commandLen <= 1) {
fprintf(stderr, "No command given.\n"); fprintf(stderr, "No command given.\n");
continue; continue;
@@ -8,7 +8,7 @@ SEARCH_SOURCE
USES_BE_API on <build>makebootable = true ; USES_BE_API on <build>makebootable = true ;
local hostPlatformSources ; local hostPlatformSources ;
if $(HOST_PLATFORM) = linux { if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd {
hostPlatformSources = PartitionMap.cpp PartitionMapParser.cpp ; hostPlatformSources = PartitionMap.cpp PartitionMapParser.cpp ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel