# $Header: /home/amb/routino/src/xml/RCS/Makefile,v 1.10 2010/07/07 17:26:24 amb Exp $ # # XML test programs Makefile # # Part of the Routino routing software. # # This file Copyright 2010 Andrew M. Bishop # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Programs CC=gcc LD=gcc # Program options CFLAGS=-Wall -Wmissing-prototypes -O0 -g LDFLAGS=-lm -lc # Required to use stdio with files > 2GiB on 32-bit system. FLAGS64=-D_FILE_OFFSET_BITS=64 # Compilation targets XMLDIR=../../xml X=$(notdir $(wildcard $(XMLDIR)/*.xsd)) C=$(foreach f,$(X),$(addsuffix -skeleton.c,$(basename $f))) D=$(foreach f,$(C),$(addprefix .deps/,$(addsuffix .d,$(basename $f)))) O=$(foreach f,$(C),$(addsuffix .o,$(basename $f))) E=$(foreach f,$(C),$(basename $f)) EXE=xsd-to-xmlparser ######## all : $(EXE) $(C) $(E) @true ######## xsd-to-xmlparser : xsd-to-xmlparser.o ../xmlparse.o $(LD) xsd-to-xmlparser.o ../xmlparse.o -o $@ $(LDFLAGS) ######## %-skeleton.c : $(XMLDIR)/%.xsd xsd-to-xmlparser -./xsd-to-xmlparser < $< > $@ @test -s $@ || rm $@ %-skeleton : %-skeleton.o ../xmlparse.o $(LD) $< ../xmlparse.o -o $@ $(LDFLAGS) .SECONDARY : $(O) ######## ../xmlparse.o : ../xmlparse.c ../xmlparse.h cd .. && $(MAKE) xmlparse.o ../xmlparse.c : ../xmlparse.l cd .. && $(MAKE) xmlparse.o ######## %.o : %.c $(CC) -c $(CFLAGS) $(FLAGS64) -I.. $< -o $@ -MMD -MP -MF $(addprefix .deps/,$(addsuffix .d,$(basename $<))) ######## test : all test-skeleton .FORCE @status=true ;\ echo "" ;\ for good in test/good*.xml; do \ echo "Testing: $$good ... " ;\ if ./test-skeleton < $$good > /dev/null; then echo "... passed"; else echo "... FAILED"; status=false; fi ;\ echo "" ;\ done ;\ for bad in test/bad*.xml; do \ echo "Testing: $$bad ... " ;\ if ./test-skeleton < $$bad > /dev/null; then echo "... FAILED"; status=false; else echo "... passed"; fi ;\ echo "" ;\ done ;\ if $$status; then echo "Success: all tests passed"; else echo "Warning: Some tests FAILED"; fi ;\ $$status test-skeleton : test-skeleton.o $(LD) $< ../xmlparse.o -o $@ $(LDFLAGS) test-skeleton.c : test/test.xsd xsd-to-xmlparser ./xsd-to-xmlparser < $< | sed -e 's/XMLPARSE_UNKNOWN_ATTR_WARN/XMLPARSE_UNKNOWN_ATTR_ERROR/' > $@ ######## clean: rm -f *.o rm -f *~ ######## distclean: clean -rm -f $(EXE) -rm -f $(E) test-skeleton -rm -f $(D) .deps/test-skeleton.d -rm -f $(C) test-skeleton.c -rm -fr .deps ######## .deps : .FORCE @[ -d .deps ] || mkdir $@ $(D) : .deps @touch $@ include $(D) ######## .FORCE :