]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxPython/distrib/build.py
check for strtok_r() using C++ compiler
[wxWidgets.git] / utils / wxPython / distrib / build.py
index e8f0b3d5b8518bcfdb26114215747d49970b00b2..7d8a913511c6ec2c2d99b52561ee87e565958e90 100755 (executable)
@@ -65,7 +65,7 @@ Configuration Files
     separate namespace which is then used later as a configuration object.
     This keeps the build script simple in that it doesn't have to parse
     anything, and the config files can be much more than just names and
     separate namespace which is then used later as a configuration object.
     This keeps the build script simple in that it doesn't have to parse
     anything, and the config files can be much more than just names and
-    values as any pretty much any python code can be executed.  The global
+    values as pretty much any python code can be executed.  The global
     variables set in the config namespace are what are used later as
     configuation values.
 
     variables set in the config namespace are what are used later as
     configuation values.
 
@@ -119,7 +119,7 @@ import sys, os, string, getopt
 # This is really the wxPython version number, and will be placed in the
 # Makefiles for use with the distribution related targets.
 
 # This is really the wxPython version number, and will be placed in the
 # Makefiles for use with the distribution related targets.
 
-__version__ = '2.1b3'
+__version__ = '2.1.14'
 
 #----------------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------------
 
@@ -163,9 +163,10 @@ def main(args):
                          runClean = runClean,
                          runUninstall = runUninstall)
 
                          runClean = runClean,
                          runUninstall = runUninstall)
 
+    err = 0
     if config.readConfigFiles(args):
     if config.readConfigFiles(args):
+        config.doFixups()
         config.makeMakefile()
         config.makeMakefile()
-        err = 0
 
         if config.runBuild:
             cmd = "%s -f %s" % (config.MAKE, config.MAKEFILE)
 
         if config.runBuild:
             cmd = "%s -f %s" % (config.MAKE, config.MAKEFILE)
@@ -188,6 +189,7 @@ def main(args):
             print "Running:", cmd
             err = os.system(cmd)
 
             print "Running:", cmd
             err = os.system(cmd)
 
+    return err/256
 
 
 #----------------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------------
@@ -209,18 +211,6 @@ def splitlines(st):
 
 #----------------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------------
 
-def strippath(st):
-    # remove any leading paths, retrieve only file name. Used while
-    # parsing the SOURCES file list, so that object files are local, 
-    # while source may be anywere)
-    if sys.platform == 'win32':
-       sep = '\\'
-    else:
-       sep = '/'
-    return string.split(st,sep)[-1]
-
-#----------------------------------------------------------------------------
-
 class BuildConfig:
     def __init__(self, **kw):
         self.__dict__.update(kw)
 class BuildConfig:
     def __init__(self, **kw):
         self.__dict__.update(kw)
@@ -231,7 +221,7 @@ class BuildConfig:
         self.VERSION = __version__
         self.MODULE = ''
         self.SWIGFILES = []
         self.VERSION = __version__
         self.MODULE = ''
         self.SWIGFILES = []
-        self.SWIGFLAGS = '-c++ -shadow -python -dnone -I$(WXPSRCDIR)'
+        self.SWIGFLAGS = '-c++ -shadow -python -keyword -dnone -I$(WXPSRCDIR)'
         self.SOURCES = []
         self.PYFILES = []
         self.LFLAGS = ''
         self.SOURCES = []
         self.PYFILES = []
         self.LFLAGS = ''
@@ -241,6 +231,7 @@ class BuildConfig:
         self.OTHERLIBS = ''
         self.OTHERTARGETS = ''
         self.OTHERINSTALLTARGETS = ''
         self.OTHERLIBS = ''
         self.OTHERTARGETS = ''
         self.OTHERINSTALLTARGETS = ''
+        self.OTHERUNINSTALLTARGETS = ''
         self.OTHERRULES = ''
         self.DEFAULTRULE = 'default: $(GENCODEDIR) $(TARGET)'
         self.PYVERSION = sys.version[:3]
         self.OTHERRULES = ''
         self.DEFAULTRULE = 'default: $(GENCODEDIR) $(TARGET)'
         self.PYVERSION = sys.version[:3]
