# $Id: Makefile,v 1.10 1999/09/03 14:50:43 dirk Exp $
# 
# *sweat* ... This makefile is prone to confuse your development system.
#
#         _please_ send any corrections to milliByte@DeathsDoor if this
#         does not work as is.
#

# Set these to the locations of your XView include files and libraries.
#
INCDIR = $(OPENWINHOME)/include
LIBDIR = $(OPENWINHOME)/lib

# Location of the X libraries
XLIBDIR = /usr/X11/lib
# Set these to the directory names in which to install the software and
# help files.
BINDIR = $(OPENWINHOME)/bin
HLPDIR = $(OPENWINHOME)/lib/help

# Set this to the directory containing manual pages.  Manual pages will only
# be installed if you "make install.man".
MANDIR = $(OPENWINHOME)/man

# Set these to the manual sections (e.g. 1, 4, 5, l) for the program and
# database file manual pages, respectively.
PEXT = 1
DEXT = 5

#
# Uncomment and adjust the following if you want fast database lookups using
# the Berkeley libdb code.  You can find libdb on ftp.cs.berkeley.edu in the
# /ucb/4bsd directory.  Make sure you adjust the last part of DBCFLAGS
# to match your system type as listed in libdb's PORT directory.
# Sorry for the bad configurability this time...
#

#DBCFLAGS = -DLIBDB -Idb.1.85/PORT/include -Idb.1.85/PORT/linux
#DBLIB = db.1.85/PORT/linux/libdb.a

# And don't worry about anything from this line on.

############################################################################
# Parameters.

PROGRAM = workman
SOURCES.c = workman_stubs.c database.c cdinfo.c display.c setup.c \
	ui_cdinfo.c plat_sun.c plat_hpux.c plat_linux.c plat_news.c \
	plat_aix.c \
	plat_bsd386.c plat_ultrix.c cdrom.c scsi.c drv_toshiba.c drv_sony.c \
	plat_svr4.c plat_freebsd.c plat_osf1.c plat_irix.c \
	ui_goodies.c cddb.c index.c

SOURCES.h = struct.h workman_ui.h ui_cdinfo.h setup.h workman_stubs.h \
	display.h config.h proto.h cdrom.h plat_.h database.h \
	scsi.h cdinfo.h ui_goodies.h

OBJECTS = \
	$(SOURCES.c:%.c=%.o)

WBPROGRAM = workbone
WBSOURCES.c = workbone.c cdinfo.c \
	plat_sun.c plat_hpux.c plat_linux.c plat_news.c \
	plat_aix.c \
	plat_bsd386.c plat_ultrix.c cdrom.c scsi.c drv_toshiba.c drv_sony.c \
	plat_svr4.c plat_freebsd.c plat_osf1.c plat_irix.c

WBSOURCES.h = struct.h workbone.h config.h proto.h cdrom.h plat_.h \
	database.h cdinfo.h

WBOBJECTS = \
	$(WBSOURCES.c:%.c=%.o)


CDDASLAVE.c = cddaslave.c plat_sun_cdda.c plat_sun_audio.c \
	      plat_linux_cdda.c plat_linux_audio.c
CDDASLAVE.o = $(CDDASLAVE.c:%.c=%.o)

# Compiler flags.

CFLAGS = -O2 -Wall $(PASS) -g # -fwritable-strings
CPPFLAGS = -I$(INCDIR)
LDFLAGS = -L$(LIBDIR) -L$(XLIBDIR) $(LIBLOC)
LDLIBS = -lxview -lolgx -lX11
WBLDLIBS =
CC = gcc 

# Standard targets.

all:	 $(PROGRAM) $(PROGRAM).doc workmandb.doc

$(PROGRAM): $(SOURCES.c) $(OBJECTS)
	$(CC) $(CFLAGS) -I$(INCDIR) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS)

$(WBPROGRAM): $(WBSOURCES.c) $(WBOBJECTS)
	$(CC) $(CFLAGS) -I$(INCDIR) $(LDFLAGS) -o $@ $(WBOBJECTS) $(WBLDLIBS)

buildindex: buildindex.c
	$(CC) $(LDFLAGS) $(CFLAGS) -I$(INCDIR) $(DBCFLAGS) $< $(DBLIB) -o $@

cddaslave: $(CDDASLAVE.o)
	$(CC) $(CFLAGS) -I$(INCDIR) $(LDFLAGS) -o $@ $(CDDASLAVE.o) $(CDDALIBS)

clean:
	$(RM) $(OBJECTS) $(WBOBJECTS) $(CDDASLAVE.o) *.BAK *.delta core workman.doc workmandb.doc

install: $(PROGRAM)
	cp $(PROGRAM) $(BINDIR)

#	chown root $(BINDIR)/$(PROGRAM)
#	chmod 4755 $(BINDIR)/$(PROGRAM)

	cp $(PROGRAM).info $(HLPDIR)
	chmod 644 $(HLPDIR)/$(PROGRAM).info

install.man: workman.man workmandb.man $(MANDIR)/man$(PEXT) $(MANDIR)/man$(DEXT)
	cp workman.man $(MANDIR)/man$(PEXT)/workman.$(PEXT)
	chmod 644 $(MANDIR)/man$(PEXT)/workman.$(PEXT)
	cp workmandb.man $(MANDIR)/man$(DEXT)/workmandb.$(DEXT)
	chmod 644 $(MANDIR)/man$(DEXT)/workmandb.$(DEXT)

display.o: display.c workman_ui.h
setup.o: setup.c workman_ui.h
workman_stubs.o: workman_stubs.c workman_ui.h
ui_cdinfo.o: ui_cdinfo.c workman_ui.h
# This next one isn't completely true, but close enough
# $(OBJECTS): struct.h config.h
$(OBJECTS): $(SOURCES.h)
$(WBOBJECTS): $(WBSOURCES.h)

index.o: index.c
	$(CC) $(CFLAGS) $(DBCFLAGS) -c $<

$(PROGRAM).doc: $(PROGRAM).man
	nroff -man $(PROGRAM).man > $(PROGRAM).doc

workmandb.doc: workmandb.man
	nroff -man workmandb.man > workmandb.doc

#
# Build the DOCS subdirectory from the HTML sources.
#
docs:
	@cd HTML; for i in *.html; do \
		lynx -dump file://localhost`pwd`/$$i > ../DOCS/`basename $$i .html`; \
		echo Converted $$i; \
	done


