Skip to content

Commit

Permalink
Merge pull request rebol#53 from hostilefork/haiku-os-build
Browse files Browse the repository at this point in the history
Minor changes to build process for HaikuOS (POSIX binding, of course)
  • Loading branch information
carls committed Dec 27, 2012
2 parents 3a1b847 + 2218278 commit 553ccb3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
13 changes: 13 additions & 0 deletions src/include/reb-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,14 @@ These are now obsolete (as of A107) and should be removed:
#define AGG_FREETYPE //use freetype2 library for fonts by default
#define FINITE finite
#define INLINE

#ifndef TO_HAIKU
// Unsupported by gcc 2.95.3-haiku-121101
#define API_EXPORT __attribute__((visibility("default")))
#else
#define API_EXPORT
#endif

#define API_IMPORT
#endif

Expand All @@ -162,6 +169,12 @@ These are now obsolete (as of A107) and should be removed:
#define HAS_LONG_DOUBLE
#endif

#ifdef TO_HAIKU // same as Linux/Intel seems to work
#define ENDIAN_LITTLE
#define HAS_LONG_DOUBLE
#define HAS_LOG10L
#endif

#ifdef TO_OSXI // OSX/Intel
#define ENDIAN_LITTLE
#define HAS_ECVT
Expand Down
29 changes: 29 additions & 0 deletions src/os/posix/dev-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,31 @@
**
***********************************************************************/

#ifndef DT_DIR
// dirent.d_type is a BSD extension, actually not part of POSIX
// reformatted from: http://ports.haiku-files.org/wiki/CommonProblems
static int Is_Dir(const char *path, const char *name)
{
int len1 = strlen(path);
int len2 = strlen(name);
struct stat st;

char pathname[len1 + 1 + len2 + 1 + 13];
strcpy(pathname, path);

/* Avoid UNC-path "//name" on Cygwin. */
if (len1 > 0 && pathname[len1 - 1] != '/')
strcat(pathname, "/");

strcat(pathname, name);

if (stat(pathname, &st))
return 0;

return S_ISDIR(st.st_mode);
}
#endif

static REBOOL Seek_File_64(REBREQ *file)
{
// Performs seek and updates index value. TRUE on success.
Expand Down Expand Up @@ -197,12 +222,16 @@ static int Get_File_Info(REBREQ *file)
file->modes = 0;
COPY_BYTES(file->file.path, cp, MAX_FILE_NAME);

#ifdef DT_DIR
// NOTE: not all posix filesystems support this (mainly
// the Linux and BSD support it.) If this fails to build, a
// different mechanism must be used. However, this is the
// most efficient, because it does not require a separate
// file system call for determining directories.
if (d->d_type == DT_DIR) SET_FLAG(file->modes, RFM_DIR);
#else
if (Is_Dir(dir->file.path, file->file.path)) SET_FLAG(file->modes, RFM_DIR);
#endif

// Line below DOES NOT WORK -- because we need full path.
//Get_File_Info(file); // updates modes, size, time
Expand Down
2 changes: 1 addition & 1 deletion src/tools/make-make.r
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ RLIB_FLAGS=
# Flags for core and for host:
RFLAGS= -c -D$(TO_OS) -DREB_API $(RAPI_FLAGS) $I
HFLAGS= -c -D$(TO_OS) -DREB_CORE $(HOST_FLAGS) $I
CLIB= -lm
CLIB=
# REBOL builds various include files:
REBOL= $(CD)r3-make -qs
Expand Down
27 changes: 15 additions & 12 deletions src/tools/systems.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ REBOL [

systems: [
[plat os-name os-base build-flags]
[0.1.03 "amiga" posix [HID NPS +SC CMT COP -SP]]
[0.2.04 "osx" posix [+OS NCM]] ; no shared lib possible
[0.2.05 "osxi" posix [ARC +O1 NPS PIC NCM HID STX]]
[0.3.01 "win32" win32 [+O2 UNI W32 WIN S4M EXE DIR]]
[0.4.02 "linux" posix [+O2 LDL ST1]] ; libc 2.3
[0.4.03 "linux" posix [+O2 HID LDL ST1]] ; libc 2.5
[0.4.04 "linux" posix [+O2 HID LDL ST1 M32]] ; libc 2.11
[0.4.10 "linux_ppc" posix [+O1 HID LDL ST1]]
[0.4.20 "linux_arm" posix [+O2 HID LDL ST1]]
[0.4.30 "linux_mips" posix [+O2 HID LDL ST1]] ; glibc does not need C++
[0.7.02 "freebsd" posix [+O1 C++ ST1]]
[0.9.04 "openbsd" posix [+O1 C++ ST1]]
[0.1.03 "amiga" posix [HID NPS +SC CMT COP -SP -LM]]
[0.2.04 "osx" posix [+OS NCM -LM]] ; no shared lib possible
[0.2.05 "osxi" posix [ARC +O1 NPS PIC NCM HID STX -LM]]
[0.3.01 "win32" win32 [+O2 UNI W32 WIN S4M EXE DIR -LM]]
[0.4.02 "linux" posix [+O2 LDL ST1 -LM]] ; libc 2.3
[0.4.03 "linux" posix [+O2 HID LDL ST1 -LM]] ; libc 2.5
[0.4.04 "linux" posix [+O2 HID LDL ST1 M32 -LM]] ; libc 2.11
[0.4.10 "linux_ppc" posix [+O1 HID LDL ST1 -LM]]
[0.4.20 "linux_arm" posix [+O2 HID LDL ST1 -LM]]
[0.4.30 "linux_mips" posix [+O2 HID LDL ST1 -LM]] ; glibc does not need C++
[0.5.75 "haiku" posix [+O2 ST1 NWK]]
[0.7.02 "freebsd" posix [+O1 C++ ST1 -LM]]
[0.9.04 "openbsd" posix [+O1 C++ ST1 -LM]]
]

compile-flags: [
Expand Down Expand Up @@ -61,6 +62,8 @@ linker-flags: [
W32: "-lwsock32 -lcomdlg32"
WIN: "-mwindows"; build as Windows GUI binary
S4M: "-Wl,--stack=4194300"
-LM: "-lm" ; HaikuOS has math in libroot, for instance
NWK: "-lnetwork" ; Needed by HaikuOS
]

other-flags: [
Expand Down

0 comments on commit 553ccb3

Please sign in to comment.