@@ -252,6 +243,8 @@ class BuildConfig:
         self.WXUSINGDLL = '1'
         self.OTHERDEP = ''
         self.WXPSRCDIR = '$(WXDIR)/utils/wxPython/src'
         self.WXUSINGDLL = '1'
         self.OTHERDEP = ''
         self.WXPSRCDIR = '$(WXDIR)/utils/wxPython/src'
+        self.SWIGDEPS = ''
+        self.OTHERDEPS = ''
 
 
         if sys.platform == 'win32':
 
 
         if sys.platform == 'win32':
@@ -268,6 +261,10 @@ class BuildConfig:
             self.RESFILE = ''
             self.RESRULE = ''
             self.OVERRIDEFLAGS = '/GX-'
             self.RESFILE = ''
             self.RESRULE = ''
             self.OVERRIDEFLAGS = '/GX-'
+            self.RMCMD  = '-erase '
+            self.WXPSRCDIR = os.path.normpath(self.WXPSRCDIR)
+            self.CRTFLAG = ''
+
 
         else:
             self.MAKE      = 'make'
 
         else:
             self.MAKE      = 'make'
@@ -280,12 +277,15 @@ class BuildConfig:
             self.HELPERLIB = 'wxPyHelpers'
             self.HELPERLIBDIR = '/usr/local/lib'
             self.CFLAGS = '-DSWIG_GLOBAL -DHAVE_CONFIG_H $(THREAD) -I. '\
             self.HELPERLIB = 'wxPyHelpers'
             self.HELPERLIBDIR = '/usr/local/lib'
             self.CFLAGS = '-DSWIG_GLOBAL -DHAVE_CONFIG_H $(THREAD) -I. '\
-                          '`wx-config --cflags` -I$(PYINCLUDE) -I$(EXECINCLUDE) '\
+                          '`$(WXCONFIG) --cflags` -I$(PYINCLUDE) -I$(EXECINCLUDE) '\
                           '-I$(WXPSRCDIR)'
                           '-I$(WXPSRCDIR)'
-            self.LFLAGS = '-L$(WXPSRCDIR) `wx-config --libs`'
+            self.LFLAGS = '-L$(WXPSRCDIR) `$(WXCONFIG) --libs`'
             self.LIBS   = '-l$(HELPERLIB)'
             self.LIBS   = '-l$(HELPERLIB)'
+            self.RMCMD  = '-rm -f '
+            self.WXCONFIG = 'wx-config'
 
 
-            # **** what to do when I start supporting Motif, etc.???
+
+            # **** What to do when I start supporting Motif, etc.???
             self.GENCODEDIR = 'gtk'
             self.SWIGTOOLKITFLAG = '-D__WXGTK__'
 
             self.GENCODEDIR = 'gtk'
             self.SWIGTOOLKITFLAG = '-D__WXGTK__'
 
@@ -299,13 +299,7 @@ class BuildConfig:
                 raise SystemExit, "Python development files not found"
 
             self.CCC = self.findMFValue(mfText, 'CCC')
                 raise SystemExit, "Python development files not found"
 
             self.CCC = self.findMFValue(mfText, 'CCC')
-           if not self.CCC:
-               print "Warning: C++ compiler not specified (CCC). Assuming c++"
-               self.CCC = 'c++'
             self.CC = self.findMFValue(mfText, 'CC')
             self.CC = self.findMFValue(mfText, 'CC')
-           if not self.CC:
-               print "Warning: C compiler not specified (CCC). Assuming cc"
-               self.CC = 'cc'
             self.OPT = self.findMFValue(mfText, 'OPT')
             self.SO = self.findMFValue(mfText, 'SO')
             self.LDSHARED = self.findMFValue(mfText, 'LDSHARED')
             self.OPT = self.findMFValue(mfText, 'OPT')
             self.SO = self.findMFValue(mfText, 'SO')
             self.LDSHARED = self.findMFValue(mfText, 'LDSHARED')
@@ -324,6 +318,22 @@ class BuildConfig:
                                         ' ')
 
 
                                         ' ')
 
 
