Debian Codegraph @

examples/sample.makefile.regen

raw
1 #!/bin/sh
2 #
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 #
13
14 if test -z "$ASN1PDU" \
15 -o -z "$ASN1MODULES" \
16 -o -z "$PROGNAME" \
17 ; then
18 echo "ASN1CMDOPTS=\"$ASN1CMDOPTS\""
19 echo "ASN1MODULES=\"$ASN1MODULES\""
20 echo "ASN1PDU=\"$ASN1PDU\""
21 echo "PROGNAME=\"$PROGNAME\""
22 echo "ASN1PDU, ASN1MODULES, and PROGNAME are mandatory"
23 exit
24 fi
25
26 CMDOPTS="-pdu=${ASN1PDU} ${ASN1CMDOPTS} ${ASN1MODULES}"
27
28 if test -x ../../asn1c/asn1c ; then
29 echo "Compiling ${ASN1MODULES} using local compiler"
30 ../../asn1c/asn1c -S ../../skeletons ${CMDOPTS} || exit $?
31 else
32 echo "Compiling ${ASN1MODULES} using system compiler"
33 asn1c ${CMDOPTS} || exit $?
34 fi
35
36 if test ! -f Makefile.am.sample ; then
37 echo "Makefile.am.sample is missing"
38 exit 1
39 fi
40
41 EXTRA_CFLAGS="-DJUNKTEST"
42 test -f config.h && EXTRA_CFLAGS="-DHAVE_CONFIG_H ${EXTRA_CFLAGS}"
43 test -n "$TITLE" && EXTRA_CFLAGS="-DASN_CONVERTER_TITLE=\"$TITLE\" ${EXTRA_CFLAGS}"
44
45 set -x
46 cat Makefile.am.sample \
47 | sed -e "s/^CFLAGS += /CFLAGS += ${EXTRA_CFLAGS} /" \
48 | sed -e "s/^all: /all: ${ASN1PDU}.c /" \
49 | sed -e "s/progname/${PROGNAME}/" \
50 > Makefile.$$
51 set +x
52
53 ( echo
54 echo "${ASN1PDU}.c: $0 ${ASN1MODULES}"
55 echo " make regen-makefile"
56 echo " @touch ${ASN1PDU}.c"
57 echo " make"
58 echo
59 echo "regen-makefile:"
60 test -n "$TITLE" && echo " TITLE=\"$TITLE\" \\"
61 echo " ASN1CMDOPTS=\"${ASN1CMDOPTS}\" \\"
62 echo " ASN1MODULES=\"${ASN1MODULES}\" \\"
63 echo " ASN1PDU=${ASN1PDU} \\"
64 echo " PROGNAME=${PROGNAME} \\"
65 echo " $0"
66 echo
67 echo 'check: ${TARGET} check-ber check-xer check-per'
68 echo ' @echo ================'
69 echo ' @echo All tests passed'
70 echo ' @echo ================'
71 echo
72 echo 'check-ber:'
73 echo " @if test -f sample-${ASN1PDU}-1.[db]er ; then \\"
74 echo " for f in sample-${ASN1PDU}-*.[db]er; do \\"
75 echo ' for b in 1 17 33 980 8192; do \'
76 echo ' echo "Recoding $$f into XER and back ($$b)..."; \'
77 echo ' ./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \'
78 echo ' ./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
79 echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \'
80 echo ' rm -f ./.tmp.[12].$$$$; \'
81 echo ' echo "Test junking $$f (please wait)..."; \'
82 echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \'
83 echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \'
84 echo ' done; done; fi'
85 echo
86 echo 'check-xer:'
87 echo " @if test -f sample-${ASN1PDU}-1.xer ; then \\"
88 echo " for f in sample-${ASN1PDU}-*.xer; do \\"
89 echo ' for b in 1 17 33 980 8192; do \'
90 echo ' echo "Recoding $$f into DER and back ($$b)..."; \'
91 echo ' ./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
92 echo ' ./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
93 echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \'
94 echo ' rm -f ./.tmp.[12].$$$$; \'
95 echo ' echo "Test junking $$f (please wait)..."; \'
96 echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \'
97 echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \'
98 echo ' done; done; fi'
99 echo
100 echo 'check-per:'
101 echo " @if test -f sample-${ASN1PDU}-1-nopad.per ; then \\"
102 echo " for f in sample-${ASN1PDU}-[1-9]-nopad.per; do \\"
103 echo ' for b in 1 17 33 980 8192; do \'
104 echo ' echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \'
105 echo ' ./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
106 echo ' ./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
107 echo ' ./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \'
108 echo ' diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \'
109 echo ' rm -f ./.tmp.[123].$$$$; \'
110 echo ' echo "Test junking $$f (please wait)..."; \'
111 echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \'
112 echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \'
113 echo ' done; done; fi'
114 echo " @if test -f sample-${ASN1PDU}-1.per ; then \\"
115 echo " for f in sample-*-[1-9].per; do \\"
116 echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \'
117 echo ' for b in 1 17 33 980 8192; do \'
118 echo ' echo "Recoding $$f into DER into XER and back ($$b)..."; \'
119 echo ' ./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \'
120 echo ' ./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \'
121 echo ' ./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \'
122 echo ' diff $$f ./.tmp.1.$$$$ || exit 6; \'
123 echo ' rm -f ./.tmp.[12].$$$$; \'
124 echo ' echo "Test junking $$f (please wait)..."; \'
125 echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \'
126 echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \'
127 echo ' done; done; fi'
128 echo
129 echo "distclean: clean"
130 echo ' rm -f $(ASN_MODULE_SOURCES)'
131 echo ' rm -f $(ASN_MODULE_HEADERS)'
132 echo ' rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)'
133 echo " rm -f Makefile.am.sample"
134 ) >> Makefile.$$
135
136 set -x
137 mv Makefile.$$ Makefile || exit $?
138 rm Makefile.am.sample || exit $?
139 set +x
140
141 echo
142 echo "Makefile generation finished"