Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | # This script converts Makefile.in.in and config.c.in into Makefile.in |
| 4 | # and config.c, based on the module definitions found in the file |
| 5 | # Setup. |
| 6 | |
| 7 | NL="\\ |
| 8 | " |
| 9 | |
| 10 | sed -e 's/#.*//' -e '/^[ ]*$/d' ${1-Setup} | |
| 11 | ( |
| 12 | DEFS= |
| 13 | MODS= |
| 14 | OBJS= |
| 15 | LIBS= |
| 16 | RULES= |
| 17 | |
| 18 | while read line |
| 19 | do |
| 20 | case $line in |
| 21 | *=*) DEFS="$DEFS$line$NL"; continue;; |
| 22 | esac |
| 23 | objs= |
| 24 | cpps= |
| 25 | set $line |
| 26 | for arg |
| 27 | do |
| 28 | case $arg in |
| 29 | -[IDUC]*) cpps="$cpps $arg";; |
| 30 | -[Ll]*) LIBS="$LIBS $arg";; |
| 31 | *.a) LIBS="$LIBS $arg";; |
| 32 | *.o) objs="$objs $arg";; |
| 33 | *.*) echo 1>&2 "bad word $arg in $line" |
| 34 | exit 1;; |
| 35 | [a-zA-Z_]*) MODS="$MODS $arg";; |
| 36 | *) echo 1>&2 "bad word $arg in $line" |
| 37 | exit 1;; |
| 38 | esac |
| 39 | done |
| 40 | for obj in $objs |
| 41 | do |
| 42 | src=`basename $obj .o`.c |
| 43 | RULES="$RULES$obj: $src; \$(CC) \$(CFLAGS) $cpps -c $src$NL" |
| 44 | done |
| 45 | OBJS="$OBJS $objs" |
| 46 | done |
| 47 | |
| 48 | EXTDECLS= |
| 49 | INITBITS= |
| 50 | for mod in $MODS |
| 51 | do |
| 52 | EXTDECLS="${EXTDECLS}extern void init$mod();$NL" |
| 53 | INITBITS="${INITBITS} {\"$mod\", init$mod},$NL" |
| 54 | done |
| 55 | sed -e " |
| 56 | /MARKER 1/i$NL$EXTDECLS |
| 57 | |
| 58 | /MARKER 2/i$NL$INITBITS |
| 59 | |
| 60 | " config.c.in >config.c |
| 61 | |
| 62 | sed -e " |
| 63 | s%@MODOBJS@%$OBJS% |
| 64 | s%@MODLIBS@%$LIBS% |
| 65 | /Rules added by ..makesetup/a$NL$NL$RULES |
| 66 | |
| 67 | /Definitions added by ..makesetup/a$NL$NL$DEFS |
| 68 | |
| 69 | " Makefile.in.in >Makefile.in |
| 70 | |
| 71 | ) |