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

View File

@ -294,7 +294,7 @@ HOST_UNARFLAGS ?= x ;
# check the host platform compatibility
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
if $(LEX) = lex {
LEX = flex ;
@ -422,6 +422,11 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
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
# build platform we need to make sure, this is also defined.
if $(HOST_CPU) = x86 {
@ -449,7 +454,7 @@ if $(METROWERKS) {
HOST_BE_API_HEADERS = ;
HOST_BE_API_CCFLAGS = ;
HOST_BE_API_C++FLAGS = ;
if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
HOST_BE_API_HEADERS =
[ FDirName $(HAIKU_TOP) headers build ]
@ -465,6 +470,10 @@ if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
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 -
@ -655,7 +664,7 @@ CC = bad-cc ;
C++ = bad-c++ ;
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:
C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ;
# Same for buggy find_directory threadsafety fixes

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);
// 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
// we can abuse this flag for our purposes (we filter it in libroot).
#ifndef O_NOTRAVERSE

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

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

View File

@ -1,158 +1,166 @@
#define BUILDING_HAIKU_ERROR_MAPPER 1
#include <BeOSBuildCompatibility.h>
#include <errno.h>
#include <string.h>
#include <map>
using namespace std;
static map<int, int> sToHaikuErrorMap;
static map<int, int> sToHostErrorMap;
static bool sErrorMapsInitialized = false;
// init_error_map
static void
init_error_map()
{
if (sErrorMapsInitialized)
return;
#define ADD_ERROR(error) \
sToHaikuErrorMap[error] = HAIKU_##error; \
sToHostErrorMap[HAIKU_##error] = error;
ADD_ERROR(E2BIG);
ADD_ERROR(ECHILD);
ADD_ERROR(EDEADLK);
ADD_ERROR(EFBIG);
ADD_ERROR(EMLINK);
ADD_ERROR(ENFILE);
ADD_ERROR(ENODEV);
ADD_ERROR(ENOLCK);
ADD_ERROR(ENOSYS);
ADD_ERROR(ENOTTY);
ADD_ERROR(ENXIO);
ADD_ERROR(ESPIPE);
ADD_ERROR(ESRCH);
#ifdef EFPOS
ADD_ERROR(EFPOS);
#endif
#ifdef ESIGPARM
ADD_ERROR(ESIGPARM);
#endif
ADD_ERROR(EDOM);
ADD_ERROR(ERANGE);
ADD_ERROR(EPROTOTYPE);
ADD_ERROR(EPROTONOSUPPORT);
ADD_ERROR(EPFNOSUPPORT);
ADD_ERROR(EAFNOSUPPORT);
ADD_ERROR(EADDRINUSE);
ADD_ERROR(EADDRNOTAVAIL);
ADD_ERROR(ENETDOWN);
ADD_ERROR(ENETUNREACH);
ADD_ERROR(ENETRESET);
ADD_ERROR(ECONNABORTED);
ADD_ERROR(ECONNRESET);
ADD_ERROR(EISCONN);
ADD_ERROR(ENOTCONN);
ADD_ERROR(ESHUTDOWN);
ADD_ERROR(ECONNREFUSED);
ADD_ERROR(EHOSTUNREACH);
ADD_ERROR(ENOPROTOOPT);
ADD_ERROR(ENOBUFS);
ADD_ERROR(EINPROGRESS);
ADD_ERROR(EALREADY);
ADD_ERROR(EILSEQ);
ADD_ERROR(ENOMSG);
ADD_ERROR(ESTALE);
ADD_ERROR(EOVERFLOW);
ADD_ERROR(EMSGSIZE);
ADD_ERROR(EOPNOTSUPP);
ADD_ERROR(ENOTSOCK);
ADD_ERROR(EHOSTDOWN);
ADD_ERROR(EBADMSG);
ADD_ERROR(ECANCELED);
ADD_ERROR(EDESTADDRREQ);
ADD_ERROR(EDQUOT);
ADD_ERROR(EIDRM);
ADD_ERROR(EMULTIHOP);
ADD_ERROR(ENODATA);
ADD_ERROR(ENOLINK);
ADD_ERROR(ENOSR);
ADD_ERROR(ENOSTR);
ADD_ERROR(ENOTSUP);
ADD_ERROR(EPROTO);
ADD_ERROR(ETIME);
ADD_ERROR(ETXTBSY);
ADD_ERROR(ENOMEM);
ADD_ERROR(EACCES);
ADD_ERROR(EINTR);
ADD_ERROR(EIO);
ADD_ERROR(EBUSY);
ADD_ERROR(EFAULT);
ADD_ERROR(ETIMEDOUT);
ADD_ERROR(EAGAIN);
ADD_ERROR(EWOULDBLOCK);
ADD_ERROR(EBADF);
ADD_ERROR(EEXIST);
ADD_ERROR(EINVAL);
ADD_ERROR(ENAMETOOLONG);
ADD_ERROR(ENOENT);
ADD_ERROR(EPERM);
ADD_ERROR(ENOTDIR);
ADD_ERROR(EISDIR);
ADD_ERROR(ENOTEMPTY);
ADD_ERROR(ENOSPC);
ADD_ERROR(EROFS);
ADD_ERROR(EMFILE);
ADD_ERROR(EXDEV);
ADD_ERROR(ELOOP);
ADD_ERROR(ENOEXEC);
ADD_ERROR(EPIPE);
sErrorMapsInitialized = true;
}
// to_host_error
static int
to_host_error(int error)
{
init_error_map();
map<int, int>::iterator it = sToHostErrorMap.find(error);
return (it != sToHostErrorMap.end() ? it->second : error);
}
// to_haiku_error
static int
to_haiku_error(int error)
{
init_error_map();
map<int, int>::iterator it = sToHaikuErrorMap.find(error);
if (it != sToHaikuErrorMap.end())
return it->second;
return (error > 0 ? -error : error);
}
// _haiku_build_strerror
char *
_haiku_build_strerror(int errnum)
{
return strerror(to_host_error(errnum));
}
// _haiku_build_errno
int *
_haiku_build_errno()
{
static int localErrno = 0;
localErrno = to_haiku_error(errno);
return &localErrno;
}
#define BUILDING_HAIKU_ERROR_MAPPER 1
#include <BeOSBuildCompatibility.h>
#include <errno.h>
#include <string.h>
#include <map>
using namespace std;
static map<int, int> sToHaikuErrorMap;
static map<int, int> sToHostErrorMap;
static bool sErrorMapsInitialized = false;
// init_error_map
static void
init_error_map()
{
if (sErrorMapsInitialized)
return;
#define ADD_ERROR(error) \
sToHaikuErrorMap[error] = HAIKU_##error; \
sToHostErrorMap[HAIKU_##error] = error;
ADD_ERROR(E2BIG);
ADD_ERROR(ECHILD);
ADD_ERROR(EDEADLK);
ADD_ERROR(EFBIG);
ADD_ERROR(EMLINK);
ADD_ERROR(ENFILE);
ADD_ERROR(ENODEV);
ADD_ERROR(ENOLCK);
ADD_ERROR(ENOSYS);
ADD_ERROR(ENOTTY);
ADD_ERROR(ENXIO);
ADD_ERROR(ESPIPE);
ADD_ERROR(ESRCH);
#ifdef EFPOS
ADD_ERROR(EFPOS);
#endif
#ifdef ESIGPARM
ADD_ERROR(ESIGPARM);
#endif
ADD_ERROR(EDOM);
ADD_ERROR(ERANGE);
ADD_ERROR(EPROTOTYPE);
ADD_ERROR(EPROTONOSUPPORT);
ADD_ERROR(EPFNOSUPPORT);
ADD_ERROR(EAFNOSUPPORT);
ADD_ERROR(EADDRINUSE);
ADD_ERROR(EADDRNOTAVAIL);
ADD_ERROR(ENETDOWN);
ADD_ERROR(ENETUNREACH);
ADD_ERROR(ENETRESET);
ADD_ERROR(ECONNABORTED);
ADD_ERROR(ECONNRESET);
ADD_ERROR(EISCONN);
ADD_ERROR(ENOTCONN);
ADD_ERROR(ESHUTDOWN);
ADD_ERROR(ECONNREFUSED);
ADD_ERROR(EHOSTUNREACH);
ADD_ERROR(ENOPROTOOPT);
ADD_ERROR(ENOBUFS);
ADD_ERROR(EINPROGRESS);
ADD_ERROR(EALREADY);
ADD_ERROR(EILSEQ);
ADD_ERROR(ENOMSG);
ADD_ERROR(ESTALE);
ADD_ERROR(EOVERFLOW);
ADD_ERROR(EMSGSIZE);
ADD_ERROR(EOPNOTSUPP);
ADD_ERROR(ENOTSOCK);
ADD_ERROR(EHOSTDOWN);
ADD_ERROR(EBADMSG);
ADD_ERROR(ECANCELED);
ADD_ERROR(EDESTADDRREQ);
ADD_ERROR(EDQUOT);
ADD_ERROR(EIDRM);
ADD_ERROR(EMULTIHOP);
#ifdef ENODATA
ADD_ERROR(ENODATA);
#endif
ADD_ERROR(ENOLINK);
#ifdef ENOSR
ADD_ERROR(ENOSR);
#endif
#ifdef ENOSTR
ADD_ERROR(ENOSTR);
#endif
ADD_ERROR(ENOTSUP);
ADD_ERROR(EPROTO);
#ifdef ETIME
ADD_ERROR(ETIME);
#endif
ADD_ERROR(ETXTBSY);
ADD_ERROR(ENOMEM);
ADD_ERROR(EACCES);
ADD_ERROR(EINTR);
ADD_ERROR(EIO);
ADD_ERROR(EBUSY);
ADD_ERROR(EFAULT);
ADD_ERROR(ETIMEDOUT);
ADD_ERROR(EAGAIN);
ADD_ERROR(EWOULDBLOCK);
ADD_ERROR(EBADF);
ADD_ERROR(EEXIST);
ADD_ERROR(EINVAL);
ADD_ERROR(ENAMETOOLONG);
ADD_ERROR(ENOENT);
ADD_ERROR(EPERM);
ADD_ERROR(ENOTDIR);
ADD_ERROR(EISDIR);
ADD_ERROR(ENOTEMPTY);
ADD_ERROR(ENOSPC);
ADD_ERROR(EROFS);
ADD_ERROR(EMFILE);
ADD_ERROR(EXDEV);
ADD_ERROR(ELOOP);
ADD_ERROR(ENOEXEC);
ADD_ERROR(EPIPE);
sErrorMapsInitialized = true;
}
// to_host_error
static int
to_host_error(int error)
{
init_error_map();
map<int, int>::iterator it = sToHostErrorMap.find(error);
return (it != sToHostErrorMap.end() ? it->second : error);
}
// to_haiku_error
static int
to_haiku_error(int error)
{
init_error_map();
map<int, int>::iterator it = sToHaikuErrorMap.find(error);
if (it != sToHaikuErrorMap.end())
return it->second;
return (error > 0 ? -error : error);
}
// _haiku_build_strerror
char *
_haiku_build_strerror(int errnum)
{
return strerror(to_host_error(errnum));
}
// _haiku_build_errno
int *
_haiku_build_errno()
{
static int localErrno = 0;
localErrno = to_haiku_error(errno);
return &localErrno;
}

View File

@ -15,7 +15,7 @@ rule ISAPnPHeaderGen
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 ;
@ -33,7 +33,7 @@ rule USBHeaderGen
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 ;
@ -51,7 +51,7 @@ rule PCIHeaderGen
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 ;

View File

@ -6,7 +6,7 @@
and some versions of Unix). To further avoid complications I've also
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
NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED.
@ -14,8 +14,8 @@
Dominic Giampaolo
dbg@be.com
*/
*/
#ifndef _COMPAT_H
#define _COMPAT_H
@ -51,6 +51,19 @@ typedef struct iovec iovec;
# include <image.h> /* for a few typedefs */
# include <Drivers.h> /* for various ioctl structs, etc */
# 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
# include <sys/uio.h>
# include <image.h> /* for a few typedefs */

View File

@ -55,8 +55,12 @@ static error_entry sErrors[] = {
{ FS_ENXIO, ENXIO },
{ FS_ESPIPE, ESPIPE },
{ FS_ESRCH, ESRCH },
// { FS_EFPOS, EFPOS },
// { FS_ESIGPARM, ESIGPARM },
#ifdef EFPOS
{ FS_EFPOS, EFPOS },
#endif
#ifdef ESIGPARM
{ FS_ESIGPARM, ESIGPARM },
#endif
{ FS_EDOM, EDOM },
{ FS_ERANGE, ERANGE },
{ FS_EPROTOTYPE, EPROTOTYPE },
@ -93,13 +97,21 @@ static error_entry sErrors[] = {
{ FS_EDQUOT, EDQUOT },
{ FS_EIDRM, EIDRM },
{ FS_EMULTIHOP, EMULTIHOP },
{ FS_ENODATA, ENODATA },
#ifdef ENODATA
{ FS_ENODATA, ENODATA },
#endif
{ FS_ENOLINK, ENOLINK },
{ FS_ENOSR, ENOSR },
{ FS_ENOSTR, ENOSTR },
#ifdef ENOSR
{ FS_ENOSR, ENOSR },
#endif
#ifdef ENOSTR
{ FS_ENOSTR, ENOSTR },
#endif
{ FS_ENOTSUP, ENOTSUP },
{ FS_EPROTO, EPROTO },
{ FS_ETIME, ETIME },
#ifdef ETIME
{ FS_ETIME, ETIME },
#endif
{ FS_ETXTBSY, ETXTBSY },
{ FS_ENOMEM, ENOMEM },

View File

@ -121,7 +121,8 @@ get_external_command(const char *prompt, char *input, int len)
}
// 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) {
fprintf(stderr, "No command given.\n");
continue;

View File

@ -8,7 +8,7 @@ SEARCH_SOURCE
USES_BE_API on <build>makebootable = true ;
local hostPlatformSources ;
if $(HOST_PLATFORM) = linux {
if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd {
hostPlatformSources = PartitionMap.cpp PartitionMapParser.cpp ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel