######################################################################
# $Id: Makefile.in,v 1.52 2002/12/24 04:23:57 hartmann Exp $
######################################################################

TARGET = freesweep
VERSION = 0.91

SRCS = clear.c drawing.c error.c fgui.c files.c game.c gpl.c main.c pbests.c\
	play.c sl.c stats.c tick.c utils.c image.c
HEADS = sweep.h defaults.h acconfig.h
MISC = README Makefile sweeprc install-sh configure.in Makefile.in\
	config.guess configure config.sub sweep.h.in freesweep.6.in CHANGES\
	config.h.in
CLEANUP = a.out $(TARGET) core made $(OBJS) config.cache config.log\
	config.status

srcdir = @srcdir@
VPATH = @srcdir@

prefix = @prefix@
exec_prefix = @exec_prefix@
#bindir = $(exec_prefix)/bin
bindir = @bindir@

CC = @CC@
CFLAGS = -Wall -DVERSION=\"$(VERSION)\" @CFLAGS@
LIBS = @LIBS@
LDFLAGS = @LDFLAGS@
OBJS = $(SRCS:.c=.o)

TARGET_DIR = $(TARGET)-$(VERSION)
FILES = $(SRCS) $(MISC) $(HEADS)

# for systems that have purify
PURE_ARGS = /s/purify/bin/purify -collector=/s/purify/bin/collect2

.SUFFIXES: .c .o
.PHONY: clean sterile lines distclean maintainer-clean mrproper
#######################################################################
%.o: %.c $(HEADS) Makefile
	@@RM@ -f $*.o 
	$(CC) $(CFLAGS) -c $<

$(TARGET): $(OBJS) $(HEADS) $(MISC)
	@@RM@ -f $(TARGET)
	$(PURIFY) $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $(TARGET)

configure: configure.in
	autoconf

#config.h.in: acconfig.h
#	autoheader

clean:
	@-@RM@ -rf $(CLEANUP)

pure:
	@make clean
	@make "PURIFY=$(PURE_ARGS)"

install: $(TARGET) $(TARGET).6
	touch sweeptimes
	./install-sh -c -m 2555 -o root -g games -s $(TARGET) $(bindir)/$(TARGET)
	./install-sh -c -m 0664 -o root -g games sweeptimes @SCORESDIR@/sweeptimes
	./install-sh -c -m 0644 -o root -g games sweeprc @PREFSDIR@/sweeprc
	./install-sh -c -m 0444 -o root -g games $(TARGET).6 @mandir@/man6/$(TARGET).6

distclean:
	@make sterile

maintainer-clean:
	@make sterile

mrproper:
	@make sterile

sterile:
	-make clean
	@-@RM@ -f *.o core made $(TARGET) a.out sweep.h configure Makefile freesweep.6 debug.log

tar: $(SRCS) $(MISC)
	(cd ../ ; @LN_S@ sweep $(TARGET_DIR))
	(cd ../ ; @TAR@ cvfh $(TARGET_DIR).tar $(FILES:%=$(TARGET_DIR)/%))
	(cd ../ ; rm $(TARGET_DIR))

tags: $(SRCS) $(HEADS) $(MISC)
	@ctags $(SRCS) $(HEADS)

lines: $(SRCS) $(HEADS)
	@echo 'Total lines of code:'
	@wc -l $(SRCS) $(HEADS) | sort -rn
