CC = gcc           # which compiler to use
CFLAGS = -O2       # options, e.g. for optimisation or ANSI compilation
LIBS = -lnsl -lsocket   # extra libraries needed: Solaris 2 needs LIBS = -lnsl;
                   # SCO Unix needs LIBS = -lsocket
PAGER = less       # Your favourite pager program, e.g. more

PROGRAM = analog
SOURCES = alias.c analog.c formgen.c hash.c init.c output.c sscanf.c utilities.c
OBJS = $(SOURCES:.c=.o)
HEADERS = analhead.h analhead2.h

# Form interface options:
FORMPROG = analform.cgi     # The program that processes the data from the form
FORMSRC = analform.c        # The source code for that program
FORMHTML = analogform.html  # Where the form itself will go
FORMOPTS =                  # Extra analog options when constructing the form

$(PROGRAM): $(OBJS) $(HEADERS) Makefile
	$(CC) $(CFLAGS) $(OBJS) -o $(PROGRAM) $(LIBS)

$(OBJS): $(HEADERS) Makefile
	$(CC) $(CFLAGS) -c $*.c

$(FORMPROG): $(FORMSRC) Makefile
	$(CC) $(CFLAGS) $(FORMSRC) -o $(FORMPROG)

form: $(PROGRAM) $(FORMPROG)
	$(PROGRAM) -form $(FORMOPTS) +O$(FORMHTML)

force:
	touch $(SOURCES)
	make $(PROGRAM) 'CFLAGS=$(CFLAGS)' 'LIBS=$(LIBS)' CC=$(CC)

lint:
	lint $(SOURCES) $(LIBS) | $(PAGER)
