## This is the makefile for dcd, dave's cd player.

# Select your compiler; gcc is probably just fine.
CC = gcc

# Prefix for installing dcd. `make install' will put files in PREFIX/bin
# and PREFIX/man/man1 .
PREFIX = /usr/local

# Is the system where dcd will be used connected to the 'net regularly?
# If so, uncomment the following line. (Even if you don't define this,
# you can tell dcd that the 'net is available with the 'c' command-line
# option.) Enabled by default.
NET = true

# Where should dcd look for CD Index entries? (relative to ~)
# This is the default, which you probably don't need to change.
# Not many CD players use the CD Index yet (http://www.cdindex.org/)
# so this may change as a "standard" emerges (assuming CD Index actually
# survives much longer - see their Web page for painful details).
# CDI = .cdindex

# Should dcd warn you about CDs that aren't in the CD Index database?
# If this is enabled, just about every invocation of dcd will print an
# error message if the CD in your player isn't listed. Though enabled
# by default, beware; CD Index URLs are kinda big and ugly. Comment
# out the next line to disable this "feature".
UNKNOWN_CD = true

# Where should dcd store its process ID? (relative to ~)
# This is the default, which you probably don't need to change.
# PID = .dcdpid

# Some CD-ROMs are a bit buggy, and take a second or two to switch
# tracks. The net result is that, usually, the last second or two
# of a track is cut off. If you have that problem, change this 'define'
# to be something greater than zero and uncomment it. (It's in seconds.)
# SLEEP = -DEXTRA_SLEEP_TIME=0

# This is your CD-ROM device. The default is /dev/cdrom so if you're okay
# with that, you don't even need to uncomment the next line.
# CDROM = /dev/cdrom
# Or, if you use devfs, uncomment this line:
CDROM = /dev/cdroms/cdrom0



## Less-configurable stuff here.

# Uncomment the next line to enable debugging flags. This will bloat the
# programs, and dump all sorts of mildly-useful stuff to stderr.
# In all likelihood you never want to do this. BTW, defining DEBUG as 1
# will put in some debugging, and defining it > 1 puts in bucketloads of it.
# DEBUG = 1
# DEBUG = 2

# Don't enable this unless you have severe problems, as it's dorky.
# (For the gearheads: this uses CDROMSTOP instead of CDROMSTART to handle
# some track-change behaviours. CDROMSTART is more standards-compliant,
# friendlier, and emits 20% fewer oxides of nitrogen.)
# OLDSTOP = 1

RM = rm

## Here be dragons... (Non-configurable parts past here.)

ifdef DEBUG
EXTRA_CFLAGS = -DDEBUG=${DEBUG} -Wall -pedantic -g
else
EXTRA_CFLAGS = -O2
endif

ifdef CDROM
EXTRA_CFLAGS += -DCDROM_DEVICE=\"${CDROM}\"
endif

ifdef CDI
EXTRA_CFLAGS += -DCDINDEX_HOME=\"${CDI}\"
endif

ifdef PID
EXTRA_CFLAGS += -DPIDFILE=\"${PID}\"
endif

ifdef NET
EXTRA_CFLAGS += -DNETWORK_CAPABLE=TRUE
endif

ifdef SLEEP
EXTRA_CFLAGS += ${SLEEP}
endif

ifdef UNKNOWN_CD
EXTRA_CFLAGS += -DUNKNOWN_CD_WARN
endif

ifdef OLDSTOP
EXTRA_CFLAGS += -DOLD_STOP_BEHAVIOUR
endif

# end of compile-time option twiddlers

PROGS = dcd
OBJECTS = screenop.o infinite.o libcdplay.o process.o \
	sha.o base64.o cdindex.o cd-misc.o dcd.o 
SRCS = screenop.c screenop.h infinite.c infinite.h libcdplay.c libcdplay.h \
       process.c process.h dcd.c dcd.h sha.c sha.h base64.c \
       base64.h endian.h version.h cdindex.c cdindex.h cd-misc.h cd-misc.c \
       Makefile

all: ${PROGS}

.c.o: ${SRCS}
	$(CC) -c $(CFLAGS) ${EXTRA_CFLAGS} $< -o $@
 
${PROGS}: ${OBJECTS}
	${CC} ${CFLAGS} ${EXTRA_CFLAGS} ${OBJECTS} -o $@

clean:;
	-${RM} *.o ${PROGS}

install: dcd
	install -m 755 -d ${PREFIX}/bin
	install -m 755 -s dcd ${PREFIX}/bin
	install -m 755 -d ${PREFIX}/man/man1
	install -m 644 dcd.1 ${PREFIX}/man/man1
	install -m 755 -d ${HOME}/${CDI}

# depend:
# 	makedepend -- ${CFLAGS} ${EXTRA_CFLAGS} -- ${SRCS}
# The above option seems to be extraneous now.

# DO NOT DELETE
