
# You probably only want to edit config.h to install Alex.

# for prof both CF and LDF need "-p"

# CFLAGS= -g -O -p -pg
CFLAGS= -O

# -g -pg
LDFLAGS= 

RPCGEN=	rpcgen
CC= cc

#------------------------------End of configuration section.


NFSOBJS= nfs_prot_svc.o nfs_prot_xdr.o unfsd.o init.o fh.o 

MOUNTOBJS= mount_svc.o mount_xdr.o unfsmntd.o fh.o alexlib.o phonehome.o \
           readinfo.o cmucs.o compat.o

ALEXOBJS= alex.o dirtoinfo.o ftpparent.o ftpchild.o alexlib.o remtimezone.o \
          stringtotime.o readinfo.o cmucs.o compat.o phonehome.o


all: basic alexfsck evictor printinfo 

# Basic is what is needed to get started.
basic: alexd alexmountd

alexd:  ${NFSOBJS} ${ALEXOBJS} defs
	${CC} $(LDFLAGS) -o alexd ${NFSOBJS} ${ALEXOBJS} -lm `./libdefs` 

alexmountd: ${MOUNTOBJS}
	${CC} $(LDFLAGS) -o alexmountd ${MOUNTOBJS} `./libdefs`

# Non basic
#
evictor: evictor.o alexlib.o cmucs.o phonehome.o
	${CC} ${LDFLAGS} -o evictor evictor.o alexlib.o cmucs.o compat.o phonehome.o

alexfsck: readinfo.o alexlib.o alexfsck.o cmucs.o compat.o phonehome.o
	${CC} -o alexfsck alexfsck.o alexlib.o readinfo.o cmucs.o compat.o phonehome.o

printinfo: printinfo.c
	${CC} ${CFLAGS} -o printinfo printinfo.c

defs: defs.o alexlib.o cmucs.o compat.o phonehome.o 
	${CC} ${LDFLAGS} -o defs defs.o alexlib.o cmucs.o compat.o phonehome.o


# -----------------  major items above minor things below --------------------

# if you do not have yacc just say "make noyacc" and then do "make"       
noyacc:
	touch stringtotime.c 

stringtotime.c: stringtotime.y
	yacc -vd stringtotime.y
	mv y.tab.c stringtotime.c

stringtotime.o: stringtotime.c
	${CC} ${CFLAGS} -c -DYYDEBUG stringtotime.c

stringtotime: stringtotime.o stringtotimemain.o alexlib.o phonehome.o
	cc -o stringtotime stringtotime.o stringtotimemain.o alexlib.o phonehome.o


#  Installasion stuff  -----------------------------------------------------

install: all installbasic defs
	./install nonbasic

installbasic: basic defs
	./install basic

#  NFS Stuff ------------------------------------------------------------------

norpcgen:
	touch nfs_prot.h
	touch nfs_prot_svc.c
	touch nfs_prot_xdr.c
	touch mount.h
	touch mount_svc.c
	touch mount_xdr.c

nfs_prot.h: nfs_prot.x config.nfs.h
	${RPCGEN} -h -o $@ nfs_prot.x

nfs_prot_svc.c: nfs_prot.x config.nfs.h
	${RPCGEN} -s udp nfs_prot.x | \
	sed \
		-e 's/main()/main(argc,argv,envp) int argc; char **argv, **envp; /' \
 		-e 's/pmap_unset(/init_Log(); pmap_unset(/' \
		-e 's/RPC_ANYSOCK/makesock(NFS_PORT, NFS_MAXDATA)/' \
		-e 's/svc_run();/unfsd_init(argc,argv,envp); svc_run();/' \
	    > $@

nfs_prot_xdr.c: nfs_prot.x config.nfs.h
	${RPCGEN} -c -o $@ nfs_prot.x



mount.h: mount.x config.nfs.h
	${RPCGEN} -h -o $@ mount.x

mount_svc.c: mount.x config.nfs.h
	${RPCGEN} -s udp mount.x | \
	sed \
		-e 's/main()/main(argc,argv) int argc; char **argv;/' \
 		-e 's/pmap_unset(/init_Log(); pmap_unset(/' \
		-e 's/svc_run();/unfsmntd_init(argc,argv); svc_run();/' \
	    > $@

mount_xdr.c: mount.x config.nfs.h
	${RPCGEN} -c -o $@ mount.x

#  misc    ---------------------------------------------------------------------

clean:
	rm -rf *.o nfs_prot_svc.c nfs_prot_xdr.c nfs_prot.h y.tab.h \
	    stringtotime.c mount_svc.c mount_xdr.c mount.h  alexd alexmountd 

# could make and install "UidStr" but not needed 

UidStr:
	cat /etc/passwd /etc/passwds | awk -f UidStrA.awk | sort -nu | awk -f UidStrB.awk > UidStr


#  To get and make a new version of the software ------------------------------

alpha:
	./getalex alex.alpha.tar.Z

new:
	./getalex alex.tar.Z


#  These are sort of development things ----------------------------------------

LINTFLAGS = -abchx -DDEBUG 
alexlint:
	lint -u alexlib.c dirtoinfo.c alex.c ftpparent.c ftpchild.c remtimezone.c stringtotime.c \
		unfsd.c fh.c readinfo.c phonehome.c

mountlint:
	lint -u alexlib.c unfsmntd.c fh.c readinfo.c

rcs:
	rcsci -q -l unfsd.c init.c fh.c alex.c ftpparent.c ftpchild.c dirtoinfo.c \
		alexlib.c phonehome.c remtimezone.c stringtotime.y readinfo.c \
		remtimezone.c mount.x nfs_prot.x alex.h alexincs.h \
               	config.h config.nfs.h Makefile makerelease printinfo.c \
                alexfsck.c evictor.c getalex defs.c install scripts/*

backup:
	cp *.x backups
	cp *.c backups
	cp *.h backups
	cp *.y backups
	cp Makefile backups
	cp getalex backups
	cp makerelease backups

release:
	makerelease

releaseget:
	cp getalex /../alex/usr/anon/src


# include dependencies    -------------------------------------------------------

nfs_prot_svc.o nfs_prot_xdr.o unfsd.o fh.o init.o: nfs_prot.h config.nfs.h

mount_svc.o mount_xdr.o unfsmntd.o: mount.h config.nfs.h

fh.o unfsd.o init.o: unfsd.h fh.h config.nfs.h

ftpparent.o ftpchild.o: alexftp.h

init.o fh.o unfsd.o dirtoinfo.o ftpparent.o ftpchild.o alexlib.o \
remtimezone.o alexmain.o remtimezonemain.o stringtotimemain.o \
stringtotime.o stringtotime.c alex.o readinfo.o unfsmntd.o evictor.o \
phonehome.o defs.o: alex.h alexincs.h config.h

 
