##
##  Top-level Makefile for Dialup IP.
##  Copyright (c) 1991 Bolt Beranek and Newman, Inc.
##  All rights reserved.
##
##  Redistribution and use in source and binary forms are permitted
##  provided that: (1) source distributions retain this entire copyright
##  notice and comment, and (2) distributions including binaries display
##  the following acknowledgement:  ``This product includes software
##  developed by Bolt Beranek and Newman, Inc. and CREN/CSNET'' in the
##  documentation or other materials provided with the distribution and in
##  all advertising materials mentioning features or use of this software.
##  Neither the name of Bolt Beranek and Newman nor CREN/CSNET may be used
##  to endorse or promote products derived from this software without
##  specific prior written permission.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
##  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
include Makefile.inc


TARFILE		= dialup.tar
SUBDIRS		= dulib dumisc diald dialmon
DIAL_VARS	= DIAL_BUILD=$(DIAL_BUILD) DIAL_ROOT=$(DIAL_ROOT)


##  Common targets.
all lint:		FORCE
	for dir in $(SUBDIRS) ; do \
	    cd $$dir ; make $(DIAL_VARS) $@ ; cd .. ; \
	done

clean:			FORCE
	rm -f foo core tags lint* a.out *.o $(PROGRAMS) $(LOG_DIR)/*.log
	rm -f $(DIPLINTLIB) $(DIPLIB) ../MANIFEST
	for dir in $(SUBDIRS) ; do \
	    cd $$dir ; make $(DIAL_VARS) $@ ; cd .. ; \
	done

##  Install everything.
install:		FORCE $(BIN_DIR)/. $(CONFIG_DIR)/. \
			$(LOG_DIR)/. $(LOG_DIR)/call.log $(LOG_DIR)/dial.log
	@echo "Dialup IP " | tr -d '\012'
	-@ident dulib/diprelease.c | awk '$$1 ~ /\$$Revision\:/ {print $$2}'
	for dir in $(SUBDIRS) ; do \
	    cd $$dir ; make $(DIAL_VARS) $@ ; cd .. ; \
	done

$(BIN_DIR)/.:
	mkdir $(BIN_DIR)
	chmod 755 $(BIN_DIR)

$(CONFIG_DIR)/.:
	mkdir $(CONFIG_DIR)
	chmod 755 $(CONFIG_DIR)
	cp ../config/* $(CONFIG_DIR)/.
	@echo "Edit templates in $(CONFIG_DIR) as necessary."

$(LOG_DIR)/.:
	mkdir $(LOG_DIR)
	chmod 755 $(LOG_DIR)
$(LOG_DIR)/call.log:
	touch $(LOG_DIR)/call.log
$(LOG_DIR)/dial.log:
	touch $(LOG_DIR)/dial.log

tar:			FORCE ../MANIFEST
	@rm -f ../$(TARFILE)
	cd .. ; tar vcf $(TARFILE) `cat MANIFEST`

tarlist ../MANIFEST:	Makefile Makefile.inc
	@echo You should make sure you did a \"make clean\" first!
	@rm -f ../MANIFEST
	echo bin >../MANIFEST
	echo log >>../MANIFEST
	echo lib >>../MANIFEST
	echo README >>../MANIFEST
	echo MANIFEST >>../MANIFEST
	cd .. ; find doc src sys config ifconfig.sun -type f -print \
		| grep -v RCS >>MANIFEST
	sort ../MANIFEST -o ../MANIFEST

FORCE:
