Big changes. The makefiles now recurse correctly, and targets (e.g.

experiment, swim, swig, pymod, etc.) are passed along to sub-makes
correctly.  Also, a mechanism has been devised to avoid the use of *.o
in the toplevel Makefile, as it was linking files which were not intended
for use in the final executable.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@148 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dustin Mitchell 2000-01-24 22:43:13 +00:00
commit 4d6f8c3326
10 changed files with 171 additions and 73 deletions

View file

@ -1,3 +1,4 @@
configure config.*
Makefile
swig
objs.tmp experiment

View file

@ -64,13 +64,13 @@ All SWIG modules must be written in either ANSI C or one of the
scripting languages for which SWIG can generate an interface (e.g.,
Perl, Python, or Tcl). <B>C++ is NOT an acceptable alternative and
will not be utilized for any future development due to the fact that
it is too complicated, too dogmatic, too problematic, and that Dave would rather
take a bullet to the head than write one more line of code in this
most decidedly unpleasant language. </B> Rare exceptions to this rule
may be made if there is a justifiable need to interface an existing
piece of software written in C++ into the SWIG module system. Anyone
who finds this rule to be unreasonable is more than welcome to go
write their own wrapper generator--so there.
it is too complicated, too dogmatic, too problematic, and that Dave
would rather take a bullet to the head than write one more line of
code in this most decidedly unpleasant language. </B> Rare exceptions
to this rule may be made if there is a justifiable need to interface
an existing piece of software written in C++ into the SWIG module
system. Anyone who finds this rule to be unreasonable is more than
welcome to go write their own wrapper generator--so there.
<p>
Module writers should make every attempt to use only those functions
@ -115,7 +115,7 @@ CVS version, include guards, and be C++ aware. For example:
<blockquote>
<pre>
/* -----------------------------------------------------------------------------
/* -------------------------------------------------------------------------
* swigperl.h
*
* All of the externally visible functions in the Perl module.
@ -126,7 +126,7 @@ CVS version, include guards, and be C++ aware. For example:
* See the file LICENSE for information on usage and redistribution.
*
* $Header$
* ----------------------------------------------------------------------------- */
* ------------------------------------------------------------------------- */
#ifndef _SWIGPERL_H
#define _SWIGPERL_H 1
@ -135,7 +135,7 @@ CVS version, include guards, and be C++ aware. For example:
extern "C" {
#endif
/* You're declarations here */
/* Your declarations here */
...
#ifdef __cplusplus
@ -255,11 +255,11 @@ and a short description like this:
<blockquote>
<pre>
/* -----------------------------------------------------------------------------
/* -------------------------------------------------------------------------
* Swig_add_directory()
*
* Adds a directory to the SWIG search path.
* ----------------------------------------------------------------------------- */
* ------------------------------------------------------------------------- */
void
Swig_add_directory(DOH *dirname) {
@ -384,7 +384,8 @@ typedef struct Foo {
</pre>
</blockquote>
It is better to hide the implementation of Foo and provide an function-call interface like this:
It is better to hide the implementation of Foo and provide an
function-call interface like this:
<blockquote>
<pre>
@ -394,10 +395,51 @@ extern void Foo_setline(Foo *f, int line);
</pre>
</blockquote>
Although this results in worse performance, there are many practical reasons for doing
this. The most important reason is that it allows you to change the internal representation
of Foo without breaking all of the other modules or having to recompile the entire
universe after making your changes.
Although this results in worse performance, there are many practical
reasons for doing this. The most important reason is that it allows
you to change the internal representation of Foo without breaking all
of the other modules or having to recompile the entire universe after
making your changes.
<h2>10. DOH</h2>
SWIG uses <a href="http://islab.cs.uchicago.edu/doh.html">DOH</a> to
store all of its runtime data. It uses the basic DOH types as well as
some special types:
<ul>
<li>SuperString
</ul>
<h3>10.1 Reference Counting</h3>
DOH objects are reference counted. They are not garbage collected
until their reference count has reached zero.
When a DOH object is created (with a function such as
<tt>NewString()</tt>), its reference count is one. Use
<tt>Incref(x)</tt> to increment the reference count on any object to
which you are storing a reference. Use <tt>Delete(x)</tt> to
decrement the reference count. So, for example:
<blockquote>
<pre>
static int foo() {
DOH *swig_string = NewString("SWIG");
...
Delete(swig_string);
}
static void push(DOH *string) {
Incref(string);
Swig_some_strings[Swig_num_strings++] = string;
}
</pre>
</blockquote>
<h3>10.2 SuperStrings</h3>
More later.
</body>
</html>

View file

@ -6,8 +6,8 @@
prefix = @prefix@
exec_prefix= @exec_prefix@
srcdir = @ROOT_DIR@
TARGET = swig
SHELL = /bin/sh
CC = @CC@
CXX = @CXX@
@ -17,55 +17,76 @@ SWIG_LIB = $(prefix)/lib/swig1.3
BIN_DIR = $(exec_prefix)/bin
LIB_DIR = $(prefix)/lib
#
#
#
GOAL := all
OBJS_FILE := $(srcdir)/objs.tmp
OBJS = `cat $(OBJS_FILE)`
MODULES :=
SWIGOBJS = Source/SWIG1.1/*.o Source/Modules1.1/*.o Source/DOH/Doh/*.o Source/Swig/*.o Source/Preprocessor/*.o
#####################################################################
# TARGET: swig
#####################################################################
swig: GOAL := all
swig: MODULES := SWIG1.1 Modules1.1 Swig Preprocessor
swig: _recurse DOH
$(CXX) $(OBJS) $(LIBS) -o swig
EXPOBJS = Source/DOH/Doh/*.o Source/Swig/*.o Source/Preprocessor/*.o Source/LParse/*.o Source/Experiment/*.o Source/SWILL/SWILL/*.o Source/Swim/*.o
#####################################################################
# TARGET: experiment
#####################################################################
experiment: GOAL := experiment
experiment: MODULES := Swig Preprocessor LParse Experiment Swim
experiment: _recurse DOH SWILL
$(CC) $(OBJS) $(LIBS) -o experiment
swig: objs
$(CXX) $(SWIGOBJS) $(LIBS) -o $(TARGET)
#####################################################################
# TARGET: clean
#####################################################################
clean: GOAL := clean
clean: _recurse
rm -f swig experiment
experiment: objs
$(CC) $(EXPOBJS) $(LIBS) -o $(TARGET)
objs:
@ORIG_DIR=`pwd`; \
for i in `ls Source/`; \
do \
if [ -d Source/$$i -a -f Source/$$i/Makefile ]; then \
(cd Source/$$i && $(MAKE)) || exit 1; \
cd $$ORIG_DIR ;\
fi \
done;
clean:
@ORIG_DIR=`pwd`; \
for i in `ls Source/`; \
do \
if [ -d Source/$$i -a -f Source/$$i/Makefile ]; then \
(cd Source/$$i && $(MAKE) clean) || exit 1; \
cd $$ORIG_DIR ;\
fi \
done;
rm -f swig
nuke:
@ORIG_DIR=`pwd`; \
for i in `ls Source/`; \
do \
if [ -d Source/$$i -a -f Source/$$i/Makefile ]; then \
(cd Source/$$i && $(MAKE) nuke) || exit 1; \
cd $$ORIG_DIR ;\
fi \
done;
#####################################################################
# TARGET: nuke
#####################################################################
nuke: GOAL := nuke
nuke: clean _recurse
rm -f Makefile Makefile.template config.*
#####################################################################
# TARGET: _recurse (UTILITY)
#####################################################################
# this target recurses through the directories in $(MODULES), executing
# $(MAKE) $(GOAL) in each one, with the variable OBJS_FILE set to
# the name of a file into which will be recorded the names of the
# relevant object files. See the "swig" target for an example.
_recurse:
@ORIG_DIR=`pwd`; \
echo "" > $(OBJS_FILE); \
for i in $(MODULES); \
do \
if [ -d Source/$$i -a -f Source/$$i/Makefile ]; then \
(cd Source/$$i && $(MAKE) $(TARGET) OBJS_FILE=$(OBJS_FILE)) || exit 1; \
cd $$ORIG_DIR ;\
fi \
done;
#####################################################################
# TARGET: DOH (an independent project)
#####################################################################
DOH:
cd Source/DOH; $(MAKE)
ls Source/DOH/Doh/*.o >> $(OBJS_FILE)
# Install the SWIG program
#####################################################################
# TARGET: SWILL (an independent project)
#####################################################################
SWILL:
cd Source/SWILL; $(MAKE)
ls Source/SWILL/SWILL/*.o >> $(OBJS_FILE)
#####################################################################
# TARGETS: install & friends
#####################################################################
INSTALL = ./install-sh -c
INSTALL_DATA = ${INSTALL} -m 644

View file

@ -1,2 +1,3 @@
Makefile
y.tab.*
config.cache config.log config.status configure

View file

@ -1,3 +1,7 @@
#####################################################################
# LParse
#####################################################################
# Generated automatically from Makefile.in by configure.
CC = @CC@
@ -14,12 +18,17 @@ YACC = @YACC@
INCLUDE = -I. -I../Swig -I../DOH/Include -I../Preprocessor
SRCS = cscanner.c type.c
OBJS = cscanner.o type.o
OBJS = parser.o cscanner.o type.o
.c.o:
$(CC) $(CCSHARED) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
all: parser.o $(OBJS)
#####################################################################
# TARGET: experiment
#####################################################################
# friendly to the toplevel makefile
experiment: $(OBJS)
for i in $(OBJS); do echo Source/LParse/$$i >> $(OBJS_FILE); done
parser.o: parser.c
$(CC) $(CCSHARED) $(INCLUDE) $(CFLAGS) -c -o $*.o $<

View file

@ -48,9 +48,13 @@ SHELL = /bin/sh
.cxx.o:
$(CC) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
all: $(TARGET)
$(TARGET): $(WRAPOBJS)
#####################################################################
# TARGET: swig
#####################################################################
# friendly to the toplevel makefile
all: swig
swig: $(WRAPOBJS)
for i in $(WRAPOBJS); do echo Source/Modules1.1/$$i >> $(OBJS_FILE); done
clean::
rm -f *.o *~

View file

@ -17,7 +17,13 @@ OBJS = expr.o cpp.o
.c.o:
$(CC) $(CCSHARED) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
all: $(OBJS)
#####################################################################
# TARGET: swig
#####################################################################
# friendly to the toplevel makefile
all: swig
swig: $(OBJS)
for i in $(OBJS); do echo Source/Preprocessor/$$i >> $(OBJS_FILE); done
clean:
rm -f *.o *~ core *.so *.a

View file

@ -52,6 +52,8 @@ INCLUDE = -I../Include -I. -I../Swig -I../Preprocessor -I../DOH/Include
CFLAGS = @CFLAGS@ -DSWIG_LIB='"$(SWIG_LIB)"' -DSWIG_CC='"$(CC)"' @DEFS@
SHELL = /bin/sh
OBJS = parser.o $(LIBOBJS)
#
#
#
@ -60,7 +62,13 @@ SHELL = /bin/sh
.cxx.o:
$(CC) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
all: parser.o $(LIBOBJS)
#####################################################################
# TARGET: swig
#####################################################################
# friendly to the toplevel makefile
all: swig
swig: $(OBJS)
for i in $(OBJS); do echo Source/SWIG1.1/$$i >> $(OBJS_FILE); done
parser.o: parser.cxx $(LIBHEADERS)
$(CC) $(INCLUDE) $(CFLAGS) parser.cxx -c -o parser.o

View file

@ -17,6 +17,7 @@
#----------------------------------------------------------------
SRCS = types.c scanner.c include.c getopt.c misc.c super.c
OBJS = $(SRCS:.c=.o)
INTERFACE = swig.i
WRAPFILE = $(INTERFACE:.i=_wrap.c)
WRAPOBJ = $(INTERFACE:.i=_wrap.o)
@ -46,11 +47,6 @@ SWIGCC = $(CC)
# SWIG Library files. Uncomment if rebuilding the Python interpreter
#SWIGLIB = -lembed.i
# Rules for creating .o files from source.
OBJS = $(SRCS:.c=.o)
ALLOBJS = $(OBJS)
# Command that will be used to build the final extension.
BUILD = $(SWIGCC)
@ -82,7 +78,15 @@ BUILD_LIBS = $(LIBS) # Dynamic loading
# Toplevel Targets
# ----------------------------------------------------------------------
all: $(OBJS) # the object files
######################################################################
# TARGET: swig
#####################################################################
# note that here we echo the names of all of our object files,
# relative to the project root, into $(OBJS_FILE), for compatibility
# with the parent makefile.
all: swig
swig: $(OBJS)
for i in $(OBJS); do echo Source/Swig/$$i >> $(OBJS_FILE); done
python: $(TARGET) # the python module
@ -104,5 +108,5 @@ $(WRAPFILE) : $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE)
$(TARGET): $(WRAPOBJ) $(ALLOBJS)
$(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET)
$(BUILD) $(WRAPOBJ) $(OBJS) $(BUILD_LIBS) -o $(TARGET)

View file

@ -451,6 +451,8 @@ if test "$PERL" != nope; then
AC_SUBST(PERL5EXT)
AC_SUBST(ROOT_DIR)ROOT_DIR=`pwd`
IMPORTED_DIRS="Source/SWILL/ Source/DOH/"
# execute configure for our imported directories