
#######
# Where the executable goes
BINDIR=/usr/local/bin

#######
# Man pages

# Directory for super(1) man page
MANDIR=/usr/local/man/man1

# Extension on the super(1) man page
MANEXT=1

# Directory for the man page describing the format of the super.tab file.
# Note: file formats usually go into section 4 (SysV) or section 5 (BSD).
MAN_FMT_DIR=/usr/local/man/man4

# Extension on the super.tab format man page.
MAN_FMT_EXT=4

#######
# CC
CC=cc

#######
# CFLAGS

#   1. USE_NETGROUP: This indicates whether the hostname "+xxx" should mean
#	any host in netgroup "xxx"; e.g. `joe@+xyz' means allow
#	joe to execute the command from any host in NIS netgroup xyz.
#	If USE_NETGROUP is not defined, `joe@+xyz' means joe at host `+xyz'.
#	(Netgroups are typically defined in /etc/netgroup on your NIS master.)

#   2. USE_SYSLOG: This indicates whether the error-message printing routine
#	should be compiled with the option of calling syslog().  You should
#	define this if you have syslog() available.  The actual printing to
#	syslog at runtime is controlled by the global option syslog=y|n.
#	See also SYSLOG_PRIORITY, below.

#   3. MAXFD: if you don't have the system call getdtablesize() to return the
#	number of file descriptors, define
#		MAXFD=<expression to give max ok value of a file descr>.
#	If MAXFD is not defined, getdtablesize() is used.
#	Examples: 	-DMAXFD=63	-- hardwired for 64 max descriptors;
#			-DMAXFD="sysconf(_SC_OPEN_MAX)-1" -- HP-UX 8.x, 9.x

#   4. SUPERFILE: if you want the superfile to be other than
#	/usr/local/lib/super.tab, add -DSUPERFILE=\"FullPathName\"

#   5. SAFE_PATH: this is the setting of the PATH variable for any command
#	executed by super.  The default is "/bin:/usr/bin:/usr/ucb".
#	If you prefer a different path, add -DSAFE_PATH=\"MyPreferredPath\",
#	and change the description of PATH in the man page to match.

#   6. TIMESTAMP_DIR: This is the directory in which timestamp files are
#	kept for commands requiring passwords to be entered.  The default
#	is "/usr/local/lib/superstamps".  If you prefer a different path,
#	add -DTIMESTAMP_DIR=\"/My/Preferred/Directory\".

#   7. L14: define this if your filenames can only be 14 characters long.
#	Timestamp filenames usually look like hostname/user; with this option,
#	the hostname part is truncated to 14 characters.

#   8. INTERPRETER_HACK: If your execve() function doesn't support the
#	"#!" hack, in which executable scripts beginning
#		"#! interpreter [arg]"
#	are automatically passed to the interpreter, define -DINTERPRETER_HACK.
#	Super will include code to implement "#!" processing.

#   9. USE_GETHOSTBYNAME: If you have a nameserver, you should enable
#	this, which does the following:  If super tries and fails to match
#	the hostname (as returned by gethostname()), it will try removing
#	trailing components of the fully-qualified hostname and seeing if
#	they match the host pattern.

#   10. SCO: if you are compiling for SCO 3.2v4 unix use this define.

#   11. SCO_SHADOW_PWD: Depending on the defined level of security used
#	on an SCO platform (i.e. traditional, low, medium, or high), the 
#	encrypted user passwords are contained in the /etc/shadow file.
#	For all levels except low, you must define SCO_SHADOW_PWD, so that the
# 	get_password routine retrieves the password from the proper file.

#   12. ONETRUENAME: the name under which the program assumes it is installed.
#	If argv[0] isn't [/.../]ONETRUENAME, we assume we're running via
#	symlink, and act as if `super xxx args' had been typed instead of
#	`super args', where xxx is argv[0].  The default is "super", and
#	you should _not_ change this without a good reason!

