3 # This script attempts to compile the given ASN.1 specification by first
4 # building the specialized Makefile.
6 # The information which is necessary for this script is passed from the
7 # Makefile which is going to be replaced with an updated Makefile.
10 if test -z "$ASN_PDU" \
11 -o -z "$ASN_MODULES" \
12 -o -z "$ASN_PROGRAM" \
15 ASN_CMDOPTS="$ASN_CMDOPTS"
16 ASN_MODULES="$ASN_MODULES"
18 ASN_PROGRAM="$ASN_PROGRAM"
19 ASN_PDU, ASN_MODULES, and ASN_PROGRAM are mandatory.
24 EFFECTIVE_CMDOPTS="-pdu=${ASN_PDU} ${ASN_CMDOPTS} ${ASN_MODULES}"
26 if test -x ../../asn1c/asn1c ; then
27 echo "Compiling ${ASN_MODULES} using local compiler"
28 ../../asn1c/asn1c -S ../../skeletons ${EFFECTIVE_CMDOPTS} || exit $?
30 echo "Compiling ${ASN_MODULES} using system compiler"
31 asn1c ${EFFECTIVE_CMDOPTS} || exit $?
34 if test ! -f converter-example.mk ; then
35 echo "converter-example.mk is missing"
39 EXTRA_CFLAGS="-DJUNKTEST -D_DEFAULT_SOURCE"
40 test -f config.h && EXTRA_CFLAGS="-DHAVE_CONFIG_H ${EXTRA_CFLAGS}"
41 test -n "$TITLE" && EXTRA_CFLAGS="-DASN_CONVERTER_TITLE=\"$TITLE\" ${EXTRA_CFLAGS}"
44 echo "ASN_PROGRAM = ${ASN_PROGRAM}"
45 echo "CFLAGS += ${EXTRA_CFLAGS}"
46 echo "begin: ${ASN_PDU}.c maybe-wip-pause all"
48 echo "-include converter-example.mk"
50 echo "${ASN_PDU}.c: $0 ${ASN_MODULES}"
51 echo " make regen-makefile"
52 echo " @touch ${ASN_PDU}.c"
55 echo "regen-makefile:"
56 test -n "$TITLE" && echo " TITLE=\"$TITLE\" \\"
57 echo " ASN_CMDOPTS=\"${ASN_CMDOPTS}\" \\"
58 echo " ASN_MODULES=\"${ASN_MODULES}\" \\"
59 echo " ASN_PDU=${ASN_PDU} \\"
60 echo " ASN_PROGRAM=${ASN_PROGRAM} \\"
63 echo 'check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per check-aper'
64 echo ' @echo ================'
65 echo ' @echo All tests passed'
66 echo ' @echo ================'
69 echo " @if test -f sample-${ASN_PDU}-1.[db]er ; then \\"
70 echo " for f in sample-*-*.[db]er; do \\"
71 echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
72 echo ' for b in 1 17 33 980 8192; do \'
73 echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \'
74 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \'
75 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
76 echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \'
77 echo ' rm -f ./.tmp.[12].$$$$; \'
78 echo ' echo "Test junking $$f (please wait)..."; \'
79 echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \'
80 echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \'
81 echo ' done; done; fi'
84 echo " @if test -f sample-${ASN_PDU}-1.xer ; then \\"
85 echo " for f in sample-*-*.xer; do \\"
86 echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
87 echo ' for b in 1 17 33 980 8192; do \'
88 echo ' echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \'
89 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
90 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
91 echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \'
92 echo ' rm -f ./.tmp.[12].$$$$; \'
93 echo ' echo "Test junking $$f (please wait)..."; \'
94 echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \'
95 echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \'
96 echo ' done; done; fi'
99 echo " @if test -f sample-${ASN_PDU}-1.*oer ; then \\"
100 echo " for f in sample-*-*.*oer; do \\"
101 echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
102 echo ' for b in 1 17 33 980 8192; do \'
103 echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \'
104 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \'
105 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
106 echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \'
107 echo ' rm -f ./.tmp.[12].$$$$; \'
108 echo ' echo "Test junking $$f (please wait) ($$b) ..."; \'
109 echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \'
110 echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \'
111 echo ' done; done; fi'
114 echo " @if test -f sample-${ASN_PDU}-1-nopad.per ; then \\"
115 echo " for f in sample-*-[1-9]-nopad.per; do \\"
116 echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
117 echo ' for b in 1 17 33 980 8192; do \'
118 echo ' echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \'
119 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
120 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
121 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \'
122 echo ' diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \'
123 echo ' rm -f ./.tmp.[123].$$$$; \'
124 echo ' echo "Test junking $$f (please wait)..."; \'
125 echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \'
126 echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \'
127 echo ' done; done; fi'
128 echo " @if test -f sample-${ASN_PDU}-1.per ; then \\"
129 echo " for f in sample-*-[1-9].per; do \\"
130 echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
131 echo ' for b in 1 17 33 980 8192; do \'
132 echo ' echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \'
133 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \'
134 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \'
135 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \'
136 echo ' diff $$f ./.tmp.1.$$$$ || exit 6; \'
137 echo ' rm -f ./.tmp.[12].$$$$; \'
138 echo ' echo "Test junking $$f (please wait)..."; \'
139 echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \'
140 echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \'
141 echo ' done; done; fi'
144 echo " @files=\$\$(find . -type f -regex '^.*\/sample-.*-[0-9]+.aper\$\$' | sort -V); \\"
145 echo ' if [ -n "$$files" ]; then \'
146 echo ' for f in $$files; do \'
147 echo ' pdu=`echo $$f | sed -E -e "s/.*sample-([A-Za-z0-9-]+)-[0-9]+.*/\\1/"`; \'
148 echo ' for b in 1 17 33 980 8192; do \'
149 echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \'
150 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iaper -oxer $$f > ./.tmp.1.$$$$ || exit 3; \'
151 echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oaper ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \'
152 echo ' diff $$f ./.tmp.2.$$$$ || exit 6; \'
153 echo ' rm -f ./.tmp.[12].$$$$; \'
154 echo ' echo "Test junking $$f (please wait)..."; \'
155 echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iaper -onull $$f || exit 7; \'
156 echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iaper -onull $$f || exit 8; \'
157 echo ' done; done; fi'
159 echo "maybe-wip-pause:"
160 echo " @if [ -f WIP ]; then cat WIP; sleep 2; fi"
162 echo "distclean: clean"
163 echo ' rm -f $(ASN_MODULE_SRCS)'
164 echo ' rm -f $(ASN_MODULE_HDRS)'
165 echo ' rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)'
166 echo " rm -f converter-example.mk"
170 echo "Makefile generation finished"