From a5cc6167a1fc7195f43828613970826658fc35f8 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Tue, 14 Oct 2014 14:42:10 +0200
Subject: Make build script work on haiku

* Compiler default output is not a.out
* Include dir is not /usr/include

diff --git a/build b/build
index 647373d..d00cbf9 100755
--- a/build
+++ b/build
@@ -275,9 +275,9 @@ do
 		CCOPT='-O'
 		LBOPT=
 		EXTRA=
-		[ -f /usr/include/sys/dir.h ] && { SYSDIR=yes; }
-		[ -f /usr/include/dirent.h ] && { DIRENT=yes; }
-		[ -f /usr/include/utime.h ] && { UTIME_H=yes; }
+		[ -f `finddir B_SYSTEM_HEADERS_DIRECTORY`/posix/sys/dir.h ] && { SYSDIR=yes; }
+		[ -f `finddir B_SYSTEM_HEADERS_DIRECTORY`/posix/dirent.h ] && { DIRENT=yes; }
+		[ -f `finddir B_SYSTEM_HEADERS_DIRECTORY`/posix/utime.h ] && { UTIME_H=yes; }
 		[ -d /usr/local/bin ] && { BINDIR=/usr/local/bin; }
 		[ -d /usr/local/man ] && { BINDIR=/usr/local/man/man1; }
 		[ -f /usr/bin/compress ] && { BINDIR=/usr/bin; }
@@ -322,7 +322,7 @@ do
 				return 0;
 			}
 !
-		${CC} /tmp/sh$$.c && IBUFSIZ=`./a.out`
+		${CC} -o a.out /tmp/sh$$.c && IBUFSIZ=`./a.out`
 		rm -f /tmp/sh$$.c a.out
 		OBUFSIZ=${IBUFSIZ}
 		echo "${IBUFSIZ}"
@@ -339,7 +339,7 @@ do
 				return 0;
 			}
 !
-		${CC} /tmp/sh$$.c && BYTEORDER=`./a.out`
+		${CC} -o a.out /tmp/sh$$.c && BYTEORDER=`./a.out`
 		BYTEORDER="${BYTEORDER:-0000}"
 		echo ${BYTEORDER}
 		rm -f /tmp/sh$$.c a.out
@@ -374,7 +374,7 @@ do
 				return 0;
 			}
 !
-		${CC} /tmp/sh$$.c && NOALLIGN=`( ./a.out ) 2>/dev/null`
+		${CC} -o a.out /tmp/sh$$.c && NOALLIGN=`( ./a.out ) 2>/dev/null`
 		NOALLIGN="${NOALLIGN:-yes}"
 		echo ${NOALLIGN}
 		rm -f /tmp/sh$$.c a.out core
@@ -410,7 +410,7 @@ do
 				exit(0);
 			}
 !
-		cc /tmp/sh$$.c && REGISTERS=`./a.out`
+		cc -o a.out /tmp/sh$$.c && REGISTERS=`./a.out`
 		REGISTERS=${REGISTERS:-2};
 		echo ${REGISTERS}
 		rm -f a.out /tmp/sh$$.c
@@ -424,7 +424,7 @@ do
 				return	errno;
 			}
 !
-		if cc /tmp/sh$$.c
+		if cc -o a.out /tmp/sh$$.c
 		then
 			echo "Yes"
 		else
@@ -443,11 +443,11 @@ do
 			}
 !
 		LSTAT=no
-		${CC} /tmp/sh$$.c >/dev/null 2>&1 && LSTAT=yes
+		${CC} -o a.out /tmp/sh$$.c >/dev/null 2>&1 && LSTAT=yes
 		echo "${LSTAT}"
 		rm -f a.out /tmp/sh$$.c
 
-		echo ${n} "Test availble memory${c}"
+		echo ${n} "Test available memory${c}"
 		for size in 75000 130000 230000 440000 800000
 		do
 			cat >/tmp/sh$$.c <<!
@@ -477,14 +477,14 @@ do
 					return 0;
 				}
 !
-			${CC} /tmp/sh$$.c >/dev/null 2>&1 || break
+			${CC} -o a.out /tmp/sh$$.c >/dev/null 2>&1 || break
 			./a.out || break
 			rm a.out /tmp/sh$$.c
 			USERMEM=${size}
 			echo ${n} " ${size}${c}"
 		done
 
-		rm a.out /tmp/sh$$.c
+		rm -f a.out /tmp/sh$$.c
 
 		echo ""
 
@@ -509,7 +509,7 @@ do
 			main() {return 0;}
 !
 			rm -f ./a.out
-			if ${CC} /tmp/sh$$.c >/dev/null 2>&1 
+			if ${CC} -o a.out /tmp/sh$$.c >/dev/null 2>&1 
 			then
 				:
 			else
-- 
1.8.3.4

