blob: 1b8f8c4ad1f89502cc8bc8f76bf2d0a1e468c0c8 [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..."; \'
vlme7e9bd92006-09-17 11:02:53 +000063 echo ' ./${TARGET} -iber -oxer -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \'
64 echo ' ./${TARGET} -iber -oxer -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \'
65 echo ' ./${TARGET} -iber -oxer -b 33 $$f > ./.tmp.1.$$$$ || exit 2; \'
66 echo ' ./${TARGET} -iber -oxer -b 980 $$f > ./.tmp.1.$$$$ || exit 2; \'
67 echo ' ./${TARGET} -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \'
68 echo ' ./${TARGET} -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \'
69 echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \'
70 echo ' rm -f ./.tmp.[12].$$$$; \'
vlme0fb1e82006-09-15 18:33:25 +000071 echo ' done; fi'
vlmfbceb502006-09-17 06:31:08 +000072 echo " @if test -f ./sample-${ASN1PDU}-1.xer ; then \\"
73 echo " for f in ./sample-${ASN1PDU}-*.xer; do \\"
74 echo ' echo "Recoding $$f into DER and back..."; \'
vlme7e9bd92006-09-17 11:02:53 +000075 echo ' ./${TARGET} -ixer -oder -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \'
76 echo ' ./${TARGET} -ixer -oder -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \'
77 echo ' ./${TARGET} -ixer -oder -b 33 $$f > ./.tmp.1.$$$$ || exit 2; \'
78 echo ' ./${TARGET} -ixer -oder -b 980 $$f > ./.tmp.1.$$$$ || exit 2; \'
79 echo ' ./${TARGET} -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
80 echo ' ./${TARGET} -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \'
81 echo ' diff $$f ./.tmp.2.$$$$ || exit 2; \'
82 echo ' rm -f ./.tmp.[12].$$$$; \'
vlmfbceb502006-09-17 06:31:08 +000083 echo ' done; fi'
84 echo " @if test -f ./sample-${ASN1PDU}-1.per ; then \\"
85 echo " for f in ./sample-${ASN1PDU}-*.per; do \\"
86 echo ' echo "Recoding $$f into DER into XER and back..."; \'
vlme7e9bd92006-09-17 11:02:53 +000087 echo ' ./${TARGET} -iper -oder -b 1 $$f > ./.tmp.1.$$$$ || exit 2; \'
88 echo ' ./${TARGET} -iper -oder -b 17 $$f > ./.tmp.1.$$$$ || exit 2; \'
89 echo ' ./${TARGET} -iper -oder -b 33 $$f > ./.tmp.1.$$$$ || exit 2; \'
90 echo ' ./${TARGET} -iper -oder -b 980 $$f > ./.tmp.1.$$$$ || exit 2; \'
91 echo ' ./${TARGET} -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
92 echo ' ./${TARGET} -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \'
93 echo ' ./${TARGET} -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \'
94 echo ' diff $$f ./.tmp.1.$$$$ || exit 2; \'
95 echo ' rm -f ./.tmp.[12].$$$$; \'
vlmfbceb502006-09-17 06:31:08 +000096 echo ' done; fi'
vlme0fb1e82006-09-15 18:33:25 +000097 echo ' @echo ================'
98 echo ' @echo All tests passed'
99 echo ' @echo ================'
100 echo
vlm94c92c02006-09-13 02:10:23 +0000101 echo "distclean: clean"
vlm66cea382006-09-17 02:57:40 +0000102 echo ' rm -f $(ASN_MODULE_SOURCES)'
103 echo ' rm -f $(ASN_MODULE_HEADERS)'
vlm94c92c02006-09-13 02:10:23 +0000104 echo ' rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)'
105 echo " rm -f Makefile.am.sample"
106) >> Makefile.$$
107
108rm Makefile.am.sample || exit $?
109
110mv Makefile.$$ Makefile
111
112set +x
113echo
114echo "Makefile generation finished"