#
# $Id: Makefile,v 1.4 2003/08/23 10:56:33 ed Exp $
#
# Copyright 1993, 2001, Geoff Kuenning, Claremont, CA
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All modifications to the source code must be clearly marked as
#    such.  Binary redistributions based on modified source code
#    must be clearly marked as modified versions in the documentation
#    and/or other materials provided with the distribution.
# (clause 4 removed with permission from Geoff Kuenning)
# 5. The name of Geoff Kuenning may not be used to endorse or promote
#    products derived from this software without specific prior
#    written permission.
#
# THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Log: Makefile,v $
# Revision 1.4  2003/08/23 10:56:33  ed
# Purging my old email address.
#
# Revision 1.3  2001/11/07 18:59:26  ed
# Rewrite of fix8bit.c prompted by SuSE's ispell-3.2.06-languages.patch.
# I wanted to make sure the patch wouldn't break anything, so I wrote a
# test suite, but doing that I found lots of other things that were
# wrong, so I started trying to fix those...
#
# Makefile: fixed dependencies for fix8bit, added 'test' target.  The
# test suite checks fix8bit's pushback routines, runs test_fix8bit (see
# below) and checks a couple of additional properties: fix8bit -8 |
# fix8bit -7 == cat; fix8bit -7 | fix8bit -7 == fix8bit -7.
#
# fix8bit.c: rewrote to8bit() to better handle cases when the
# backslashed sequence turns out to be illegal.  The initial backslash
# is printed and the remaining characters are pushed back to be read
# again.  This means that for example \\x41 will print as \A, in the
# same way that !\x41 produces !A.  It also handles escape sequences
# cut off by EOF properly (again they are printed unchanged).  This uses
# a mini pushback library which has a test suite if you give main() the
# argument --test-pushback.  Also fixed the original problem with hex
# sequences being miscomputed, which SuSE wrote the patch for.  Added a
# warning if the input already contains 8-bit chars (that would stop
# -8 | -7 being identity).
#
# test_fix8bit: new file.  This is a Perl script to run fix8bit -7 and
# fix8bit -8 on every input file in test_data/ and check the results
# against the expected results also in that directory.
#
# test_data/: new directory.  Contains test cases, some written by hand
# and some randomly generated by rand_gen.  rand_gen tries to make 'well
# behaved' input that doesn't muck up fix8bit -8 | fix8bit -7 or other
# commands - but there are three flags you can use to tell it not to.
# The random test cases have not been checked by hand, so they should be
# used in addition to human-written ones.
#
# Revision 1.2  2001/10/05 14:22:30  ed
# Imported 3.2.06.epa1 release.  This was previously developed using
# sporadic RCS for certain files, but I'm not really bothered about
# rolling back beyond this release.
#
# Revision 1.5  2001/07/25 21:51:47  geoff
# *** empty log message ***
#
# Revision 1.4  2001/07/23 20:43:38  geoff
# *** empty log message ***
#
# Revision 1.3  1994/01/25 07:12:25  geoff
# Get rid of all old RCS log lines in preparation for the 3.1 release.
#
#

SHELL = /bin/sh
MAKE = make

CONFIG		=	../config.sh
FIX8BIT		=	../fix8bit

all:	fix8bit

install:

fix8bit:	$(CONFIG) fix8bit.c
	@. $(CONFIG); \
	  set -x; \
	  $$CC $$CFLAGS -o fix8bit fix8bit.c

clean:
	rm -f core *.log fix8bit
# clean for individual languages is called from top-level Makefile (ugh).

test: fix8bit
# Test the pushback code.
	for i in test_data/*.in; do \
	  ./fix8bit --test-pushback <$$i >$$i.test-pushback.out; \
	  diff -qs $$i $$i.test-pushback.out || exit 1; \
	  rm $$i.test-pushback.out; \
	done
# Main part of the tests: check that -7, -8 produce expected output.
	./test_fix8bit
# Run some additional tests to check some properties of fix8bit.  We
# diff against ref; test_fix8bit has already checked this matches out.
# 
# fix8bit -8 | fix8bit -7 should be identity, provided no flags given
# to rand_gen.  Other way round does not hold.
	./fix8bit -7 <test_data/rand.8.ref >test_data/rand.87.out
	diff -qs test_data/rand.in test_data/rand.87.out && rm test_data/rand.87.out
# -8 is not idempotent; -7 is.
	for i in test_data/*.7.ref; do \
	    ./fix8bit -7 <$$i >$$i.7.out; \
	    diff -qs $$i $$i.7.out || exit 1; \
	    rm $$i.7.out; \
	done
