blob: ba0351483b91cd66c3097de705d9b3d6dd65ccf0 [file] [log] [blame]
vlm94c92c02006-09-13 02:10:23 +00001#!/bin/sh
vlm13d1c512006-09-17 03:53:11 +00002#
3# This script attempts to compile the given ASN.1 specification and then
4# transforms the resulting Makefile.am.sample tailored to that specification
5# into a customized Makefile.
6#
7# The information which is necessary for this script is passed from the
8# Makefile which is going to be replaced with an updated Makefile.
9# This is called "boot-strapping" and is frequently the source of inside jokes.
10#
11# $Id$
12#
vlm94c92c02006-09-13 02:10:23 +000013
vlmfa58cc72006-09-17 00:20:47 +000014if test -z "$ASN1PDU" \
vlm94c92c02006-09-13 02:10:23 +000015 -o -z "$ASN1MODULES" \
16 -o -z "$PROGNAME" \
vlmfa58cc72006-09-17 00:20:47 +000017; then
vlmebfee8e2006-09-15 22:45:40 +000018 echo "ASN1CMDOPTS=\"$ASN1CMDOPTS\""
vlm94c92c02006-09-13 02:10:23 +000019 echo "ASN1MODULES=\"$ASN1MODULES\""
vlmebfee8e2006-09-15 22:45:40 +000020 echo "ASN1PDU=\"$ASN1PDU\""
vlm94c92c02006-09-13 02:10:23 +000021 echo "PROGNAME=\"$PROGNAME\""
vlmebfee8e2006-09-15 22:45:40 +000022 echo "ASN1PDU, ASN1MODULES, and PROGNAME are mandatory"
vlm94c92c02006-09-13 02:10:23 +000023 exit
24fi
25
26../../asn1c/asn1c -S ../../skeletons ${ASN1CMDOPTS} ${ASN1MODULES} || exit $?
27
vlmfa58cc72006-09-17 00:20:47 +000028if test ! -f Makefile.am.sample ; then
vlm94c92c02006-09-13 02:10:23 +000029 echo "Makefile.am.sample is missing"
30 exit 1
31fi
32
vlm43c8ac52006-09-17 04:52:50 +000033ASN1DEFPDU=`echo "$ASN1PDU" | tr - _`
34CFLAGS="-DPDU=${ASN1DEFPDU}"
vlm70c232d2006-09-17 04:01:29 +000035if test -f config.h ; then
vlm43c8ac52006-09-17 04:52:50 +000036 CFLAGS="-DHAVE_CONFIG_H $CFLAGS"
vlm13d1c512006-09-17 03:53:11 +000037fi
38
vlm94c92c02006-09-13 02:10:23 +000039set -x
40cat Makefile.am.sample \
vlm43c8ac52006-09-17 04:52:50 +000041 | sed -e "s/^CFLAGS += /CFLAGS += ${CFLAGS} /" \
vlm94c92c02006-09-13 02:10:23 +000042 | sed -e "s/^all: /all: ${ASN1PDU}.c /" \
43 | sed -e "s/progname/${PROGNAME}/" \
44 > Makefile.$$
45
46( echo
47 echo "${ASN1PDU}.c: $0"
vlm13d1c512006-09-17 03:53:11 +000048 echo " make regen-makefile"
49 echo " @touch ${ASN1PDU}.c"
50 echo " make"
51 echo
52 echo "regen-makefile:"
vlm94c92c02006-09-13 02:10:23 +000053 echo " ASN1CMDOPTS=\"${ASN1CMDOPTS}\" \\"
54 echo " ASN1MODULES=\"${ASN1MODULES}\" \\"
55 echo " ASN1PDU=${ASN1PDU} \\"
56 echo " PROGNAME=${PROGNAME} \\"
57 echo " $0"
vlm94c92c02006-09-13 02:10:23 +000058 echo
vlme0fb1e82006-09-15 18:33:25 +000059 echo 'check: ${TARGET}'
60 echo " @if test -f ./sample-${ASN1PDU}-1.[db]er ; then \\"
61 echo " for f in ./sample-${ASN1PDU}-*.[db]er; do \\"
62 echo ' echo "Recoding $$f into XER and back..."; \'
63 echo ' ./${TARGET} -iber -oxer $$f > ./.tmp.1.$$ || exit 2; \'
64 echo ' ./${TARGET} -ixer -oxer ./.tmp.1.$$ > ./.tmp.2.$$ || exit 2; \'
65 echo ' diff ./.tmp.1.$$ ./.tmp.2.$$ || exit 2; \'
66 echo ' rm -f ./.tmp.[12].$$; \'
67 echo ' done; fi'
68 echo ' @echo ================'
69 echo ' @echo All tests passed'
70 echo ' @echo ================'
71 echo
vlm94c92c02006-09-13 02:10:23 +000072 echo "distclean: clean"
vlm66cea382006-09-17 02:57:40 +000073 echo ' rm -f $(ASN_MODULE_SOURCES)'
74 echo ' rm -f $(ASN_MODULE_HEADERS)'
vlm94c92c02006-09-13 02:10:23 +000075 echo ' rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)'
76 echo " rm -f Makefile.am.sample"
77) >> Makefile.$$
78
79rm Makefile.am.sample || exit $?
80
81mv Makefile.$$ Makefile
82
83set +x
84echo
85echo "Makefile generation finished"