vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 1 | #!/bin/sh |
vlm | 13d1c51 | 2006-09-17 03:53:11 +0000 | [diff] [blame] | 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 | # |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 13 | |
vlm | fa58cc7 | 2006-09-17 00:20:47 +0000 | [diff] [blame] | 14 | if test -z "$ASN1PDU" \ |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 15 | -o -z "$ASN1MODULES" \ |
| 16 | -o -z "$PROGNAME" \ |
vlm | fa58cc7 | 2006-09-17 00:20:47 +0000 | [diff] [blame] | 17 | ; then |
vlm | ebfee8e | 2006-09-15 22:45:40 +0000 | [diff] [blame] | 18 | echo "ASN1CMDOPTS=\"$ASN1CMDOPTS\"" |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 19 | echo "ASN1MODULES=\"$ASN1MODULES\"" |
vlm | ebfee8e | 2006-09-15 22:45:40 +0000 | [diff] [blame] | 20 | echo "ASN1PDU=\"$ASN1PDU\"" |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 21 | echo "PROGNAME=\"$PROGNAME\"" |
vlm | ebfee8e | 2006-09-15 22:45:40 +0000 | [diff] [blame] | 22 | echo "ASN1PDU, ASN1MODULES, and PROGNAME are mandatory" |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 23 | exit |
| 24 | fi |
| 25 | |
| 26 | ../../asn1c/asn1c -S ../../skeletons ${ASN1CMDOPTS} ${ASN1MODULES} || exit $? |
| 27 | |
vlm | fa58cc7 | 2006-09-17 00:20:47 +0000 | [diff] [blame] | 28 | if test ! -f Makefile.am.sample ; then |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 29 | echo "Makefile.am.sample is missing" |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
vlm | 43c8ac5 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 33 | ASN1DEFPDU=`echo "$ASN1PDU" | tr - _` |
| 34 | CFLAGS="-DPDU=${ASN1DEFPDU}" |
vlm | 70c232d | 2006-09-17 04:01:29 +0000 | [diff] [blame] | 35 | if test -f config.h ; then |
vlm | 43c8ac5 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 36 | CFLAGS="-DHAVE_CONFIG_H $CFLAGS" |
vlm | 13d1c51 | 2006-09-17 03:53:11 +0000 | [diff] [blame] | 37 | fi |
| 38 | |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 39 | set -x |
| 40 | cat Makefile.am.sample \ |
vlm | 43c8ac5 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 41 | | sed -e "s/^CFLAGS += /CFLAGS += ${CFLAGS} /" \ |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 42 | | sed -e "s/^all: /all: ${ASN1PDU}.c /" \ |
| 43 | | sed -e "s/progname/${PROGNAME}/" \ |
| 44 | > Makefile.$$ |
| 45 | |
| 46 | ( echo |
vlm | f49ca90 | 2006-09-18 20:04:14 +0000 | [diff] [blame] | 47 | echo "${ASN1PDU}.c: $0 ${ASN1MODULES}" |
vlm | 13d1c51 | 2006-09-17 03:53:11 +0000 | [diff] [blame] | 48 | echo " make regen-makefile" |
| 49 | echo " @touch ${ASN1PDU}.c" |
| 50 | echo " make" |
| 51 | echo |
| 52 | echo "regen-makefile:" |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 53 | echo " ASN1CMDOPTS=\"${ASN1CMDOPTS}\" \\" |
| 54 | echo " ASN1MODULES=\"${ASN1MODULES}\" \\" |
| 55 | echo " ASN1PDU=${ASN1PDU} \\" |
| 56 | echo " PROGNAME=${PROGNAME} \\" |
| 57 | echo " $0" |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 58 | echo |
vlm | e0fb1e8 | 2006-09-15 18:33:25 +0000 | [diff] [blame] | 59 | echo 'check: ${TARGET}' |
vlm | de70d69 | 2006-09-18 21:19:32 +0000 | [diff] [blame] | 60 | echo " @if test -f sample-${ASN1PDU}-1.[db]er ; then \\" |
| 61 | echo " for f in sample-${ASN1PDU}-*.[db]er; do \\" |
vlm | 774407b | 2006-09-18 21:30:04 +0000 | [diff] [blame] | 62 | echo ' for b in 1 17 33 980 8192; do \' |
| 63 | echo ' echo "Recoding $$f into XER and back ($$b)..."; \' |
| 64 | echo ' ./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \' |
| 65 | echo ' ./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \' |
vlm | e7e9bd9 | 2006-09-17 11:02:53 +0000 | [diff] [blame] | 66 | echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \' |
| 67 | echo ' rm -f ./.tmp.[12].$$$$; \' |
vlm | 774407b | 2006-09-18 21:30:04 +0000 | [diff] [blame] | 68 | echo ' done; done; fi' |
vlm | de70d69 | 2006-09-18 21:19:32 +0000 | [diff] [blame] | 69 | echo " @if test -f sample-${ASN1PDU}-1.xer ; then \\" |
| 70 | echo " for f in sample-${ASN1PDU}-*.xer; do \\" |
vlm | 774407b | 2006-09-18 21:30:04 +0000 | [diff] [blame] | 71 | echo ' for b in 1 17 33 980 8192; do \' |
| 72 | echo ' echo "Recoding $$f into DER and back ($$b)..."; \' |
| 73 | echo ' ./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \' |
| 74 | echo ' ./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \' |
vlm | e7e9bd9 | 2006-09-17 11:02:53 +0000 | [diff] [blame] | 75 | echo ' diff $$f ./.tmp.2.$$$$ || exit 2; \' |
| 76 | echo ' rm -f ./.tmp.[12].$$$$; \' |
vlm | 774407b | 2006-09-18 21:30:04 +0000 | [diff] [blame] | 77 | echo ' done; done; fi' |
vlm | de70d69 | 2006-09-18 21:19:32 +0000 | [diff] [blame] | 78 | echo " @if test -f sample-${ASN1PDU}-1.per ; then \\" |
| 79 | echo " for f in sample-${ASN1PDU}-[1-9].per; do \\" |
vlm | 774407b | 2006-09-18 21:30:04 +0000 | [diff] [blame] | 80 | echo ' for b in 1 17 33 980 8192; do \' |
| 81 | echo ' echo "Recoding $$f into DER into XER and back ($$b)..."; \' |
| 82 | echo ' ./${TARGET} -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \' |
| 83 | echo ' ./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \' |
| 84 | echo ' ./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \' |
vlm | f49ca90 | 2006-09-18 20:04:14 +0000 | [diff] [blame] | 85 | echo ' diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \' |
vlm | 774407b | 2006-09-18 21:30:04 +0000 | [diff] [blame] | 86 | echo ' rm -f ./.tmp.[123].$$$$; \' |
| 87 | echo ' done; done; fi' |
vlm | de70d69 | 2006-09-18 21:19:32 +0000 | [diff] [blame] | 88 | echo " @if test -f sample-${ASN1PDU}-1-padded.per ; then \\" |
| 89 | echo " for f in sample-*-[1-9]-padded.per; do \\" |
| 90 | echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \' |
vlm | 774407b | 2006-09-18 21:30:04 +0000 | [diff] [blame] | 91 | echo ' for b in 1 17 33 980 8192; do \' |
| 92 | echo ' echo "Recoding byte-padded $$f into DER into XER and back ($$b)..."; \' |
| 93 | echo ' ./${TARGET} -b $$b -per-padded -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \' |
| 94 | echo ' ./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \' |
| 95 | echo ' ./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \' |
vlm | e7e9bd9 | 2006-09-17 11:02:53 +0000 | [diff] [blame] | 96 | echo ' diff $$f ./.tmp.1.$$$$ || exit 2; \' |
vlm | 774407b | 2006-09-18 21:30:04 +0000 | [diff] [blame] | 97 | echo ' rm -f ./.tmp.[12].$$$$; \' |
| 98 | echo ' done; done; fi' |
vlm | e0fb1e8 | 2006-09-15 18:33:25 +0000 | [diff] [blame] | 99 | echo ' @echo ================' |
| 100 | echo ' @echo All tests passed' |
| 101 | echo ' @echo ================' |
| 102 | echo |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 103 | echo "distclean: clean" |
vlm | 66cea38 | 2006-09-17 02:57:40 +0000 | [diff] [blame] | 104 | echo ' rm -f $(ASN_MODULE_SOURCES)' |
| 105 | echo ' rm -f $(ASN_MODULE_HEADERS)' |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 106 | echo ' rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)' |
| 107 | echo " rm -f Makefile.am.sample" |
| 108 | ) >> Makefile.$$ |
| 109 | |
| 110 | rm Makefile.am.sample || exit $? |
| 111 | |
| 112 | mv Makefile.$$ Makefile |
| 113 | |
| 114 | set +x |
| 115 | echo |
| 116 | echo "Makefile generation finished" |