From 81a2cd7aaed73278f7a879b394689dab93557c71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Wed, 20 Mar 2024 01:55:06 -0400
Subject: [PATCH] Support MacPorts locations as well.

Search in both /usr/local (Homebrew) and /opt/local (MacPorts) for
libraries.

Also, have the name of GNU make be an in option in CI so we can use
the Apple-provided make.
---
 .gitlab-ci-unix.yml                  | 48 +++++++++++++++-------------
 .gitlab-ci.yml                       |  1 +
 3rdp/build/js-darwin-configure.patch | 21 ++++++++----
 src/sbbs3/GNUmakefile                |  4 +--
 4 files changed, 43 insertions(+), 31 deletions(-)

diff --git a/.gitlab-ci-unix.yml b/.gitlab-ci-unix.yml
index a4f837aebf..33e1594251 100644
--- a/.gitlab-ci-unix.yml
+++ b/.gitlab-ci-unix.yml
@@ -17,6 +17,8 @@ spec:
       default: 'yes'
     has_gtk:
       default: 'no'
+    gnu_make:
+      default: 'gmake'
 ---
 
 ".$[[ inputs.os ]]":
@@ -38,7 +40,7 @@ spec:
   script:
     - cd 3rdp/build
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS libmozjs
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS libmozjs
   artifacts:
     expire_in: 30 mins
     name: "spidermonkey-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -55,7 +57,7 @@ spec:
   script:
     - cd 3rdp/build
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS cryptlib
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS cryptlib
   artifacts:
     expire_in: 30 mins
     name: "cryptlib-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -68,7 +70,7 @@ spec:
   script:
     - cd src/xpdev
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     expire_in: 30 mins
     name: "xpdev-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -82,7 +84,7 @@ spec:
   script:
     - cd src/encode
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     expire_in: 30 mins
     name: "encode-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -96,7 +98,7 @@ spec:
   script:
     - cd src/hash
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     expire_in: 30 mins
     name: "hash-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -110,7 +112,7 @@ spec:
   script:
     - cd src/conio
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     expire_in: 30 mins
     name: "ciolib-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -124,7 +126,7 @@ spec:
   script:
     - cd src/sftp
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     expire_in: 30 mins
     name: "sftp-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -138,7 +140,7 @@ spec:
   script:
     - cd src/smblib
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     expire_in: 30 mins
     name: "smblib-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -152,7 +154,7 @@ spec:
   script:
     - cd src/uifc
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     expire_in: 30 mins
     name: "uifc-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -166,7 +168,7 @@ spec:
   script:
     - cd src/sbbs3
     - touch depend
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS gitinfo
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS gitinfo
   artifacts:
     expire_in: 30 mins
     name: "gitinfo-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -188,7 +190,7 @@ spec:
     - touch uifc
     - touch uifc-mt
     - touch cl
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS GIT=NO
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS GIT=NO
   artifacts:
     expire_in: 30 mins
     name: "scfg-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -219,7 +221,7 @@ spec:
     - touch ciolib-mt
     - touch uifc
     - touch uifc-mt
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS GIT=NO
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS GIT=NO
   artifacts:
     expire_in: 30 mins
     name: "uedit-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -253,7 +255,7 @@ spec:
     - touch ciolib-mt
     - touch uifc
     - touch uifc-mt
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     expire_in: 30 mins
     name: "umonitor-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -283,7 +285,7 @@ spec:
     - touch ciolib-mt
     - touch uifc
     - touch uifc-mt
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS GIT=NO standalone-utils
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS GIT=NO standalone-utils
   artifacts:
     expire_in: 30 mins
     name: "utils-$[[ inputs.os ]]-$[[ inputs.platform ]]"
@@ -332,8 +334,8 @@ spec:
     - touch umonitor/uifc-mt
     - touch umonitor/xpdev-mt
     - touch umonitor/smblib
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS GIT=NO all
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS jsdoor
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS GIT=NO all
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS jsdoor
   artifacts:
     name: "sbbs-$[[ inputs.os ]]-$[[ inputs.platform ]]"
     paths:
@@ -377,7 +379,7 @@ spec:
     - touch uifc-mt
     - touch sftp-mt
     - touch cl
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     name: "syncterm-$[[ inputs.os ]]-$[[ inputs.platform ]]"
     paths:
@@ -400,7 +402,7 @@ spec:
     - touch xpdev
     - touch xpdev-mt
     - touch ciolib-mt
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     name: "syncdraw-$[[ inputs.os ]]-$[[ inputs.platform ]]"
     paths:
