Support shared library creation.

This commit is contained in:
Guido van Rossum 1994-09-12 10:42:20 +00:00
parent 9adae8e182
commit 7cc5abd454
3 changed files with 129 additions and 63 deletions

View File

@ -27,9 +27,19 @@ LIBS= @LIBS@
LIBM= @LIBM@ LIBM= @LIBM@
LIBC= @LIBC@ LIBC= @LIBC@
# Machine-dependent subdirectories
MACHDEP= @MACHDEP@
# Install prefix, may be changed by configure # Install prefix, may be changed by configure
prefix= /usr/local prefix= /usr/local
# Symbols used for using shared libraries
SO= @SO@
LDSHARED= @LDSHARED@
CCSHARED= @CCSHARED@
LINKFORSHARED= @LINKFORSHARED@
DESTSHARED= $(prefix)/lib/python/$(MACHDEP)
# === Variables that are customizable by hand === # === Variables that are customizable by hand ===
@ -60,13 +70,13 @@ SYSLIBS= $(LIBM) $(LIBC)
all: $(LIB) ../python all: $(LIB) ../python
$(LIB): $(OBJS) $(LIB): $(OBJS) Makefile
-rm -f $(LIB) -rm -f $(LIB)
$(AR) cr $(LIB) $(OBJS) $(AR) cr $(LIB) $(OBJS)
$(RANLIB) $(LIB) $(RANLIB) $(LIB)
../python: config.o $(MYLIBS) ../python: config.o $(MYLIBS) Makefile
$(CC) $(OPT) config.o \ $(CC) $(OPT) config.o $(LINKFORSHARED) \
$(MYLIBS) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(MYLIBS) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python
mv python ../python mv python ../python
@ -136,8 +146,9 @@ timingmodule.o: timingmodule.c
xxmodule.o: xxmodule.c xxmodule.o: xxmodule.c
yuvconvert.o: yuvconvert.c yuvconvert.o: yuvconvert.c
# === Rules added by makesetup === # Rules to build and install all shared modules
sharedmods: $(SHAREDMODS)
sharedinstall: $(SHAREDMODS)
mv $(SHAREDMODS) $(DESTSHARED)
# DO NOT DELETE THIS LINE -- mkdep uses it. # Stuff is appended here by makesetup and make depend
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY

View File

@ -28,6 +28,16 @@
# <name> = <value> # <name> = <value>
# #
# which defines a Make variable definition inserted into Makefile.in # which defines a Make variable definition inserted into Makefile.in
#
# Finally, if a line has the literal form
#
# *noconfig*
#
# (that is including the '*' and '*' !) then the following modules will
# not be included in the config.c file, nor in the list of objects to be
# added to the library archive, and their linker options won't be added
# to the linker options, but rules to create their .o files and their
# shared libraries will still be added to the Makefile
# NOTE: As a standard policy, as many modules as can be supported by a # NOTE: As a standard policy, as many modules as can be supported by a
# platform should be present. The distribution comes with all modules # platform should be present. The distribution comes with all modules
@ -47,13 +57,10 @@ DESTLIB=$(prefix)/lib/python
# Standard enabled (tests are always available) # Standard enabled (tests are always available)
TESTPATH=:$(DESTLIB)/test TESTPATH=:$(DESTLIB)/test
# Enable this for SGI systems # Path for machine- or system-dependent modules (and shared libraries)
#ARCHPATH=:$(DESTLIB)/sgi MACHDEPPATH=:$(DESTLIB)/$(MACHDEP)
# Enable this for Sun systems PYTHONPATH=.:$(DESTLIB)$(TESTPATH)$(MACHDEPPATH)$(STDWINPATH)$(TKPATH)
#ARCHPATH=:$(DESTLIB)/sun4
PYTHONPATH=.:$(DESTLIB)$(TESTPATH)$(ARCHPATH)$(STDWINPATH)$(TKPATH)
# Modules that should always be present (non UNIX dependent) # Modules that should always be present (non UNIX dependent)
@ -86,6 +93,7 @@ signal signalmodule.c # signal(2)
#dbm dbmmodule.c # dbm(3) may require -lndbm or similar #dbm dbmmodule.c # dbm(3) may require -lndbm or similar
#nis nismodule.c # Sun yellow pages -- not everywhere #nis nismodule.c # Sun yellow pages -- not everywhere
#termios termios.c # Steen Lumholt's termios module
# Multimedia modules -- on by default. # Multimedia modules -- on by default.
@ -109,6 +117,18 @@ rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably)
#stdwin stdwinmodule.c -I$(STDWIN)/H $(STDWIN)/Build/$(ARCH)/x11/lib/lib.a -lX11 #stdwin stdwinmodule.c -I$(STDWIN)/H $(STDWIN)/Build/$(ARCH)/x11/lib/lib.a -lX11
#STDWINPATH=:$(DESTLIB)/stdwin #STDWINPATH=:$(DESTLIB)/stdwin
# For STDWIN 1.0 it's a bit different:
#STDWIN=/ufs/guido/src/stdwin
#LIBTEXTEDIT=$(STDWIN)/$(MACHDEP)/Packs/textedit/libtextedit.a
#LIBX11STDWIN=$(STDWIN)/$(MACHDEP)/Ports/x11/libstdwin.a
#LIBALFASTDWIN=$(STDWIN)/$(MACHDEP)/Ports/alfa/libstdwin.a
#stdwin stdwinmodule.c -I$(STDWIN)/H $(LIBTEXTEDIT) $(LIBX11STDWIN) -lX11
# Or use the following for the alphanumeric version:
#stdwin stdwinmodule.c -I$(STDWIN)/H $(LIBTEXTEDIT) $(LIBALFASTDWIN) -ltermcap
# The md5 module implements the RSA Data Security, Inc. MD5 # The md5 module implements the RSA Data Security, Inc. MD5
# Message-Digest Algorithm, described in RFC 1321. The necessary files # Message-Digest Algorithm, described in RFC 1321. The necessary files

