1Index: acinclude.m4 2=================================================================== 3--- acinclude.m4 (revision 7048) 4+++ acinclude.m4 (working copy) 5@@ -206,10 +206,9 @@ 6 dnl AC_CHECK_LIB(m, main, echo) 7 dnl AC_CHECK_LIB(z, main, echo) 8 9- C_LIB=-lc 10+ GB_LIBC() 11 12- AC_SUBST(C_LIB) 13- 14+ dnl ---- Check for C++ libraries 15 AC_CHECK_LIB(gcc_s, main, CXX_LIB="$CXX_LIB -lgcc_s") 16 AC_CHECK_LIB(stdc++, main, CXX_LIB="$CXX_LIB -lstdc++") 17 18@@ -370,6 +369,13 @@ 19 GBX_THREAD_INC="-pthread -D_REENTRANT" 20 GBX_THREAD_LDFLAGS="" 21 ;; 22+ *-*-haiku* ) 23+ THREAD_LIB="" 24+ THREAD_INC="" 25+ GBX_THREAD_LIB="" 26+ GBX_THREAD_INC="" 27+ GBX_THREAD_LDFLAGS="" 28+ ;; 29 *) 30 THREAD_LIB="-lpthread" 31 THREAD_INC="-D_REENTRANT" 32@@ -393,6 +399,30 @@ 33 34 35 ## --------------------------------------------------------------------------- 36+## GB_LIBC 37+## Detect C library 38+## --------------------------------------------------------------------------- 39+ 40+AC_DEFUN([GB_LIBC], 41+[ 42+ case "${host}" in 43+ *-*-haiku* ) 44+ dnl Haiku has implicit C library in libroot. 45+ C_LIB="" 46+ ;; 47+ *) 48+ C_LIB="-lc" 49+ ;; 50+ esac 51+ 52+ AC_MSG_CHECKING(for C library) 53+ AC_MSG_RESULT($C_LIB) 54+ 55+ AC_SUBST(C_LIB) 56+]) 57+ 58+ 59+## --------------------------------------------------------------------------- 60 ## GB_MATH 61 ## Detect mathematic libraries 62 ## --------------------------------------------------------------------------- 63@@ -403,6 +433,9 @@ 64 *-*-freebsd* ) 65 MATH_LIB="-lm" 66 ;; 67+ *-*-haiku* ) 68+ MATH_LIB="" 69+ ;; 70 *) 71 MATH_LIB="-lm" 72 ;; 73@@ -521,6 +554,12 @@ 74 AC_DEFINE(OS_HURD, 1, [Target system is Hurd]) 75 AC_DEFINE(SYSTEM, "Hurd", [Operating system]) 76 ;; 77+ *-*-haiku* ) 78+ SYSTEM=HAIKU 79+ dnl AC_DEFINE(OS_GNU, 1, [Target system is of GNU family]) 80+ AC_DEFINE(OS_HAIKU, 1, [Target system is Haiku]) 81+ AC_DEFINE(SYSTEM, "Haiku", [Operating system]) 82+ ;; 83 * ) 84 SYSTEM=UNKNOWN 85 AC_DEFINE(SYSTEM, "unknown", [Operating system]) 86@@ -641,6 +680,18 @@ 87 88 gb_sub_dir_list_64=`echo "$gb_sub_dir_list" | sed s/"lib"/"lib64"/g` 89 90+if test $SYSTEM == "HAIKU"; then 91+ gb_arch="`getarch`" 92+ gb_main_dir_list="$gb_main_dir_list `findpaths -c' ' -a "$gb_arch" B_FIND_PATH_DEVELOP_DIRECTORY`" 93+ gb_arch_inc_subdir=headers 94+ gb_arch_lib_subdir=lib 95+ if test "$gb_arch" != "`getarch -p`"; then 96+ gb_arch_inc_subdir="headers/$gb_arch" 97+ gb_arch_lib_subdir="lib/$gb_arch" 98+ fi 99+ gb_sub_dir_list=`echo "$gb_sub_dir_list" | sed "s:include:$gb_arch_inc_subdir:g;s:lib:$gb_arch_lib_subdir:g"` 100+fi 101+ 102 ## if there is 'lib' inside sub-directories, then we decide to search "lib64" first. 103 104 if test "$gb_sub_dir_list_64" != "$gb_sub_dir_list"; then 105Index: gb.net/src/CDnsClient.c 106=================================================================== 107--- gb.net/src/CDnsClient.c (revision 7048) 108+++ gb.net/src/CDnsClient.c (working copy) 109@@ -530,7 +530,7 @@ 110 else 111 { /* Synchronous mode */ 112 inet_aton(THIS->sHostIP,&addr); 113-#ifdef __sun__ 114+#if defined(__sun__) || defined(__HAIKU__) 115 stHost=gethostbyaddr((const char *)&addr,sizeof(addr),AF_INET); 116 #else 117 stHost=gethostbyaddr(&addr,sizeof(addr),AF_INET); 118Index: gb.net/src/CSerialPort.c 119=================================================================== 120--- gb.net/src/CSerialPort.c (revision 7048) 121+++ gb.net/src/CSerialPort.c (working copy) 122@@ -42,6 +42,10 @@ 123 #define TIOCINQ FIONREAD 124 #endif 125 126+#ifndef TIOCM_RNG 127+#define TIOCM_RNG TIOCM_RI 128+#endif 129+ 130 #include "main.h" 131 #include "tools.h" 132 133@@ -646,8 +650,12 @@ 134 135 if (THIS->status) 136 { 137+#ifdef TIOCINQ 138 if (ioctl(THIS->port, TIOCINQ, &ret)) 139 GB.Error("Unable to read input buffer size: &1", strerror(errno)); 140+#else 141+ GB.Error("Unable to read input buffer size: &1", strerror(ENOSYS)); 142+#endif 143 } 144 145 GB.ReturnInteger(ret); 146@@ -660,8 +668,12 @@ 147 148 if (THIS->status) 149 { 150+#ifdef TIOCOUTQ 151 if (ioctl(THIS->port, TIOCOUTQ, &ret)) 152 GB.Error("Unable to read output buffer size: &1", strerror(errno)); 153+#else 154+ GB.Error("Unable to read output buffer size: &1", strerror(ENOSYS)); 155+#endif 156 } 157 158 GB.ReturnInteger(ret); 159Index: gb.net/src/CSocket.c 160=================================================================== 161--- gb.net/src/CSocket.c (revision 7048) 162+++ gb.net/src/CSocket.c (working copy) 163@@ -32,6 +32,7 @@ 164 #include <sys/socket.h> 165 #include <sys/ioctl.h> 166 #include <sys/poll.h> 167+#include <sys/time.h> 168 #include <sys/un.h> 169 #include <netinet/in.h> 170 #include <arpa/inet.h> 171Index: gb.xml/src/element.cpp 172=================================================================== 173--- gb.xml/src/element.cpp (revision 7048) 174+++ gb.xml/src/element.cpp (working copy) 175@@ -19,6 +19,7 @@ 176 177 ***************************************************************************/ 178 179+#define _GNU_SOURCE /* for memrchr() */ 180 #include "element.h" 181 182 #include "node.h" 183Index: gb.xml/src/html/cssfilter.cpp 184=================================================================== 185--- gb.xml/src/html/cssfilter.cpp (revision 7048) 186+++ gb.xml/src/html/cssfilter.cpp (working copy) 187@@ -1,3 +1,4 @@ 188+#define _GNU_SOURCE /* for memrchr() */ 189 #include "cssfilter.h" 190 #include "htmlmain.h" 191 #include "htmlelement.h" 192Index: gb.xml/src/utils.cpp 193=================================================================== 194--- gb.xml/src/utils.cpp (revision 7048) 195+++ gb.xml/src/utils.cpp (working copy) 196@@ -19,6 +19,7 @@ 197 198 ***************************************************************************/ 199 200+#define _GNU_SOURCE /* for memrchr() */ 201 #include "utils.h" 202 #include "gbinterface.h" 203 #include "../gb_common.h" 204Index: main/configure.ac 205=================================================================== 206--- main/configure.ac (revision 7048) 207+++ main/configure.ac (working copy) 208@@ -9,6 +9,14 @@ 209 LT_INIT 210 AM_PROG_CC_C_O 211 212+dnl ---- Check for POSIX.1-2001 calls 213+ 214+AC_CHECK_FUNCS(getpriority setpriority waitpid statvfs) 215+ 216+dnl ---- Haiku needs -lbsd for daemon() 217+ 218+AC_SEARCH_LIBS(daemon, bsd) 219+ 220 dnl ---- Check for internationalization library 221 222 GB_COMPONENT( 223@@ -87,7 +95,7 @@ 224 dnl ---- We do not use libtool to load shared libraries anymore! 225 226 AC_DEFINE(DONT_USE_LTDL, 1, [Do not use libtool to load shared libraries]) 227-if test "$SYSTEM" != "OPENBSD" && test "$SYSTEM" != "FREEBSD"; then 228+if test "$SYSTEM" != "OPENBSD" && test "$SYSTEM" != "FREEBSD" && test "$SYSTEM" != "HAIKU"; then 229 DL_LIB="-ldl" 230 else 231 DL_LIB="" 232Index: main/gbc/gbi.c 233=================================================================== 234--- main/gbc/gbi.c (revision 7048) 235+++ main/gbc/gbi.c (working copy) 236@@ -45,7 +45,7 @@ 237 238 #include <dlfcn.h> 239 240-#if defined(OS_LINUX) || defined(OS_GNU) || defined(OS_OPENBSD) || defined(OS_FREEBSD) || defined(OS_CYGWIN) 241+#if defined(OS_LINUX) || defined(OS_GNU) || defined(OS_OPENBSD) || defined(OS_FREEBSD) || defined(OS_CYGWIN) || defined(OS_HAIKU) 242 #define lt_dlinit() (0) 243 #define lt_dlhandle void * 244 #define lt_dlopenext(_path) dlopen(_path, RTLD_LAZY) 245Index: main/gbx/gbx_c_application.c 246=================================================================== 247--- main/gbx/gbx_c_application.c (revision 7048) 248+++ main/gbx/gbx_c_application.c (working copy) 249@@ -238,8 +238,12 @@ 250 if (!_daemon && VPROP(GB_BOOLEAN)) 251 { 252 old_pid = getpid(); 253+#ifdef HAVE_DAEMON 254 if (daemon(FALSE, FALSE)) 255 THROW_SYSTEM(errno, NULL); 256+#else 257+ THROW_SYSTEM(ENOSYS, NULL); 258+#endif 259 // Argh! daemon() changes the current process id... 260 _daemon = TRUE; 261 init_again(old_pid); 262@@ -257,12 +261,16 @@ 263 264 BEGIN_PROPERTY(Application_Priority) 265 266- int pr; 267+ int pr = -1; 268 269 if (READ_PROPERTY) 270 { 271 errno = 0; 272+#ifdef HAVE_GETPRIORITY 273 pr = getpriority(PRIO_PROCESS, 0); 274+#else 275+ errno = ENOSYS; 276+#endif 277 if (pr == -1 && errno > 0) 278 THROW_SYSTEM(errno, NULL); 279 GB_ReturnInteger(pr); 280@@ -276,8 +284,12 @@ 281 else if (pr > 19) 282 pr = 19; 283 284+#ifdef HAVE_SETPRIORITY 285 if (setpriority(PRIO_PROCESS, 0, VPROP(GB_INTEGER)) < 0) 286 THROW_SYSTEM(errno, NULL); 287+#else 288+ THROW_SYSTEM(ENOSYS, NULL); 289+#endif 290 } 291 292 END_PROPERTY 293Index: main/gbx/gbx_c_process.c 294=================================================================== 295--- main/gbx/gbx_c_process.c (revision 7048) 296+++ main/gbx/gbx_c_process.c (working copy) 297@@ -834,7 +834,11 @@ 298 { 299 int status; 300 301+#ifdef HAVE_WAITPID 302+ if (waitpid(process->pid, &status, WNOHANG) == process->pid) 303+#else 304 if (wait4(process->pid, &status, WNOHANG, NULL) == process->pid) 305+#endif 306 { 307 process->status = status; 308 _last_status = status; 309Index: main/gbx/gbx_c_task.c 310=================================================================== 311--- main/gbx/gbx_c_task.c (revision 7048) 312+++ main/gbx/gbx_c_task.c (working copy) 313@@ -120,7 +120,11 @@ 314 while (_object) 315 { 316 next = THIS->list.next; 317+#ifdef HAVE_WAITPID 318+ if (waitpid(THIS->pid, &status, WNOHANG) == THIS->pid) 319+#else 320 if (wait4(THIS->pid, &status, WNOHANG, NULL) == THIS->pid) 321+#endif 322 { 323 THIS->status = status; 324 stop_task(THIS); 325Index: main/lib/signal/csignal.c 326=================================================================== 327--- main/lib/signal/csignal.c (revision 7048) 328+++ main/lib/signal/csignal.c (working copy) 329@@ -42,7 +42,11 @@ 330 #define SIGPWR -1 331 #endif 332 333-#ifdef OS_CYGWIN 334+#ifndef SIGIO 335+#define SIGIO -1 336+#endif 337+ 338+#if defined(OS_CYGWIN) || defined(OS_HAIKU) 339 #define SIGIOT -1 340 #endif 341 342Index: main/share/gb_file_temp.h 343=================================================================== 344--- main/share/gb_file_temp.h (revision 7048) 345+++ main/share/gb_file_temp.h (working copy) 346@@ -38,7 +38,9 @@ 347 348 #ifdef PROJECT_EXEC 349 350-#if defined(OS_FREEBSD) || defined(OS_OPENBSD) 351+#ifdef HAVE_STATVFS 352+#include <sys/statvfs.h> 353+#elif defined(OS_FREEBSD) || defined(OS_OPENBSD) 354 #include <sys/mount.h> 355 #else 356 #include <sys/statfs.h> 357@@ -1022,12 +1024,20 @@ 358 359 int64_t FILE_free(const char *path) 360 { 361+#ifdef HAVE_STATVFS 362+ struct statvfs info; 363+#else 364 struct statfs info; 365+#endif 366 367 if (FILE_is_relative(path)) 368 return 0; 369 370+#ifdef HAVE_STATVFS 371+ statvfs(path, &info); 372+#else 373 statfs(path, &info); 374+#endif 375 return (int64_t)(getuid() == 0 ? info.f_bfree : info.f_bavail) * info.f_bsize; 376 } 377 378