# Linux Makefile for cd Play 0.3 Audio CD Control Panel
# 
WARN = -Wall 
LIBPATH=/usr/lib
LIBS = -ltermcap -L$(LIBPATH) -lncurses
OBJS = cdp.o color.o display.o misc.o hardware.o database.o getline.o


#
# The directory where you installed the ncurses include files.
# On some Linux machines it's on /usr/include/ncurses, if you don't
# change this you will get another ncurses.h and get plenty of error
# messages when compiling main.c.
#
# If you compile under SystemV, set the NCURSES variable to `.'
#
NCURSES=/usr/local/include
ifeq ($(wildcard /usr/include/ncurses), /usr/include/ncurses)
NCURSES=/usr/include/ncurses
endif

DBG = -I$(NCURSES) 

.c.o:
	gcc $(WARN) -O2 -c $(DBG) $*.c 

all: cdp cdp.1.Z
	
cdp: $(OBJS)
	gcc -o cdp $(OBJS) -s $(DBG) $(LIBS)

cdp.1.Z: cdp.1
	groff -Tascii -man cdp.1 | compress >cdp.1.Z
		
display.o: display.c display.h struct.h

misc.o: misc.c misc.h struct.h

hardware.o: hardware.c struct.h

color.o: color.c

database.o: database.c 

getline.o: getline.c getline.h 

cdp.o: cdp.c cdp.h misc.h display.h struct.h

install: cdp cdp.1.Z
	chmod 755 cdp
	chmod 644 cdp.1.Z
	cp cdp /usr/local/bin
	ln -s /usr/local/bin/cdp /usr/local/bin/cdplay
	cp cdp.1.Z /usr/man/cat1

clean:
	rm -f cdp cdp.1.Z *.o core *~

