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 | |
vlm | 13d1c51 | 2006-09-17 03:53:11 +0000 | [diff] [blame] | 26 | ASN1DEFPDU=`echo "$ASN1PDU" | tr - _` |
vlm | fa58cc7 | 2006-09-17 00:20:47 +0000 | [diff] [blame] | 27 | |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 28 | ../../asn1c/asn1c -S ../../skeletons ${ASN1CMDOPTS} ${ASN1MODULES} || exit $? |
| 29 | |
vlm | fa58cc7 | 2006-09-17 00:20:47 +0000 | [diff] [blame] | 30 | if test ! -f Makefile.am.sample ; then |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 31 | echo "Makefile.am.sample is missing" |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
vlm | 13d1c51 | 2006-09-17 03:53:11 +0000 | [diff] [blame] | 35 | CFLAGS="" |
vlm | fa58cc7 | 2006-09-17 00:20:47 +0000 | [diff] [blame] | 36 | |
vlm | 70c232d | 2006-09-17 04:01:29 +0000 | [diff] [blame^] | 37 | if test -f config.h ; then |
| 38 | CFLAGS="$CFLAGS -DHAVE_CONFIG_H" |
| 39 | fi |
| 40 | |
vlm | f556dd8 | 2006-09-17 00:38:30 +0000 | [diff] [blame] | 41 | FIXEDPDU=`echo "[$ASN1CMDOPTS]" | sed -e "s/.*-pdu=auto.*//"` |
vlm | 8658423 | 2006-09-17 00:30:54 +0000 | [diff] [blame] | 42 | if test ! "$FIXEDPDU" ; then |
vlm | 13d1c51 | 2006-09-17 03:53:11 +0000 | [diff] [blame] | 43 | CFLAGS="$CFLAGS -DASN_PDU_COLLECTION" |
| 44 | fi |
| 45 | |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 46 | set -x |
| 47 | cat Makefile.am.sample \ |
vlm | 13d1c51 | 2006-09-17 03:53:11 +0000 | [diff] [blame] | 48 | | sed -e "s/^CFLAGS.*/CFLAGS +=$CFLAGS -DPDU=${ASN1DEFPDU} -I./" \ |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 49 | | sed -e "s/^all: /all: ${ASN1PDU}.c /" \ |
| 50 | | sed -e "s/progname/${PROGNAME}/" \ |
| 51 | > Makefile.$$ |
| 52 | |
| 53 | ( echo |
| 54 | echo "${ASN1PDU}.c: $0" |
vlm | 13d1c51 | 2006-09-17 03:53:11 +0000 | [diff] [blame] | 55 | echo " make regen-makefile" |
| 56 | echo " @touch ${ASN1PDU}.c" |
| 57 | echo " make" |
| 58 | echo |
| 59 | echo "regen-makefile:" |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 60 | echo " ASN1CMDOPTS=\"${ASN1CMDOPTS}\" \\" |
| 61 | echo " ASN1MODULES=\"${ASN1MODULES}\" \\" |
| 62 | echo " ASN1PDU=${ASN1PDU} \\" |
| 63 | echo " PROGNAME=${PROGNAME} \\" |
| 64 | echo " $0" |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 65 | echo |
vlm | e0fb1e8 | 2006-09-15 18:33:25 +0000 | [diff] [blame] | 66 | echo 'check: ${TARGET}' |
| 67 | echo " @if test -f ./sample-${ASN1PDU}-1.[db]er ; then \\" |
| 68 | echo " for f in ./sample-${ASN1PDU}-*.[db]er; do \\" |
| 69 | echo ' echo "Recoding $$f into XER and back..."; \' |
| 70 | echo ' ./${TARGET} -iber -oxer $$f > ./.tmp.1.$$ || exit 2; \' |
| 71 | echo ' ./${TARGET} -ixer -oxer ./.tmp.1.$$ > ./.tmp.2.$$ || exit 2; \' |
| 72 | echo ' diff ./.tmp.1.$$ ./.tmp.2.$$ || exit 2; \' |
| 73 | echo ' rm -f ./.tmp.[12].$$; \' |
| 74 | echo ' done; fi' |
| 75 | echo ' @echo ================' |
| 76 | echo ' @echo All tests passed' |
| 77 | echo ' @echo ================' |
| 78 | echo |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 79 | echo "distclean: clean" |
vlm | 66cea38 | 2006-09-17 02:57:40 +0000 | [diff] [blame] | 80 | echo ' rm -f $(ASN_MODULE_SOURCES)' |
| 81 | echo ' rm -f $(ASN_MODULE_HEADERS)' |
vlm | 94c92c0 | 2006-09-13 02:10:23 +0000 | [diff] [blame] | 82 | echo ' rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)' |
| 83 | echo " rm -f Makefile.am.sample" |
| 84 | ) >> Makefile.$$ |
| 85 | |
| 86 | rm Makefile.am.sample || exit $? |
| 87 | |
| 88 | mv Makefile.$$ Makefile |
| 89 | |
| 90 | set +x |
| 91 | echo |
| 92 | echo "Makefile generation finished" |