# These options are used only by 'make install' and 'make installbinaries'

TOPDIR  = /usr/pfs
P_BINARIES	= /usr/pfs/bin
OWNER   = pfs
GROUP   = pfs

# This definition of install is useful if you do not plan to throw away 
# debugging information.
# INSTALL = install
# If space is at a premium and you want the binaries stripped of their 
# symbol tables and other debugging informaiton when they're installed, 
# use the following definition of INSTALL instead.  If you are going to throw 
# away the debugging information anyway, you can speed up the compile 
# and linking process by changing the definition of CFLAGS below to not 
# include the -g option, which means 'include debugging information'.
# This is now turned on by default.
INSTALL = install -s
#
# If you're using HP-UX (or other systems without a BSD-like 'install'
# command, use the version we provide in the misc subdirectory of this
# distribution.
# INSTALL = sh /usr/pfs/source/misc/install.sh


MACHDEF =		# empty for most systems
# If you're using AIX, set MACHDEF to be this:
# MACHDEF = -DAIX
#
# The system include files on Ultrix systems depend on the compiler predefining
# __LANGUAGE_C, __mips or __vax, and, if on a MIPS system,
# __MIPSEL for the little-endian version and __MIPSEB for the big-endian 
# version.   The version of GCC I was using did not predefine these constants,
# although the system's C compiler did.  If you are on an ULTRIX system and
# encounter errors involving 'struct sigcontext' or '.w_Retcode' being
# undefined, set MACHDEF to include these definitions.  One of the following
# three choices will work, depending upon your configuration.
# MACHDEF = -D__mips -D__MIPSEL -D__LANGUAGE_C
# MACHDEF = -D__mips -D__MIPSEB -D__LANGUAGE_C
# MACHDEF = -D__vax -D__LANGUAGE_C
#
# In addition, under Ultrix4.2 using GCC version 1.37.1 OSF 1.9.2.13, I 
# encountered a bug explained in <include/pprot.h>.  Add this to the 
# definition of MACHDEF if you get error messages complaining that NULL 
# has been redefined.
#	-DCONFLICT_BETWEEN_DEFINITION_OF_NULL_IN_SYS_PARAM_H_AND_STDDEF_H


CC	= gcc
# Debugging is turned off in the default distribution in order to keep things
# reasonably small.
# If you encounter segmentation faults or other problems, we may ask you to
# reset this to '-g', 'make clean', and recompile the binaries so that we can
# get a stack trace and other useful debugging information.
# CFLAGS  = -g
CFLAGS  =
F_CC	= ${CFLAGS} -c 
F_CCL   = $(CFLAGS)
# Define this if you feel like making AR verbose when it builds the libraries.
# AR_FLAGS=v



# Use the following definitions if you want Kerberos Version 5
# authentication. 
# The location of the Kerberos version 5 libraries and include files will vary
# from machine to machine.
# We don't enable the Kerberos libraries and include files by default because 
# searching the huge Kerberos libraries substantially slows down the linker.
# K_INC   = -I/nfs/kerberos/v5/include
# KRB_LIBS = -L/nfs/kerberos/v5/lib -lkrb5 -lcrypto /nfs/kerberos/v5/extlib/libisode.a
# Use the following definitions if you don't want Kerberos.
K_INC    =
KRB_LIBS =



# Unneeded; defined by the subsidiary Makefiles as needed.  
# P_INC   = -I/usr/pfs/source/include
# INCS    = $(P_INC) $(K_INC)

MAKE	= make

PASTHRU = P_BINARIES=${P_BINARIES} INSTALL="${INSTALL}" OWNER=${OWNER} \
	  GROUP=${GROUP} CC=${CC} F_CC="${F_CC}" F_CCL="${F_CCL}" \
	  K_INC="${K_INC}" MAKE=${MAKE} KRB_LIBS="${KRB_LIBS}" LIBS="${LIBS}" \
	  MACHDEF="${MACHDEF}" AR_FLAGS="${AR_FLAGS}" \
	  MORE_USER_PROGS="${MORE_USER_PROGS}"  \
  	  MORE_SERVER_PROGS="${MORE_SERVER_PROGS}"

# Programs that live in subdirectories, and have makefiles of their own.
# "lib" has to be built first and lib/pfs and lib/pcompat before lib/filters.
SUBDIR	= \
	 lib/pfs \
	 lib/psrv \
	 lib/ardp \
	 server \
	 lib/pcompat \
	 lib/filters \
	 user \
	 app


# We pipe this through this sed script in order to precede CC and GCC error
# messages with the full pathname name of the file at fault.  This lets 
# EMACS's (next-error) function visit compilation errors that occur in 
# subdirectories.

all:
	for i in ${SUBDIR}; do \
	    (cd $$i; \
 	    echo "Making in $$i"; \
	    ${MAKE} ${PASTHRU} all 2>&1 | sed -e '/^[a-z_\/\.]*\.[ch]:/s,^,'$$i'\/,'); \
	    done

install: installdirs installbinaries

installdirs:
	-mkdir ${TOPDIR} ${TOPDIR}/shadow ${TOPDIR}/pfsdat ${P_BINARIES}
	-chown ${OWNER} ${TOPDIR} ${TOPDIR}/shadow ${TOPDIR}/pfsdat 
	-chgrp ${GROUP} ${TOPDIR} ${TOPDIR}/shadow ${TOPDIR}/pfsdat 
	-chmod 755 ${TOPDIR} ${TOPDIR}/shadow ${TOPDIR}/pfsdat 


installbinaries:
	-for i in user server app; do \
	    (cd $$i; \
	    ${MAKE} ${PASTHRU} install); \
	    done

clean:
	rm -f *~
	for i in ${SUBDIR}; do (cd $$i; ${MAKE} clean); done

# Piping this through SED hides the many error messages from files not found.
# mv -f isn't the same as RM -f; no way to make MV not complain about unfound
# files, so we'd have to write our own.	
hide:
	-(mkdir .hide ; \
	mv -f *~ .hide ; \
	for i in ${SUBDIR}; do (cd $$i; ${MAKE} hide); done) 2>&1 | \
	       sed -e '/^mv:.*: Cannot access: No such file or directory$$/d' \
			-e '/^\*\*\* Error code 1 (ignored)$$/d' \
			-e '/^mkdir: .hide: File exists$$/d'

unhide:
	-mv .hide/* .hide/.??* .
	-rmdir .hide
	for i in ${SUBDIR}; do (cd $$i; ${MAKE} unhide); done
		
# Dependencies
