#! /bin/sh # Convert templates into Makefile and config.c, based on the module # definitions found in the file Setup. # # Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...] # # Options: # -s directory: alternative source directory (default .) # -l directory: library source directory (default derived from $0) # -c file: alternative config.c template (default $libdir/config.c.in) # -c -: don't write config.c # -m file: alternative Makefile template (default ./Makefile.pre) # -m -: don't write Makefile # # Remaining arguments are one or more Setup files (default ./Setup). # Setup files after a -n option are used for their variables, modules # and libraries but not for their .o files. # # See Setup.dist for a description of the format of the Setup file. # # The following edits are made: # # Copying config.c.in to config.c: # - insert an identifying comment at the start # - for each <module> mentioned in Setup before *noconfig*: # + insert 'extern PyObject* PyInit_<module>(void);' before MARKER 1 # + insert '{"<module>", PyInit_<module>},' before MARKER 2 # # Copying Makefile.pre to Makefile: # - insert an identifying comment at the start # - replace _MODNAMES_ by the list of modules from Setup # - replace _MODOBJS_ by the list of objects from Setup (except for # Setup files after a -n option) # - replace _MODLIBS_ by the list of libraries from Setup # - for each object file mentioned in Setup, append a rule # '<file>.o: <file>.c; <build commands>' to the end of the Makefile # - for each module mentioned in Setup, append a rule # which creates a shared library version to the end of the Makefile # - for each variable definition found in Setup, insert the definition # before the comment 'Definitions added by makesetup' # Loop over command line options usage=' usage: makesetup [-s srcdir] [-l libdir] [-c config.c.in] [-m Makefile.pre] [Setup] ... [-n [Setup] ...]' srcdir='.' libdir='' config='' makepre='' noobjects='' doconfig=yes while : do case $1 in -s) shift; srcdir=$1; shift;; -l) shift; libdir=$1; shift;; -c) shift; config=$1; shift;; -m) shift; makepre=$1; shift;; --) shift; break;; -n) noobjects=yes;; -*) echo "$usage" 1>&2; exit 2;; *) break;; esac done # Set default libdir and config if not set by command line # (Not all systems have dirname) case $libdir in '') case $0 in */*) libdir=`echo $0 | sed 's,/[^/]*$,,'`;; *) libdir=.;; esac;; esac case $config in '') config=$libdir/config.c.in;; esac case $makepre in '') makepre=Makefile.pre;; esac # Newline for sed i and a commands NL='\ ' # Setup to link with extra libraries when making shared extensions. # Currently, only Cygwin needs this baggage. case `uname -s` in CYGWIN*) if test $libdir = . then ExtraLibDir=. else ExtraLibDir='$(LIBPL)' fi ExtraLibs="-L$ExtraLibDir -lpython\$(LDVERSION)";; esac # Main loop for i in ${*-Setup} do case $i in -n) echo '*noobjects*';; *) echo '*doconfig*'; cat "$i";; esac done | sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | ( rulesf="@rules.$$" trap 'rm -f $rulesf' 0 1 2 3 echo " # Rules appended by makedepend " >$rulesf DEFS= NAMES= MODS= SHAREDMODS= OBJS= LIBS= LOCALLIBS= BASELIBS= while read line do # to handle backslashes for sh's that don't automatically # continue a read when the last char is a backslash while echo $line | grep '\\$' > /dev/null do read extraline line=`echo $line| sed s/.$//`$extraline done # Output DEFS in reverse order so first definition overrides case $line in *=*) DEFS="$line$NL$DEFS"; continue;; 'include '*) DEFS="$line$NL$DEFS"; continue;; '*noobjects*') case $noobjects in yes) ;; *) LOCALLIBS=$LIBS; LIBS=;; esac noobjects=yes; continue;; '*doconfig*') doconfig=yes; continue;; '*static*') doconfig=yes; continue;; '*noconfig*') doconfig=no; continue;; '*shared*') doconfig=no; continue;; esac srcs= cpps= libs= mods= skip= for arg in $line do case $skip in libs) libs="$libs $arg"; skip=; continue;; cpps) cpps="$cpps $arg"; skip=; continue;; srcs) srcs="$srcs $arg"; skip=; continue;; esac case $arg in -framework) libs="$libs $arg"; skip=libs; # OSX/OSXS/Darwin framework link cmd ;; -[IDUCfF]*) cpps="$cpps $arg";; -Xcompiler) skip=cpps;; -Xlinker) libs="$libs $arg"; skip=libs;; -rpath) libs="$libs $arg"; skip=libs;; --rpath) libs="$libs $arg"; skip=libs;; -[A-Zl]*) libs="$libs $arg";; *.a) libs="$libs $arg";; *.so) libs="$libs $arg";; *.sl) libs="$libs $arg";; /*.o) libs="$libs $arg";; *.def) libs="$libs $arg";; *.o) srcs="$srcs `basename $arg .o`.c";; *.[cC]) srcs="$srcs $arg";; *.m) srcs="$srcs $arg";; # Objective-C src *.cc) srcs="$srcs $arg";; *.c++) srcs="$srcs $arg";; *.cxx) srcs="$srcs $arg";; *.cpp) srcs="$srcs $arg";; \$*) libs="$libs $arg" cpps="$cpps $arg";; *.*) echo 1>&2 "bad word $arg in $line" exit 1;; -u) skip=libs; libs="$libs -u";; [a-zA-Z_]*) NAMES="$NAMES $arg"; mods="$mods $arg";; *) echo 1>&2 "bad word $arg in $line" exit 1;; esac done case $doconfig in yes) LIBS="$LIBS $libs" MODS="$MODS $mods" ;; esac case $noobjects in yes) continue;; esac objs='' for src in $srcs do case $src in *.c) obj=`basename $src .c`.o; cc='$(CC)';; *.cc) obj=`basename $src .cc`.o; cc='$(CXX)';; *.c++) obj=`basename $src .c++`.o; cc='$(CXX)';; *.C) obj=`basename $src .C`.o; cc='$(CXX)';; *.cxx) obj=`basename $src .cxx`.o; cc='$(CXX)';; *.cpp) obj=`basename $src .cpp`.o; cc='$(CXX)';; *.m) obj=`basename $src .m`.o; cc='$(CC)';; # Obj-C *) continue;; esac obj="$srcdir/$obj" objs="$objs $obj" case $src in glmodule.c) ;; /*) ;; \$*) ;; *) src='$(srcdir)/'"$srcdir/$src";; esac case $doconfig in no) cc="$cc \$(CCSHARED) \$(PY_CFLAGS) \$(PY_CPPFLAGS)";; *) cc="$cc \$(PY_CORE_CFLAGS)";; esac rule="$obj: $src; $cc $cpps -c $src -o $obj" echo "$rule" >>$rulesf done case $doconfig in yes) OBJS="$OBJS $objs";; esac for mod in $mods do file="$srcdir/$mod\$(EXT_SUFFIX)" case $doconfig in no) SHAREDMODS="$SHAREDMODS $file";; esac rule="$file: $objs" rule="$rule; \$(BLDSHARED) $objs $libs $ExtraLibs -o $file" echo "$rule" >>$rulesf done done case $SHAREDMODS in '') ;; *) DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";; esac case $noobjects in yes) BASELIBS=$LIBS;; *) LOCALLIBS=$LIBS;; esac LIBS='$(LOCALMODLIBS) $(BASEMODLIBS)' DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS" DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS" EXTDECLS= INITBITS= for mod in $MODS do EXTDECLS="${EXTDECLS}extern PyObject* PyInit_$mod(void);$NL" INITBITS="${INITBITS} {\"$mod\", PyInit_$mod},$NL" done case $config in -) ;; *) sed -e " 1i$NL/* Generated automatically from $config by makesetup. */ /MARKER 1/i$NL$EXTDECLS /MARKER 2/i$NL$INITBITS " $config >config.c ;; esac case $makepre in -) ;; *) sedf="@sed.in.$$" trap 'rm -f $sedf' 0 1 2 3 echo "1i\\" >$sedf str="# Generated automatically from $makepre by makesetup." echo "$str" >>$sedf echo "s%_MODNAMES_%$NAMES%" >>$sedf echo "s%_MODOBJS_%$OBJS%" >>$sedf echo "s%_MODLIBS_%$LIBS%" >>$sedf echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf sed -f $sedf $makepre >Makefile cat $rulesf >>Makefile rm -f $sedf ;; esac rm -f $rulesf )
Mode | Type | Size | Ref | File |
---|---|---|---|---|
100644 | blob | 582 | 58471109208922c9ee8c4b06135725f03ed16814 | .bzrignore |
100644 | blob | 545 | fcf9df6a7a698e4bd87ed0c1cc4ed70bad8b9887 | .codecov.yml |
100644 | blob | 255 | 82694d81f276b2c59a0a93a4f678e1852e625052 | .gitattributes |
040000 | tree | - | 7e849e161267e730810fbbe6a848b14d5d002788 | .github |
100644 | blob | 1397 | 8b54c2c4861389f6e8bbfbab5ae0c8b6bbbad041 | .gitignore |
100644 | blob | 1060 | eb19a6c88d28d05588db25d21525ee2e19c22666 | .hgeol |
100644 | blob | 1358 | 68c607f2e8d420c8dfd0748efcd3b3b5447def16 | .hgignore |
100644 | blob | 8917 | 8f51c2ced49aed46d8b480280b630ea4264c57c3 | .hgtags |
100644 | blob | 1328 | b9be0f11fdb829f16e9de1921257eb7ee45fac57 | .hgtouch |
100644 | blob | 248 | 0614a299b6221dc7faedaa9139ae8b034e618a85 | .mention-bot |
100644 | blob | 3512 | e7e8694530ca21a6d7a19da3fab687a3e9d79e9c | .travis.yml |
040000 | tree | - | ef39fb38058ea1cb07d5a66c7d0c338d5c9c634d | Doc |
040000 | tree | - | 5dd6fc9dc09374506491247872c868eca111e256 | Grammar |
040000 | tree | - | df0de9d4359f11311c74fd0dbad471bb2613a2d4 | Include |
100644 | blob | 12773 | f5d0b39a0cdddb91a31a537052b7d8d31a4aa79f | LICENSE |
040000 | tree | - | 41936e36e534f9069cb438b31908d8e097c673ee | Lib |
040000 | tree | - | 1db7415d4375525eaf8d05ddd5b088de3321041c | Mac |
100644 | blob | 58983 | 4145634c032d543d02295bd2c28a0c6ce839fa86 | Makefile.pre.in |
040000 | tree | - | 5ce39d28202a5713d0cff1c4cd7eb73267ea1a08 | Misc |
040000 | tree | - | b74dfdc5f8f5700baaab0dbd2aa197899f8b79d9 | Modules |
040000 | tree | - | 774ee56f73f58d31a7e7d59314020c9176eeb9d8 | Objects |
040000 | tree | - | ed4f35810e9633502c16ae038c2ce697d3987201 | PC |
040000 | tree | - | 37a613ac0022a9cfefaf3f13913fec7debe59259 | PCbuild |
040000 | tree | - | 75771c7c20fe7a121d596299c5440aef10c6f884 | Parser |
040000 | tree | - | 3efbcc80237ab7c3d4eb5bf31c893ca6de88e747 | Programs |
040000 | tree | - | ec8f975802930f631229dd3f1c1dd6e327557ae8 | Python |
100644 | blob | 9325 | 9c95815d9e9d91b8dae8e05d8bbc696fe19f796b | README.rst |
040000 | tree | - | 6f90a7ecc8b4a12e0377f892c8639ef99da08920 | Tools |
100644 | blob | 10910 | 9a9cc557281571f0d46c506c0e9d1b9fb25e063c | aclocal.m4 |
100755 | blob | 42856 | 1f5c50c0d1529d50b94dc3533ca72a47f0fa5849 | config.guess |
100755 | blob | 35740 | d654d03cdcd2226a5d7584890717e674a8122f4f | config.sub |
100755 | blob | 485283 | 87504d206837baf5a5781b6e1cc44dcce7138af9 | configure |
100644 | blob | 160661 | f9bd92ce3da29ea7674a32bd5fe511b1fc4c4d0a | configure.ac |
100755 | blob | 7122 | 0ec27bcd488da5cad6ead13d70accbdbc40d31ef | install-sh |
100644 | blob | 41449 | 21354a5cb84fe5530dd0d460561ba95569abe1d4 | pyconfig.h.in |
100644 | blob | 98743 | 3b3d097454211c790c1602d759918bb65a622c97 | setup.py |