define(`concat',$1$2$3$4$5$6$7$8$9)
changequote([,])

# os - one of:
#   "bsd" - bsd 4.2, bsd 4.3, ultrix 1.1, acis 4.2,4.3 other
#       "standard" bsd systems without nfs
#   "ultrix12" - Ultrix 1.2
#   "ultrix20" - Ultrix 2.0 or greater
#   "ultrix40" - Ultrix 4.0 or greater
#   "hpux" - HP/UX
#   "aux" - A/UX
#   "xenix5" - SCO Xenix System V
#   "aix" - IBM AIX System V
#   "pyr" - pyramid (in BSD universe)
#   "sunos" - SunOS
#   "encore" - Encore MultiMax
#   "next" - NeXT/MACH
#   "dynix" - Sequent Balance
#   "irix" - Silicon Graphics IRIS-4D/IRIX
# Warning: hpux, pyr are hardcoded in some of the makefiles (sorry)

# MAJOR CONFIGURATION
# set to one of the above (or configure your own below)
define([os],[sunos])

# System call configuration (not for system v compatibilty)
# known: X_GETOPT, X_VPRINTF, X_GETMNT, X_STATFS, X_QUOTA,
# X_SUNQUOTA, X_FLOCK, X_LOCKF, X_FCNTLLOCKF
# getopt - "cap: argument processing"
define([X_GETOPT],1)
# getmnt - "aufs: info on file systems (dec)"
# define([X_GETMNT],1)
# statfs - "aufs: info on file systems (sun nfs)"
define([X_STATFS],1)
# quota - "aufs: info on user quota"
# define([X_QUOTA],1)
# getmntent - "aufs: used by sunquota"
define([X_SUNQUOTA],1)
# flock - "afp: file locking"
define([X_FLOCK],1)
# lockf - "afp: byte range locking using unistd.h"
define([X_LOCKF],1)
# lockf - "afp: byte range locking using fcntl.h"
# define([X_FCNTLLOCKF],1)
# vfprintf - "cap: variable arg fprintf"
define([X_VPRINTF],1)
# recvmsg - "cap: lib: scatter gather recv"
# define([X_NORECVMSG],1)
# sendmsg - "cap: lib: scatter gather send"
# define([X_NOSENDMSG],1)
# ffs - "cap: lib: ffs - find first set bit"
# define([X_NOFFS],1)

# GETOPT support
ifdef([X_GETOPT],[],[define([needgetopt],[att_getopt.o])])
# VPRINTF support
ifdef([X_VPRINTF],[define([usevprintf], 1)],[])

# Path to cap sources: useful for testing
define([cwd],[/home/munnari/staff/djh/src/cap60.beta])
# turn on if your system sends packets very quickly
# (see applications/aufs/INSTALLATION)
# define([fastether],1) # For papif and samples

# The following selects the correct lap delivery objects
define([lapobj],[abkip.o abddp.o abnbp.o atalkdbm.o])

# This determines what happens to UAB
define([uabprogs],[])
define([uabplibs],[])
define([uabpobjs],[])

# This sets up Native EtherTalk support
define([etherprogs],[])
define([etherpobjs],[])

# The following selects byteswapping or otherwise
# define([usebyteswap],1)

# uncomment if your param.h includes types.h and types.h doesn't
# prevent itself from being included twice
# define _TYPES
# define([selfdefinetypes],1)
# MINOR CONFIGURATION: configure various programs

#define([columbia],1) # so columbia can do things quickly
#define([debug],1) # testing things (without disrupting)

# location of include files
define([includedir],[[/usr/include]])
# location of des subroutine source (see lib/afp/README)
define([desloc],[[../../extras]])
# location of atalk.local, etc.
define([etcdest],[[/etc]])
ifdef([columbia],[define([etcdest],[[/usr/local/lib/cap]])])
# location of user cap programs
define([capdestdir],[[/usr/local/cap]])
# location of cap "server" programs (aufs, lwsrv, papif, uab etc.)
define([capsrvrdestdir],[[/usr/local/cap]])
# location of some cap data files
define([caplibdestdir],[[/usr/local/lib/cap]])
# location of cap libraries
define([libdestdir],[[/usr/local/lib]])
# override for aux (doesn't search /usr/local/lib)
ifelse(os,[aux],[define([libdestdir],[[/usr/lib]])])
# cap library names
define([caplib],[[libcap.a]])
define([afplib],[[libafp.a]])
define([afpclib],[[libafpc.a]])
# names to load cap libraries with
define([libcap],[[-lcap]])
define([libafp],[[-lafp]])
define([libafpc],[[-lafpc]])
ifelse(os,[encore],
	[define([libcap],concat([-L],libdestdir,[ ],libcap))])
ifelse(os,[encore],
	[define([libafp],concat([-L],libdestdir,[ ],libafp))])
ifelse(os,[encore],
	[define([libafpc],concat([-L],libdestdir,[ ],libafpc))])
ifelse(os,[aix],
	[define([libcap],concat([-L],libdestdir,[ ],libcap))])
ifelse(os,[aix],
	[define([libafp],concat([-L],libdestdir,[ ],libafp))])
ifelse(os,[aix],
	[define([libafpc],concat([-L],libdestdir,[ ],libafpc))])
# any special libraries
define([libspecial],[])
ifelse(os,[xenix5],[
	define([libspecial],concat(libspecial,[ -lsocket]))])
ifelse(os,[dynix],[
	define([libspecial],concat(libspecial,[ -lseq]))])
ifelse(os,[irix],[
	define([libspecial],concat(libspecial,[ -lbsd]))])
ifelse(os,[aix],[
	define([libspecial],concat(libspecial,[ -lbsd]))])
ifelse(os,[aux],[
	define([libspecial],concat(libspecial,[ -lat]))])

#
# special configurations for individual source files
#

#
# Aufs: see applications/aufs/INSTALLATION
#
# WARNING: OS DEPENDENT
# define([smartunixfinderinfo],1)
#
# Valid here are -DNONXLATE, -DFULL_NCS_SUPPORT
#  or GGTYPE="gid_t"
# Others: USESTATFS, USEGETMNT, USECHOWN, USEQUOTA, USESUNQUOTA
#  are autoconfigured
define([aufsosdefs],[])

#
# lib/cap/authenticate.c: configuration file
#
define([authconfig],[[\"/etc/cap.auth\"]])

#
# lwsrv: see applications/lwsrv/README
#
# Valid is: -DADOBE_DSC2_CONFORMANT
define([simpleflags],[])
#
# Valid are: -DDOCNAME, -DPAGECOUNT=buffer_size
define([lwflags],[-DDOCNAME -DPAGECOUNT=512])
# and more later ...

#
# lwrename: set name of file containing list of printers to be renamed
#
define([lwrenamefile],[[\"/usr/local/lib/cap/lwrename.list\"]])

#
# papif: see applications/papif/README
#
# uncomment and set to right location to turn on printing "plain text files"
# define([pstextloc],[[\"/usr/local/lib/ps/pstext\"]])
#
# uncomment and set to right location to turn on page reversal
# define([psrevloc],[[\"/usr/local/lib/ps/psrev\"]])
#
# Valid are:
#  -DVERBOSELOG - default (set =0 to turn off)
#  -DNO_STRUCT - default is on (structured)
#  -DNOACCT - default is on (accounting)
#  -DIDLESTUFF - default is off
#  -DSFLOWQ - default is 8 (min 1, max 8)
#  -DRFLOWQ - default is 8 (min 1, max 8)
#  -DATPRESPONSETIMEOUT - default is 120 (2 minutes) - in seconds
#  -DWATCHTIME - default is 10 seconds (in seconds)
#  -DDEBUG - default is off
#  -DSTRIPCONTROLD - default is off
#  -DMAPCRTOLF - default is off
#  -DMACUSER - default is off (need LPD_JOB environment variable in lpd)
#  see papif README file for explanations of the above
# The following defines are recommended for System V lp printers (vs. bsd lpd)
#  -DWATCHTIME=0 (no status) -DNOACCT
define([papflags],[-DMACUSER])
define([papflags],concat(papflags,[ -DIDLESTUFF]))

# Set -DBANNERFIRST if you want the banner page to come out as the
#  first page instead of the last page 
# Set -DBANNERLAST if want it last
# Set -DPSBANNER if you want a custom PostScipt Banner (must specify
#  short banners in printcap). This still defaults to regular banners
# Add -DCHARGEBANNER if you want to charge the banner page to the user
#  on system V - there is no accounting, so leave blank
define([papbanner],[-DCHARGEBANNER])

# for cap.printers - uncomment and change the following line to point
# papif, et. al. to a location other than /etc/cap.printers.  (Note:
# line below would set it to $etcdir/cap.printers)
# define([capprinters],concat([\"],etcdest,[/],[cap.printers],[\"]))
ifdef([columbia],
       [define([capprinters],concat([\"],etcdest,[/],[cap.printers],[\"]))])
# for atalkdbm - allows change following line(s) to modify atalk.local
# (probably shouldn't).  Remember that atalk.local is expected to
# be in etcdest
define([atalklocal],concat([\"],etcdest,[/],[atalk.local],[\"]))
define([configdir],concat([\"],etcdest,[\"]))

# in case you want to globally change the c compiler
define([thecompiler],[cc])
define([theloader],[ld])
define([theinstaller],[cp])

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#		      END OF CONFIGABLE OPTIONS                            #
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# You should only edit past here if you are "porting"
# Automatics
define([osname],
	ifelse(	os,[ultrix12],[Ultrix 1.2],
		os,[ultrix20],[Ultrix 2.0],
		os,[ultrix40],[Ultrix 4.0],
		os,[aux],[A/UX],
		os,[sunos],[SunOS],
		os,[encore],[Encore Umax],
		os,[hpux],[HP-UX (for 9000 series)],
		os,[bsd],[Standard BSD],
		os,[pyr],[Pyramid in BSD universe],
		os,[xenix5],[SCO Xenix System V],
		os,[aix],[IBM AIX System V],
		os,[next],[NeXT/MACH],
		os,[dynix],[Sequent Balance],
		os,[irix],[Silicon Graphics IRIS/IRIX],
		[Unknown]))
define([cflags],ifdef([selfdefinetypes],[-D_TYPES],[]))
define([cflags],concat(cflags,ifdef([usebyteswap],[ -DBYTESWAPPED],[])))
define([bigcflags],ifelse(os,[hpux],[+Nd2000 +Ns2000]))
# The encore optimiser is slightly over zealous
ifelse(os,[encore],[],[
    define([cflags],concat(cflags,[ -O]))])
ifelse(os,[pyr],[
    define([cflags],concat(cflags,[ -q]))])
ifelse(os,[next],[
    define([cflags],concat(cflags,[ -DNeXT -DADDRINPACK]))])
ifelse(os,[xenix5],[
    define([cflags],concat(cflags,[ -Dxenix5 -I$I -DLAI_TCP -Di386]))])
ifelse(os,[aix],[
    define([cflags],concat(cflags,[ -DAIX -DUSETIMES -DNOWAIT3 -DUSEDIRENT]))])
ifelse(os,[irix],[
    define([cflags],concat(cflags,[ -D_BSD_COMPAT]))])

# was used for nbp, but found we needed more... leave in case
define([nbpflags],[])
define([lflags],[])
define([mflags],[])

# aux's c compiler isn't nice - it doesn't have a preprocessor
# definition for aux.  So, let's invent one.  Also turn on -n
# for shared code.
ifelse(os,[aux],[
	define([cflags],concat(cflags,[ -n -Daux]))
	define([lflags],concat(lflags,[ -n]))])

# check to see if we need sysvinstall usage
ifelse(os,[aux], [define([sysvinstall],[yes])],
       os,[hpux],[define([sysvinstall],[yes])],
       os,[irix],[define([sysvinstall],[yes])])

# or if we really want to use install
# ifelse(os,[someOS], [define([theinstaller],[install])])

# for cap library
# Valid are:
#  NOFFS - no ffs function defined, fake it out
#  LOCALTIME_GTOD - uses pd localtime, but gettimeofday always reads
#   disk based time of day.  Always defined for AUX for now.  Probably
#   needs to be changed for versions of Aux after 1.0
#  NORECVMSG - no recvmsg in system (fake it out)
#  NOSENDMSG - no recvmsg in system (fake it out)
define([caposdefs],
	concat( ifdef([X_NOFFS],[ -DNOFFS],[]),
		ifelse(os,[aux],[ -DLOCALTIME_GTOD],[]),
		ifdef([X_NORECVMSG], [ -DNORECVMSG],[]),
		ifdef([X_NOSENDMSG], [ -DNOSENDMSG],[])))
# for afp library
# two cases for X_LOCKF - if lockf isn't defined
# first: X_FCNTLLOCKF is defined, so just note that lockf uses fcntl.h
# second: "         " isn't defined so define no lockf
define([afposdefs],
	concat(	ifdef([X_FLOCK],[],[ -DNOFLOCK]),
		ifdef([X_LOCKF],[],
		   [ifdef([X_FCNTLLOCKF],[-DLOCKFUSESFCNTL],[-DNOLOCKF])])))
# for aufs
define([aufsosdefs],
    concat(aufsosdefs,
	ifdef([X_STATFS],[ -DUSESTATFS],[]),
	ifdef([X_GETMNT],[ -DUSEGETMNT],[]),
	ifdef([X_QUOTA],[ -DUSEQUOTA],[]),
	ifdef([X_SUNQUOTA],[ -DUSESUNQUOTA],[]),
	ifelse(os,[aix],[ -DNOVFORK -DUSECHOWN],[])))

# if no ranlib (or fakeout like hpux) and need to order libaries
ifelse(os,[dummy],[define(uselordertsort,[1])],
       os,[aux],  [define(uselordertsort,[1])],
       os,[irix], [define(uselordertsort,[1])])

# lw config
define([lwflags],
    concat(lwflags,
	ifdef([fastether],[-DSFLOWQ=1],[]),
	ifelse(os,[aix],[],[])))

# more papif config
define([papflags],
    concat(papflags,
	ifelse(os,[aix],[ -DNOVFORK],[])))

#NBPFLAGS = nbpflags()
#SPECCFLAGS = specialcflags()
#BIGCFLAGS = bigcflags()
#CFLAGS = cflags()
#LFLAGS = lflags()
#AFPOSDEFS = afposdefs()
#AUFSOSDEFS = aufsosdefs()

ifdef([debug],[
# location of include files
 define([includedir],[cwd])
# location of des subroutine source (see lib/afp/README)
 define([desloc],[[../../extras]])
# location of atalk.local, etc.
 define([etcdest],concat(cwd,[[[/etc]]]))
# location of user cap programs
 define([capdestdir],concat(cwd,[[[/bin]]]))
# location of cap "server" programs (aufs, lwsrv, papif, uab etc.)
 define([capsrvrdestdir],concat(cwd,[[[/bin]]]))
# location of some cap data files
 define([caplibdestdir],concat(cwd,[[[/bin]]]))
# location of cap libraries
 define([libdestdir],concat(cwd,[[[/lib]]]))
# cap library names
 define([caplib],[[libcap.a]])
 define([afplib],[[libafp.a]])
 define([afpclib],[[libafpc.a]])
# names to load cap libraries with
 define([libcap],concat(cwd,[[[/lib/libcap.a]]]))
 define([libafp],concat(cwd,[[[/lib/libafp.a]]]))
 define([libafpc],concat(cwd,[[[/lib/libafpc.a]]]))
 define([capprinters],concat([\"],etcdest,[/],[cap.printers],[\"]))
 define([cflags],concat(cflags,[ -I],includedir))
 define([atalklocal],concat([\"],etcdest,[/],[atalk.local],[\"]))
 define([configdir],concat([\"],etcdest,[\"]))
])

define([datestring],maketemp(/tmp/capcXXXXXX))
syscmd(date > datestring())
##########MARKER##########
# Makefile autoconfigured for ...
[#] osname() system on include(datestring())
syscmd(rm datestring())

MFLAGS=mflags()
LFLAGS=lflags()
CC=thecompiler()
LD=theloader()
SHELL=/bin/sh
INSTALLER=theinstaller()
