SHELL	= /bin/sh
# HPUX 9.01 compilation flags:
# CFLAGS	= -z -g -Aa -D_POSIX_SOURCE
# CC	= c89
# GCC compilation flags:
CFLAGS	= -O2
CC	= gcc
LDFLAGS	= -lm
CSRC	= files.c hash.c main.c mem_alloc.c place.c scale.c
HSRC	= defines.h

OBJS	= files.o hash.o main.o mem_alloc.o place.o scale.o
HDRS	= files.h hash.h main.h mem_alloc.h place.h scale.h

##### primary target to make
graphplace: $(OBJS)
	$(CC) -o graphplace $(OBJS) $(LDFLAGS)

#### other make rules
clean:
	rm -f $(OBJS) $(HDRS) core

tags: $(CSRC)
	ctags $(CSRC)

TAGS: $(CSRC)
	etags $(CSRC)

tar: graphplace.1.ps
	gnutar -cvZf graphplace.tar.Z  README Makefile graphplace.1 \
		graphplace.1.ps graphpro.ps $(HSRC) $(CSRC)

depend: $(CSRC)
	mv Makefile Makefile.prev
	awk 'NR==1,/^######### include dependencies/' Makefile.prev >Makefile
	gcc -MM $(CSRC) >>Makefile

graphplace.1.ps: graphplace.1
	groff -man $< > $@

.c.h:
	grep '^export' $< | sed -e 's/export/extern/' -e 's/)$$/);/' >$@

$(OBJS): Makefile

######### include dependencies ##############
files.o : files.c defines.h main.h hash.h mem_alloc.h scale.h 
hash.o : hash.c defines.h main.h mem_alloc.h 
main.o : main.c defines.h files.h mem_alloc.h scale.h place.h 
mem_alloc.o : mem_alloc.c defines.h main.h 
place.o : place.c defines.h mem_alloc.h main.h files.h 
scale.o : scale.c defines.h main.h files.h place.h 
