Change hardcoded references to /usr/local and /usr/X11R6 to $(PREFIX). This
has been reported to the developer by email but they have not reacted.

Fix the install target not to use sudo, not to use the GNU-specific -t flag,
and to use DESTDIR. This has been reported to the developer by email but
they have not reacted.

Fix the clean target so it also deletes bin/docker.

Add -Wno-implicit-function-declaration to fix errors like the following with
Apple Clang 12 and later and LLVM.org Clang 16 and later:

error: implicit declaration of function 'mkcon_' [-Werror,-Wimplicit-function-declaration]

The separate ambfor makefile already does this. This makes the port
potentially incompatible with the arm64 architecture. This project has a
zillion implicit function declarations which it is too much work for me to
fix myself; the developer should do it. This has been reported to the
developer by email but they have not reacted.

Add -fallow-argument-mismatch to FFLAGS to fix errors like the following
with GCC 10 and later:

Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/REAL(4)).
--- docker/makefile.orig	2023-02-09 03:52:11.000000000 -0600
+++ docker/makefile	2023-08-30 08:18:20.000000000 -0500
@@ -95,8 +95,8 @@
 CC=gcc
 
 EXT= -std=gnu89 -Wno-return-type -DDARWIN ${EXTRAZ}
-FFLAGS=-O3 -funroll-loops
-CFLAGS= -g -std=gnu89 -Wno-return-type -DDARWIN -Wno-logical-op-parentheses -Wno-tautological-pointer-compare -Wno-tautological-constant-out-of-range-compare 
+FFLAGS=-O3 -funroll-loops -fallow-argument-mismatch
+CFLAGS= -g -std=gnu89 -Wno-return-type -DDARWIN -Wno-logical-op-parentheses -Wno-tautological-pointer-compare -Wno-tautological-constant-out-of-range-compare -Wno-implicit-function-declaration
 LDR = ${FC}
 endif
 
--- makefile.orig	2023-05-24 02:18:35.000000000 -0500
+++ makefile	2023-08-30 08:14:52.000000000 -0500
@@ -16,7 +16,7 @@
 CC = cc
 LIBS =  -lX11 -lm
 LDR = ${FC} 
-LIBSG = -L/usr/X11R6/lib -lGLU -lGL -lXmu -lX11 -lm
+LIBSG = -L$(PREFIX)/lib -lGLU -lGL -lXmu -lX11 -lm
 ARCH := $(shell getconf LONG_BIT)
 AFLAG= -m$(ARCH)
 EXTEN=
@@ -132,11 +132,11 @@
 # Mac OS X g77
 #
 CC=cc
-FFLAGS+=-O3 -funroll-loops -DDARWIN ${EXTRAZ}
-LIBS = -L/usr/X11R6/lib -lX11 -lm
-LIBSG = -L/usr/X11R6/lib -lGLU "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib" -lGL -lXmu -lX11 -lm
+FFLAGS+=-O3 -funroll-loops -fallow-argument-mismatch -DDARWIN ${EXTRAZ}
+LIBS = -L$(PREFIX)/lib -lX11 -lm
+LIBSG = -L$(PREFIX)/lib -lGLU "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib" -lGL -lXmu -lX11 -lm
 EXT= -std=gnu89 -Wno-return-type -DDARWIN ${EXTRAZ}
-CFLAGS= -g -std=gnu90 -Wno-return-type -DDARWIN -I/usr/X11R6/include -DDOBACK -DHASTIMER -DCOLOR_OFFSET=0.0 -Wno-logical-op-parentheses -Wno-tautological-pointer-compare -Wno-tautological-constant-out-of-range-compare
+CFLAGS= -g -std=gnu90 -Wno-return-type -DDARWIN -I$(PREFIX)/include -DDOBACK -DHASTIMER -DCOLOR_OFFSET=0.0 -Wno-logical-op-parentheses -Wno-tautological-pointer-compare -Wno-tautological-constant-out-of-range-compare -Wno-implicit-function-declaration
 LDR = ${FC}
 endif
 
@@ -267,7 +267,7 @@
 # and the full opengl version of molden 'gmolden', (does not need glut)
 # (make gmolden)
 #
-LIBSOGL = -lglut -lGLU -lGL -lXmu -lX11 -lm
+LIBSOGL = -L$(PREFIX)/lib -lglut -lGLU -lGL -lXmu -lX11 -lm
 #
 # on linux :
 #
@@ -354,7 +354,7 @@
 	$(LDR) -o bin/cad2mol src/cad2mol.o
 
 clean:
-	rm -f src/$(OBJS) src/mpdum.o src/xwin.o src/xwingl.o bin/molden bin/gmolden bin/ambfor bin/ambmd bin/surf src/ambfor/*.o src/surf/*.o docker/*.o
+	rm -f src/$(OBJS) src/mpdum.o src/xwin.o src/xwingl.o bin/molden bin/gmolden bin/ambfor bin/ambmd bin/surf bin/docker src/ambfor/*.o src/surf/*.o docker/*.o
 
 exten:
 ifeq ("/usr/bin/gio", "$(shell which gio)")
@@ -364,7 +364,7 @@
 endif
 
 exten2:
-	utils/register_extension.sh /usr/local/bin
+	utils/register_extension.sh $(PREFIX)/bin
 
 install:	$(EXTENZ)
-	sudo install -t /usr/local/bin -m 755 bin/molden bin/gmolden bin/ambfor bin/ambmd bin/surf
+	install -m 755 bin/molden bin/gmolden bin/ambfor bin/ambmd bin/surf $(DESTDIR)$(PREFIX)/bin
--- src/surf/Makefile.orig	2022-05-06 15:51:50.000000000 -0500
+++ src/surf/Makefile	2022-05-14 03:23:26.000000000 -0500
@@ -6,7 +6,7 @@
 LINCLUDE    = -lm
 OPT_CFLAGS  = -O2 $(FLAGS) $(INCLUDE)
 #CFLAGS	    = -g $(FLAGS) $(INCLUDE)
-CFLAGS	    = -Wno-implicit-int -O2 $(FLAGS) $(INCLUDE) ${EXT}
+CFLAGS	    = -Wno-implicit-int -O2 $(FLAGS) $(INCLUDE) ${EXT} -Wno-implicit-function-declaration
 
 ifeq ($(uname), Darwin)
 #
