#
# Copyright (c) 1988 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by the University of California, Berkeley.  The name of the
# University may not be used to endorse or promote products derived
# from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
#	@(#)Makefile	5.11 (Berkeley) 1/3/89
#	@(#)$Id: Makefile,v 1.17 1991/08/14 18:28:19 paul Exp $
#
HDRS=	conf.h mailstats.h sendmail.h useful.h flock.h def.h
SRCS=	alias.c arpadate.c clock.c collect.c conf.c convtime.c daemon.c \
	deliver.c domain.c envelope.c err.c getloadavg.c headers.c \
	macro.c main.c parseaddr.c queue.c readcf.c recipient.c \
	savemail.c srvrsmtp.c stab.c stats.c sysexits.c trace.c \
	usersmtp.c util.c ../ida/charset/strcnv.c flock.c setenv.c \
	syslog.c vprintf.c version.c 
OBJS=	alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \
	deliver.o domain.o envelope.o err.o getloadavg.o headers.o \
	macro.o main.o parseaddr.o queue.o readcf.o recipient.o \
	savemail.o srvrsmtp.o stab.o stats.o sysexits.o trace.o \
	usersmtp.o util.o strcnv.o flock.o setenv.o syslog.o vprintf.o \
	version.o
CONFIGS = \
	config/3b1.h      config/dynix.h    config/ptx.h \
	config/aix3.h     config/hpux.h     config/riscos.h \
	config/aixrt.h    config/irix.h     config/sunos4.h \
	config/bsd43.h    config/isc.h      config/ultrix3.h \
	config/bsd44.h    config/next.h     config/ultrix4.h \
	config/convex.h   config/osx.h      config/umax.h \
	config/domainos.h 
MAN=	sendmail.0 newaliases.0 aliases.0

SHELL=	/bin/sh

# Reasonable defaults.  A CPU type must usually be specified with ANSI C
# compilers in order to select the correct byte-ordering in <arpa/nameser.h>
# and to use the right getloadavg() routine.  IT'S LIKELY THAT THE -Dvax
# BELOW WILL BE WRONG FOR YOUR MACHINE.
CC=	cc
#CC=	gcc -Dvax -ansi -fpcc-struct-return -fstrength-reduce 
DEFS=	
CFLAGS=	-O -I. ${DEFS} 
LDFLAGS= 
# Choose the dbm library based on the setting in conf.h.
# GDBM: -lndbm, SDBM: -lsdbm, HDBM: -lhash, MDBM: -lmdbm, else: -ldbm or none
DBMLIB=	
LIBS=	${DBMLIB}
LIBDIR=	/usr/local/lib/mail

#
# Look for any missing routines in ../support and add them as needed to the
# SRCS/OBJS after copying them over to .  Also be sure that the pathnames
# in conf.h reflect reality for your system.  Platform-specific settings
# are located in config/foo.h where foo is the OS name.
#
# HP-UX systems will need strcasecmp.c and sysexits.h from ../support.
#
# HP Apollos running >= 10.1 will complain a lot about wrong const char
#  usage since their ANSI include files are wrong.  You may need the
#  stdarg.h file from the ../support directory.  The vendor libresolv
#  file does not seem to work, best results are obtained by installing
#  libresolv.a from Bind 4.8.3 sources (uxc has them).  Don't use -A nansi
#  as getloadavg() will seg-fault.  The file /usr/include/apollo/time.h is
#  missing the #ifdef _PROTOTYPE defines (see base.h in the same directory).
#  HP and Apollo are made for each other - neither company really understands
#  software.  The sendmail.fc file doesn't work.  See the top-level install
#  file for comments about /bin/mail as well.  Then trade-in your Apollo.
# CFLAGS=	-A ansi -O -I. ${DEFS} 
#
# Encore MultiMax will need a more recent version of the Bind software if
#  the vendor libresolv.a file is missing the res_search() call.  
# CFLAGS=	-q host_is_target -q optimize=time -O -I. ${DEFS}
# PARALLEL=	4
#
# Sequents running Dynix can use the defaults above.  Systems running PTX
#  will need
# LIBS= -lsocket -linet -lnsl
#  Uncommenting the next line will result in faster compilation with both.
# PAR=	&
#
# Mips running RISC/os.
# CFLAGS=	-systype bsd43 -O -Olimit 600 -I. ${DEFS} 
# LIBS=	-ldbm -lmld
#
# Silicon Graphics Iris systems.  SGI broke vfork() for some mysterious reason.
#  Add -lsun if #define YP is set in conf.h .
# LIBS=	-lmld -lsun
#
# Interactive Systems Corp UNIX systems
# LIBS=	-linet -ldbm -lc -lPW
#
# Next systems cannot use sendmail.fc as Mach lacks sbrk().  Don't use
#  -fpcc-struct-return!
# CFLAGS=	-fstrength-reduce -ansi -DNeXT -bsd -O -I. ${DEFS}
#
# Convexen will need to add -DSHARE to DEFS and -lshare to LIBS if the share
#  scheduler is used.  -pcc is no longer required. /usr/include/arpa/nameser.h
#  should have the bit field type changed from u_char to u_int and
#  "|| defined(__convex__)" added to the #if clause for
#  BIT_ZERO_ON_LEFT (BIG_ENDIAN).
# DEFS=	-DSHARE
# LIBS=	-ldbm -lshare
#
# AIX 3.0 systems can now use sendmail.fc with the LDFLAGS below.  RTs under
#  AIX can't use sendmail.fc and will also need a ndbm replacement.  AIX should
#  really be junked, but that's another story.
# CFLAGS=	-qlanglvl=ansi -O -I. ${DEFS}	# AIX on both RS/6000 and PC/RT
# LDFLAGS=	-bnso -bI:/lib/syscalls.exp	# AIX on RS/6000 only
# LIBS=	-lc -lbsd -lm				# AIX on RS/6000 only
#
# Suns with shared libraries need to be linked with -Bstatic for reliable
#  operation.  If when sendmail.fc is used and the executable either complains
#  when re-building the alias database or spawns runaway child processes,
#  then you have the localtime() bug introduced in SUNOS 4.1 (it stomps
#  on byte 9 of an 8 byte malloc).  Use ../uiuc/malloc.c or get the fix
#  from SUN.  If your SUN has more 16 Mbytes of memory and running sendmail
#  crashes it, you have the 'pmeg' bug.  Get patch 100092-03 and install it.
#  It's available via anon-FTP from princeton.edu in
#  pub/sun-fixes/sunos4.1/{100092-03.tar.Z,README.100092-03}
# CFLAGS= -Bstatic -O -I. ${DEFS} 
#
# Get and install Bind 4.8.3 if your libc.a || libresolv.a lack the 
# res_search() call.
#