+    #------------------------------------------------------------
+    def doFixups(self):
+        # This is called after the config files have been evaluated
+        # so we can do some sanity checking...
+        if sys.platform != 'win32':
+           if not self.CCC:
+                self.CCC = os.popen('%(WXCONFIG)s --cxx' % self.__dict__, 'r').read()[:-1]
+                if not self.CCC:
+                    print "Warning: C++ compiler not specified (CCC). Assuming c++"
+                    self.CCC = 'c++'
+            if not self.CC:
+                self.CCC = os.popen('%(WXCONFIG)s --cc' % self.__dict__, 'r').read()[:-1]
+                if not self.CC:
+                    print "Warning: C compiler not specified (CC). Assuming cc"
+                    self.CC = 'cc'
+
     #------------------------------------------------------------
     def findMFValue(self, mfText, st):
         # Find line begining with st= and return the value
     #------------------------------------------------------------
     def findMFValue(self, mfText, st):
         # Find line begining with st= and return the value
@@ -343,7 +353,7 @@ class BuildConfig:
         for name in self.SWIGFILES:
             objects = objects + os.path.splitext(name)[0] + self.OBJEXT + ' '
         for name in self.SOURCES:
         for name in self.SWIGFILES:
             objects = objects + os.path.splitext(name)[0] + self.OBJEXT + ' '
         for name in self.SOURCES:
-           obj = strippath(name)
+           obj = os.path.basename(name)
             objects = objects + os.path.splitext(obj)[0] + self.OBJEXT + ' '
         self.OBJECTS = splitlines(objects)
 
             objects = objects + os.path.splitext(obj)[0] + self.OBJEXT + ' '
         self.OBJECTS = splitlines(objects)
 
@@ -351,14 +361,26 @@ class BuildConfig:
         # now build the text for the dependencies
         depends = ""
         for name in self.SWIGFILES:
         # now build the text for the dependencies
         depends = ""
         for name in self.SWIGFILES:
-            text = '$(GENCODEDIR)/%s.cpp $(GENCODEDIR)/%s.py : %s.i\n' \
+            rootname = os.path.splitext(name)[0]
+            text = '$(GENCODEDIR)/%s.cpp $(GENCODEDIR)/%s.py : %s.i %s\n' \
                    '$(TARGETDIR)\\%s.py : $(GENCODEDIR)\\%s.py\n' % \
                    '$(TARGETDIR)\\%s.py : $(GENCODEDIR)\\%s.py\n' % \
-                   tuple([os.path.splitext(name)[0]] * 5)
+                   (rootname, rootname, rootname, self.SWIGDEPS, rootname, rootname)
             depends = depends + text
             depends = depends + text
+            if self.OTHERDEPS:
+                text = '%s%s : %s\n' % \
+                       (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS)
+                depends = depends + text
         for name in self.PYFILES:
             text = '$(TARGETDIR)\\%s.py : %s.py\n' % \
                    tuple([os.path.splitext(name)[0]] * 2)
             depends = depends + text
         for name in self.PYFILES:
             text = '$(TARGETDIR)\\%s.py : %s.py\n' % \
                    tuple([os.path.splitext(name)[0]] * 2)
             depends = depends + text
+        if self.OTHERDEPS:
+            for name in self.SOURCES:
+                name = os.path.basename(name)
+                text = '%s%s : %s\n' % \
+                       (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS)
+                depends = depends + text
+
         self.DEPENDS = swapslash(depends)
 
 
         self.DEPENDS = swapslash(depends)
 
 
@@ -371,6 +393,14 @@ class BuildConfig:
         self.PYMODULES = splitlines(swapslash(pymodules))
 
 
         self.PYMODULES = splitlines(swapslash(pymodules))
 
 
+        # now make a list of the python files that would need uninstalled
+        pycleanup = ""
+        for name in self.SWIGFILES:
+            pycleanup = pycleanup + self.makeCleanupList(name)
+        for name in self.PYFILES:
+            pycleanup = pycleanup + self.makeCleanupList(name)
+        self.PYCLEANUP = swapslash(pycleanup)
+
 
         # finally, build the makefile
         if sys.platform == 'win32':
 
         # finally, build the makefile
         if sys.platform == 'win32':
@@ -388,6 +418,16 @@ class BuildConfig:
         print "Makefile created: ", self.MAKEFILE
 
 
         print "Makefile created: ", self.MAKEFILE
 
 
