# Makefile for the `samefile' program written by Jens Schweikhardt
#
# $Id: Makefile.in,v 1.11 2005/08/07 19:04:33 schweikh Exp $

prefix      = @prefix@
exec_prefix = @exec_prefix@
bindir      = @bindir@
mandir      = @mandir@
man1dir     = $(mandir)/man1

AWK         = @AWK@
CC          = @CC@
CFLAGS      = @CFLAGS@
LDFLAGS     = @LDFLAGS@
INSTALL     = @INSTALL@

PROGRAM     = samefile
MANPAGE     = samefile.1
VERSION     = 2.12
CVSTAG      = SAMEFILE_2_12
PROGVERS    = $(PROGRAM)-$(VERSION)
RELEASED    = 200508070212
CSOURCE     = $(PROGRAM).c error.c fgetline.c options.c
OBJECTS     = $(PROGRAM).o error.o fgetline.o options.o
SOURCE      = $(CSOURCE) error.h fgetline.h options.h shutup.h
CONFIGS     = Makefile.in configure configure.in config.h.in
OTHER       = install-sh INSTALL README test.exp ChangeLog schweikh3.c \
              samefile.spec
MAKABLE     = Makefile config.h config.status config.cache config.log \
              configure.lineno
DISTRIB     = $(SOURCE) $(CONFIGS) $(MANPAGE) $(OTHER)

all: $(PROGRAM)

$(PROGRAM): $(OBJECTS)
	$(CC) $(LDFLAGS) -o $@ $(OBJECTS)

install: all
	if test ! -d $(DESTDIR)$(bindir); then $(INSTALL) -d $(DESTDIR)$(bindir); fi
	if test ! -d $(DESTDIR)$(man1dir); then $(INSTALL) -d $(DESTDIR)$(man1dir); fi
	$(INSTALL) -m 0755 $(PROGRAM) $(DESTDIR)$(bindir)
	$(INSTALL) -m 0644 $(MANPAGE) $(DESTDIR)$(man1dir)

uninstall:
	rm -f $(bindir)/$(PROGRAM) $(man1dir)/$(MANPAGE)

clean:
	rm -rf $(PROGRAM) *.o *core samefile-* tst test.out *.bak schweikh3

distclean: clean
	rm -f $(MAKABLE)

tgz: $(PROGVERS).tar.gz
	md5 $(PROGVERS).tar.gz | tee port/samefile/distinfo
	printf 'SIZE ($(PROGVERS).tar.gz) = %s\n' `stat -f %z $(PROGVERS).tar.gz` \
		>> port/samefile/distinfo
	perl -pi -e 's/(PORTVERSION=).*/$$1\t$(VERSION)/' port/samefile/Makefile

tag:
	cvs tag -F $(CVSTAG)

