###########################################################################
# LPRng - An Extended Print Spooler System
#
# Copyright 1988-1995 Patrick Powell, San Diego State University
#     [email protected]
# See LICENSE for conditions of use.
#
###########################################################################
# MODULE: Makefile.in
# PURPOSE: top level Makefile for LPD Software
# $Id: Makefile.bsd.in,v 1.4 1997/12/18 09:48:06 papowell Exp papowell $
##########################################################################

SRC=@srcdir@
@SET_MAKE@

#=============================================================================
# List the directories you want to generate:
# DIRS for all, clean, etc.
# ALLDIRS for other such as documentation
#=============================================================================

DIRS= src man
ALLDIRS= $(DIRS) ${SRC}/fonts
TARGET=monitor ifhp

# define default target
MAKETARGET=all

all: $(DIRS)

PHONY: all clean FRC install tar ci cifiles DIRS ALLDIRS warn
#force phony target to be made

$(ALLDIRS): FRC
       (cd $@; $(MAKE) -f Makefile.bsd $(MAKEFLAGS) $(MAKETARGET))

FRC:
###############################################################################

install:
       $(MAKE) MAKETARGET=$@ $(DIRS)

###############################################################################

ci: cifiles
       if test ! -d RCS ; then mkdir RCS; fi;
       $(MAKE) MAKETARGET=$@ $(ALLDIRS)

cifiles: newmake
       if test ! -d RCS ; then mkdir RCS; fi;
       checkin() { \
               ci $(CI) -l -mUpdate -t-Initial $$1; \
       }; \
       for i in *; do \
               if test -f "$$i" ; then \
                       case "$$i" in  \
                       config.h.in ) checkin $$i;; \
                       config.* ) ;; \
                       * ) checkin $$i ;; \
                       esac; \
               fi; \
       done;

newmake:
       for i in Makefile.bsd.in */Makefile.bsd.in ; do \
               d=`dirname $$i`; b=`basename $$i .bsd.in`; c=$${d}/$${b}.in; \
               sed -e '/^#GNU/,/^#/d' -e 's/^#BSD.//' -e 's/$$>/$$>/' \
                -e     's/^if /.if /' -e 's/^endif/.endif/' $$c >/tmp/Makefile.bsd.in; \
               diff $$i /tmp/Makefile.bsd.in >/dev/null || cp /tmp/Makefile.bsd.in $$i;\
       done


###############################################################################

clean:
       -rm -f *.o *.core core $(TARGET)
       $(MAKE) MAKETARGET=$@ $(DIRS)

realclean distclean: clean
       $(MAKE) MAKETARGET=distclean $(DIRS)
       -rm -f Makefile Makefile.bsd \
               config.cache config.h config.log config.status

###############################################################################

shar:
       DIR=`pwd | sed 's,.*/,,' `; \
       if [ ! -f /tmp/$${DIR}.tgz ]; then \
               echo You must make TAR file first; \
               exit 1; \
       fi; \
       cd ..; tar ztf /tmp/$${DIR}.tgz | sed -e '/\/$$/d' |  \
               shar -S -n $${DIR} -a -s [email protected] \
                  -c -o /tmp/$${DIR}-Part -L100

dist:
       echo RCS >/tmp/L_X
       echo Makefile >>/tmp/L_X
       echo core >>/tmp/L_X
       echo '?' >>/tmp/L_X
       echo '*.o' >>/tmp/L_X
       echo '*,v' >>/tmp/L_X
       echo '*.a' >>/tmp/L_X
       echo '*.orig' >>/tmp/L_X
       echo '*.rej' >>/tmp/L_X
       echo '*.sh' >>/tmp/L_X
       for i in $(TARGET) Makefile config.cache config.h config.log config.status; \
                do echo \*/$$i >>/tmp/L_X; done
       cat /tmp/L_X
       DIR=`pwd | sed 's,.*/,,' `; \
       cd ..; \
               tar zXcfv /tmp/L_X $${DIR}.tgz $${DIR}; \
               md5 $${DIR}.tgz |pgp -fast > $$DIR.tgz.md5

cifast:
       find . -type f -newer VERSION -print \
               | sed \
                       -e '/core$$/d' \
                       -e '/RCS/d' \
                       -e '/\.o$$/d'  \
                       -e '/.*liblpr.a$$/d' \
                       -e '/.*checkpc$$/d' \
                       -e '/.*lpr$$/d' \
                       -e '/.*lpd$$/d' \
                       -e '/.*lpq$$/d' \
                       -e '/.*lprm$$/d' \
                       -e '/.*lpc$$/d' \
                       -e '/.*lpbanner$$/d' \
                       -e '/.*lpf$$/d' \
                       -e '/.*lpraccnt$$/d' \
                >/tmp/list
       echo README >>/tmp/list
       cat /tmp/list
       ci $(CI) -l -mUpdate -t-Initial `cat /tmp/list`; \

update:
       pwd | sed -n -e 's,.*/,,' -e 's,.*,#define VERSION "&",p' > src/version.h
       pwd | sed -n -e 's,.*/,,' -e 's,.*,VERSION &,p' > VERSION