CC	= @CC@
CFLAGS	= @CFLAGS@ @CPPFLAGS@ @X_CFLAGS@
LDFLAGS	= @LDFLAGS@
LIBS  = @X_PRE_LIBS@ @X_LIBS@ @LIBS@ @X_EXTRA_LIBS@
prefix = @prefix@
BINDIR        = $(prefix)/bin
LIBLOC        = $(prefix)/lib/logo

# LIBLOC      = `pwd`

OBJS 	= coms.o error.o eval.o files.o graphics.o init.o intern.o \
	  libloc.o lists.o logodata.o main.o math.o mem.o paren.o parse.o \
	  print.o term.o wrksp.o xgraphics.o nographics.o

SRCS	= coms.c error.c eval.c files.c graphics.c init.c intern.c \
	  libloc.c lists.c logodata.c main.c math.c mem.c paren.c parse.c \
	  print.c term.c wrksp.c xgraphics.c nographics.c

HDRS	= globals.h logo.h xgraphics.h

all:	logo logolib helpfiles helpfiles/HELPCONTENTS

logo:	$(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o logo

tags:	$(SRCS)
	ctags -t $(SRCS) $(HDRS)

libloc.c:
	echo 'char *libloc="'$(LIBLOC)'/logolib";' > libloc.c
	echo 'char *helploc="'$(LIBLOC)'/helpfiles";' >> libloc.c
	echo 'char *temploc="/tmp";' >> libloc.c
	echo 'char *separator="/";' >> libloc.c

logolib:	makelib
	chmod +x makelib
	./makelib

helpfiles:
	mkdir helpfiles

helpfiles/HELPCONTENTS:	makehelp usermanual
	./makehelp

makehelp:	makehelp.c
	$(CC) -o makehelp makehelp.c

clean:
	rm *.o libloc.c

ship:
	rm config.h config.cache config.log config.status
	rm makefile makehelp logo *.o libloc.c

install: all
	for d in $(BINDIR) $(LIBLOC) $(LIBLOC)/logolib $(LIBLOC)/helpfiles; do [ -d $$d ] || mkdir -p $$d || exit 1; done
	cp logo $(BINDIR)/.
	cp logolib/* $(LIBLOC)/logolib/.
	cp helpfiles/* $(LIBLOC)/helpfiles/.
