# --------------------------------------------------------------------------
#
# Makefile for xwatch
#
# --------------------------------------------------------------------------

# Note: you will need the XForms library to get things compiled. You can
# obtain the library at one of the Linux ftp sites (sunsite.unc.edu,
# tsx-11.mit.edu) or at the primary sites: bloch.phys.uwm.edu:/pub/xforms
# and ftp.cs.ruu.nl:/pub/XFORMS.

# If you have installed XForms as the Makefile of the package does, you won't
# have any problems compiling all. Otherwise, set XFLIBDIR to "-L..." (the
# directory where the library lives) and XFLIBINC to "-I..." (the directory
# where the include file forms.h lives).
# XFLIBDIR = -L/usr/local/lib
# XFINCDIR = -I/usr/local/inc

# A `make install' will create a stripped version of xwatch and install it
# to BINDIR. Define that directory here. If you want to make the program first
# to check it out, before installing it, must do a `make final' before the
# `make install'.
BINDIR = /usr/local/bin

# X barfs on too long commandlines (X11R6 does at least). Comment this out
# if you don't want commandline length checks.
CMDLINEFLAG = -DMAXCMDLINE=1024

# Standard compilation flags. You probably won't have to change these, if
# you are using gcc.
STDCFLAGS = -c -O2 -Wall $(CMDLINEFLAG) $(XFINCDIR)
STDLFLAGS = -s

# Compilation flags for `make debug'. Again, OK for gcc.
DEBUGCFLAGS = -g
DEBUGLFLAGS = -static

# You have edited enough. Now run `make'.
# --------------------------------------------------------------------------


# objects we need for the program
OBJ =  xwatch.o callbacks.o usage.o createbrowser.o \
       createoptions.o alarmhandler.o addfile.o rescanfiles.o scanfile.o \
       warning.o addline.o error.o checksetting.o getcolorindex.o

foobar:
	@echo 'Make what? Choose one of:'
	@echo 'make final : make final version of xwatch'
	@echo 'make debug : make debugging version of xwatch'
	@echo 'make clean : remove objects and binary'
	@echo 'make install : make final version and install to' $(BINDIR)
	@echo 'make dist : make distribution (for me, Karel, only)'
	exit 1

final:
	make xwatch CFLAGS="$(STDCFLAGS)" LFLAGS="$(STDLFLAGS)"

debug:
	make xwatch CFLAGS="$(STDCFLAGS) $(DEBUGCFLAGS)" \
	    LFLAGS="$(DEBUGLFLAGS)"

clean:
	rm -f xwatch $(OBJ) fdesign/*.c fdesign/*.h

install: final $(BINDIR)/xwatch
	cp -p xwatch $(BINDIR)
	
xwatch: $(OBJ)
	$(CC) -o xwatch.new $(OBJ) $(XFLIBDIR) -lforms -lX11 -lm $(LFLAGS)
	mv xwatch.new xwatch

dist: install clean
	header -rk *.c *.h
	.makedist $(BINDIR)

# extra deps
xwatch.o: xwatch.c version.h flres.h settings.h
usage.o: usage.c version.h
