From 8d1fd936b9fe34ed1ec98fdec9664a4b3082cec5 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Sun, 19 Oct 2014 21:56:48 +0200
Subject: Fix build for Haiku.

This needed more changes than I expected. Maybe an HaikuArchives repo is
a good idea.

diff --git a/PortLib/makefile b/PortLib/makefile
index ec7539e..868f446 100644
--- a/PortLib/makefile
+++ b/PortLib/makefile
@@ -104,5 +104,5 @@ LINKER_FLAGS =
 
 
 ## include the makefile-engine
-include /boot/develop/etc/makefile-engine
+include /system/develop/etc/makefile-engine
 
diff --git a/PortManager/makefile b/PortManager/makefile
index c69746b..fc33940 100644
--- a/PortManager/makefile
+++ b/PortManager/makefile
@@ -59,7 +59,7 @@ LIBS= PortManager be
 #	be recursive, so include all of the paths where libraries can
 #	be found.  Directories where source files are found are
 #	automatically included.
-LIBPATHS= /boot/home/config/lib
+LIBPATHS= /boot/home/config/lib ../PortLib/$(OBJ_DIR)
 
 #	additional paths to look for system headers
 #	thes use the form: #include <header>
@@ -104,5 +104,5 @@ LINKER_FLAGS =
 
 
 ## include the makefile-engine
-include /boot/develop/etc/makefile-engine
+include /system/develop/etc/makefile-engine
 
diff --git a/Squares/makefile b/Squares/makefile
index 53c9741..7212b16 100644
--- a/Squares/makefile
+++ b/Squares/makefile
@@ -59,7 +59,7 @@ LIBS= PortManager be
 #	be recursive, so include all of the paths where libraries can
 #	be found.  Directories where source files are found are
 #	automatically included.
-LIBPATHS= /boot/home/config/lib
+LIBPATHS= /boot/home/config/lib ../PortLib/$(OBJ_DIR)
 
 #	additional paths to look for system headers
 #	thes use the form: #include <header>
@@ -104,5 +104,5 @@ LINKER_FLAGS =
 
 
 ## include the makefile-engine
-include /boot/develop/etc/makefile-engine
+include /system/develop/etc/makefile-engine
 
diff --git a/makefile b/makefile
index 4e144cf..5048dae 100644
--- a/makefile
+++ b/makefile
@@ -14,8 +14,8 @@ all: 		portlib portman squares brexx
 
 portlib:
 		@echo " "
-		@echo "Creating PortManager library, and copying to /boot/home/config/lib"
-		-cd PortLib; make; copyattr -d $(OBJ_DIR)/libPortManager.so /boot/home/config/lib
+		@echo "Creating PortManager library"
+		-cd PortLib; make
 
 
 portman:
@@ -31,15 +31,16 @@ squares:
 brexx:
 		@echo " "
 		@echo "Creating BRexx itself"
-		-cd src; make
+		-cd src; make OBJ_DIR=$(OBJ_DIR)
 
 install:
 		@echo " "
-		@echo "Installing BRexx executables"
+		@echo "Installing BRexx executables and libraries"
 		-kill PortManager
 		-copyattr -d PortManager/$(OBJ_DIR)/PortManager /boot/home/config/bin
 		-copyattr -d Squares/$(OBJ_DIR)/Squares /boot/home/config/bin
 		-copyattr -d src/$(OBJ_DIR)/rx /boot/home/config/bin
+		-copyattr -d PortLib/$(OBJ_DIR)/libPortManager.so /boot/home/config/lib
 
 uninstall:
 		@echo " "
diff --git a/src/PropDump.h b/src/PropDump.h
index ccb003a..388812f 100644
--- a/src/PropDump.h
+++ b/src/PropDump.h
@@ -1,6 +1,7 @@
 #ifndef _propdump_h
 #define _propdump_h
 
+#include <PropertyInfo.h>
 #include <String.h>
 
 enum {
@@ -16,4 +17,4 @@ BString DumpPropInfo(const BPropertyInfo* info, int32 pprint);
 BString GetCommandName(type_code command);
 BString GetSpecName(type_code spec);
 
-#endif /* _propdump_h */
\ No newline at end of file
+#endif /* _propdump_h */
diff --git a/src/be_cmd.cpp b/src/be_cmd.cpp
index d7315fd..898e103 100644
--- a/src/be_cmd.cpp
+++ b/src/be_cmd.cpp
@@ -3,8 +3,6 @@
 *   Commands and functions that apply to BeOS
 *
 **/
-#ifdef __BEOS__
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -358,4 +356,3 @@ char *be_app_list(Lstr *appname, char pad, char listtype)
    return(buff);
 }
 
-#endif
diff --git a/src/be_main.cpp b/src/be_main.cpp
index 8f56d0d..d1a28ea 100644
--- a/src/be_main.cpp
+++ b/src/be_main.cpp
@@ -3,7 +3,6 @@
 *   Commands and functions that apply to BeOS
 *
 **/
-#ifdef __BEOS__
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -484,4 +483,3 @@ void R_closeconsole(args *arg)
    return;
 }
 
