#######################################################################
#
# Makefile for xldlas.c
#
#
#	Easiest installation:		1) Log on as root
#					2) Type `make world'
#
#	To make a normal binary:	1) Type `make'
#
#	To make a static binary:	1) Type 'make static'
#
#######################################################################
#
#	If you are using an older Xforms (such as version 0.81), you'll
#	want to remove the -DXFORMS86 declaration in the CCFLAG 
#	assignment. 
#
CCFLAG		= -O2 -Wall -DXFORMS86
CC		= gcc
COMMONLIBS	= -L/usr/X11R6/lib/ -lX11 -lm
SHAREDLIBS	= -lforms
STATICLIBS	= -lXpm /usr/X11R6/lib/libforms.a
ECHO		= echo
RM		= rm
RMOPTS		= -f
CP		= cp
CPOPTS		= -i
INSTALL		= install
INSTALLOPTS	= -d 

BINDIR		= /usr/local/bin
MANDIR		= /usr/man/man1
HELPDIR		= /usr/local/xldlas/help
SRCDIR		:= $$PWD
USER		:= $$LOGNAME

########################################################################


all:		shared

world:		all install install.man

shared:		xldlas.o frontend.o setstate.o files.o data.o log.o\
		graph.o analysis.o help.o generate.o tips.o tests.o filters.o
		$(RM) $(RMOPTS) ./xldlas
		$(CC) $(CCFLAG) xldlas.o frontend.o setstate.o files.o data.o\
		log.o graph.o analysis.o help.o generate.o tips.o tests.o\
		filters.o -o xldlas\
		$(COMMONLIBS) $(SHAREDLIBS)

static:		xldlas.o frontend.o setstate.o files.o data.o log.o\
		graph.o analysis.o help.o generate.o tips.o tests.o filters.o
		$(RM) $(RMOPTS) ./xldlas
		$(CC) $(CCFLAG) xldlas.o frontend.o setstate.o files.o data.o\
		log.o graph.o analysis.o help.o generate.o tips.o tests.o\
		filters.o  -o xldlas\
		$(COMMONLIBS) $(STATICLIBS)

xldlas.o:	xldlas.h xldlas.c
		$(CC) $(CCFLAG) xldlas.c -c 

frontend.o:	xldlas.h frontend.c xldlas_logo.xpm humboldt_logo.xpm
		$(CC) $(CCFLAG) frontend.c -c

setstate.o:	xldlas.h setstate.c
		$(CC) $(CCFLAG) setstate.c -c

files.o:	xldlas.h files.c
		$(CC) $(CCFLAG) files.c -c

data.o:		xldlas.h data.c
		$(CC) $(CCFLAG) data.c -c


log.o:		xldlas.h log.c
		$(CC) $(CCFLAG) log.c -c


graph.o:	xldlas.h graph.c
		$(CC) $(CCFLAG) graph.c -c


analysis.o:	xldlas.h analysis.c
		$(CC) $(CCFLAG) analysis.c -c


help.o:		xldlas.h help.c
		$(CC) $(CCFLAG) help.c -c

generate.o:	xldlas.h generate.c
		$(CC) $(CCFLAG) generate.c -c

tips.o:		xldlas.h tips.c
		$(CC) $(CCFLAG) tips.c -c

tests.o:	xldlas.h tests.c
		$(CC) $(CCFLAG) tests.c -c

filters.o:	xldlas.h filters.c
		$(CC) $(CCFLAG) filters.c -c

clean:		
		@$(ECHO) Removing all object files, text backup files, \
		and the xldlas executable ...
		@$(RM) $(RMOPTS) *~ *.o ./help/*~ xldlas

install:	xldlas
		@$(ECHO)
		@$(ECHO) Installing executable and help files ...
		@if test 'root' = $(USER); then \
			$(ECHO) " "; else \
			$(ECHO) "I don't think you're root,\
			so the following commands will probably fail"; fi 
		@$(ECHO)
		@$(CP) $(CPOPTS) xldlas $(BINDIR)
		@if test '/usr/local/xldlas' = $(SRCDIR); then \
			$(ECHO) Help Files Already in Place; else \
			$(INSTALL) $(INSTALLOPTS) ./help $(HELPDIR); fi
install.man:	
		@$(ECHO)
		@if test 'root' = $(USER); then \
			$(ECHO) "Copying man page..."; else \
			$(ECHO) "I don't think you're root,\
			so the following commands will probably fail"; fi 
		@$(ECHO)
		@$(CP) $(CPOPTS) ./xldlas.1 $(MANDIR)
		