# One of sendmail or dsendmail to set your local default make target
#all:	dsendmail
all:	sendmail

# The date sendmail was compiled is written to the freeze file,
# to avoid reading in a .fc file created by a different version.
sendmail:${PAR} ${OBJS}
	echo 'char datecompiled[] = "' `date` '";' >datecompiled.c
	${CC} ${CFLAGS} ${LDFLAGS} -o $@ datecompiled.c ${OBJS} ${LIBS}
	size sendmail; ls -l sendmail; ${WHAT} < version.o

dsendmail:${PAR} ${OBJS}
	echo 'char datecompiled[] = "' `date` '";' >datecompiled.c
	${CC} ${CFLAGS} ${LDFLAGS} -o sendmail datecompiled.c ${OBJS} ${LIBS} -lresolv
	size sendmail; ls -l sendmail; ${WHAT} < version.o

install: ${MAN}
#	install -c -s -o root -m 4511 sendmail ${DESTDIR}/usr/lib
	install -c -s -o root -m 4511 sendmail ${DESTDIR}/usr/sbin
	-mkdir ${DESTDIR}/${LIBDIR}
	-mkdir ${DESTDIR}/${LIBDIR}/char
#	install -c -o bin -g bin -m 644 /dev/null ${DESTDIR}/etc/sendmail.fc
	install -c -o bin -g bin -m 666 /dev/null ${DESTDIR}/${LIBDIR}/sendmail.st
	install -c -o bin -g bin -m 444 sendmail.hf ${DESTDIR}/${LIBDIR}/sendmail.hf
	install -c -o bin -g bin -m 444 sendmail.0 ${DESTDIR}/usr/man/cat8
	install -c -o bin -g bin -m 444 aliases.0 ${DESTDIR}/usr/man/cat5
	install -c -o bin -g bin -m 444 newaliases.0 ${DESTDIR}/usr/man/cat1
	-mkdir ${DESTDIR}/usr/spool/mqueue
	chown root.wheel ${DESTDIR}/usr/spool/mqueue
	chmod 755 ${DESTDIR}/usr/spool/mqueue
	rm -f ${DESTDIR}/usr/ucb/newaliases
#	ln -s ${DESTDIR}/usr/lib/sendmail ${DESTDIR}/usr/ucb/newaliases
	cd ${DESTDIR}/usr/sbin; rm -f newaliases mailq; ln sendmail mailq; ln sendmail newaliases
	rm -f ${DESTDIR}/usr/ucb/mailq
	ln -s ${DESTDIR}/usr/lib/sendmail ${DESTDIR}/usr/ucb/mailq

strcnv.o:	../ida/charset/strcnv.c
	${CC} ${CFLAGS} -DMAPDIR=\"${DESTDIR}/${LIBDIR}/char\" -c \
		../ida/charset/strcnv.c

newaliases.0:	newaliases.1
	nroff -man newaliases.1 > newaliases.0

aliases.0:	aliases.5
	nroff -man aliases.5 > aliases.0

sendmail.0:	sendmail.8
	nroff -man sendmail.8 > sendmail.0

clean: ${SRCS}
	rm -f ${OBJS} core sendmail a.out Version.o datecompiled.*

cleandir: clean
	rm -f ${MAN} tags .depend

depend: ${SRCS} ${HDRS}
	mkdep ${CFLAGS} ${SRCS}

prt:
	@(pr -f READ_ME NOTES Makefile; pr -f -b *.h ${SRCS}) | \
		out -dest 3800 -bin 38 -pagedef L66 -font gt12

tags: ${SRCS}
	ctags ${SRCS}

lint: ${SRCS}
	lint -chpb -I. ${DEFS} ${SRCS}

# However we put in one default dependency, to minimize the problems of those
# who don't do a 'make depend'

$(OBJS):	$(HDRS) $(CONFIGS)

# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.

