$NetBSD: patch-aa,v 1.14 2008/05/10 11:52:14 obache Exp $

--- Makefile.orig	1994-01-26 11:32:33.000000000 -0600
+++ Makefile	2006-07-20 22:10:32.000000000 -0500
@@ -20,13 +20,13 @@
 # RM = rm -f
 
 # How to run Make 
-MAKE = make
+#MAKE = make
 
 # How to copy files
 CP = cp
 
 # How to compile C programs
-CC = cc
+#CC = cc
 
 # You may also want to change the CFLAGS variable, which will be passed on 
 # to all subdirectories.    If you do that, the changes will only work right if you
@@ -38,7 +38,7 @@
 
 STATICFLAG=FOOBAR${HOST_ARCH}
 
-CFLAGS = -g -I.  ${$(STATICFLAG)} 
+CFLAGS += -I.  ${$(STATICFLAG)}
 # The following is better if you want to make sure you run with SYSV defined
 # CFLAGS = -g -I.  ${$(STATICFLAG)}  -DSYSV
 # Also, for SGI Irix, compile in K&R mode
@@ -49,9 +49,12 @@
 # LDLIBS variable.
 #
 # For Sun and BSD systems, the following should work...
-LDLIBS =
+# LDLIBS =
 # On BSD 4.4 systems, you will need the following
-# LDLIBS = -lcompat
+OPSYS!= uname -s
+.if ${OPSYS} == "NetBSD" || ${OPSYS} == "FreeBSD" || ${OPSYS} == "DragonFly"
+LDLIBS = -s -lcompat
+.endif
 # On SGI machines, we need -lsun for getpw...(), and -lc_s saves some space.
 # LDLIBS = -lsun -lc_s
 # ISC SysVr3.2.2 has a shared C library and requires libinet.a to resolve
@@ -72,18 +75,18 @@
 #	install -s -c $(LOCALBINDIR) $$file
 #
 #INSTALL = cp
-INSTALL = install -c -s
+#INSTALL = install -c -s
 
 # Root of installation tree
-INSTROOT = /usr/local
+INSTROOT = ${DESTDIR}${PREFIX}
 #
 # This is where binaries should be copied
 LOCALBINDIR = ${INSTROOT}/bin
 
 # This is where man pages should be copied, and their extensions
-MAN1DIR = ${INSTROOT}/man/man1
+MAN1DIR = ${INSTROOT}/${PKGMANDIR}/man1
 MAN1EXT = 1
-MAN4DIR = ${INSTROOT}/man/man4
+MAN4DIR = ${INSTROOT}/${PKGMANDIR}/man4
 MAN4EXT = 4
 
 # Sets the font suffix your version of X uses - snf for X11R4, pcf for X11R5
@@ -91,23 +94,27 @@
 FONTSUFFIX=pcf
 
 # This is where the mailcap file should be put
-MAILCAPDIR = ${INSTROOT}/etc
+MAILCAPDIR = ${INSTROOT}/share/examples/metamail
 
 # This helps with the "for" constructs below on some platforms:
 SHELL=/bin/sh
 
-install: basics
+BINARIES=	mailto metamail mmencode richtext richtoatk	\
+		splitmail
+SCRIPTS=	audiocompose audiosend extcompose getfilename mailserver \
+		mailto-hebrew metasend patch-metamail rcvAppleSingle 	\
+		showaudio showexternal shownonascii showpartial 	\
+		showpicture sndAppleSingle sun-audio-file sun-message.csh \
+		sun-to-mime sun2mime
 
-basics::
+install: install-all
+
+all basics::
 	(cd metamail ; $(MAKE)  CONFIGDIR=../${CONFIGDIR}  CFLAGS="${CFLAGS}" CC="${CC}"  LDLIBS="${LDLIBS}")
 	-${RM} bin/metamail
 	(cd bin; ${LN} ../metamail/metamail metamail)
 	-${RM} bin/mmencode
 	(cd bin; ${LN} ../metamail/mmencode mmencode)
-	-${RM} bin/mimencode
-	(cd bin; ${LN} ../metamail/mmencode mimencode)
-	-${RM} man/mimencode.1
-	(cd man; ${LN} ../man/mmencode.1 mimencode.1)
 	-${RM} bin/mailto
 	(cd bin; ${LN} ../metamail/mailto mailto)
 	-${RM} bin/splitmail
@@ -117,7 +124,7 @@
 	(cd bin; ${LN} ../richmail/richtext richtext)
 	-${RM} bin/richtoatk
 	(cd bin; ${LN} ../richmail/richtoatk richtoatk)
-	(cd fonts ; $(MAKE)  CONFIGDIR=../${CONFIGDIR}  CFLAGS="${CFLAGS}" CC="${CC}"   LDLIBS="${LDLIBS}" FONTSUFFIX="${FONTSUFFIX}")
+	(cd fonts ; $(MAKE) PREFIX=${PREFIX} CONFIGDIR=../${CONFIGDIR}  CFLAGS="${CFLAGS}" CC="${CC}"   LDLIBS="${LDLIBS}" FONTSUFFIX="${FONTSUFFIX}")
 	-${RM} bin/shownonascii
 	(cd bin; ${LN} ../fonts/shownonascii shownonascii)
 	-${RM} bin/mailto-hebrew
@@ -125,30 +132,38 @@
 
 install-all: basics 
 	@(cd bin; 				\
-	for file in *; 				\
+	for file in $(BINARIES); 		\
+	do 					\
+	    target=$(LOCALBINDIR)/$$file; 	\
+	    echo "installing binary $$target";	\
+	    ${BSD_INSTALL_PROGRAM} $$file $$target; 	\
+	done;					\
+	for file in $(SCRIPTS); 		\
 	do 					\
 	    target=$(LOCALBINDIR)/$$file; 	\
 	    echo "installing binary $$target";	\
-	    ${INSTALL} $$file $$target; 	\
+	    ${BSD_INSTALL_SCRIPT} $$file $$target; 	\
 	done)
+	${RM} -f ${LOCALBINDIR}/mimencode ; ${LN} -s mmencode ${LOCALBINDIR}/mimencode
 	@(cd man;				\
 	for file in *.1;			\
 	do 					\
 	    target=$(MAN1DIR)/`basename $$file .1`.$(MAN1EXT); \
 	    echo "installing man page $$target";\
-	    ${CP} $$file $$target; 		\
+	    ${BSD_INSTALL_MAN} $$file $$target; 		\
 	done)
+	${RM} -f ${MAN1DIR}/mimencode.1 ; ${LN} -s mmencode.1 ${MAN1DIR}/mimencode.1
 	@(cd man;				\
 	for file in *.4;			\
 	do 					\
 	    target=$(MAN4DIR)/`basename $$file .4`.$(MAN4EXT); \
 	    echo "installing man page $$target";\
-	    ${CP} $$file $$target; 		\
+	    ${BSD_INSTALL_MAN} $$file $$target; 		\
 	done)
-	@echo "Renaming old mailcap file to $(MAILCAPDIR)/mailcap.old
+	@echo "Renaming old mailcap file to $(MAILCAPDIR)/mailcap.old"
 	-mv $(MAILCAPDIR)/mailcap $(MAILCAPDIR)/mailcap.old
 	@echo "installing file $(MAILCAPDIR)/mailcap"
-	${CP} mailcap $(MAILCAPDIR)
+	${BSD_INSTALL_DATA} mailcap $(MAILCAPDIR)
 
 uninstall-all:
 	@(cd bin; 				\
