From 40b8a7ae99bb60b720ba464c0360dbc9015d01ea Mon Sep 17 00:00:00 2001 From: Lev Walkin Date: Sun, 8 Oct 2017 22:36:29 -0700 Subject: [PATCH] simpler makefile generation --- examples/sample.makefile.regen | 129 +++++++++++------------ examples/sample.source.1609.2/Makefile | 92 ++++++---------- examples/sample.source.J2735/Makefile | 92 ++++++---------- examples/sample.source.LDAP3/Makefile | 101 +++++++----------- examples/sample.source.LTE-RRC/Makefile | 8 +- examples/sample.source.MEGACO/Makefile | 8 +- examples/sample.source.MHEG5/Makefile | 8 +- examples/sample.source.PKIX1/Makefile | 91 ++++++---------- examples/sample.source.RRC/Makefile | 8 +- examples/sample.source.TAP3/Makefile | 8 +- examples/sample.source.ULP/Makefile | 8 +- libasn1compiler/asn1c_save.c | 14 +-- tests/tests-c-compiler/Makefile.am | 4 +- tests/tests-c-compiler/check-assembly.sh | 94 ++++------------- tests/tests-randomized/Makefile.am | 14 ++- tests/tests-randomized/check-bundles.sh | 31 ++++-- 16 files changed, 281 insertions(+), 429 deletions(-) diff --git a/examples/sample.makefile.regen b/examples/sample.makefile.regen index a84132d0..16e100b7 100755 --- a/examples/sample.makefile.regen +++ b/examples/sample.makefile.regen @@ -1,33 +1,34 @@ #!/bin/sh # -# This script attempts to compile the given ASN.1 specification and then -# transforms the resulting Makefile.am.example tailored to that specification -# into a customized Makefile. +# This script attempts to compile the given ASN.1 specification by first +# building the specialized Makefile. # # The information which is necessary for this script is passed from the # Makefile which is going to be replaced with an updated Makefile. # -if test -z "$ASN1PDU" \ - -o -z "$ASN1MODULES" \ - -o -z "$PROGNAME" \ +if test -z "$ASN_PDU" \ + -o -z "$ASN_MODULES" \ + -o -z "$ASN_PROGRAM" \ ; then - echo "ASN1CMDOPTS=\"$ASN1CMDOPTS\"" - echo "ASN1MODULES=\"$ASN1MODULES\"" - echo "ASN1PDU=\"$ASN1PDU\"" - echo "PROGNAME=\"$PROGNAME\"" - echo "ASN1PDU, ASN1MODULES, and PROGNAME are mandatory" - exit + cat <<-NOTE + ASN_CMDOPTS="$ASN_CMDOPTS" + ASN_MODULES="$ASN_MODULES" + ASN_PDU="$ASN_PDU" + ASN_PROGRAM="$ASN_PROGRAM" + ASN_PDU, ASN_MODULES, and ASN_PROGRAM are mandatory. +NOTE + exit 1 fi -CMDOPTS="-pdu=${ASN1PDU} ${ASN1CMDOPTS} ${ASN1MODULES}" +EFFECTIVE_CMDOPTS="-pdu=${ASN_PDU} ${ASN_CMDOPTS} ${ASN_MODULES}" if test -x ../../asn1c/asn1c ; then - echo "Compiling ${ASN1MODULES} using local compiler" - ../../asn1c/asn1c -S ../../skeletons ${CMDOPTS} || exit $? + echo "Compiling ${ASN_MODULES} using local compiler" + ../../asn1c/asn1c -S ../../skeletons ${EFFECTIVE_CMDOPTS} || exit $? else - echo "Compiling ${ASN1MODULES} using system compiler" - asn1c ${CMDOPTS} || exit $? + echo "Compiling ${ASN_MODULES} using system compiler" + asn1c ${EFFECTIVE_CMDOPTS} || exit $? fi if test ! -f Makefile.am.example ; then @@ -39,107 +40,104 @@ EXTRA_CFLAGS="-DJUNKTEST -D_DEFAULT_SOURCE" test -f config.h && EXTRA_CFLAGS="-DHAVE_CONFIG_H ${EXTRA_CFLAGS}" test -n "$TITLE" && EXTRA_CFLAGS="-DASN_CONVERTER_TITLE=\"$TITLE\" ${EXTRA_CFLAGS}" -set -x -cat Makefile.am.example \ - | sed -e "s/^include /-include /" \ - | sed -e "s/^TARGET = converter-example/TARGET = ${PROGNAME}/" \ - | sed -e "s/^CFLAGS += /CFLAGS += ${EXTRA_CFLAGS} /" \ - | sed -e "s/^all: /all: maybe-wip-pause ${ASN1PDU}.c /" \ - > Makefile.$$ -set +x - -( echo - echo "${ASN1PDU}.c: $0 ${ASN1MODULES}" +{ + echo "ASN_PROGRAM = ${ASN_PROGRAM}" + echo "CFLAGS += ${EXTRA_CFLAGS}" + echo "begin: ${ASN_PDU}.c maybe-wip-pause all" + echo + echo "-include Makefile.am.example" + echo + echo "${ASN_PDU}.c: $0 ${ASN_MODULES}" echo " make regen-makefile" - echo " @touch ${ASN1PDU}.c" + echo " @touch ${ASN_PDU}.c" echo " make" echo echo "regen-makefile:" test -n "$TITLE" && echo " TITLE=\"$TITLE\" \\" - echo " ASN1CMDOPTS=\"${ASN1CMDOPTS}\" \\" - echo " ASN1MODULES=\"${ASN1MODULES}\" \\" - echo " ASN1PDU=${ASN1PDU} \\" - echo " PROGNAME=${PROGNAME} \\" + echo " ASN_CMDOPTS=\"${ASN_CMDOPTS}\" \\" + echo " ASN_MODULES=\"${ASN_MODULES}\" \\" + echo " ASN_PDU=${ASN_PDU} \\" + echo " ASN_PROGRAM=${ASN_PROGRAM} \\" echo " $0" echo - echo 'check: ${TARGET} check-ber check-xer check-oer check-per' + echo 'check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per' echo ' @echo ================' echo ' @echo All tests passed' echo ' @echo ================' echo echo 'check-ber:' - echo " @if test -f sample-${ASN1PDU}-1.[db]er ; then \\" + echo " @if test -f sample-${ASN_PDU}-1.[db]er ; then \\" echo " for f in sample-*-*.[db]er; do \\" echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \' echo ' for b in 1 17 33 980 8192; do \' echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \' - echo ' ./${TARGET} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \' - echo ' ./${TARGET} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \' echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \' echo ' rm -f ./.tmp.[12].$$$$; \' echo ' echo "Test junking $$f (please wait)..."; \' - echo ' ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \' - echo ' ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \' + echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \' + echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \' echo ' done; done; fi' echo echo 'check-xer:' - echo " @if test -f sample-${ASN1PDU}-1.xer ; then \\" + echo " @if test -f sample-${ASN_PDU}-1.xer ; then \\" echo " for f in sample-*-*.xer; do \\" echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \' echo ' for b in 1 17 33 980 8192; do \' echo ' echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \' - echo ' ./${TARGET} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \' - echo ' ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \' echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \' echo ' rm -f ./.tmp.[12].$$$$; \' echo ' echo "Test junking $$f (please wait)..."; \' - echo ' ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \' - echo ' ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \' + echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \' + echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \' echo ' done; done; fi' echo echo 'check-oer:' - echo " @if test -f sample-${ASN1PDU}-1.*oer ; then \\" + echo " @if test -f sample-${ASN_PDU}-1.*oer ; then \\" echo " for f in sample-*-*.*oer; do \\" echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \' echo ' for b in 1 17 33 980 8192; do \' echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \' - echo ' ./${TARGET} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \' - echo ' ./${TARGET} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \' echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \' echo ' rm -f ./.tmp.[12].$$$$; \' echo ' echo "Test junking $$f (please wait) ($$b) ..."; \' - echo ' ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \' - echo ' ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \' + echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \' + echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \' echo ' done; done; fi' echo echo 'check-per:' - echo " @if test -f sample-${ASN1PDU}-1-nopad.per ; then \\" + echo " @if test -f sample-${ASN_PDU}-1-nopad.per ; then \\" echo " for f in sample-*-[1-9]-nopad.per; do \\" echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \' echo ' for b in 1 17 33 980 8192; do \' echo ' echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \' - echo ' ./${TARGET} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \' - echo ' ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \' - echo ' ./${TARGET} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \' echo ' diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \' echo ' rm -f ./.tmp.[123].$$$$; \' echo ' echo "Test junking $$f (please wait)..."; \' - echo ' ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \' - echo ' ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \' + echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \' + echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \' echo ' done; done; fi' - echo " @if test -f sample-${ASN1PDU}-1.per ; then \\" + echo " @if test -f sample-${ASN_PDU}-1.per ; then \\" echo " for f in sample-*-[1-9].per; do \\" echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \' echo ' for b in 1 17 33 980 8192; do \' echo ' echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \' - echo ' ./${TARGET} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \' - echo ' ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \' - echo ' ./${TARGET} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \' + echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \' echo ' diff $$f ./.tmp.1.$$$$ || exit 6; \' echo ' rm -f ./.tmp.[12].$$$$; \' echo ' echo "Test junking $$f (please wait)..."; \' - echo ' ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \' - echo ' ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \' + echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \' + echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \' echo ' done; done; fi' echo echo "maybe-wip-pause:" @@ -148,14 +146,9 @@ set +x echo "distclean: clean" echo ' rm -f $(ASN_MODULE_SOURCES)' echo ' rm -f $(ASN_MODULE_HEADERS)' - echo ' rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)' + echo ' rm -f $(ASN_PROGRAM_SOURCES) $(ASN_PROGRAM_HEADERS)' echo " rm -f Makefile.am.example" -) >> Makefile.$$ - -set -x -mv Makefile.$$ Makefile || exit $? -rm Makefile.am.example || exit $? -set +x +} > Makefile echo echo "Makefile generation finished" diff --git a/examples/sample.source.1609.2/Makefile b/examples/sample.source.1609.2/Makefile index 9054abaa..9bb5387b 100644 --- a/examples/sample.source.1609.2/Makefile +++ b/examples/sample.source.1609.2/Makefile @@ -1,36 +1,8 @@ --include Makefile.am.libasncodec - -TARGET = 1609-2-dump -ASN_LIBRARY=libasncodec.a -LIBS += -lm -CFLAGS += -DASN_CONVERTER_TITLE="IEEE 1609.2-2016 decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE $(ASN_MODULE_CFLAGS) -DPDU=Certificate -DASN_PDU_COLLECTION -I. -ASN_CONVERTER_SOURCES = \ - converter-example.c\ - pdu_collection.c - -all: maybe-wip-pause Certificate.c $(TARGET) - -$(TARGET): $(ASN_LIBRARY) $(ASN_CONVERTER_SOURCES:.c=.o) - $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) $(ASN_CONVERTER_SOURCES:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS) - -$(ASN_LIBRARY): $(ASN_MODULE_SOURCES:.c=.o) - $(AR) rcs $@ $^ - -.SUFFIXES: -.SUFFIXES: .c .o - -.c.o: - $(CC) $(CFLAGS) -o $@ -c $< - -clean: - rm -f $(TARGET) $(ASN_LIBRARY) - rm -f $(ASN_MODULE_SOURCES:.c=.o) $(ASN_CONVERTER_SOURCES:.c=.o) - -regen: regenerate-from-asn1-source - -regenerate-from-asn1-source: - ../../asn1c/asn1c -S ../../skeletons -pdu=Certificate -pdu=auto -pdu=Ieee1609Dot2Data -fcompound-names -gen-OER ../IEEE-1609.2-2016.asn1 +ASN_PROGRAM = 1609-2-dump +CFLAGS += -DASN_CONVERTER_TITLE="IEEE 1609.2-2016 decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE +begin: Certificate.c maybe-wip-pause all +-include Makefile.am.example Certificate.c: ../sample.makefile.regen ../IEEE-1609.2-2016.asn1 make regen-makefile @@ -39,13 +11,13 @@ Certificate.c: ../sample.makefile.regen ../IEEE-1609.2-2016.asn1 regen-makefile: TITLE="IEEE 1609.2-2016 decoder" \ - ASN1CMDOPTS="-pdu=auto -pdu=Ieee1609Dot2Data -fcompound-names -gen-OER" \ - ASN1MODULES="../IEEE-1609.2-2016.asn1" \ - ASN1PDU=Certificate \ - PROGNAME=1609-2-dump \ + ASN_CMDOPTS="-pdu=auto -pdu=Ieee1609Dot2Data -fcompound-names -gen-OER" \ + ASN_MODULES="../IEEE-1609.2-2016.asn1" \ + ASN_PDU=Certificate \ + ASN_PROGRAM=1609-2-dump \ ../sample.makefile.regen -check: ${TARGET} check-ber check-xer check-oer check-per +check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per @echo ================ @echo All tests passed @echo ================ @@ -56,13 +28,13 @@ check-ber: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \ done; done; fi check-xer: @@ -71,13 +43,13 @@ check-xer: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff $$f ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \ done; done; fi check-oer: @@ -86,13 +58,13 @@ check-oer: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff $$f ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait) ($$b) ..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \ done; done; fi check-per: @@ -101,28 +73,28 @@ check-per: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \ diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \ rm -f ./.tmp.[123].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \ done; done; fi @if test -f sample-Certificate-1.per ; then \ for f in sample-*-[1-9].per; do \ pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \ diff $$f ./.tmp.1.$$$$ || exit 6; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \ done; done; fi maybe-wip-pause: @@ -131,5 +103,5 @@ maybe-wip-pause: distclean: clean rm -f $(ASN_MODULE_SOURCES) rm -f $(ASN_MODULE_HEADERS) - rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS) + rm -f $(ASN_PROGRAM_SOURCES) $(ASN_PROGRAM_HEADERS) rm -f Makefile.am.example diff --git a/examples/sample.source.J2735/Makefile b/examples/sample.source.J2735/Makefile index 164a30df..efe9fa0b 100644 --- a/examples/sample.source.J2735/Makefile +++ b/examples/sample.source.J2735/Makefile @@ -1,36 +1,8 @@ --include Makefile.am.libasncodec - -TARGET = j2735-dump -ASN_LIBRARY=libasncodec.a -LIBS += -lm -CFLAGS += -DASN_CONVERTER_TITLE="J2735 DSRC decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE $(ASN_MODULE_CFLAGS) -DPDU=MessageFrame -DASN_PDU_COLLECTION -I. -ASN_CONVERTER_SOURCES := \ - converter-example.c\ - pdu_collection.c - -all: maybe-wip-pause MessageFrame.c $(TARGET) - -$(TARGET): $(ASN_LIBRARY) $(ASN_CONVERTER_SOURCES:.c=.o) - $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) $(ASN_CONVERTER_SOURCES:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS) - -$(ASN_LIBRARY): $(ASN_MODULE_SOURCES:.c=.o) - $(AR) rcs $@ $^ - -.SUFFIXES: -.SUFFIXES: .c .o - -.c.o: - $(CC) $(CFLAGS) -o $@ -c $< - -clean: - rm -f $(TARGET) $(ASN_LIBRARY) - rm -f $(ASN_MODULE_SOURCES:.c=.o) $(ASN_CONVERTER_SOURCES:.c=.o) - -regen: regenerate-from-asn1-source - -regenerate-from-asn1-source: - ../../asn1c/asn1c -S ../../skeletons -pdu=MessageFrame -fcompound-names -gen-PER -pdu=all ../J2735_201603.asn1 +ASN_PROGRAM = j2735-dump +CFLAGS += -DASN_CONVERTER_TITLE="J2735 DSRC decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE +begin: MessageFrame.c maybe-wip-pause all +-include Makefile.am.example MessageFrame.c: ../sample.makefile.regen ../J2735_201603.asn1 make regen-makefile @@ -39,13 +11,13 @@ MessageFrame.c: ../sample.makefile.regen ../J2735_201603.asn1 regen-makefile: TITLE="J2735 DSRC decoder" \ - ASN1CMDOPTS="-fcompound-names -gen-PER -pdu=all" \ - ASN1MODULES="../J2735_201603.asn1" \ - ASN1PDU=MessageFrame \ - PROGNAME=j2735-dump \ + ASN_CMDOPTS="-fcompound-names -gen-PER -pdu=all" \ + ASN_MODULES="../J2735_201603.asn1" \ + ASN_PDU=MessageFrame \ + ASN_PROGRAM=j2735-dump \ ../sample.makefile.regen -check: ${TARGET} check-ber check-xer check-oer check-per +check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per @echo ================ @echo All tests passed @echo ================ @@ -56,13 +28,13 @@ check-ber: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \ done; done; fi check-xer: @@ -71,13 +43,13 @@ check-xer: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff $$f ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \ done; done; fi check-oer: @@ -86,13 +58,13 @@ check-oer: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff $$f ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait) ($$b) ..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \ done; done; fi check-per: @@ -101,28 +73,28 @@ check-per: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \ diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \ rm -f ./.tmp.[123].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \ done; done; fi @if test -f sample-MessageFrame-1.per ; then \ for f in sample-*-[1-9].per; do \ pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \ diff $$f ./.tmp.1.$$$$ || exit 6; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \ done; done; fi maybe-wip-pause: @@ -131,5 +103,5 @@ maybe-wip-pause: distclean: clean rm -f $(ASN_MODULE_SOURCES) rm -f $(ASN_MODULE_HEADERS) - rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS) + rm -f $(ASN_PROGRAM_SOURCES) $(ASN_PROGRAM_HEADERS) rm -f Makefile.am.example diff --git a/examples/sample.source.LDAP3/Makefile b/examples/sample.source.LDAP3/Makefile index c54cd41b..e2909fd4 100644 --- a/examples/sample.source.LDAP3/Makefile +++ b/examples/sample.source.LDAP3/Makefile @@ -1,35 +1,8 @@ --include Makefile.am.libasncodec - -TARGET = ldap3dump -ASN_LIBRARY=libasncodec.a -LIBS += -lm -CFLAGS += -DASN_CONVERTER_TITLE="Lightweight Directory Access Protocol V3 decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE $(ASN_MODULE_CFLAGS) -DPDU=LDAPMessage -I. -ASN_CONVERTER_SOURCES = \ - converter-example.c - -all: maybe-wip-pause LDAPMessage.c $(TARGET) - -$(TARGET): $(ASN_LIBRARY) $(ASN_CONVERTER_SOURCES:.c=.o) - $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) $(ASN_CONVERTER_SOURCES:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS) - -$(ASN_LIBRARY): $(ASN_MODULE_SOURCES:.c=.o) - $(AR) rcs $@ $(ASN_MODULE_SOURCES:.c=.o) - -.SUFFIXES: -.SUFFIXES: .c .o - -.c.o: - $(CC) $(CFLAGS) -o $@ -c $< - -clean: - rm -f $(TARGET) $(ASN_LIBRARY) - rm -f $(ASN_MODULE_SOURCES:.c=.o) $(ASN_CONVERTER_SOURCES:.c=.o) - -regen: regenerate-from-asn1-source - -regenerate-from-asn1-source: - ../../asn1c/asn1c -S ../../skeletons -pdu=LDAPMessage -fcompound-names ../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1 +ASN_PROGRAM = ldap3dump +CFLAGS += -DASN_CONVERTER_TITLE="Lightweight Directory Access Protocol V3 decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE +begin: LDAPMessage.c maybe-wip-pause all +-include Makefile.am.example LDAPMessage.c: ../sample.makefile.regen ../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1 make regen-makefile @@ -38,13 +11,13 @@ LDAPMessage.c: ../sample.makefile.regen ../rfc4511-Lightweight-Directory-Access- regen-makefile: TITLE="Lightweight Directory Access Protocol V3 decoder" \ - ASN1CMDOPTS="-fcompound-names" \ - ASN1MODULES="../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1" \ - ASN1PDU=LDAPMessage \ - PROGNAME=ldap3dump \ + ASN_CMDOPTS="-fcompound-names" \ + ASN_MODULES="../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1" \ + ASN_PDU=LDAPMessage \ + ASN_PROGRAM=ldap3dump \ ../sample.makefile.regen -check: ${TARGET} check-ber check-xer check-oer check-per +check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per @echo ================ @echo All tests passed @echo ================ @@ -52,76 +25,76 @@ check: ${TARGET} check-ber check-xer check-oer check-per check-ber: @if test -f sample-LDAPMessage-1.[db]er ; then \ for f in sample-*-*.[db]er; do \ - pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \ + pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \ done; done; fi check-xer: @if test -f sample-LDAPMessage-1.xer ; then \ for f in sample-*-*.xer; do \ - pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \ + pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff $$f ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \ done; done; fi check-oer: @if test -f sample-LDAPMessage-1.*oer ; then \ for f in sample-*-*.*oer; do \ - pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \ + pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff $$f ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait) ($$b) ..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \ done; done; fi check-per: @if test -f sample-LDAPMessage-1-nopad.per ; then \ for f in sample-*-[1-9]-nopad.per; do \ - pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \ + pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \ diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \ rm -f ./.tmp.[123].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \ done; done; fi @if test -f sample-LDAPMessage-1.per ; then \ for f in sample-*-[1-9].per; do \ - pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \ + pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \ diff $$f ./.tmp.1.$$$$ || exit 6; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \ done; done; fi maybe-wip-pause: @@ -130,5 +103,5 @@ maybe-wip-pause: distclean: clean rm -f $(ASN_MODULE_SOURCES) rm -f $(ASN_MODULE_HEADERS) - rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS) + rm -f $(ASN_PROGRAM_SOURCES) $(ASN_PROGRAM_HEADERS) rm -f Makefile.am.example diff --git a/examples/sample.source.LTE-RRC/Makefile b/examples/sample.source.LTE-RRC/Makefile index bbdb3ce1..d918a97b 100644 --- a/examples/sample.source.LTE-RRC/Makefile +++ b/examples/sample.source.LTE-RRC/Makefile @@ -3608,10 +3608,10 @@ DL-DCCH-Message.c: ../sample.makefile.regen ../lte-rrc-14.2.1.asn1 make regen-makefile: - ASN1CMDOPTS="-pdu=auto -fcompound-names -gen-PER" \ - ASN1MODULES="../lte-rrc-14.2.1.asn1" \ - ASN1PDU=DL-DCCH-Message \ - PROGNAME=lte-rrc-dump \ + ASN_CMDOPTS="-pdu=auto -fcompound-names -gen-PER" \ + ASN_MODULES="../lte-rrc-14.2.1.asn1" \ + ASN_PDU=DL-DCCH-Message \ + ASN_PROGRAM=lte-rrc-dump \ CFLAGS="" \ ../sample.makefile.regen diff --git a/examples/sample.source.MEGACO/Makefile b/examples/sample.source.MEGACO/Makefile index 47c830b4..caf9385a 100644 --- a/examples/sample.source.MEGACO/Makefile +++ b/examples/sample.source.MEGACO/Makefile @@ -37,10 +37,10 @@ MegacoMessage.c: ../sample.makefile.regen ../rfc3525-MEDIA-GATEWAY-CONTROL.asn1 make regen-makefile: - ASN1CMDOPTS="-fcompound-names" \ - ASN1MODULES="../rfc3525-MEDIA-GATEWAY-CONTROL.asn1" \ - ASN1PDU=MegacoMessage \ - PROGNAME=megaco-dump \ + ASN_CMDOPTS="-fcompound-names" \ + ASN_MODULES="../rfc3525-MEDIA-GATEWAY-CONTROL.asn1" \ + ASN_PDU=MegacoMessage \ + ASN_PROGRAM=megaco-dump \ ../sample.makefile.regen check: ${TARGET} check-ber check-xer check-oer check-per diff --git a/examples/sample.source.MHEG5/Makefile b/examples/sample.source.MHEG5/Makefile index bcafe0c4..432aebea 100644 --- a/examples/sample.source.MHEG5/Makefile +++ b/examples/sample.source.MHEG5/Makefile @@ -477,10 +477,10 @@ InterchangedObject.c: ../sample.makefile.regen ../ISO13522-MHEG-5.asn make regen-makefile: - ASN1CMDOPTS="-fcompound-names" \ - ASN1MODULES="../ISO13522-MHEG-5.asn" \ - ASN1PDU=InterchangedObject \ - PROGNAME=mheg5dump \ + ASN_CMDOPTS="-fcompound-names" \ + ASN_MODULES="../ISO13522-MHEG-5.asn" \ + ASN_PDU=InterchangedObject \ + ASN_PROGRAM=mheg5dump \ CFLAGS="" \ ../sample.makefile.regen diff --git a/examples/sample.source.PKIX1/Makefile b/examples/sample.source.PKIX1/Makefile index 18aec49e..10825d08 100644 --- a/examples/sample.source.PKIX1/Makefile +++ b/examples/sample.source.PKIX1/Makefile @@ -1,35 +1,8 @@ --include Makefile.am.libasncodec - -TARGET = x509dump -ASN_LIBRARY=libasncodec.a -LIBS += -lm -CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE $(ASN_MODULE_CFLAGS) -DPDU=Certificate -I. -ASN_CONVERTER_SOURCES := \ - converter-example.c - -all: maybe-wip-pause Certificate.c $(TARGET) - -$(TARGET): $(ASN_LIBRARY) $(ASN_CONVERTER_SOURCES:.c=.o) - $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) $(ASN_CONVERTER_SOURCES:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS) - -$(ASN_LIBRARY): $(ASN_MODULE_SOURCES:.c=.o) - $(AR) rcs $@ $^ - -.SUFFIXES: -.SUFFIXES: .c .o - -.c.o: - $(CC) $(CFLAGS) -o $@ -c $< - -clean: - rm -f $(TARGET) $(ASN_LIBRARY) - rm -f $(ASN_MODULE_SOURCES:.c=.o) $(ASN_CONVERTER_SOURCES:.c=.o) - -regen: regenerate-from-asn1-source - -regenerate-from-asn1-source: - ../../asn1c/asn1c -S ../../skeletons -pdu=Certificate -fcompound-names -fwide-types ../rfc3280-PKIX1Explicit88.asn1 ../rfc3280-PKIX1Implicit88.asn1 +ASN_PROGRAM = x509dump +CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE +begin: Certificate.c maybe-wip-pause all +-include Makefile.am.example Certificate.c: ../sample.makefile.regen ../rfc3280-*.asn1 make regen-makefile @@ -37,13 +10,13 @@ Certificate.c: ../sample.makefile.regen ../rfc3280-*.asn1 make regen-makefile: - ASN1CMDOPTS="-fcompound-names -fwide-types" \ - ASN1MODULES="../rfc3280-*.asn1" \ - ASN1PDU=Certificate \ - PROGNAME=x509dump \ + ASN_CMDOPTS="-fcompound-names -fwide-types" \ + ASN_MODULES="../rfc3280-*.asn1" \ + ASN_PDU=Certificate \ + ASN_PROGRAM=x509dump \ ../sample.makefile.regen -check: ${TARGET} check-ber check-xer check-oer check-per +check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per @echo ================ @echo All tests passed @echo ================ @@ -54,13 +27,13 @@ check-ber: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \ done; done; fi check-xer: @@ -69,13 +42,13 @@ check-xer: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff $$f ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \ done; done; fi check-oer: @@ -84,13 +57,13 @@ check-oer: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ diff $$f ./.tmp.2.$$$$ || exit 4; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait) ($$b) ..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \ done; done; fi check-per: @@ -99,28 +72,28 @@ check-per: pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \ diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \ rm -f ./.tmp.[123].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \ done; done; fi @if test -f sample-Certificate-1.per ; then \ for f in sample-*-[1-9].per; do \ pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \ for b in 1 17 33 980 8192; do \ echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \ - ./${TARGET} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \ - ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \ - ./${TARGET} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \ + ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \ diff $$f ./.tmp.1.$$$$ || exit 6; \ rm -f ./.tmp.[12].$$$$; \ echo "Test junking $$f (please wait)..."; \ - ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \ - ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \ + ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \ + ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \ done; done; fi maybe-wip-pause: @@ -129,5 +102,5 @@ maybe-wip-pause: distclean: clean rm -f $(ASN_MODULE_SOURCES) rm -f $(ASN_MODULE_HEADERS) - rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS) + rm -f $(ASN_PROGRAM_SOURCES) $(ASN_PROGRAM_HEADERS) rm -f Makefile.am.example diff --git a/examples/sample.source.RRC/Makefile b/examples/sample.source.RRC/Makefile index ae911c09..ba80e69a 100644 --- a/examples/sample.source.RRC/Makefile +++ b/examples/sample.source.RRC/Makefile @@ -38,10 +38,10 @@ DL-DCCH-Message.c: ../sample.makefile.regen ../rrc-7.1.0.asn1 make regen-makefile: - ASN1CMDOPTS="-pdu=auto -fcompound-names -gen-PER" \ - ASN1MODULES="../rrc-7.1.0.asn1" \ - ASN1PDU=DL-DCCH-Message \ - PROGNAME=rrc-dump \ + ASN_CMDOPTS="-pdu=auto -fcompound-names -gen-PER" \ + ASN_MODULES="../rrc-7.1.0.asn1" \ + ASN_PDU=DL-DCCH-Message \ + ASN_PROGRAM=rrc-dump \ ../sample.makefile.regen check: ${TARGET} check-ber check-xer check-oer check-per diff --git a/examples/sample.source.TAP3/Makefile b/examples/sample.source.TAP3/Makefile index e7ddb71f..aec06c15 100644 --- a/examples/sample.source.TAP3/Makefile +++ b/examples/sample.source.TAP3/Makefile @@ -38,10 +38,10 @@ DataInterChange.c: ../sample.makefile.regen ../tap3.asn1 regen-makefile: TITLE="GSM TAP3 (Transferred Account Procedure, Version 3) decoder" \ - ASN1CMDOPTS="" \ - ASN1MODULES="../tap3.asn1" \ - ASN1PDU=DataInterChange \ - PROGNAME=tap3dump \ + ASN_CMDOPTS="" \ + ASN_MODULES="../tap3.asn1" \ + ASN_PDU=DataInterChange \ + ASN_PROGRAM=tap3dump \ ../sample.makefile.regen check: ${TARGET} check-ber check-xer check-oer check-per diff --git a/examples/sample.source.ULP/Makefile b/examples/sample.source.ULP/Makefile index 852e42c5..3b4b2bfd 100644 --- a/examples/sample.source.ULP/Makefile +++ b/examples/sample.source.ULP/Makefile @@ -39,10 +39,10 @@ ULP-PDU.c: ../sample.makefile.regen ../ulp.asn1 regen-makefile: TITLE="OMA UserPlane Location Protocol decoder" \ - ASN1CMDOPTS="-pdu=SUPLINIT -fcompound-names -gen-PER" \ - ASN1MODULES="../ulp.asn1" \ - ASN1PDU=ULP-PDU \ - PROGNAME=ulp-dump \ + ASN_CMDOPTS="-pdu=SUPLINIT -fcompound-names -gen-PER" \ + ASN_MODULES="../ulp.asn1" \ + ASN_PDU=ULP-PDU \ + ASN_PROGRAM=ulp-dump \ ../sample.makefile.regen check: ${TARGET} check-ber check-xer check-oer check-per diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c index 41601af4..0cad1a99 100644 --- a/libasn1compiler/asn1c_save.c +++ b/libasn1compiler/asn1c_save.c @@ -159,11 +159,11 @@ asn1c__save_example_makefile(arg_t *arg, const asn1c_fdeps_t *deps, safe_fprintf( mkf, "include %s\n\n" - "TARGET = converter-example\n" - "ASN_LIBRARY=libasncodec.a\n" "LIBS += -lm\n" "CFLAGS += $(ASN_MODULE_CFLAGS) %s%s-I.\n" - "ASN_CONVERTER_SOURCES = ", + "ASN_LIBRARY ?= libasncodec.a\n" + "ASN_PROGRAM ?= converter-example\n" + "ASN_PROGRAM_SOURCES ?= ", library_makefile_name, (arg->flags & A1C_PDU_TYPE) ? generate_pdu_C_definition() : "", need_to_generate_pdu_collection(arg) ? "-DASN_PDU_COLLECTION " : ""); @@ -187,9 +187,9 @@ asn1c__save_example_makefile(arg_t *arg, const asn1c_fdeps_t *deps, safe_fprintf( mkf, - "\n\nall: $(TARGET)\n" - "\n$(TARGET): $(ASN_LIBRARY) $(ASN_CONVERTER_SOURCES:.c=.o)" - "\n\t$(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) $(ASN_CONVERTER_SOURCES:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS)\n" + "\n\nall: $(ASN_PROGRAM)\n" + "\n$(ASN_PROGRAM): $(ASN_LIBRARY) $(ASN_PROGRAM_SOURCES:.c=.o)" + "\n\t$(CC) $(CFLAGS) $(CPPFLAGS) -o $(ASN_PROGRAM) $(ASN_PROGRAM_SOURCES:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS)\n" "\n$(ASN_LIBRARY): $(ASN_MODULE_SOURCES:.c=.o)" "\n\t$(AR) rcs $@ $(ASN_MODULE_SOURCES:.c=.o)\n" "\n.SUFFIXES:" @@ -198,7 +198,7 @@ asn1c__save_example_makefile(arg_t *arg, const asn1c_fdeps_t *deps, "\n\t$(CC) $(CFLAGS) -o $@ -c $<\n" "\nclean:" "\n\trm -f $(TARGET) $(ASN_LIBRARY)" - "\n\trm -f $(ASN_MODULE_SOURCES:.c=.o) $(ASN_CONVERTER_SOURCES:.c=.o)\n" + "\n\trm -f $(ASN_MODULE_SOURCES:.c=.o) $(ASN_PROGRAM_SOURCES:.c=.o)\n" "\nregen: regenerate-from-asn1-source\n" "\nregenerate-from-asn1-source:\n\t"); diff --git a/tests/tests-c-compiler/Makefile.am b/tests/tests-c-compiler/Makefile.am index 1eaf9117..3102a68d 100644 --- a/tests/tests-c-compiler/Makefile.am +++ b/tests/tests-c-compiler/Makefile.am @@ -44,7 +44,6 @@ TESTS += check-src/check-39.c TESTS += check-src/check-41.-fwide-types.c TESTS += check-src/check-41.c TESTS += check-src/check-42.c -TESTS += check-src/check-42.-fwide-types.cc TESTS += check-src/check-43.c TESTS += check-src/check-44.c TESTS += check-src/check-46.c @@ -72,8 +71,7 @@ EXTRA_DIST = \ data-119 \ data-126 \ check-src/check64-134.-gen-PER.c \ - check-src/check64-136.-gen-OER.c \ - check-src/check-42.-fwide-types.cc + check-src/check64-136.-gen-OER.c clean-local: rm -rf test-* diff --git a/tests/tests-c-compiler/check-assembly.sh b/tests/tests-c-compiler/check-assembly.sh index 55eacd36..299f833d 100755 --- a/tests/tests-c-compiler/check-assembly.sh +++ b/tests/tests-c-compiler/check-assembly.sh @@ -28,26 +28,10 @@ fi source_short=$(echo "$source_full" | sed -e 's/.*\///') testno=$(echo "$source_short" | cut -f2 -d'-' | cut -f1 -d'.') -CODECS_FLAGS="" -has_oer=$(echo "$source_short" | grep "gen-OER" || :) -if [ ! "$has_oer" ]; then - CODECS_FLAGS="${CODECS_FLAGS} -DASN_DISABLE_OER_SUPPORT" -fi -has_per=$(echo "$source_short" | grep "gen-PER" || :) -if [ ! "$has_per" ]; then - CODECS_FLAGS="${CODECS_FLAGS} -DASN_DISABLE_PER_SUPPORT" -fi - args=$(echo "$source_short" | sed -E -e 's/\.c+$//') source_obj=$(echo "$source_short" | sed -E -e 's/\.c+$/.o/') ext=$(echo "$source_short" | sed -E -e 's/.*\.(c+)$/\1/') -if [ "$ext" = "cc" ]; then - COMPILER='$(CXX) $(CXX_CFLAGS)' -else - COMPILER='$(CC)' -fi - OFS=$IFS IFS="." set $args @@ -84,25 +68,25 @@ asn_module=$(echo "${abs_top_srcdir}/tests/tests-asn1c-compiler/${testno}"-*.asn AUTOGENERATED="# This file is autogenerated by $0 ${source_full} ${AFLAGS}" # Create a common Makefile for the project -cat < "${testdir}/Makefile.targets" +cat < "${testdir}/Makefile" ${AUTOGENERATED} - COMMON_FLAGS= -I. CFLAGS = \${COMMON_FLAGS} ${CFLAGS:-} -g -O1 -CFLAGS += -DSRCDIR=../${srcdir} ${CODECS_FLAGS} +CFLAGS += -DSRCDIR=../${srcdir} CXXFLAGS = \${CFLAGS} ${CXXFLAGS} LIBFUZZER_CFLAGS = ${LIBFUZZER_CFLAGS} LDFLAGS = ${LDFLAGS:-} +ASN_PROGRAM = check-program +ASN_PROGRAM_SOURCES = ${source_short} + CC ?= ${CC} CXX ?= ${CXX} -all: compiled-module - \$(MAKE) check-executable +-include Makefile.am.example -check-executable: \$(OBJS) - @rm -f *.core - ${COMPILER} \$(CFLAGS) \$(LDFLAGS) -o check-executable \$(OBJS) -lm +all: compiled-module + \$(MAKE) check-program # Compile the corresponding .asn1 spec. compiled-module: ${asn_module} ${abs_top_builddir}/asn1c/asn1c @@ -113,33 +97,30 @@ compiled-module: ${asn_module} ${abs_top_builddir}/asn1c/asn1c rm -f converter-example.c @touch compiled-module -TARGETS +END_MAKEFILE if [ "${MAKE_FUZZER}" != "yes" ]; then CHECK_FUZZER="@echo \"No fuzzer defined, skipping.\"" -cat <> "${testdir}/Makefile.targets" +cat <> "${testdir}/Makefile" .PHONY: check-fuzzer check-fuzzer: -TARGETS +END_MAKEFILE else CHECK_FUZZER="ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 ./check-fuzzer -timeout=3 -max_total_time=60 -max_len=512 ${OPT_DATA_DIR}" -cat <> "${testdir}/Makefile.targets" -check-fuzzer: \$(OBJS) - rm -f ${source_obj} - ${COMPILER} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) -c -o ${source_obj} ${source_short} - ${COMPILER} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) \$(LDFLAGS) -o check-fuzzer \$(OBJS) - rm -f ${source_obj} -TARGETS +cat <> "${testdir}/Makefile" +check-fuzzer: ${source_short} \$(ASN_LIBRARY) + ${CC} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) \$(LDFLAGS) -o check-fuzzer \$^ +END_MAKEFILE fi -cat <> "${testdir}/Makefile.targets" +cat <> "${testdir}/Makefile" -check-succeeded: compiled-module - \$(MAKE) check-executable +check-succeeded: compiled-module \$(ASN_LIBRARY) ${source_short} + \$(MAKE) check-program \$(MAKE) check-fuzzer @rm -f check-succeeded - ./check-executable + ./check-program \$(MAKE) fuzz @touch check-succeeded @echo "OK: ${source_full}" @@ -150,43 +131,10 @@ fuzz: check: check-succeeded -clean: - @rm -f *.o check-executable -TARGETS - -# Create a BSD- or GNU-specific Makefile for the project. -produce_specific_makefile() { - local make_type=$1 - local make_file="$testdir/${make_type}makefile" - - if [ ${make_type} = "BSD" ]; then - cat <<-OBJECTS > ${make_file} - ${AUTOGENERATED} - SRCS_C!=find . -name \*.c - SRCS_CXX!=find . -name \*.cc - SRCS=\$(SRCS_C) \$(SRCS_CXX) - OBJS=\${SRCS_C:.c=.o} \${SRCS_CXX:.cc=.o} - include Makefile.targets - OBJECTS - else - cat <<-OBJECTS > ${make_file} - ${AUTOGENERATED} - SRCS_C := \$(wildcard *.c) - SRCS_CXX := \$(wildcard *.cc) - SRCS = \$(SRCS_C) \$(SRCS_CXX) - OBJS =\$(patsubst %.c,%.o,\$(SRCS_C)) - OBJS+=\$(patsubst %.cc,%.o,\$(SRCS_CXX)) - include Makefile.targets - OBJECTS - fi - -} - -produce_specific_makefile BSD -produce_specific_makefile GNU +END_MAKEFILE # Perform building and checking -${TEST_DRIVER} make -C "$testdir" check +${TEST_DRIVER} ${MAKE:-make} -C "${testdir}" check # Make sure the test is not marked as failed any longer. rm -f "${testdir}-FAILED" diff --git a/tests/tests-randomized/Makefile.am b/tests/tests-randomized/Makefile.am index f367b8d8..57090f63 100644 --- a/tests/tests-randomized/Makefile.am +++ b/tests/tests-randomized/Makefile.am @@ -16,12 +16,18 @@ TESTS_ENVIRONMENT= \ ASAN_ENV_FLAGS="@ASAN_ENV_FLAGS@" \ srcdir=${srcdir} \ abs_top_srcdir=${abs_top_srcdir} \ - abs_top_builddir=${abs_top_builddir} + abs_top_builddir=${abs_top_builddir} \ + ${srcdir}/check-bundles.sh -TESTS = $(dist_check_SCRIPTS) +TESTS = +TESTS += bundles/01-1.txt +TESTS += bundles/01-2.txt -EXTRA_DIST = bundles random-test-driver.c +EXTRA_DIST = \ + random-test-driver.c \ + $(srcdir)/bundles/README \ + $(srcdir)/bundles/*.txt clean-local: - rm -rf .tmp.random + rm -rf .tmp.* diff --git a/tests/tests-randomized/check-bundles.sh b/tests/tests-randomized/check-bundles.sh index 48440a55..8a2804db 100755 --- a/tests/tests-randomized/check-bundles.sh +++ b/tests/tests-randomized/check-bundles.sh @@ -26,7 +26,7 @@ usage() { exit 1 } -RNDTEMP=.tmp.random +RNDTEMP="${RNDTEMP:-.tmp.random}" srcdir="${srcdir:-.}" abs_top_srcdir="${abs_top_srcdir:-`pwd`/../../}" @@ -38,7 +38,7 @@ stop_after_failed=1 # We stop after 3 failures. need_clean_before_bundle=1 # Clean before testing a bundle file need_clean_before_test=0 # Before each line in a bundle file encodings="" # Default is to verify all supported ASN.1 transfer syntaxes -parallelism=4 +parallelism=1 asn1c_flags="" make_clean_before_bundle() { @@ -229,9 +229,12 @@ asn_compile() { fi rm -f converter-example.c ln -sf "../${srcdir}/random-test-driver.c" || cp "../${srcdir}/random-test-driver.c" . - echo "CFLAGS+= -DASN1_TEXT='$short_asn'" > Makefile - sed -e 's/converter-example/random-test-driver/' \ - < Makefile.am.example >> Makefile + { + echo "CFLAGS+= -DASN1_TEXT='$short_asn'"; + echo "ASN_PROGRAM = random-test-driver" + echo "ASN_PROGRAM_SOURCES = random-test-driver.c" + echo "include Makefile.am.example" + } > Makefile echo "Makefile.am.example -> Makefile" } @@ -271,11 +274,26 @@ test_drive() { fi } +if echo "$*" | grep ' -- ' > /dev/null; then + TEST_DRIVER=`echo "$*" | sed -e 's/ -- .*/ -- /g'` + args=`echo "$*" | sed -e 's/.* //g'` + set "${args}" +else + TEST_DRIVER="" +fi + # Command line parsing while :; do case "$1" in -h) usage ;; --asn1c) asn1c_flags="${asn1c_flags} $2"; shift 2; continue ;; + --bundle) + shift + base=`basename "$1" | sed -e 's/.txt$//'` + RNDTEMP=".tmp.${base}" + test_drive verify_asn_types_in_file "$@" + break + ;; --dirty) need_clean_before_bundle=0 need_clean_before_test=0 @@ -285,7 +303,6 @@ while :; do -e) encodings="${encodings} -e $2"; shift 2; continue;; -j) parallelism="$1"; shift 2; continue;; -t) - parallelism=1 # Better for debuggability test_drive verify_asn_type "$2" "(command line)" || exit 1 ;; "") for bundle in `ls -1 ${srcdir}/bundles/*.txt | sort -nr`; do @@ -293,7 +310,7 @@ while :; do done ;; *) - test_drive verify_asn_types_in_file "$@" + exec ${TEST_DRIVER} $0 --bundle "$@" ;; esac break