-#endif
diff --git a/src/consolebe.cc b/src/consolebe.cc
index 7ab1b42..f6260cd 100644
--- a/src/consolebe.cc
+++ b/src/consolebe.cc
@@ -11,8 +11,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef __BEOS__
-
 #include <AppKit.h>
 #include <InterfaceKit.h>
 #include "consolebe.hh"
@@ -295,4 +293,3 @@ void ConsoleBe::InsertText(const char *text, int32 length, int32 offset, const t
    return;
 }
 
-#endif
diff --git a/src/consolebe.hh b/src/consolebe.hh
index da24682..56cebb1 100644
--- a/src/consolebe.hh
+++ b/src/consolebe.hh
@@ -8,7 +8,6 @@
 #ifndef CONSOLEBE__H
 #define CONSOLEBE__H
 
-#ifdef __BEOS__
 #include <SupportKit.h>
 #include <TextView.h>
 #include <string.h>
@@ -64,4 +63,3 @@ private:
 };
 
 #endif
-#endif
diff --git a/src/consoletty.cc b/src/consoletty.cc
index f5f29a0..a4e680c 100644
--- a/src/consoletty.cc
+++ b/src/consoletty.cc
@@ -57,7 +57,7 @@ void ConsoleTTY::setraw(long wait)
 {
    if (cooked == 0) return;
 
-#ifdef __BEOS__
+#ifdef __HAIKU__
    waitflag = wait;
    struct termios termios;
 
@@ -142,7 +142,7 @@ ConsoleTTY::~ConsoleTTY()
 void ConsoleTTY::setcooked(void)
 {
    if (cooked) return;
-#ifdef __BEOS__
+#ifdef __HAIKU__
    if (fd >= 0) {
       tcsetattr(fd, TCSANOW, &savedsettings);
       if (waitflag == 0) {
@@ -172,7 +172,7 @@ int ConsoleTTY::get_char(void)
 
    if (cooked) return((long) getchar());
 
-#ifndef __BEOS__
+#ifndef __HAIKU__
    if (waitflag == 0) {
       ioctl(fd, FIONREAD, &nbytes);
       if (nbytes <= 0) return(-1);
diff --git a/src/consoletty.hh b/src/consoletty.hh
index 8df54c3..cc01d18 100644
--- a/src/consoletty.hh
+++ b/src/consoletty.hh
@@ -35,7 +35,7 @@ protected:
 private:
    int fd;
 
-#ifndef __BEOS__
+#ifndef __HAIKU__
    sgttyb savedsettings;
 #else
    termios savedsettings;
diff --git a/src/hey.cpp b/src/hey.cpp
index dc29a64..e00dfdc 100644
--- a/src/hey.cpp
+++ b/src/hey.cpp
@@ -34,6 +34,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <AppKit.h>
 #include <Path.h>
 #include "PropDump.h"
diff --git a/src/hey.h b/src/hey.h
index 0711bd7..108da88 100644
--- a/src/hey.h
+++ b/src/hey.h
@@ -1,6 +1,8 @@
 #ifndef HEY_H
 #define HEY_H
 
+#include <Message.h>
+#include <Messenger.h>
 #include <SupportDefs.h>
 
 
diff --git a/src/makefile b/src/makefile
index ebf288a..bfc0b62 100644
--- a/src/makefile
+++ b/src/makefile
@@ -63,7 +63,7 @@ LIBS= PortManager be tracker
 #	be recursive, so include all of the paths where libraries can
 #	be found.  Directories where source files are found are
 #	automatically included.
-LIBPATHS= /boot/home/config/lib
+LIBPATHS= /boot/home/config/lib ../PortLib/obj
 
 #	additional paths to look for system headers
 #	thes use the form: #include <header>
@@ -108,5 +108,5 @@ LINKER_FLAGS =
 
 
 ## include the makefile-engine
-include /boot/develop/etc/makefile-engine
+include /system/develop/etc/makefile-engine
 
diff --git a/src/rexx.c b/src/rexx.c
index 1bfdf25..eb99123 100644
--- a/src/rexx.c
+++ b/src/rexx.c
@@ -220,7 +220,7 @@ void release_everything( void )
 } /* release_everything */
 
 /* -------------------------------------------------------------- */
-#ifdef __BEOS__
+#ifdef __HAIKU__
 int BRexxMain(int argc, char **argv)
 #else
 int main(     int argc, char **argv)
diff --git a/src/rxfiles.c b/src/rxfiles.c
index 5e1e706..933e5a3 100644
--- a/src/rxfiles.c
+++ b/src/rxfiles.c
@@ -12,11 +12,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#ifdef __sun__
 #include <dirent.h>
-#else
-#include <sys/dir.h>
-#endif
 #include <time.h>
 
 #include "rexx.h"
diff --git a/src/utils.c b/src/utils.c
index 004bc10..bd82efa 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -226,7 +226,7 @@ void set_trace( char *str )
 /* ---------------------------------------------------------- */
 Lstr *readline ( Lstr **A)
 {
-#ifdef __BEOS__
+#ifdef __HAIKU__
     extern char *bgetline(char *, long);
     char buff[4096];
     int i, l;
-- 
1.8.3.4