#   13. RLOG_MACHINE: If you enable the use of syslog() (-DUSE_SYSLOG),
#	by default standard syslog() calls will be used.  But you also have
#	the option of using rsyslog(), which will direct the syslog messages to
#	a host on your network.  If you want to use rsyslog(), then you
#	must define RLOG_MACHINE, and you should also define SYSLOG_PRIORITY
#	(see following item).  RLOG_MACHINE specifies the machine
#	which will receive the networked syslog messages.  For example:
#		-DRLOG_MACHINE=\"toto.domain\"
#	(If you distribute this code, be careful to remove the name of
#	your collecting machine from this Makefile.  Note that the "make
#	shar" command, below, will strip this for you.).

#   14. SYSLOG_PRIORITY: This variable specifies the priority of syslog
#	messages.  If you don't define it, the default is LOG_ERR.
#	(Regardless of this setting, _successful_ executions are logged
#	at priority LOG_INFO.)

#	If you are using standard syslog(), you may define it symbolically,
#	for example:
#		-DSYSLOG_PRIORITY=LOG_ERR
#	or
#		-DSYSLOG_PRIORITY="(LOG_LOCAL1 | LOG_WARNING)"

#	But if you are using rsyslog(), you should define it differently:
#	its value depends on the machine which will _receive_ the log
#	messages, NOT the sending machine.  It should be defined in the
#	Makefile because the value can differ on the machine that compiles
#	and runs super, compared to the value on the log host.

#	For example, if your receiving machine is a Sun running SunOS 4.1.3,
#	or HP-UX 8.x or 9.x, using -DRLOG_PRIORITY='((17<<3)+4)' will set
#	the priority of the networked syslog to the facility LOG_LOCAL1, with
#	the priority LOG_WARNING.  The log machine should have a line that
#	matches this in its syslog.conf file; for the above priority, use
#	an entry like:
#		/etc/syslog.conf:local1.warning        /var/adm/super.log

#   3. NEED_MEMSET: This indicates whether you have a memset() routine.
#	If you don't, define -DNEED_MEMSET and one will be compiled for you.

# AIX
# CFLAGS= -O -DUSE_NETGROUP -DUSE_SYSLOG -DUSE_GETHOSTBYNAME

# HP-UX 9.01:
#    Note: unpatched HP-UX 9.01 c89 has a bug, so that compiling with -O
#    doesn't work.  Patched version is OK.
# CFLAGS= -Aa -D_HPUX_SOURCE -DUSE_NETGROUP -DMAXFD="sysconf(_SC_OPEN_MAX)-1" -DUSE_SYSLOG -DUSE_GETHOSTBYNAME -DRLOG_MACHINE=\"toto.domain\" -DSYSLOG_PRIORITY='((17<<3)+4)'

# IRIX v4.0.5:
# CFLAGS= -g -DUSE_NETGROUP -DSAFE_PATH=\"/bin:/usr/bin:/usr/bsd\"  -DUSE_SYSLOG -DUSE_GETHOSTBYNAME

# Solaris 2.2, 2.3; SunOS 5.2, 5.3:
# CFLAGS= -O -DUSE_NETGROUP -DMAXFD="sysconf(_SC_OPEN_MAX)-1"  -DSUNOS5 -DUSE_SYSLOG -DUSE_GETHOSTBYNAME

# SunOS 4.1.3:
# CFLAGS= -O -DUSE_NETGROUP -DUSE_SYSLOG -DUSE_GETHOSTBYNAME -DRLOG_MACHINE=\"toto.domain\" -DSYSLOG_PRIORITY='((17<<3)+4)'


# Clix 3.1 r.7.1.3 (Intergraph)
# CFLAGS=  -O -DUSE_NETGROUP -DINTERPRETER_HACK

# SCO 3.2v4
# CFLAGS= -g -DSCO -DSCO_SHADOW_PWD -DUSE_SYSLOG 

