From 80906990e8cb66f024336e71af75896458bd2bc4 Mon Sep 17 00:00:00 2001
From: Gabriele Baldassarre <gabriele@gabrielebaldassarre.com>
Date: Mon, 25 May 2020 23:11:01 +0000
Subject: Added Haiku support to autotools


diff --git a/Makefile.in b/Makefile.in
index c641a4d..10e7832 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -119,7 +119,7 @@ install:	lib${PACKAGE}.a ${INSTALL_DIRS}
 		done
 		/bin/cp fitsio.h fitsio2.h longnam.h drvrsmem.h ${CFITSIO_INCLUDE}
 		/bin/cp cfitsio.pc ${CFITSIO_LIB}/pkgconfig
-		@for task in ${FPACK_UTILS} ${UTILS}; do \
+		@for task in ${FPACK_UTILS}; do \
 		    if [ -f $$task ]; then \
 			if [ ! -d ${CFITSIO_BIN} ]; then mkdir -p ${CFITSIO_BIN}; fi; \
 			echo "/bin/cp $$task ${CFITSIO_BIN}"; \
@@ -135,7 +135,7 @@ UTILS		= cookbook fitscopy imcopy smem speed testprog
 FPACK_UTILS	= fpack funpack
 
 # Optional build target:
-utils:		${FPACK_UTILS} ${UTILS}
+utils:		${FPACK_UTILS}
 
 swapproc.o:	swapproc.c
 		${CC} -c ${CFLAGS} ${CPPFLAGS} ${SSE_FLAGS} ${DEFS} $<
diff --git a/configure.in b/configure.in
index 7d2e003..0df5765 100644
--- a/configure.in
+++ b/configure.in
@@ -151,6 +151,11 @@ case $host in
 	ARCH="hp"
 	EXT="hpu"
 	;;
+    *haiku*)
+  # Haiku can be arm, i386 or x86_64
+  ARCH=`uname -p`
+  EXT="haiku"
+  ;;
     *irix*)
 	ARCH="sgi"
 	EXT="sgi"
@@ -329,6 +334,11 @@ case $host in
         # LDFLAGS used by utilities:
         LDFLAGS_BIN="$LDFLAGS_BIN -Wl,-rpath,\${CFITSIO_LIB}"
 	;;
+    *haiku*)
+        # For large file support:
+        AC_DEFINE(_LARGEFILE_SOURCE)
+        AC_DEFINE(_FILE_OFFSET_BITS,64)
+  ;;
     *mingw32*)
         AC_MSG_CHECKING([for large file support])
         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],
@@ -440,6 +450,11 @@ case $EXT in
     CFITSIO_SHLIB="lib\${PACKAGE}\${SHLIB_SUFFIX}.\${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}"
     CFITSIO_SHLIB_SONAME="lib\${PACKAGE}\${SHLIB_SUFFIX}.\${CFITSIO_SONAME}"
     ;;
+  haiku)
+    SHLIB_LD=":"
+    CFITSIO_SHLIB="lib\${PACKAGE}\${SHLIB_SUFFIX}.\${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}"
+    CFITSIO_SHLIB_SONAME="lib\${PACKAGE}\${SHLIB_SUFFIX}.\${CFITSIO_SONAME}"
+    ;;
   osf)
     SHLIB_LD="ld -shared -expect_unresolved '*'"
     LD_FLAGS="-taso"
-- 
2.30.0