View File

@ -22,7 +22,7 @@
# #
# Copying config.c.in to config.c: # Copying config.c.in to config.c:
# - insert an identifying comment at the start # - insert an identifying comment at the start
# - for each <module> mentioned in Setup: # - for each <module> mentioned in Setup before *noconfig*:
# + insert 'extern void init<module>();' before MARKER 1 # + insert 'extern void init<module>();' before MARKER 1
# + insert '{"<module>", initmodule},' before MARKER 2 # + insert '{"<module>", initmodule},' before MARKER 2
# #
@ -31,9 +31,10 @@
# - replace @MODOBJS@ by the list of objects from Setup (except for # - replace @MODOBJS@ by the list of objects from Setup (except for
# Setup files after a -n option) # Setup files after a -n option)
# - replace @MODLIBS@ by the list of libraries from Setup # - replace @MODLIBS@ by the list of libraries from Setup
# - for each object file mentioned in Setup, insert a rule # - for each object file mentioned in Setup, append a rule
# '<file>.o: <file>.c; <build commands>' before the comment # '<file>.o: <file>.c; <build commands>' to the end of the Makefile
# 'Rules added by makesetup' # - 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 # - for each variable definition found in Setup, insert the definition
# before the comment 'Definitions added by makesetup' # before the comment 'Definitions added by makesetup'
@ -45,6 +46,7 @@ srcdir=''
config='' config=''
makepre='' makepre=''
noobjects='' noobjects=''
doconfig=yes
while : while :
do do
case $1 in case $1 in
@ -81,17 +83,22 @@ NL="\\
for i in ${*-Setup} for i in ${*-Setup}
do do
case $i in case $i in
-n) echo '<noobjects>';; -n) echo '*noobjects*';;
*) cat "$i";; *) echo '*doconfig*'; cat "$i";;
esac esac
done | done |
sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
( (
rulesf="@rules.$$"
trap 'rm -f $rulesf' 0 1 2 3
echo "
# Rules appended by makedepend
" >$rulesf
DEFS= DEFS=
MODS= MODS=
SHAREDMODS=
OBJS= OBJS=
LIBS= LIBS=
RULES=
LOCALLIBS= LOCALLIBS=
BASELIBS= BASELIBS=
while read line while read line
@ -99,68 +106,91 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
# Output DEFS in reverse order so first definition overrides # Output DEFS in reverse order so first definition overrides
case $line in case $line in
*=*) DEFS="$line$NL$DEFS"; continue;; *=*) DEFS="$line$NL$DEFS"; continue;;
'<noobjects>') '*noobjects*')
case $noobjects in case $noobjects in
yes) ;; yes) ;;
*) LOCALLIBS=$LIBS; LIBS=;; *) LOCALLIBS=$LIBS; LIBS=;;
esac esac
noobjects=yes; noobjects=yes;
continue;; continue;;
'*doconfig*') doconfig=yes; continue;;
'*noconfig*') doconfig=no; continue;;
esac esac
objs=
srcs= srcs=
cpps= cpps=
set $line libs=
for arg mods=
for arg in $line
do do
case $arg in case $arg in
-[IDUC]*) cpps="$cpps $arg";; -[IDUC]*) cpps="$cpps $arg";;
-[A-Zl]*) LIBS="$LIBS $arg";; -[A-Zl]*) libs="$libs $arg";;
*.a) LIBS="$LIBS $arg";; *.a) libs="$libs $arg";;
*.o) objs="$objs $arg";; *.o) srcs="$srcs `basename $arg .o`.c";;
*.[cC]) srcs="$srcs $arg";; *.[cC]) srcs="$srcs $arg";;
*.cc) srcs="$srcs $arg";; *.cc) srcs="$srcs $arg";;
*.c++) srcs="$srcs $arg";; *.c++) srcs="$srcs $arg";;
*.*) echo 1>&2 "bad word $arg in $line" *.*) echo 1>&2 "bad word $arg in $line"
exit 1;; exit 1;;
[a-zA-Z_]*) MODS="$MODS $arg";; [a-zA-Z_]*) mods="$mods $arg";;
*) echo 1>&2 "bad word $arg in $line" *) echo 1>&2 "bad word $arg in $line"
exit 1;; exit 1;;
esac esac
done done
case $doconfig in
yes)
LIBS="$LIBS $libs"
MODS="$MODS $mods"
;;
esac
case $noobjects in case $noobjects in
yes) continue;; yes) continue;;
esac esac
for obj in $objs objs=''
do
src=`basename $obj .o`.c
case $src in
glmodule.c) ;;
*) src='$(srcdir)/'$src;;
esac
RULES="$RULES$obj: $src; \$(CC) \$(CFLAGS) $cpps -c $src$NL"
done
OBJS="$OBJS $objs"
objs=
for src in $srcs for src in $srcs
do do
case $src in case $src in
*.c) obj=`basename $src .c`.o; cc='$(CC)';; *.c) obj=`basename $src .c`.o; cc='$(CC)';;
*.cc) obj=`basename $src .cc`.o; cc='$(CCC)';; *.cc) obj=`basename $src .cc`.o; cc='$(CCC)';;
*.c++) obj=`basename $src .c++`.o; cc='$(CCC)';; *.c++) obj=`basename $src .c++`.o; cc='$(CCC)';;
*.C) obj=`basename $src .C`.o; cc='$(CCC)';; *.C) obj=`basename $src .C`.o; cc='$(CCC)';;
*) continue;; *) continue;;
esac esac
objs="$objs $obj" objs="$objs $obj"
case $src in case $src in
glmodule.c) ;; glmodule.c) ;;
*) src='$(srcdir)/'$src;; *) src='$(srcdir)/'$src;;
esac esac
RULES="$RULES$obj: $src; $cc \$(CFLAGS) $cpps -c $src$NL" case $doconfig in
no) cc="cc $(CCSHARED)";;
esac
rule="$obj: $src; $cc \$(CFLAGS) $cpps -c $src"
echo "$rule" >>$rulesf
done
case $doconfig in
yes) OBJS="$OBJS $objs";;
esac
for mod in $mods
do
case $objs in
*$mod.o*) base=$mod;;
*) base=${mod}module;;
esac
file="$base\$(SO)"
case $doconfig in
no) SHAREDMODS="$SHAREDMODS $file";;
esac
rule="$file: $objs"
rule="$rule; $(LDSHARED) $objs $libs -o $file"
echo "$rule" >>$rulesf
done done
OBJS="$OBJS $objs"
done done
case $SHAREDMODS in
'') ;;
*) DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";;
esac
case $noobjects in case $noobjects in
yes) BASELIBS=$LIBS;; yes) BASELIBS=$LIBS;;
*) LOCALLIBS=$LIBS;; *) LOCALLIBS=$LIBS;;
@ -177,6 +207,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
INITBITS="${INITBITS} {\"$mod\", init$mod},$NL" INITBITS="${INITBITS} {\"$mod\", init$mod},$NL"
done done
case $config in case $config in
-) ;; -) ;;
*) sed -e " *) sed -e "
@ -189,16 +220,20 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
esac esac
case $makepre in case $makepre in
-) ;; -) ;;
*) sed -e " *) sedf="@sed.in.$$"
1i$NL# Generated automatically from $makepre by makesetup. trap 'rm -f $sedf' 0 1 2 3
s%@MODOBJS@%$OBJS% echo "1i\\" >$sedf
s%@MODLIBS@%$LIBS% str="# Generated automatically from $makepre by makesetup."
/Rules added by makesetup/a$NL$NL$RULES echo "$str" >>$sedf
/Definitions added by makesetup/a$NL$NL$DEFS echo "s%@MODOBJS@%$OBJS%" >>$sedf
echo "s%@MODLIBS@%$LIBS%" >>$sedf
" $makepre >Makefile echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf
sed -f $sedf $makepre >Makefile
cat $rulesf >>Makefile
rm -f $sedf
;; ;;
esac esac
rm -f $rulesf
) )