Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 3 | # Convert templates into Makefile and config.c, based on the module |
| 4 | # definitions found in the file Setup. |
| 5 | # |
| 6 | # Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...] |
| 7 | # |
| 8 | # Options: |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 9 | # -s directory: alternative source directory (default .) |
| 10 | # -l directory: library source directory (default derived from $0) |
| 11 | # -c file: alternative config.c template (default $libdir/config.c.in) |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 12 | # -c -: don't write config.c |
| 13 | # -m file: alternative Makefile template (default ./Makefile.pre) |
| 14 | # -m -: don't write Makefile |
| 15 | # |
| 16 | # Remaining arguments are one or more Setup files (default ./Setup). |
| 17 | # Setup files after a -n option are used for their variables, modules |
| 18 | # and libraries but not for their .o files. |
| 19 | # |
Antoine Pitrou | 961d54c | 2018-07-16 19:03:03 +0200 | [diff] [blame] | 20 | # See Setup for a description of the format of the Setup file. |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 21 | # |
| 22 | # The following edits are made: |
| 23 | # |
| 24 | # Copying config.c.in to config.c: |
| 25 | # - insert an identifying comment at the start |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 26 | # - for each <module> mentioned in Setup before *noconfig*: |
Martin v. Löwis | 1a21451 | 2008-06-11 05:26:20 +0000 | [diff] [blame] | 27 | # + insert 'extern PyObject* PyInit_<module>(void);' before MARKER 1 |
| 28 | # + insert '{"<module>", PyInit_<module>},' before MARKER 2 |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 29 | # |
| 30 | # Copying Makefile.pre to Makefile: |
| 31 | # - insert an identifying comment at the start |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 32 | # - replace _MODBUILT_NAMES_ by the list of *static* and *shared* modules |
| 33 | # from Setup |
| 34 | # - replace _MODDISABLED_NAMES_ by the list of *disabled* modules from Setup |
Guido van Rossum | 3bbc62e | 1995-01-02 19:30:30 +0000 | [diff] [blame] | 35 | # - replace _MODOBJS_ by the list of objects from Setup (except for |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 36 | # Setup files after a -n option) |
Guido van Rossum | 3bbc62e | 1995-01-02 19:30:30 +0000 | [diff] [blame] | 37 | # - replace _MODLIBS_ by the list of libraries from Setup |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 38 | # - for each object file mentioned in Setup, append a rule |
| 39 | # '<file>.o: <file>.c; <build commands>' to the end of the Makefile |
| 40 | # - for each module mentioned in Setup, append a rule |
| 41 | # which creates a shared library version to the end of the Makefile |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 42 | # - for each variable definition found in Setup, insert the definition |
| 43 | # before the comment 'Definitions added by makesetup' |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 44 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 45 | # Loop over command line options |
| 46 | usage=' |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 47 | usage: makesetup [-s srcdir] [-l libdir] [-c config.c.in] [-m Makefile.pre] |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 48 | [Setup] ... [-n [Setup] ...]' |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 49 | srcdir='.' |
| 50 | libdir='' |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 51 | config='' |
| 52 | makepre='' |
| 53 | noobjects='' |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 54 | doconfig=yes |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 55 | while : |
| 56 | do |
| 57 | case $1 in |
| 58 | -s) shift; srcdir=$1; shift;; |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 59 | -l) shift; libdir=$1; shift;; |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 60 | -c) shift; config=$1; shift;; |
| 61 | -m) shift; makepre=$1; shift;; |
| 62 | --) shift; break;; |
| 63 | -n) noobjects=yes;; |
| 64 | -*) echo "$usage" 1>&2; exit 2;; |
| 65 | *) break;; |
| 66 | esac |
| 67 | done |
| 68 | |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 69 | # Set default libdir and config if not set by command line |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 70 | # (Not all systems have dirname) |
Neil Schemenauer | 09ac1fd | 2001-01-27 21:43:40 +0000 | [diff] [blame] | 71 | case $libdir in |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 72 | '') case $0 in |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 73 | */*) libdir=`echo $0 | sed 's,/[^/]*$,,'`;; |
| 74 | *) libdir=.;; |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 75 | esac;; |
| 76 | esac |
| 77 | case $config in |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 78 | '') config=$libdir/config.c.in;; |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 79 | esac |
| 80 | case $makepre in |
| 81 | '') makepre=Makefile.pre;; |
| 82 | esac |
| 83 | |
| 84 | # Newline for sed i and a commands |
Guido van Rossum | 4a26986 | 1995-06-14 22:52:06 +0000 | [diff] [blame] | 85 | NL='\ |
| 86 | ' |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 87 | |
Martin Panter | 2dc77f0 | 2016-09-16 00:46:05 +0000 | [diff] [blame] | 88 | # Setup to link with extra libraries when making shared extensions. |
Guido van Rossum | b961920 | 2001-01-10 21:12:18 +0000 | [diff] [blame] | 89 | # Currently, only Cygwin needs this baggage. |
| 90 | case `uname -s` in |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 91 | CYGWIN*) if test $libdir = . |
Guido van Rossum | b961920 | 2001-01-10 21:12:18 +0000 | [diff] [blame] | 92 | then |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 93 | ExtraLibDir=. |
Guido van Rossum | b961920 | 2001-01-10 21:12:18 +0000 | [diff] [blame] | 94 | else |
| 95 | ExtraLibDir='$(LIBPL)' |
| 96 | fi |
Zachary Ware | 3839d99 | 2016-10-01 16:15:09 -0500 | [diff] [blame] | 97 | ExtraLibs="-L$ExtraLibDir -lpython\$(LDVERSION)";; |
Guido van Rossum | b961920 | 2001-01-10 21:12:18 +0000 | [diff] [blame] | 98 | esac |
| 99 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 100 | # Main loop |
| 101 | for i in ${*-Setup} |
| 102 | do |
| 103 | case $i in |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 104 | -n) echo '*noobjects*';; |
| 105 | *) echo '*doconfig*'; cat "$i";; |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 106 | esac |
| 107 | done | |
| 108 | sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 109 | ( |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 110 | rulesf="@rules.$$" |
| 111 | trap 'rm -f $rulesf' 0 1 2 3 |
| 112 | echo " |
Victor Stinner | 27e2d1f | 2018-11-01 00:52:28 +0100 | [diff] [blame] | 113 | # Rules appended by makesetup |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 114 | " >$rulesf |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 115 | DEFS= |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 116 | BUILT= |
| 117 | DISABLED= |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 118 | MODS= |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 119 | SHAREDMODS= |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 120 | OBJS= |
| 121 | LIBS= |
Guido van Rossum | 0b498be | 1994-08-23 13:49:15 +0000 | [diff] [blame] | 122 | LOCALLIBS= |
| 123 | BASELIBS= |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 124 | while read line |
| 125 | do |
Guido van Rossum | ae84e8d | 1999-04-19 17:16:12 +0000 | [diff] [blame] | 126 | # to handle backslashes for sh's that don't automatically |
| 127 | # continue a read when the last char is a backslash |
| 128 | while echo $line | grep '\\$' > /dev/null |
| 129 | do |
| 130 | read extraline |
| 131 | line=`echo $line| sed s/.$//`$extraline |
| 132 | done |
| 133 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 134 | # Output DEFS in reverse order so first definition overrides |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 135 | case $line in |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 136 | *=*) DEFS="$line$NL$DEFS"; continue;; |
Guido van Rossum | 9bf8445 | 1997-04-02 05:33:00 +0000 | [diff] [blame] | 137 | 'include '*) DEFS="$line$NL$DEFS"; continue;; |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 138 | '*noobjects*') |
Guido van Rossum | 0b498be | 1994-08-23 13:49:15 +0000 | [diff] [blame] | 139 | case $noobjects in |
| 140 | yes) ;; |
| 141 | *) LOCALLIBS=$LIBS; LIBS=;; |
| 142 | esac |
| 143 | noobjects=yes; |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 144 | continue;; |
| 145 | '*doconfig*') doconfig=yes; continue;; |
Guido van Rossum | 4355454 | 1996-08-20 19:49:13 +0000 | [diff] [blame] | 146 | '*static*') doconfig=yes; continue;; |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 147 | '*noconfig*') doconfig=no; continue;; |
Guido van Rossum | 4355454 | 1996-08-20 19:49:13 +0000 | [diff] [blame] | 148 | '*shared*') doconfig=no; continue;; |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 149 | '*disabled*') doconfig=disabled; continue;; |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 150 | esac |
Guido van Rossum | 0b498be | 1994-08-23 13:49:15 +0000 | [diff] [blame] | 151 | srcs= |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 152 | cpps= |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 153 | libs= |
| 154 | mods= |
Guido van Rossum | 4a26986 | 1995-06-14 22:52:06 +0000 | [diff] [blame] | 155 | skip= |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 156 | for arg in $line |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 157 | do |
Guido van Rossum | 4a26986 | 1995-06-14 22:52:06 +0000 | [diff] [blame] | 158 | case $skip in |
| 159 | libs) libs="$libs $arg"; skip=; continue;; |
| 160 | cpps) cpps="$cpps $arg"; skip=; continue;; |
| 161 | srcs) srcs="$srcs $arg"; skip=; continue;; |
| 162 | esac |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 163 | case $arg in |
Guido van Rossum | 2a78cf2 | 2001-01-10 21:46:05 +0000 | [diff] [blame] | 164 | -framework) libs="$libs $arg"; skip=libs; |
| 165 | # OSX/OSXS/Darwin framework link cmd |
| 166 | ;; |
| 167 | -[IDUCfF]*) cpps="$cpps $arg";; |
Andrew M. Kuchling | f4a4fb9 | 2002-03-29 18:00:19 +0000 | [diff] [blame] | 168 | -Xcompiler) skip=cpps;; |
Guido van Rossum | b447d11 | 1997-12-02 20:38:11 +0000 | [diff] [blame] | 169 | -Xlinker) libs="$libs $arg"; skip=libs;; |
Guido van Rossum | 8bfefce | 1999-05-21 19:18:49 +0000 | [diff] [blame] | 170 | -rpath) libs="$libs $arg"; skip=libs;; |
Fred Drake | 091ec2c | 2000-08-11 13:58:37 +0000 | [diff] [blame] | 171 | --rpath) libs="$libs $arg"; skip=libs;; |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 172 | -[A-Zl]*) libs="$libs $arg";; |
| 173 | *.a) libs="$libs $arg";; |
Guido van Rossum | a29756c | 1996-08-19 22:00:05 +0000 | [diff] [blame] | 174 | *.so) libs="$libs $arg";; |
| 175 | *.sl) libs="$libs $arg";; |
Guido van Rossum | fa1fb7d | 1998-05-14 02:37:45 +0000 | [diff] [blame] | 176 | /*.o) libs="$libs $arg";; |
Guido van Rossum | b961920 | 2001-01-10 21:12:18 +0000 | [diff] [blame] | 177 | *.def) libs="$libs $arg";; |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 178 | *.o) srcs="$srcs `basename $arg .o`.c";; |
Guido van Rossum | 0b498be | 1994-08-23 13:49:15 +0000 | [diff] [blame] | 179 | *.[cC]) srcs="$srcs $arg";; |
Guido van Rossum | 2a78cf2 | 2001-01-10 21:46:05 +0000 | [diff] [blame] | 180 | *.m) srcs="$srcs $arg";; # Objective-C src |
Guido van Rossum | 0b498be | 1994-08-23 13:49:15 +0000 | [diff] [blame] | 181 | *.cc) srcs="$srcs $arg";; |
| 182 | *.c++) srcs="$srcs $arg";; |
Guido van Rossum | babacb0 | 1997-02-14 16:44:04 +0000 | [diff] [blame] | 183 | *.cxx) srcs="$srcs $arg";; |
| 184 | *.cpp) srcs="$srcs $arg";; |
Sjoerd Mullender | 4237efc | 1995-10-11 08:45:15 +0000 | [diff] [blame] | 185 | \$*) libs="$libs $arg" |
| 186 | cpps="$cpps $arg";; |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 187 | *.*) echo 1>&2 "bad word $arg in $line" |
| 188 | exit 1;; |
Guido van Rossum | 4a26986 | 1995-06-14 22:52:06 +0000 | [diff] [blame] | 189 | -u) skip=libs; libs="$libs -u";; |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 190 | [a-zA-Z_]*) mods="$mods $arg";; |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 191 | *) echo 1>&2 "bad word $arg in $line" |
| 192 | exit 1;; |
| 193 | esac |
| 194 | done |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 195 | case $doconfig in |
| 196 | yes) |
| 197 | LIBS="$LIBS $libs" |
| 198 | MODS="$MODS $mods" |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 199 | BUILT="$BUILT $mods" |
| 200 | ;; |
| 201 | no) |
| 202 | BUILT="$BUILT $mods" |
| 203 | ;; |
| 204 | disabled) |
| 205 | DISABLED="$DISABLED $mods" |
| 206 | continue |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 207 | ;; |
| 208 | esac |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 209 | case $noobjects in |
| 210 | yes) continue;; |
| 211 | esac |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 212 | objs='' |
Guido van Rossum | 0b498be | 1994-08-23 13:49:15 +0000 | [diff] [blame] | 213 | for src in $srcs |
| 214 | do |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 215 | case $src in |
| 216 | *.c) obj=`basename $src .c`.o; cc='$(CC)';; |
Guido van Rossum | 37da22b | 2000-12-06 23:46:29 +0000 | [diff] [blame] | 217 | *.cc) obj=`basename $src .cc`.o; cc='$(CXX)';; |
| 218 | *.c++) obj=`basename $src .c++`.o; cc='$(CXX)';; |
| 219 | *.C) obj=`basename $src .C`.o; cc='$(CXX)';; |
| 220 | *.cxx) obj=`basename $src .cxx`.o; cc='$(CXX)';; |
| 221 | *.cpp) obj=`basename $src .cpp`.o; cc='$(CXX)';; |
Guido van Rossum | ad2c3c7 | 2001-03-02 07:09:54 +0000 | [diff] [blame] | 222 | *.m) obj=`basename $src .m`.o; cc='$(CC)';; # Obj-C |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 223 | *) continue;; |
| 224 | esac |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 225 | obj="$srcdir/$obj" |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 226 | objs="$objs $obj" |
| 227 | case $src in |
| 228 | glmodule.c) ;; |
Guido van Rossum | 76d1f96 | 1998-09-09 14:04:51 +0000 | [diff] [blame] | 229 | /*) ;; |
Skip Montanaro | fd02267 | 2000-07-06 17:58:06 +0000 | [diff] [blame] | 230 | \$*) ;; |
Neil Schemenauer | d32a337 | 2001-01-24 17:16:22 +0000 | [diff] [blame] | 231 | *) src='$(srcdir)/'"$srcdir/$src";; |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 232 | esac |
| 233 | case $doconfig in |
Ned Deily | b166191 | 2014-06-02 01:05:29 -0700 | [diff] [blame] | 234 | no) cc="$cc \$(CCSHARED) \$(PY_CFLAGS) \$(PY_CPPFLAGS)";; |
Neil Schemenauer | 83356ef | 2001-01-26 16:22:26 +0000 | [diff] [blame] | 235 | *) |
E. M. Bray | da324d5 | 2018-11-27 03:21:31 +0100 | [diff] [blame^] | 236 | cc="$cc \$(PY_BUILTIN_MODULE_CFLAGS)";; |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 237 | esac |
Neil Schemenauer | 83356ef | 2001-01-26 16:22:26 +0000 | [diff] [blame] | 238 | rule="$obj: $src; $cc $cpps -c $src -o $obj" |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 239 | echo "$rule" >>$rulesf |
Guido van Rossum | 0b498be | 1994-08-23 13:49:15 +0000 | [diff] [blame] | 240 | done |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 241 | case $doconfig in |
| 242 | yes) OBJS="$OBJS $objs";; |
| 243 | esac |
| 244 | for mod in $mods |
| 245 | do |
Ned Deily | b166191 | 2014-06-02 01:05:29 -0700 | [diff] [blame] | 246 | file="$srcdir/$mod\$(EXT_SUFFIX)" |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 247 | case $doconfig in |
| 248 | no) SHAREDMODS="$SHAREDMODS $file";; |
| 249 | esac |
| 250 | rule="$file: $objs" |
Thomas Wouters | 89d996e | 2007-09-08 17:39:28 +0000 | [diff] [blame] | 251 | rule="$rule; \$(BLDSHARED) $objs $libs $ExtraLibs -o $file" |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 252 | echo "$rule" >>$rulesf |
| 253 | done |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 254 | done |
| 255 | |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 256 | case $SHAREDMODS in |
| 257 | '') ;; |
| 258 | *) DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";; |
| 259 | esac |
| 260 | |
Guido van Rossum | 0b498be | 1994-08-23 13:49:15 +0000 | [diff] [blame] | 261 | case $noobjects in |
| 262 | yes) BASELIBS=$LIBS;; |
| 263 | *) LOCALLIBS=$LIBS;; |
| 264 | esac |
| 265 | LIBS='$(LOCALMODLIBS) $(BASEMODLIBS)' |
| 266 | DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS" |
| 267 | DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS" |
| 268 | |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 269 | EXTDECLS= |
| 270 | INITBITS= |
| 271 | for mod in $MODS |
| 272 | do |
Martin v. Löwis | 1a21451 | 2008-06-11 05:26:20 +0000 | [diff] [blame] | 273 | EXTDECLS="${EXTDECLS}extern PyObject* PyInit_$mod(void);$NL" |
Benjamin Peterson | a105dd3 | 2017-01-16 00:05:12 -0800 | [diff] [blame] | 274 | INITBITS="${INITBITS} {\"$mod\", PyInit_$mod},$NL" |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 275 | done |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 276 | |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 277 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 278 | case $config in |
| 279 | -) ;; |
| 280 | *) sed -e " |
| 281 | 1i$NL/* Generated automatically from $config by makesetup. */ |
| 282 | /MARKER 1/i$NL$EXTDECLS |
Serhiy Storchaka | bfbfc8d | 2015-03-29 19:12:58 +0300 | [diff] [blame] | 283 | |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 284 | /MARKER 2/i$NL$INITBITS |
| 285 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 286 | " $config >config.c |
| 287 | ;; |
| 288 | esac |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 289 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 290 | case $makepre in |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 291 | -) ;; |
| 292 | *) sedf="@sed.in.$$" |
| 293 | trap 'rm -f $sedf' 0 1 2 3 |
| 294 | echo "1i\\" >$sedf |
| 295 | str="# Generated automatically from $makepre by makesetup." |
| 296 | echo "$str" >>$sedf |
xdegaye | c0364fc | 2017-05-27 18:25:03 +0200 | [diff] [blame] | 297 | echo "s%_MODBUILT_NAMES_%$BUILT%" >>$sedf |
| 298 | echo "s%_MODDISABLED_NAMES_%$DISABLED%" >>$sedf |
Guido van Rossum | 3bbc62e | 1995-01-02 19:30:30 +0000 | [diff] [blame] | 299 | echo "s%_MODOBJS_%$OBJS%" >>$sedf |
| 300 | echo "s%_MODLIBS_%$LIBS%" >>$sedf |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 301 | echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf |
| 302 | sed -f $sedf $makepre >Makefile |
| 303 | cat $rulesf >>Makefile |
| 304 | rm -f $sedf |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 305 | ;; |
| 306 | esac |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 307 | |
Guido van Rossum | 7cc5abd | 1994-09-12 10:42:20 +0000 | [diff] [blame] | 308 | rm -f $rulesf |
Guido van Rossum | fba715a | 1994-01-02 00:26:09 +0000 | [diff] [blame] | 309 | ) |