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 |
| 47 | echo "${ASN1PDU}.c: $0" |
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}' |
| 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..."; \' |
vlm | e7e9bd9 | 2006-09-17 11:02:53 +0000 | [diff] [blame] | 63 | 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].$$$$; \' |
vlm | e0fb1e8 | 2006-09-15 18:33:25 +0000 | [diff] [blame] | 71 | echo ' done; fi' |
vlm | fbceb50 | 2006-09-17 06:31:08 +0000 | [diff] [blame] | 72 | 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..."; \' |
vlm | e7e9bd9 | 2006-09-17 11:02:53 +0000 | [diff] [blame] | 75 | 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].$$$$; \' |
vlm | fbceb50 | 2006-09-17 06:31:08 +0000 | [diff] [blame] | 83 | 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..."; \' |
vlm | e7e9bd9 | 2006-09-17 11:02:53 +0000 | [diff] [blame] | 87 | 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].$$$$; \' |
vlm | fbceb50 | 2006-09-17 06:31:08 +0000 | [diff] [blame] | 96 | echo ' done; fi' |
vlm | e0fb1e8 | 2006-09-15 18:33:25 +0000 | [diff] [blame] | 97 | echo ' @echo ================' |
| 98 | echo ' @echo All tests passed' |
| 99 | echo ' @echo ================' |
| 100 | echo |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 101 | echo "distclean: clean" |
vlm | 66cea38 | 2006-09-17 02:57:40 +0000 | [diff] [blame] | 102 | echo ' rm -f $(ASN_MODULE_SOURCES)' |
| 103 | echo ' rm -f $(ASN_MODULE_HEADERS)' |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 104 | echo ' rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)' |
| 105 | echo " rm -f Makefile.am.sample" |
| 106 | ) >> Makefile.$$ |
| 107 | |
| 108 | rm Makefile.am.sample || exit $? |
| 109 | |
| 110 | mv Makefile.$$ Makefile |
| 111 | |
| 112 | set +x |
| 113 | echo |
| 114 | echo "Makefile generation finished" |