From 0fc5c76fd8e648c4da769c36dd0c86540c598b45 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Wed, 26 Jul 2023 05:25:18 +0800
Subject: [PATCH] Fix Makefile.inc for Darwin


diff --git src/Makefile.inc src/Makefile.inc
index 6f8cf3e..8ddfd24 100644
--- src/Makefile.inc
+++ src/Makefile.inc
@@ -1,7 +1,7 @@
 # Unix configuration Makefile for Moscow ML          -*- mode: makefile -*-
 
 # Where to install stuff
-PREFIX=/usr/local
+PREFIX=@PREFIX@
 
 # BINDIR contains true executable files, such as scripts
 # LIBDIR contains bytecode files (such as mosmlcmp and library units), and .dll/.so for dynlibs.
@@ -13,13 +13,23 @@ BINDIR=${PREFIX}/bin
 LIBDIR=${PREFIX}/lib/mosml
 INCDIR=${PREFIX}/include/mosml
 DOCDIR=${PREFIX}/share/doc/mosml
-TOOLDIR=${PREFIX}/share/mosml/tools
+TOOLDIR=${PREFIX}/bin
 
 ### Where to install the man pages
 # Man pages for commands go in $(MANDIR)/man$(MANEXT)
 MANDIR=${PREFIX}/man
 MANEXT=1
 
+GMPDIR=@PREFIX@
+GMPINCDIR=${GMPDIR}/include
+GMPLIBDIR=${GMPDIR}/lib
+
+GDINCDIR=@PREFIX@/include
+GDLIBDIR=@PREFIX@/lib
+
+GDBMINCDIR=@PREFIX@/include
+GDBMLIBDIR=@PREFIX@/lib
+
 
 # The version
 VERSION=2.10
@@ -37,7 +47,7 @@ BASELIBS=-lm
 
 # This works with most systems, including MacOS X with XCode installed:
 
-CC=gcc
+CC=@CC@
 # CC=gcc -mmacosx-version-min=10.7 # for building OS X package
 # CC=/usr/sepp/bin/gcc		# Solaris at KVL
 
@@ -72,9 +82,9 @@ ifeq ($(UNAME_S),Linux)
 	DYNLD=gcc -shared
 endif
 ifeq ($(UNAME_S),Darwin) 	# For MacOS X, use the same as Linux except DYNDL
-	CPP=cpp -P -traditional -Dunix -Umsdos -Wno-invalid-pp-token
+	CPP=cpp -P -traditional -Dunix -Umsdos
 	STRIP=strip -S
-	LD=$(CC) -rdynamic -Wl,-rpath,$(LIBDIR)
+	LD=$(CC) -Wl,-rpath,$(LIBDIR)
 	DYNLD=$(LD) -bundle -undefined dynamic_lookup
 endif
 ifeq ($(UNAME_S),Cross_W32)
diff --git src/dynlibs/intinf/Makefile src/dynlibs/intinf/Makefile
index d8beaf0..425f09b 100644
--- src/dynlibs/intinf/Makefile
+++ src/dynlibs/intinf/Makefile
@@ -5,10 +5,6 @@
 
 # Where to find GMP header file and compiled library
 
-#GMPDIR=${HOME}/c/gmp-2.0.2
-GMPINCDIR=/usr/local/include
-GMPLIBDIR=/usr/local/lib
-
 include ../../Makefile.inc
 
 #OPTS=-fno-defer-pop
@@ -18,9 +14,9 @@ CFLAGS=-Dunix -O3 $(OPTS) $(ADDDYNLIBCFLAGS) -I$(CAMLRT) -I${GMPINCDIR}
 
 MOSMLTOOLS=camlrunm $(TOOLDIR)
 
-all: libmgmp.so IntInf.uo
+all: libmgmp.so IntInf.uo IntInf.ui
 
-install:
+install: all
 	$(INSTALL_DATA) libmgmp.so $(DESTDIR)$(LIBDIR)
 	$(INSTALL_DATA) IntInf.sig $(DESTDIR)$(LIBDIR)
 	$(INSTALL_DATA) IntInf.ui $(DESTDIR)$(LIBDIR)
diff --git src/launch/Makefile src/launch/Makefile
index 1b2f2aa..1f0bc13 100644
--- src/launch/Makefile
+++ src/launch/Makefile
@@ -1,6 +1,9 @@
 # Unix Makefile for launching Moscow ML
 # Based on Caml Light (copyright 1993 INRIA)
 
+TRUEBINDIR=@PREFIX@/bin
+TRUELIBDIR=@PREFIX@/lib/mosml
+
 include ../Makefile.inc
 
 all: mosml mosmlc mosmllex camlexec testprog 
@@ -20,7 +23,7 @@ old_install:
 	  cat testprog) > /tmp/testscr
 	chmod a+x /tmp/testscr
 	sh -c 'if sh -c /tmp/testscr 2>/dev/null; \
-                then echo "#!$(BINDIR)/camlrunm" > $(LIBDIR)/header; \
+                then echo "#!$(TRUEBINDIR)/camlrunm" > $(LIBDIR)/header; \
                 else ${INSTALL_PROGRAM} camlexec$(EXE) $(LIBDIR)/header; \
                 fi'
 	rm -f /tmp/testscr
@@ -35,20 +38,20 @@ uninstall:
 	cd $(DESTDIR)$(BINDIR) && ${UNINSTALL_SCRIPT} mosml mosmlc mosmllex
 
 mosml: mosml.tpl
-	sed -e "s|LIBDIR|$(LIBDIR)|" -e "s|BINDIR|$(BINDIR)|" mosml.tpl > mosml
+	sed -e "s|LIBDIR|$(TRUELIBDIR)|" -e "s|BINDIR|$(TRUEBINDIR)|" mosml.tpl > mosml
 
 mosmlc: mosmlc.tpl
-	sed -e "s|LIBDIR|$(LIBDIR)|" -e "s|BINDIR|$(BINDIR)|" -e "s|VERSION|$(VERSION)|" mosmlc.tpl > mosmlc
+	sed -e "s|LIBDIR|$(TRUELIBDIR)|" -e "s|BINDIR|$(TRUEBINDIR)|" mosmlc.tpl > mosmlc
 
 mosmllex: mosmllex.tpl
-	sed -e "s|LIBDIR|$(LIBDIR)|" -e "s|BINDIR|$(BINDIR)|" mosmllex.tpl > mosmllex
+	sed -e "s|LIBDIR|$(TRUELIBDIR)|" -e "s|BINDIR|$(TRUEBINDIR)|" mosmllex.tpl > mosmllex
 
 testprog: testprog.sml
 	$(MOSMLC) testprog.sml
 	$(MOSMLL) -noheader -o testprog BasicIO.uo testprog.uo
 
 camlexec.c: camlexec.tpl
-	sed -e "s|LIBDIR|$(LIBDIR)|" -e "s|BINDIR|$(BINDIR)|" camlexec.tpl > camlexec.c
+	sed -e "s|LIBDIR|$(TRUELIBDIR)|" -e "s|BINDIR|$(TRUEBINDIR)|" camlexec.tpl > camlexec.c
 
 camlexec: camlexec.c
 	$(CC) $(OPTS) -o camlexec$(EXE) camlexec.c
@@ -58,4 +61,3 @@ clean:
 	rm -f camlexec.c camlexec$(EXE) mosmlc mosml mosmllex testprog testprog.u[io]
 
 depend:
-
