#
# ~ppr/src/pprd/Makefile
# Copyright 1995, 1996, 1997, Trinity College Computing Center.
# Written by David Chappell.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation.  This software is provided "as is" without express or
# implied warranty.
#
# Last modified 26 February 1997.
#

include ../include/global.mk

pprd$(DOTEXE): pprd.$(OBJ) pprd_respond.$(OBJ) pprd_ppopint.$(OBJ) \
		pprd_alert.$(OBJ) pprd_nag.$(OBJ) ../libppr.$(LIBEXT)
	$(CC) $(CFLAGS) \
		-o pprd pprd.$(OBJ) pprd_respond.$(OBJ) \
		pprd_ppopint.$(OBJ) pprd_alert.$(OBJ) pprd_nag.$(OBJ) \
		../libppr.$(LIBEXT) $(OSFLIBS)
	$(STRIP) pprd$(DOTEXE)
	chmod 6711 pprd$(DOTEXE)

pprd.$(OBJ): pprd.c ../include/pprd.h pprd.auto_h ../include/global_defines.h \
		../include/global_structs.h ../include/interface.h \
		../include/respond.h
	$(CC) $(CFLAGS) -c pprd.c

pprd_respond.$(OBJ): pprd_respond.c ../include/global_defines.h \
		../include/global_structs.h \
		../include/pprd.h pprd.auto_h ../include/respond.h
	$(CC) $(CFLAGS) -c pprd_respond.c

pprd_ppopint.$(OBJ): pprd_ppopint.c ../include/global_defines.h \
		../include/global_structs.h ../include/pprd.h \
		pprd.auto_h ../include/util_exits.h \
		../include/respond.h
	$(CC) $(CFLAGS) -c pprd_ppopint.c

pprd_alert.$(OBJ): pprd_alert.c ../include/global_defines.h ../include/pprd.h \
		pprd.auto_h
	$(CC) $(CFLAGS) -c pprd_alert.c

pprd_nag.$(OBJ): pprd_nag.c ../include/global_defines.h ../include/pprd.h \
		pprd.auto_h
	$(CC) $(CFLAGS) -c pprd_nag.c

# This automatically makes a header file which has prototypes for
# all functions and has extern definitions of all global variables. 
# This file is not updated automatically, you must remove pprd.auto_h
# if a function prototype changes.
pprd.auto_h: 
	# functions
	cat pprd.c pprd_respond.c pprd_ppopint.c pprd_alert.c pprd_nag.c \
		| egrep '^[^ 	]+ [^ ]* *[^ ]+\(.*\)$$' \
		| egrep -v '^static ' \
		| sed -e 's/^\(.*\)$$/\1;/' >pprd.auto_h
	# global variables
	cat pprd.c pprd_respond.c pprd_ppopint.c \
		| sed -n -e 's/^\([^ 	][^;]*;\).*$$/extern \1/p' \
		| sed -e 's/\[[^[]*\]/[]/' -e 's/=[^;]*;/;/' \
			 >>pprd.auto_h

# install the thing
install: $(HOMEDIR)/bin/pprd$(DOTEXE)

$(HOMEDIR)/bin/pprd$(DOTEXE): pprd$(DOTEXE)
	$(RMF) $(HOMEDIR)/bin/pprd$(DOTEXE)
	$(CP) pprd $(HOMEDIR)/bin/pprd$(DOTEXE)
	chmod 6711 $(HOMEDIR)/bin/pprd$(DOTEXE)

# clean up
clean:
	$(RMF) *.$(OBJ) *.bak *~ pprd$(DOTEXE)

# end of file
