asn1c/examples/sample.makefile.regen

93 lines
2.4 KiB
Plaintext
Raw Normal View History

#!/bin/sh
#
# This script attempts to compile the given ASN.1 specification and then
# transforms the resulting Makefile.am.sample tailored to that specification
# into a customized Makefile.
#
# The information which is necessary for this script is passed from the
# Makefile which is going to be replaced with an updated Makefile.
# This is called "boot-strapping" and is frequently the source of inside jokes.
#
# $Id$
#
if test -z "$ASN1PDU" \
-o -z "$ASN1MODULES" \
-o -z "$PROGNAME" \
; then
echo "ASN1CMDOPTS=\"$ASN1CMDOPTS\""
echo "ASN1MODULES=\"$ASN1MODULES\""
echo "ASN1PDU=\"$ASN1PDU\""
echo "PROGNAME=\"$PROGNAME\""
echo "ASN1PDU, ASN1MODULES, and PROGNAME are mandatory"
exit
fi
ASN1DEFPDU=`echo "$ASN1PDU" | tr - _`
../../asn1c/asn1c -S ../../skeletons ${ASN1CMDOPTS} ${ASN1MODULES} || exit $?
if test ! -f Makefile.am.sample ; then
echo "Makefile.am.sample is missing"
exit 1
fi
CFLAGS=""
if test -f config.h ; then
CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
fi
FIXEDPDU=`echo "[$ASN1CMDOPTS]" | sed -e "s/.*-pdu=auto.*//"`
if test ! "$FIXEDPDU" ; then
CFLAGS="$CFLAGS -DASN_PDU_COLLECTION"
fi
set -x
cat Makefile.am.sample \
| sed -e "s/^CFLAGS.*/CFLAGS +=$CFLAGS -DPDU=${ASN1DEFPDU} -I./" \
| sed -e "s/^all: /all: ${ASN1PDU}.c /" \
| sed -e "s/progname/${PROGNAME}/" \
> Makefile.$$
( echo
echo "${ASN1PDU}.c: $0"
echo " make regen-makefile"
echo " @touch ${ASN1PDU}.c"
echo " make"
echo
echo "regen-makefile:"
echo " ASN1CMDOPTS=\"${ASN1CMDOPTS}\" \\"
echo " ASN1MODULES=\"${ASN1MODULES}\" \\"
echo " ASN1PDU=${ASN1PDU} \\"
echo " PROGNAME=${PROGNAME} \\"
echo " $0"
echo
echo 'check: ${TARGET}'
echo " @if test -f ./sample-${ASN1PDU}-1.[db]er ; then \\"
echo " for f in ./sample-${ASN1PDU}-*.[db]er; do \\"
echo ' echo "Recoding $$f into XER and back..."; \'
echo ' ./${TARGET} -iber -oxer $$f > ./.tmp.1.$$ || exit 2; \'
echo ' ./${TARGET} -ixer -oxer ./.tmp.1.$$ > ./.tmp.2.$$ || exit 2; \'
echo ' diff ./.tmp.1.$$ ./.tmp.2.$$ || exit 2; \'
echo ' rm -f ./.tmp.[12].$$; \'
echo ' done; fi'
echo ' @echo ================'
echo ' @echo All tests passed'
echo ' @echo ================'
echo
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 Makefile.am.sample"
) >> Makefile.$$
rm Makefile.am.sample || exit $?
mv Makefile.$$ Makefile
set +x
echo
echo "Makefile generation finished"