From 8a78b705e7ce64fac04334f7d1aaaf14760d970d Mon Sep 17 00:00:00 2001
From: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Date: Sun, 18 Apr 2021 12:16:13 +0200
Subject: Haiku support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

changes for version 2021 by jmairboeck

Signed-off-by: Joachim Mairböck <j.mairboeck@gmail.com>

diff --git a/m4/kpse-socket-libs.m4 b/m4/kpse-socket-libs.m4
index c768b95..c291884 100644
--- a/m4/kpse-socket-libs.m4
+++ b/m4/kpse-socket-libs.m4
@@ -20,7 +20,7 @@ AC_DEFUN([KPSE_CHECK_SOCKET_LIBS],
 [AC_REQUIRE([KPSE_CHECK_WIN32])
 AS_IF([test "x$kpse_cv_have_win32" = xno],
       [kpse_save_LIBS=$LIBS
-       AC_SEARCH_LIBS([connect], [socket nsl])
+       AC_SEARCH_LIBS([connect], [socket nsl network])
        LIBS=$kpse_save_LIBS],
       [AC_CHECK_LIB([wsock32], [main],
                     [ac_cv_search_connect=-lwsock32],
diff --git a/texk/dviljk/config.h b/texk/dviljk/config.h
index a92d247..3d9bd99 100644
--- a/texk/dviljk/config.h
+++ b/texk/dviljk/config.h
@@ -10,6 +10,8 @@
 #define unix
 #elif defined (__NetBSD__)
 #define unix
+#elif defined (__HAIKU__)
+#define unix
 #endif
 #endif
 
diff --git a/texk/dvipdfm-x/configure.ac b/texk/dvipdfm-x/configure.ac
index 40afd7c..054611e 100644
--- a/texk/dvipdfm-x/configure.ac
+++ b/texk/dvipdfm-x/configure.ac
@@ -50,6 +50,7 @@ AC_CHECK_SIZEOF([int])
 AC_CHECK_SIZEOF([long])
 
 AC_SEARCH_LIBS([pow], [m])
+AC_SEARCH_LIBS([getpass], [bsd])
 
 KPSE_KPATHSEA_FLAGS
 KPSE_ZLIB_FLAGS
diff --git a/texk/dvipdfm-x/dvipdfmx.c b/texk/dvipdfm-x/dvipdfmx.c
index ec4499c..afe3f31 100644
--- a/texk/dvipdfm-x/dvipdfmx.c
+++ b/texk/dvipdfm-x/dvipdfmx.c
@@ -365,6 +365,9 @@ getpass (const char *prompt)
   return pwd_buf;
 }
 #else  /* !WIN32 */
+#ifdef __HAIKU__
+#define _BSD_SOURCE
+#endif
 #include <unistd.h>
 #endif /* WIN32 */
 
diff --git a/texk/web2c/configure.ac b/texk/web2c/configure.ac
index e90ca38..ca7f8f5 100644
--- a/texk/web2c/configure.ac
+++ b/texk/web2c/configure.ac
@@ -107,9 +107,9 @@ KPSE_LUA52_DEFINES
 KPSE_LUAJIT_DEFINES
 LIBS=$kpse_save_LIBS
 if test "x$kpse_cv_have_win32" = xno; then
-  AC_SEARCH_LIBS([gethostbyname], [nsl])
-  AC_SEARCH_LIBS([hstrerror], [resolv])
-  AC_SEARCH_LIBS([inet_aton], [resolv])
+  AC_SEARCH_LIBS([gethostbyname], [nsl network])
+  AC_SEARCH_LIBS([hstrerror], [resolv bind])
+  AC_SEARCH_LIBS([inet_aton], [resolv bind])
   LIBS=$kpse_save_LIBS
   AC_SEARCH_LIBS([nanosleep], [rt])
   LIBS=$kpse_save_LIBS
-- 
2.30.2


From 4d9bca6d325d71456f1903cc80b3877abe41fcd8 Mon Sep 17 00:00:00 2001
From: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Date: Tue, 2 Jun 2015 09:30:45 +1200
Subject: Don't use the /nonesuch idiom on Haiku.


diff --git a/texk/kpathsea/cnf-to-paths.awk b/texk/kpathsea/cnf-to-paths.awk
index 894f352..a98c5cb 100644
--- a/texk/kpathsea/cnf-to-paths.awk
+++ b/texk/kpathsea/cnf-to-paths.awk
@@ -46,12 +46,9 @@
     # Replace all semicolons with colons in the SELFAUTO paths we're keeping.
     # (The path-splitting code should be changed to understand both.)
     gsub(/;/, ":", val);
-  } else if (val ~ /^\//) {
-    # If the value starts with /, presume we're compiling with changes
-    # made for a distro, and keep it.  Likewise switch to :.
-    gsub(/;/, ":", val);
   } else {
-    val = "/nonesuch";
+    # Just hard-code it on Haiku; it never does the right thing otherwise
+    gsub(/;/, ":", val);
   }
   
   print "#ifndef DEFAULT_" ident;
-- 
2.30.2


From 77986a30c780f2073650d98c95025963220fda96 Mon Sep 17 00:00:00 2001
From: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Date: Tue, 2 Jun 2015 10:16:26 +1200
Subject: Don't allow SELFAUTO* magic on Haiku.


diff --git a/texk/kpathsea/progname.c b/texk/kpathsea/progname.c
index a984eab..4792dea 100644
--- a/texk/kpathsea/progname.c
+++ b/texk/kpathsea/progname.c
@@ -661,6 +661,15 @@ kpathsea_set_program_name (kpathsea kpse,  const_string argv0,
 #endif
   /* SELFAUTODIR is actually the parent of the invocation directory,
      and SELFAUTOPARENT the grandparent.  This is how teTeX did it.  */
+#ifdef __HAIKU__
+  /* The SELFAUTO* variables don't work under a packaged TeX Live installation
+     on Haiku; normally SELFAUTOLOC would be a path like texlive/texmf-dist/bin/platform.
+     Have no idea how this is going to play out... */
+  kpathsea_xputenv (kpse, "SELFAUTOLOC", "/boot/system/bin");
+  kpathsea_xputenv (kpse, "SELFAUTODIR", "/boot/system/data/texlive/texmf-dist");
+  kpathsea_xputenv (kpse, "SELFAUTOPARENT", "/boot/system/data/texlive");
+  kpathsea_xputenv (kpse, "SELFAUTOGRANDPARENT", "/boot/system/data");
+#else
   kpathsea_xputenv (kpse, "SELFAUTOLOC", fix_selfdir (sdir));
   sdir_parent = xdirname (sdir);
   kpathsea_xputenv (kpse, "SELFAUTODIR", fix_selfdir (sdir_parent));
@@ -668,6 +677,7 @@ kpathsea_set_program_name (kpathsea kpse,  const_string argv0,
   kpathsea_xputenv (kpse, "SELFAUTOPARENT", fix_selfdir (sdir_grandparent));
   sdir_greatgrandparent = xdirname (sdir_grandparent);
   kpathsea_xputenv (kpse, "SELFAUTOGRANDPARENT", fix_selfdir (sdir_greatgrandparent));
+#endif
 
 #if defined(WIN32) || defined(__CYGWIN__)
   mk_suffixlist(kpse);
-- 
2.30.2


From 9c6e3297f09142844ed305e4e79265aea77f9b00 Mon Sep 17 00:00:00 2001
From: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Date: Sat, 12 Jun 2021 14:05:19 +0200
Subject: Try and fix up more weirdness with install-tl
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

changes for version 2021 by jmairboeck

Signed-off-by: Joachim Mairböck <j.mairboeck@gmail.com>

diff --git a/texk/texlive/linked_scripts/texlive-extra/texlinks.sh b/texk/texlive/linked_scripts/texlive-extra/texlinks.sh
index 1f0e3c1..e9ec416 100755
--- a/texk/texlive/linked_scripts/texlive-extra/texlinks.sh
+++ b/texk/texlive/linked_scripts/texlive-extra/texlinks.sh
@@ -156,25 +156,36 @@ install_link()
       # context includes wrapper scripts that create/run these.
       verbose_echo "skipped ConTeXtish symlink $src -> $dest (special case)"
       ;;
+    /boot/system/bin/*)
+      # Trying to symlink to ourself
+      verbose_echo "skipped symlinking to self: $src -> $dest (haiku case)"
+      ;;
     *)
-      test "x$src" != "x`(ls -ld $src | awk '{print $NF}') 2>/dev/null`" &&
-        rm -f "$src"
+      case $dest in
+        /boot/system/bin/*)
+          verbose_echo "skipped symlink to bin dir: $src -> $dest (haiku case)"
+          ;;
+	  *)
+        test "x$src" != "x`(ls -ld $src | awk '{print $NF}') 2>/dev/null`" &&
+          rm -f "$src"
   
-      if test -f "$src"; then
-        if $silent; then :; else
-          # i.e., the rm failed.
-          errmsg "install_link $src -> $dest failed: file already exists."
-        fi
-      else
-        if echo "$src" | grep '/pdfcsplain$' >/dev/null; then
-          # at p.olsak insistence: we have three pdfcsplain entries in
-          # fmtutil.cnf with different engines, but the executable link
-          # must point to pdftex.
-          verbose_echo "forcing pdfcsplain destination to be pdftex"
-          dest=pdftex$exeext
+        if test -f "$src"; then
+          if $silent; then :; else
+            # i.e., the rm failed.
+            errmsg "install_link $src -> $dest failed: file already exists."
+          fi
+        else
+          if echo "$src" | grep '/pdfcsplain$' >/dev/null; then
+            # at p.olsak insistence: we have three pdfcsplain entries in
+            # fmtutil.cnf with different engines, but the executable link
+            # must point to pdftex.
+            verbose_echo "forcing pdfcsplain destination to be pdftex"
+            dest=pdftex$exeext
+          fi
+          verbose_do ln -s "$dest" "$src"
         fi
-        verbose_do ln -s "$dest" "$src"
-      fi
+        ;;
+      esac
       ;;
    esac
 }
-- 
2.30.2