$(PROGVERS).tar: $(DISTRIB)
	rm -rf $(PROGVERS)
	mkdir $(PROGVERS)
	perl -pi -e 's/^(Version:).*/$$1 $(VERSION)/' samefile.spec
	cp $(DISTRIB) $(PROGVERS)
	chmod 644 $(PROGVERS)/*
	chmod 755 $(PROGVERS)/configure $(PROGVERS)/install-sh
	touch -t $(RELEASED) $(PROGVERS) $(PROGVERS)/*
	tar cfv $@ $(PROGVERS)
	touch -t $(RELEASED) $@

$(PROGVERS).tar.gz: $(PROGVERS).tar
	gzip -c9f $(PROGVERS).tar > $@
	touch -t $(RELEASED) $@

install-maintainer: $(PROGVERS).tar.gz
	cp -p $(PROGVERS).tar.gz $$HOME/prj/homepage
	cd $$HOME/prj/homepage; make upload FILES=$(PROGVERS).tar.gz

build-maintainer:
	@rm -rf cvs; mkdir cvs; cd cvs; \
	cvs -d /home/schweikh/prj/repo co -r$(CVSTAG) samefile; \
	cd samefile; ./configure --quiet; make -s test; make -s tgz

schweikh3: schweikh3.c
	gcc -std=iso9899:199409 -DM0=sizeof -DM1=long -DM2=void \
	           -DM3=realloc -DM4=calloc -DM5=free -o $@ schweikh3.c

uu: $(PROGVERS).tar.gz
	uuencode $(PROGVERS).tar.gz < $(PROGVERS).tar.gz > $(PROGVERS).tar.gz.uue
	touch -t $(RELEASED) $(PROGVERS).tar.gz.uue

shar: $(DISTRIB)
	rm -rf $(PROGVERS)
	mkdir $(PROGVERS)
	cp $(DISTRIB) $(PROGVERS)
	touch -t $(RELEASED) $(PROGVERS) $(PROGVERS)/*
	shar `find $(PROGVERS) -print` > $(PROGVERS).sh
	touch -t $(RELEASED).sh

tags: $(SOURCE)
	ctags -f $@ $(SOURCE)

test: $(PROGRAM)
	@echo 'Any output before the words "Test completed."'
	@echo 'indicates an anomaly worth investigating.'
	@rm -rf tst
	@mkdir tst
	@cp samefile.c tst/file1
	@ln tst/file1  tst/file2
	@ln tst/file1  tst/file3
	@cp samefile.c tst/file4
	@ln tst/file4  tst/file5
	@cp samefile.c tst/file6
	@ls tst/* | ./$(PROGRAM) | sed 's/^......//' >test.out
	@echo >>test.out
	@ls tst/* | ./$(PROGRAM) -i | sed 's/^......//' >>test.out
	@echo >>test.out
	@ls tst/* | ./$(PROGRAM) -ix | sed 's/^......//' >>test.out
	@echo >>test.out
	@echo 'Immediate EOF:' >>test.out
	@./$(PROGRAM) </dev/null >>test.out 2>&1 || :
	@echo >>test.out
	@echo 'Immediate EOF, verbose:' >>test.out
	@./$(PROGRAM) -v </dev/null >>test.out 2>&1 || :
	@echo >>test.out
	@echo 'One existing file:' >>test.out
	@echo test.exp | ./$(PROGRAM) </dev/null >>test.out 2>&1 || :
	@echo >>test.out
	@echo 'One non-existing file:' >>test.out
	@echo '& No_Such_File !;' | ./$(PROGRAM) </dev/null >>test.out 2>&1 || :
	@echo >>test.out
	@echo 'Invalid option:' >>test.out
	@./$(PROGRAM) -ix% </dev/null >>test.out 2>&1 || :
	@diff test.out test.exp || :
	@echo 'Test completed.'

test.exp: $(PROGRAM)
	rm -rf tst
	mkdir tst
	cp samefile.c tst/file1
	ln tst/file1  tst/file2
	ln tst/file1  tst/file3
	cp samefile.c tst/file4
	ln tst/file4  tst/file5
	cp samefile.c tst/file6
	ls tst/* | ./$(PROGRAM) | sed 's/^......//' >$@
	echo >>$@
	ls tst/* | ./$(PROGRAM) -i | sed 's/^......//' >>$@
	echo >>$@
	ls tst/* | ./$(PROGRAM) -ix | sed 's/^......//' >>$@
	echo >>$@
	echo 'Immediate EOF:' >>$@
	./$(PROGRAM) </dev/null >>$@ 2>&1 || :
	echo >>$@
	echo 'Immediate EOF, verbose:' >>$@
	./$(PROGRAM) -v </dev/null >>$@ 2>&1 || :
	echo >>$@
	echo 'One existing file:' >>$@
	echo test.exp | ./$(PROGRAM) </dev/null >>$@ 2>&1 || :
	echo >>$@
	echo 'One non-existing file:' >>$@
	echo '& No_Such_File !;' | ./$(PROGRAM) >>$@ 2>&1 || :
	echo >>$@
	echo 'Invalid option:' >>$@
	./$(PROGRAM) -ix% 2>>$@ || :

lint:
	lclint +posiclib -macroredef -incondefs -duplicatequals $(CSOURCE)

# Do not remove this line!
# Everything after this line will be deleted.
# Dependency list follows.
error.o: error.c error.h
fgetline.o: fgetline.c fgetline.h
options.o: options.c options.h
samefile.o: samefile.c config.h error.h fgetline.h options.h


syntax highlighted by Code2HTML, v. 0.9.1