asn1c/examples/sample.makefile.regen

155 lines
6.5 KiB
Plaintext
Raw Normal View History

2006-09-13 02:10:23 +00:00
#!/bin/sh
2006-09-17 03:53:11 +00:00
#
2017-10-09 05:36:29 +00:00
# This script attempts to compile the given ASN.1 specification by first
# building the specialized Makefile.
2006-09-17 03:53:11 +00:00
#
# The information which is necessary for this script is passed from the
# Makefile which is going to be replaced with an updated Makefile.
#
2006-09-13 02:10:23 +00:00
2017-10-09 05:36:29 +00:00
if test -z "$ASN_PDU" \
-o -z "$ASN_MODULES" \
-o -z "$ASN_PROGRAM" \
2006-09-17 00:20:47 +00:00
; then
2017-10-09 05:36:29 +00:00
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
2006-09-13 02:10:23 +00:00
fi
2017-10-09 05:36:29 +00:00
EFFECTIVE_CMDOPTS="-pdu=${ASN_PDU} ${ASN_CMDOPTS} ${ASN_MODULES}"
2006-09-23 02:52:12 +00:00
2006-09-21 01:51:57 +00:00
if test -x ../../asn1c/asn1c ; then
2017-10-09 05:36:29 +00:00
echo "Compiling ${ASN_MODULES} using local compiler"
../../asn1c/asn1c -S ../../skeletons ${EFFECTIVE_CMDOPTS} || exit $?
2006-09-21 01:51:57 +00:00
else
2017-10-09 05:36:29 +00:00
echo "Compiling ${ASN_MODULES} using system compiler"
asn1c ${EFFECTIVE_CMDOPTS} || exit $?
2006-09-21 01:51:57 +00:00
fi
2006-09-13 02:10:23 +00:00
if test ! -f converter-example.mk ; then
echo "converter-example.mk is missing"
2006-09-13 02:10:23 +00:00
exit 1
fi
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}"
2006-09-17 03:53:11 +00:00
2017-10-09 05:36:29 +00:00
{
echo "ASN_PROGRAM = ${ASN_PROGRAM}"
echo "CFLAGS += ${EXTRA_CFLAGS}"
echo "begin: ${ASN_PDU}.c maybe-wip-pause all"
echo
echo "-include converter-example.mk"
2017-10-09 05:36:29 +00:00
echo
echo "${ASN_PDU}.c: $0 ${ASN_MODULES}"
2006-09-17 03:53:11 +00:00
echo " make regen-makefile"
2017-10-09 05:36:29 +00:00
echo " @touch ${ASN_PDU}.c"
2006-09-17 03:53:11 +00:00
echo " make"
echo
echo "regen-makefile:"
test -n "$TITLE" && echo " TITLE=\"$TITLE\" \\"
2017-10-09 05:36:29 +00:00
echo " ASN_CMDOPTS=\"${ASN_CMDOPTS}\" \\"
echo " ASN_MODULES=\"${ASN_MODULES}\" \\"
echo " ASN_PDU=${ASN_PDU} \\"
echo " ASN_PROGRAM=${ASN_PROGRAM} \\"
2006-09-13 02:10:23 +00:00
echo " $0"
echo
2017-10-09 05:36:29 +00:00
echo 'check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per'
2006-09-24 19:47:07 +00:00
echo ' @echo ================'
echo ' @echo All tests passed'
echo ' @echo ================'
echo
echo 'check-ber:'
2017-10-09 05:36:29 +00:00
echo " @if test -f sample-${ASN_PDU}-1.[db]er ; then \\"
2017-08-27 19:54:25 +00:00
echo " for f in sample-*-*.[db]er; do \\"
2017-09-05 05:34:50 +00:00
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
2006-09-18 21:30:04 +00:00
echo ' for b in 1 17 33 980 8192; do \'
2017-08-27 19:54:25 +00:00
echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \'
2017-10-09 05:36:29 +00:00
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; \'
2007-06-26 08:24:50 +00:00
echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \'
2006-09-17 11:02:53 +00:00
echo ' rm -f ./.tmp.[12].$$$$; \'
2006-09-24 19:47:07 +00:00
echo ' echo "Test junking $$f (please wait)..."; \'
2017-10-09 05:36:29 +00:00
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; \'
2006-09-18 21:30:04 +00:00
echo ' done; done; fi'
2006-09-24 19:47:07 +00:00
echo
echo 'check-xer:'
2017-10-09 05:36:29 +00:00
echo " @if test -f sample-${ASN_PDU}-1.xer ; then \\"
2017-08-27 19:54:25 +00:00
echo " for f in sample-*-*.xer; do \\"
2017-09-05 05:34:50 +00:00
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
2006-09-18 21:30:04 +00:00
echo ' for b in 1 17 33 980 8192; do \'
2017-08-27 19:54:25 +00:00
echo ' echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \'
2017-10-09 05:36:29 +00:00
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; \'
2007-06-26 08:24:50 +00:00
echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \'
2006-09-17 11:02:53 +00:00
echo ' rm -f ./.tmp.[12].$$$$; \'
2006-09-24 19:47:07 +00:00
echo ' echo "Test junking $$f (please wait)..."; \'
2017-10-09 05:36:29 +00:00
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; \'
2006-09-18 21:30:04 +00:00
echo ' done; done; fi'
2006-09-24 19:47:07 +00:00
echo
2017-08-28 00:59:09 +00:00
echo 'check-oer:'
2017-10-09 05:36:29 +00:00
echo " @if test -f sample-${ASN_PDU}-1.*oer ; then \\"
2017-08-31 08:57:04 +00:00
echo " for f in sample-*-*.*oer; do \\"
2017-09-05 05:34:50 +00:00
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
2017-08-28 00:59:09 +00:00
echo ' for b in 1 17 33 980 8192; do \'
echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \'
2017-10-09 05:36:29 +00:00
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; \'
2017-08-31 08:57:04 +00:00
echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \'
2017-08-28 00:59:09 +00:00
echo ' rm -f ./.tmp.[12].$$$$; \'
2017-08-31 08:57:04 +00:00
echo ' echo "Test junking $$f (please wait) ($$b) ..."; \'
2017-10-09 05:36:29 +00:00
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; \'
2017-08-28 00:59:09 +00:00
echo ' done; done; fi'
echo
2006-09-24 19:47:07 +00:00
echo 'check-per:'
2017-10-09 05:36:29 +00:00
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)..."; \'
2017-10-09 05:36:29 +00:00
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)..."; \'
2017-10-09 05:36:29 +00:00
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'
2017-10-09 05:36:29 +00:00
echo " @if test -f sample-${ASN_PDU}-1.per ; then \\"
2007-06-26 08:24:50 +00:00
echo " for f in sample-*-[1-9].per; do \\"
2017-09-05 05:34:50 +00:00
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
2006-09-18 21:30:04 +00:00
echo ' for b in 1 17 33 980 8192; do \'
2017-08-27 19:54:25 +00:00
echo ' echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \'
2017-10-09 05:36:29 +00:00
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; \'
2007-06-26 08:24:50 +00:00
echo ' diff $$f ./.tmp.1.$$$$ || exit 6; \'
2006-09-18 21:30:04 +00:00
echo ' rm -f ./.tmp.[12].$$$$; \'
2006-09-24 19:47:07 +00:00
echo ' echo "Test junking $$f (please wait)..."; \'
2017-10-09 05:36:29 +00:00
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; \'
2006-09-18 21:30:04 +00:00
echo ' done; done; fi'
2006-09-15 18:33:25 +00:00
echo
2017-08-08 00:47:50 +00:00
echo "maybe-wip-pause:"
2017-08-11 00:58:48 +00:00
echo " @if [ -f WIP ]; then cat WIP; sleep 2; fi"
2017-08-08 00:47:50 +00:00
echo
2006-09-13 02:10:23 +00:00
echo "distclean: clean"
echo ' rm -f $(ASN_MODULE_SRCS)'
echo ' rm -f $(ASN_MODULE_HDRS)'
echo ' rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)'
echo " rm -f converter-example.mk"
2017-10-09 05:36:29 +00:00
} > Makefile
2006-09-21 01:51:57 +00:00
2006-09-13 02:10:23 +00:00
echo
echo "Makefile generation finished"