# Linux 1.2.x
CFLAGS = -Wall -O6 -DUSE_SYSLOG -DSAFE_PATH=\"/bin:/usr/bin\" -DTIMESTAMP_DIR=\"/var/lib/super\" 

#######
# LDFLAGS,LDLIBS

# AIX
# LDFLAGS=
# LDLIBS=

# HP-UX 9.01:
LDFLAGS=
LDLIBS=

# IRIX v4.0.5:	-lsun is for the NIS stuff (so that you can use
#	netgroup entries).  -lmalloc avoids a problem with the
#	default malloc routine that causes a core dump.
# LDFLAGS =
# LDLIBS = -lmalloc -lsun

# Solaris 2.2, 2.3: don't use -Bstatic or -static: it should not be needed
# for security (see LD_LIBRARY_PATH in ld(1)), and the groupname-lookup
# routines are for some reason only available in shared libs (see getgrnam(3)).
# LDFLAGS=
# LDLIBS= -lnsl

# SunOS 4.1.3: no special flags needed.  N.B.: If you use SunOS 4.0.x, you
# should link statically for security.  (I don't know about the proper
# flags for SunOS 4.1.1).
# LDFLAGS=
# LDLIBS=

# Clix 3.1 r.7.1.3 (Intergraph)
# LDFLAGS=
# LDLIBS=-lbsd

# SCO 3.2v4
# LDFLAGS=
# LDLIBS= -lsocket -lmalloc -lufc -lsec


####################################################################
# You shouldn't have to modify anything below this line.
####################################################################

SRC= super.c strqtokS.c regex.c re_fail.c braces.c error.c wildmat.c rsyslog.c version.h
OBJ= super.o strqtokS.o regex.o re_fail.o braces.o error.o wildmat.o rsyslog.o
ALL= README Artistic Copying WhatsNew Makefile super.1 super.5 sample.tab sample.cdmount $(SRC)

all: super

super: $(OBJ)
	$(CC) $(LDFLAGS) -o super $(OBJ) $(LDLIBS)

# NOTICE NOTICE NOTICE!
# You must install super as "super", and not use any other program name.
# This is because at run-time, the program assumes that if it's invoked
# with a different name, it must have been invoked via a symlink, and
# it treats
#	% myothernameforsuper args
# as if you typed
#	% super myothernameforsuper args
# If you insist on installing under another name, then you must
# change the #define ONETRUENAME from "super" to your other
# name, and edit the documentation to match.
install:
	cp super $(BINDIR)/super
	chmod 04755 $(BINDIR)/super
	cp super.1 $(MANDIR)/super.$(MANEXT)
	cp super.5 $(MAN_FMT_DIR)/super.$(MAN_FMT_EXT)

clean:
	rm -f super *.o

$(ALL): 
	co $@

# Because of the wide variation in shar commands, the shar arguments
# used below sticks to a minimal set, and we generate various shar file
# headers by hand.  
shar: $(ALL)
	( echo "#include <stdio.h>" ; \
	echo '#include "version.h"' ; \
	echo 'main() {printf("%s.%s\\n",Version,Patchlevel);exit(0);}') > temp.c
	cc temp.c
	V=super-`a.out`; mkdir $$V && cp $(ALL) $$V && \
	    sed -e 's/-DRLOG_MACHINE=\"toto.domain\"]*"/-DRLOG_MACHINE=\\"toto.domain\\"/' Makefile >> $$V/Makefile.orig && \
	    chmod +w $$V/Makefile && \
	    cp $$V/Makefile.orig $$V/Makefile && \
	    (echo "Submitted-by: will@nfra.nl" ; \
	    echo "Archive-name: $$V/part01" ; echo "" ; \
	    echo "---- Cut Here and feed the following to sh ----" ; \
	    shar $$V ) > $$V.shar && rm -rf $$V
	rm a.out temp.c