+
+    #------------------------------------------------------------
+    def makeCleanupList(self, name):
+        st = ""
+        st = st + '\t%s$(TARGETDIR)\\%s.py\n' % (self.RMCMD, os.path.splitext(name)[0])
+        st = st + '\t%s$(TARGETDIR)\\%s.pyc\n' % (self.RMCMD, os.path.splitext(name)[0])
+        st = st + '\t%s$(TARGETDIR)\\%s.pyo\n' % (self.RMCMD, os.path.splitext(name)[0])
+        return st
+
+
     #------------------------------------------------------------
     def readConfigFiles(self, args):
         return self.processFile(self.bldCfg, 1) and \
     #------------------------------------------------------------
     def readConfigFiles(self, args):
         return self.processFile(self.bldCfg, 1) and \
@@ -423,7 +463,7 @@ class BuildConfig:
             for st in args:
                 pair = string.split(st, '=')
                 name = pair[0]
             for st in args:
                 pair = string.split(st, '=')
                 name = pair[0]
-                value = pair[1]
+                value = string.join(pair[1:], '=')
                 self.__dict__[name] = value
         except:
             print "Error parsing command-line: %s" % st
                 self.__dict__[name] = value
         except:
             print "Error parsing command-line: %s" % st
@@ -438,6 +478,7 @@ class BuildConfig:
 
 
 
 
 
 
+#----------------------------------------------------------------------------
 #----------------------------------------------------------------------------
 #----------------------------------------------------------------------------
 
 #----------------------------------------------------------------------------
 #----------------------------------------------------------------------------
 
@@ -451,8 +492,8 @@ WXDIR = %(WXDIR)s
 VERSION = %(VERSION)s
 MODULE = %(MODULE)s
 SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s
 VERSION = %(VERSION)s
 MODULE = %(MODULE)s
 SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s
-CFLAGS = %(CFLAGS)s %(OTHERCFLAGS)s
-LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
+CFLAGS = %(CFLAGS)s
+LFLAGS = %(LFLAGS)s
 PYVERSION = %(PYVERSION)s
 PYPREFIX = %(PYPREFIX)s
 EXECPREFIX = %(EXECPREFIX)s
 PYVERSION = %(PYVERSION)s
 PYPREFIX = %(PYPREFIX)s
 EXECPREFIX = %(EXECPREFIX)s
@@ -487,12 +528,14 @@ THREAD=-DWXP_USE_THREAD=1
 
 
 NOPCH=1
 
 
 NOPCH=1
-OVERRIDEFLAGS=%(OVERRIDEFLAGS)s %(OTHERCFLAGS)s
-EXTRAFLAGS = %(CFLAGS)s
+OVERRIDEFLAGS=%(OVERRIDEFLAGS)s
+EXTRAFLAGS = $(CFLAGS) %(OTHERCFLAGS)s
 
 LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
 EXTRALIBS = %(LIBS)s %(OTHERLIBS)s
 
 
 LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
 EXTRALIBS = %(LIBS)s %(OTHERLIBS)s
 
+CRTFLAG=%(CRTFLAG)s
+
 #----------------------------------------------------------------------
 
 !include $(WXDIR)\\src\\makevc.env
 #----------------------------------------------------------------------
 
 !include $(WXDIR)\\src\\makevc.env
@@ -519,9 +562,10 @@ clean:
        -erase $(TARGET)
 
 
        -erase $(TARGET)
 
 
-uninstall:
+uninstall: %(OTHERUNINSTALLTARGETS)s
        -erase $(TARGETDIR)\\$(TARGET)
        -erase $(TARGETDIR)\\$(TARGET)
-       -erase $(PYMODULES)
+%(PYCLEANUP)s
+
 
 #----------------------------------------------------------------------
 # implicit rule for compiling .cpp and .c files
 
 #----------------------------------------------------------------------
 # implicit rule for compiling .cpp and .c files
@@ -562,7 +606,7 @@ $(CPPFLAGS) /c $<
 $(TARGET) : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(RESFILE)
        $(link) @<<
 /out:$@
 $(TARGET) : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(RESFILE)
        $(link) @<<
 /out:$@
-$(LFLAGS) /def:$(MODULE).def /implib:./$(MODULE).lib
+$(LFLAGS) /export:init$(MODULE) /implib:./$(MODULE).lib
 $(DUMMYOBJ) $(OBJECTS) $(RESFILE)
 $(LIBS)
 <<
 $(DUMMYOBJ) $(OBJECTS) $(RESFILE)
 $(LIBS)
 <<
