#!/bin/make -f
# Makefile for albums database
#
# This is the makefile that can be used with the albums program
#
# To use, define where the executables are located
# (if they are in your path, then just use the name)
#
# Without any arguments, make will check to see if the index files
# have to be re-built
#
# To run the albums program, type:
#
#	make run
#

#
# Local system definitions - define for your configuration
#

# location of executables - modify for your system
# if the executables are somewhere in your path,
#	 then just use the command name
#
ALBUMS	= ..\cd\albums.exe
BLD_KEY = ..\cd\bld_key.exe
DISCOG  = ..\cd\discog.exe
BROWSE	= ..\cd\browse.exe
FINDSONG = ..\cd\findsong.exe

# ALBUMS	= albums
# BLD_KEY = bld_key
# DISCOG  = discog
# BROWSE	= browse
# FINDSONG = findsong

#
# DAT is the list of all the album files contained in the mast file
#
# This is the list of all the album files that are in your master file.
# If you omit one of the files in this list, then you run the risk
# of totally confusing the program when the index file doesn't match
# the actual data file.
#
# You can get this list by extracting them from your master file
#
# For example, when in vi, you can type:
#	!!sed 's/\|.*//' albums.mst
#

PGMS = $(ALBUMS) $(BLD_KEY) $(DISCOG) $(BROWSE) $(FINDSONG)
FILES = albums.mst albums.hlp readme.* *.awk *.bat makefile
ZOO = albs.zoo alb_dos.zoo discog.zoo cd.zoo

DAT  = \
	africa.alb \
	britain.alb \
	bulgaria.alb \
	chapin.alb \
	classics.alb \
	cockburn.alb \
	fastfolk.alb \
	fifties.alb \
	forties.alb \
	german.alb \
	greek.alb \
	hungary.alb \
	israel.alb \
	jazz.alb \
	kids.alb \
	mideast.alb \
	newage.alb \
	popa.alb \
	popb.alb \
	popc.alb \
	popd.alb \
	pope.alb \
	popf.alb \
	popg.alb \
	poph.alb \
	popi.alb \
	popj.alb \
	popk.alb \
	popl.alb \
	popm.alb \
	popn.alb \
	popo.alb \
	popp.alb \
	popq.alb \
	popr.alb \
	pops.alb \
	popt.alb \
	popu.alb \
	popv.alb \
	popw.alb \
	popx.alb \
	popy.alb \
	popz.alb \
	rumania.alb \
	shows.alb \
	soviet.alb \
	various.alb \
	world.alb \
	xmas.alb \
	yugoslav.alb \
	zydeco.alb

ALL = sorted

TAR =	*.alb \
		readme.db \
		albums.hlp \
		readme.cd \
		albtime.awk \
		chkalb.awk \
		prtalb.awk \
		alb

default:	all
	echo use 'make run' to run the albums program

all:	$(ALL)
	touch $@

sorted:	unsorted
	sort -o albums.sar albums.kar
	sort -o albums.sti albums.kti
	sort -o albums.scu albums.kcu
	rm albums.kcu	# too big to keep around
	touch sorted

unsorted:	keys
	$(BLD_KEY) albums.mst
	touch unsorted

keys:	$(DAT)
	touch keys

run:	all
	$(ALBUMS) albums.mst

discog:	always
	..\cd\discog -a discog.art -c
	cp bulgaria.alb discog/bulgaria.dsc
	cp fastfolk.alb discog/fastfolk.alb

always:
	rm -f always		# should never exist

# checkalb checks for "common" data input errors
checkalb:	$(DAT)
	checkalb $?
	touch $@


zoo:	$(ZOO)
	touch $@

albs.zoo:	$(DAT)
	rm -f $@
	zoo a $@ $(FILES)
	zoo a $@ *.alb albums.s??

alb_dos.zoo:	$(DAT)
	rm -f $@
	zoo a $@ $(PGMS)
	zoo a $@ $(FILES)

discog.zoo:	$(DAT)
	rm -f $@
	zoo a $@ discog.art discog/*.dsc

cd.zoo:	$(DAT)
	rm -f $@
	zoo a $@ ../cd/*.c ../cd/*.h ../cd/makefile ../cd/readme.* $(FILES)

fd:	zoo
	cp $(ZOO) b:/


cd_db.tar:	$(TAR)
	tar cvf $@ $(TAR)

cd_db.tar.Z:	cd_db.tar
	rm -f cd_db.tar.Z
	compress $?
	echo make ftp to archive this file, then delete it

ftp:	cd_db.tar.Z zoo
	ftp gvl
	ftp cs.uwp.edu