@@ -417,7 +419,7 @@ spec:
     - touch depend
     - touch xpdev
     - touch xpdev-mt
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     name: "sexpots-$[[ inputs.os ]]-$[[ inputs.platform ]]"
     paths:
@@ -436,7 +438,7 @@ spec:
     - touch encode
     - touch hash
     - touch smblib
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     name: "gtkchat-$[[ inputs.os ]]-$[[ inputs.platform ]]"
     paths:
@@ -462,7 +464,7 @@ spec:
     - touch smblib
     - touch cl
     - touch js
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     name: "gtkmonitor-$[[ inputs.os ]]-$[[ inputs.platform ]]"
     paths:
@@ -489,7 +491,7 @@ spec:
     - touch smblib
     - touch cl
     - touch js
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     name: "gtkuseredit-$[[ inputs.os ]]-$[[ inputs.platform ]]"
     paths:
@@ -515,7 +517,7 @@ spec:
     - touch xpdev-mt
     - touch smblib
     - touch cl
-    - gmake $[[ inputs.build_flags ]] $BUILD_ARGS
+    - $[[ inputs.gnu_make ]] $[[ inputs.build_flags ]] $BUILD_ARGS
   artifacts:
     name: "gtkuserlist-$[[ inputs.os ]]-$[[ inputs.platform ]]"
     paths:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0d58925869..ab18c1d34a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -63,6 +63,7 @@ include:
       os: 'darwin'
       platform: 'x86'
       tagname: 'macOS'
+      gnu_make: 'make'
 
 smoketest-jsexec-linux:
   tags: [Linux]
diff --git a/3rdp/build/js-darwin-configure.patch b/3rdp/build/js-darwin-configure.patch
index 20b07b5e43..9094f445db 100644
--- a/3rdp/build/js-darwin-configure.patch
+++ b/3rdp/build/js-darwin-configure.patch
@@ -1,6 +1,6 @@
---- js-1.8.5/js/src/configure.orig	2024-03-16 21:46:17
-+++ js-1.8.5/js/src/configure	2024-03-16 21:47:48
-@@ -953,8 +953,8 @@
+--- js-1.8.5/js/src/configure.in.orig	2024-03-16 23:06:25
++++ js-1.8.5/js/src/configure.in	2024-03-16 23:06:47
+@@ -196,8 +196,8 @@
      if test -z "$MIDL"; then MIDL=midl; fi
      ;;
  *-darwin*)
@@ -11,9 +11,9 @@
      ;;
  esac
  fi
---- js-1.8.5/js/src/configure.in.orig	2024-03-16 23:06:25
-+++ js-1.8.5/js/src/configure.in	2024-03-16 23:06:47
-@@ -196,8 +196,8 @@
+--- js-1.8.5/js/src/configure.orig	2024-03-20 01:29:39
++++ js-1.8.5/js/src/configure	2024-03-20 01:30:55
+@@ -953,8 +953,8 @@
      if test -z "$MIDL"; then MIDL=midl; fi
      ;;
  *-darwin*)
@@ -24,3 +24,12 @@
      ;;
  esac
  fi
+@@ -3873,7 +3873,7 @@
+     echo "$ac_t""yes" 1>&6    
+ fi
+ 
+-  for ac_prog in $PYTHON python2.7 python2.6 python2.5 python
++  for ac_prog in $PYTHON python2.7 python2.6 python2.5 python python3
+ do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
diff --git a/src/sbbs3/GNUmakefile b/src/sbbs3/GNUmakefile
index 2377f3e197..5982cc3fa3 100644
--- a/src/sbbs3/GNUmakefile
+++ b/src/sbbs3/GNUmakefile
@@ -109,8 +109,8 @@ ifeq ($(shell pkg-config libarchive --exists && echo "yes"),yes)
  FILE_LIBS	= $(shell pkg-config libarchive --libs)
 else
  ifeq ($(os), darwin)
-  CFLAGS += -I/usr/local/opt/libarchive/include
-  LDFLAGS += -L/usr/local/opt/libarchive/lib
+  CFLAGS += -I/usr/local/opt/libarchive/include -I/opt/local/include
+  LDFLAGS += -L/usr/local/opt/libarchive/lib -I/opt/local/lib
  endif
  FILE_LIBS	= -larchive
 endif
-- 
GitLab