@@ -592,6 +636,13 @@ $(GENCODEDIR):
 
 #----------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------
 
+showflags:
+       @echo CPPFLAGS:
+       @echo $(CPPFLAGS)
+       @echo LFLAGS:
+       @echo $(LFLAGS)
+
+
 
 %(OTHERRULES)s
 '''
 
 %(OTHERRULES)s
 '''
@@ -612,7 +663,7 @@ WXDIR = %(WXDIR)s
 VERSION = %(VERSION)s
 MODULE = %(MODULE)s
 SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s
 VERSION = %(VERSION)s
 MODULE = %(MODULE)s
 SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s
-CFLAGS = %(CFLAGS)s %(OTHERCFLAGS)s
+CFLAGS = %(CFLAGS)s $(OPT) %(OTHERCFLAGS)s
 LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
 LIBS = %(LIBS)s %(OTHERLIBS)s
 PYVERSION = %(PYVERSION)s
 LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
 LIBS = %(LIBS)s %(OTHERLIBS)s
 PYVERSION = %(PYVERSION)s
@@ -629,7 +680,7 @@ GENCODEDIR = %(GENCODEDIR)s
 WXPSRCDIR = %(WXPSRCDIR)s
 HELPERLIB = %(HELPERLIB)s
 HELPERLIBDIR = %(HELPERLIBDIR)s
 WXPSRCDIR = %(WXPSRCDIR)s
 HELPERLIB = %(HELPERLIB)s
 HELPERLIBDIR = %(HELPERLIBDIR)s
-
+WXCONFIG=%(WXCONFIG)s
 TARGETDIR = %(TARGETDIR)s
 
 
 TARGETDIR = %(TARGETDIR)s
 
 
@@ -657,12 +708,12 @@ endif
 install: $(TARGETDIR) $(TARGETDIR)/$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s
 
 clean:
 install: $(TARGETDIR) $(TARGETDIR)/$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s
 
 clean:
-       -rm -f *.o *.so *~
+       -rm -f *.o *$(SO) *~
        -rm -f $(TARGET)
 
        -rm -f $(TARGET)
 
-uninstall:
+uninstall: %(OTHERUNINSTALLTARGETS)s
        -rm -f $(TARGETDIR)/$(TARGET)
        -rm -f $(TARGETDIR)/$(TARGET)
-       -rm -f $(PYMODULES)
+%(PYCLEANUP)s
 
 
 #----------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------
@@ -679,12 +730,15 @@ uninstall:
 %%.o : $(GENCODEDIR)/%%.c
        $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
 
 %%.o : $(GENCODEDIR)/%%.c
        $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
 
+ifndef NOSWIG
 $(GENCODEDIR)/%%.cpp : %%.i
        swig $(SWIGFLAGS) -c -o $@ $<
 
 $(GENCODEDIR)/%%.py : %%.i
        swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $<
        rm $(GENCODEDIR)/tmp_wrap.cpp
 $(GENCODEDIR)/%%.cpp : %%.i
        swig $(SWIGFLAGS) -c -o $@ $<
 
 $(GENCODEDIR)/%%.py : %%.i
        swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $<
        rm $(GENCODEDIR)/tmp_wrap.cpp
+endif
+
 
 $(TARGETDIR)/%% : %%
        cp -f $< $@
 
 $(TARGETDIR)/%% : %%
        cp -f $< $@
@@ -709,7 +763,7 @@ pycfiles : $(PYMODULES)
 
 
 $(TARGETDIR) :
 
 
 $(TARGETDIR) :
-       mkdir $(TARGETDIR)
+       mkdir -p $(TARGETDIR)
 
 $(GENCODEDIR):
        mkdir $(GENCODEDIR)
 
 $(GENCODEDIR):
        mkdir $(GENCODEDIR)
@@ -727,7 +781,8 @@ $(GENCODEDIR):
 #----------------------------------------------------------------------------
 
 if __name__ == '__main__':
 #----------------------------------------------------------------------------
 
 if __name__ == '__main__':
-    main(sys.argv)
+    err = main(sys.argv)
+    sys.exit(err)
 
 #----------------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------------