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@
LIBC= @LIBC@
# Machine-dependent subdirectories
MACHDEP= @MACHDEP@
# Install prefix, may be changed by configure
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 ===
@ -60,13 +70,13 @@ SYSLIBS= $(LIBM) $(LIBC)
all: $(LIB) ../python
$(LIB): $(OBJS)
$(LIB): $(OBJS) Makefile
-rm -f $(LIB)
$(AR) cr $(LIB) $(OBJS)
$(RANLIB) $(LIB)
../python: config.o $(MYLIBS)
$(CC) $(OPT) config.o \
../python: config.o $(MYLIBS) Makefile
$(CC) $(OPT) config.o $(LINKFORSHARED) \
$(MYLIBS) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python
mv python ../python
@ -136,8 +146,9 @@ timingmodule.o: timingmodule.c
xxmodule.o: xxmodule.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.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
# Stuff is appended here by makesetup and make depend

View File

@ -28,6 +28,16 @@
# <name> = <value>
#
# 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
# platform should be present. The distribution comes with all modules
@ -47,13 +57,10 @@ DESTLIB=$(prefix)/lib/python
# Standard enabled (tests are always available)
TESTPATH=:$(DESTLIB)/test
# Enable this for SGI systems
#ARCHPATH=:$(DESTLIB)/sgi
# Path for machine- or system-dependent modules (and shared libraries)
MACHDEPPATH=:$(DESTLIB)/$(MACHDEP)
# Enable this for Sun systems
#ARCHPATH=:$(DESTLIB)/sun4
PYTHONPATH=.:$(DESTLIB)$(TESTPATH)$(ARCHPATH)$(STDWINPATH)$(TKPATH)
PYTHONPATH=.:$(DESTLIB)$(TESTPATH)$(MACHDEPPATH)$(STDWINPATH)$(TKPATH)
# 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
#nis nismodule.c # Sun yellow pages -- not everywhere
#termios termios.c # Steen Lumholt's termios module
# 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
#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
# Message-Digest Algorithm, described in RFC 1321. The necessary files

View File

@ -22,7 +22,7 @@
#
# Copying config.c.in to config.c:
# - 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 '{"<module>", initmodule},' before MARKER 2
#
@ -31,9 +31,10 @@
# - 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, insert a rule
# '<file>.o: <file>.c; <build commands>' before the comment
# 'Rules added by makesetup'
# - 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'
@ -45,6 +46,7 @@ srcdir=''
config=''
makepre=''
noobjects=''
doconfig=yes
while :
do
case $1 in
@ -81,17 +83,22 @@ NL="\\
for i in ${*-Setup}
do
case $i in
-n) echo '<noobjects>';;
*) cat "$i";;
-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=
MODS=
SHAREDMODS=
OBJS=
LIBS=
RULES=
LOCALLIBS=
BASELIBS=
while read line
@ -99,49 +106,47 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
# Output DEFS in reverse order so first definition overrides
case $line in
*=*) DEFS="$line$NL$DEFS"; continue;;
'<noobjects>')
'*noobjects*')
case $noobjects in
yes) ;;
*) LOCALLIBS=$LIBS; LIBS=;;
esac
noobjects=yes;
continue;;
'*doconfig*') doconfig=yes; continue;;
'*noconfig*') doconfig=no; continue;;
esac
objs=
srcs=
cpps=
set $line
for arg
libs=
mods=
for arg in $line
do
case $arg in
-[IDUC]*) cpps="$cpps $arg";;
-[A-Zl]*) LIBS="$LIBS $arg";;
*.a) LIBS="$LIBS $arg";;
*.o) objs="$objs $arg";;
-[A-Zl]*) libs="$libs $arg";;
*.a) libs="$libs $arg";;
*.o) srcs="$srcs `basename $arg .o`.c";;
*.[cC]) srcs="$srcs $arg";;
*.cc) srcs="$srcs $arg";;
*.c++) srcs="$srcs $arg";;
*.*) echo 1>&2 "bad word $arg in $line"
exit 1;;
[a-zA-Z_]*) MODS="$MODS $arg";;
[a-zA-Z_]*) 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
for obj in $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=
objs=''
for src in $srcs
do
case $src in
@ -156,10 +161,35 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
glmodule.c) ;;
*) src='$(srcdir)/'$src;;
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
OBJS="$OBJS $objs"
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
case $SHAREDMODS in
'') ;;
*) DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";;
esac
case $noobjects in
yes) BASELIBS=$LIBS;;
@ -177,6 +207,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
INITBITS="${INITBITS} {\"$mod\", init$mod},$NL"
done
case $config in
-) ;;
*) sed -e "
@ -190,15 +221,19 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
case $makepre in
-) ;;
*) sed -e "
1i$NL# Generated automatically from $makepre by makesetup.
s%@MODOBJS@%$OBJS%
s%@MODLIBS@%$LIBS%
/Rules added by makesetup/a$NL$NL$RULES
/Definitions added by makesetup/a$NL$NL$DEFS
" $makepre >Makefile
*) 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%@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
)