# This file has been modified by Joe Kirby <kirby@utk.edu> to accomodate
# "Debianization". Changes have been clearly (I hope!) marked. 7 Feb 1996

#
#   Time-stamp: <95/10/01 22:28:12 yusuf>
#

#All the user config stuff, including directories etc..
#is found in Makefile.common
#
#
include version
include Makefile.common




all: taper taper.8

version.h:version
	echo "#define CUR_VERSION \""$(VERSION)"\"" > version.h
	grep "MS_MGC_VAL" /usr/src/linux/include/linux/fs.h >> version.h

taper: version.h .depend $(TAPER_OBJS) check_sd
	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDE) -o taper $(TAPER_OBJS) \
		$(COMPRESS_DIR)/$(COMPRESS_LIB) $(LIBPATH) \
		$(LINKLIB) -l$(FORM) -l$(CURSES)

taper-static: version.h .depend $(TAPER_OBJS) check_sd
	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDE) -o taper-static $(TAPER_OBJS) \
		$(COMPRESS_DIR)/$(COMPRESS_LIB) $(LIBPATH) $(LINKLIB) 
		-l$(FORM) -l$(CURSES) -static

check_sd: 
	make -C $(COMPRESS_DIR) $(COMPRESS_LIB)

# <jsk> The following two lines
# taper.8: taper.txt
#	cp taper.txt taper.8
# have been commented out to keep from overwriting the man page

taper.txt: taper.sgml
	sgml2txt taper

.c.o:
	$(CC) $(TAPER_CFLAGS) $(CFLAGS) $(DEFINES) $(INCLUDE) -o $@ -c $<

install:
	install --mode 755 --strip taper $(BINDIR) 
	install --mode 644 taper.8 $(MANDIR)

uninstall:
	rm -rf	$(BINDIR)/taper \
		$(MANDIR)/taper.8

# <jsk>The following two lines
# clean:
#	rm -rf core *.o taper .depend *~ taper.8 version.h 
# have been changed to
clean:
	rm -rf core *.o taper .depend *~ version.h
# to keep from removing the man page
	make -C $(COMPRESS_DIR) clean
	

.depend:
	make depend

depend:
	$(CC) -M $(INCLUDE) $(TAPER_SRCS) > .depend
	make -C $(COMPRESS_DIR) depend
	
	
dep: depend

ifeq (.depend, $(wildcard .depend))
include .depend
endif
#
#
#--for making distributions only --------------------------------------
#
INSTALL:INSTALL.raw
	sed -e "s/NEEDS_VERSION/$(VERSION)/" \
	    -e "s/NEEDS_DATE/$(DATE)/" INSTALL.raw > INSTALL

taper.sgml:taper.sgml.raw
	sed -e "s/NEEDS_VERSION/$(VERSION)/" \
	    -e "s/NEEDS_DATE/$(DATE)/" taper.sgml.raw > taper.sgml 

taper-$(VERSION).lsm:taper.lsm.raw
	sed -e "s/NEEDS_VERSION/$(VERSION)/" \
            -e "s/NEEDS_DATE/$(DATE)/" taper.lsm.raw > taper-$(VERSION).lsm


distrib:
	make clean
#move the raw files away
	cp INSTALL.raw ../INSTALL-$(VERSION).raw
	cp taper.sgml.raw ../taper.sgml-$(VERSION).raw
	cp taper.lsm.raw ../taper-$(VERSION).lsm.raw
#make the files with correct dates/version
	make INSTALL
	make taper.sgml
	make taper-$(VERSION).lsm
#for those that don't have the linuxdoc package
	make taper.txt
#remove excess files from distribution
	touch ttt
	rm ttt INSTALL.raw taper.sgml.raw taper.lsm.raw
	ln -s taper.sgml taper.sgml.raw
#make tar archive
	cd .. ; tar czf taper-$(VERSION).tar.gz taper-$(VERSION)/*
	cp *.lsm ../
#remove the corrected files
	rm INSTALL
	rm taper.sgml
	rm taper-$(VERSION).lsm
	rm taper.sgml.raw
#bring back this for the next version
#bring back my raw files
	mv ../INSTALL-$(VERSION).raw INSTALL.raw
	mv ../taper.sgml-$(VERSION).raw taper.sgml.raw
	mv ../taper-$(VERSION).lsm.raw taper.lsm.raw

backup:
	mount /drivea
	make clean
	touch taper.txt ttt INSTALL taper.sgml taper-$(VERSION).lsm
	rm taper.txt ttt INSTALL taper.sgml taper-$(VERSION).lsm
	mkdir -p /drivea/taper$(DVERSION)
	cp -a * /drivea/taper$(DVERSION)
	umount /drivea


