Browse Source

Mainly fixes for path problems

Josh Yelon 21 years ago
parent
commit
0ea72c30fb

+ 39 - 46
direct/src/directbase/ppython.cxx

@@ -51,7 +51,7 @@ void pathfail(void)
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-  char fnbuf[PATH_MAX],ppbuf[PATH_MAX],pabuf[PATH_MAX],prbuf[PATH_MAX],modcmd[PATH_MAX];
+  char fnbuf[PATH_MAX],ppbuf[PATH_MAX],pabuf[PATH_MAX],modcmd[PATH_MAX];
   int fnlen;
   int fnlen;
 
 
   // Ask windows for the file name of this executable.
   // Ask windows for the file name of this executable.
@@ -67,29 +67,12 @@ int main(int argc, char **argv)
   if (stricmp(fnbuf + fnlen - srclen, LINK_SOURCE)) pathfail();
   if (stricmp(fnbuf + fnlen - srclen, LINK_SOURCE)) pathfail();
   fnlen -= srclen; fnbuf[fnlen] = 0;
   fnlen -= srclen; fnbuf[fnlen] = 0;
   
   
-  // Fetch the command line and trim the first word.
-
-  char *cmdline = GetCommandLine();
-  char *args = cmdline;
-  bool inquote = false;
-  while (*args && ((*args != ' ')||(inquote))) {
-    if (*args == '"') inquote = !inquote;
-    args++;
-  }
-  while (*args==' ') args++;
-
-  // Calculate MODCMD
+  // See if we can find the panda root.  If not, abort.
   
   
-  if (GENPYCODE) {
-    sprintf(ppbuf,"%s\\direct\\src\\ffi\\jGenPyCode.py",fnbuf);
-    FILE *f = fopen(ppbuf,"r");
-    if (f) {
-      fclose(f);
-      sprintf(modcmd,"python %s\\direct\\src\\ffi\\jGenPyCode.py %s",fnbuf,args);
-    } else {
-      sprintf(modcmd,"python %s\\..\\direct\\src\\ffi\\jGenPyCode.py %s",fnbuf,args);
-    }
-  } else sprintf(modcmd,"python %s",args);
+  sprintf(ppbuf,"%s/direct/__init__.py",fnbuf);
+  FILE *f = fopen(ppbuf,"r");
+  if (f==0) pathfail();
+  fclose(f);
   
   
   // Set the PYTHONPATH and PATH
   // Set the PYTHONPATH and PATH
   
   
@@ -102,11 +85,28 @@ int main(int argc, char **argv)
   else      sprintf(pabuf,"PATH=%s\\bin",fnbuf);
   else      sprintf(pabuf,"PATH=%s\\bin",fnbuf);
   putenv(pabuf);
   putenv(pabuf);
   
   
+  // Fetch the command line and trim the first word.
+
+  char *cmdline = GetCommandLine();
+  char *args = cmdline;
+  bool inquote = false;
+  while (*args && ((*args != ' ')||(inquote))) {
+    if (*args == '"') inquote = !inquote;
+    args++;
+  }
+  while (*args==' ') args++;
+
   // Append LINK_TARGET to the file name.
   // Append LINK_TARGET to the file name.
   
   
   if (fnlen + strlen(LINK_TARGET) > 1023) pathfail();
   if (fnlen + strlen(LINK_TARGET) > 1023) pathfail();
   strcat(fnbuf, LINK_TARGET);
   strcat(fnbuf, LINK_TARGET);
   
   
+  // Calculate MODCMD
+  
+  if (GENPYCODE) {
+    sprintf(modcmd,"python -c \"import direct.ffi.jGenPyCode\" %s",args);
+  } else sprintf(modcmd,"python %s",args);
+  
   // Run it.
   // Run it.
 
 
   signal(SIGINT, SIG_IGN);
   signal(SIGINT, SIG_IGN);
@@ -162,7 +162,7 @@ void pathfail(void)
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-  char fnbuf[PATH_MAX],ppbuf[PATH_MAX],pabuf[PATH_MAX],prbuf[PATH_MAX],genpyc[PATH_MAX];
+  char fnbuf[PATH_MAX],ppbuf[PATH_MAX];
   char *modargv[1024];
   char *modargv[1024];
   int fnlen,modargc;
   int fnlen,modargc;
 
 
@@ -180,38 +180,31 @@ int main(int argc, char **argv)
   if (strcmp(fnbuf + fnlen - srclen, LINK_SOURCE)) pathfail();
   if (strcmp(fnbuf + fnlen - srclen, LINK_SOURCE)) pathfail();
   fnlen -= srclen; fnbuf[fnlen] = 0;
   fnlen -= srclen; fnbuf[fnlen] = 0;
 
 
-  // Calculate GENPYC
+  // See if we can find the 'direct' tree locally.
+  // If not, continue anyway.  It may be possible to succeed.
   
   
-  if (GENPYCODE) {
-    sprintf(ppbuf,"%s/direct/src/ffi/jGenPyCode.py",fnbuf);
-    FILE *f = fopen(ppbuf,"r");
-    if (f) {
-      fclose(f);
-      sprintf(genpyc,"%s/direct/src/ffi/jGenPyCode.py",fnbuf);
-    } else {
-      sprintf(genpyc,"%s/../direct/src/ffi/jGenPyCode.py",fnbuf);
-    }
+  sprintf(ppbuf,"%s/direct/__init__.py",fnbuf);
+  FILE *f = fopen(ppbuf,"r");
+  if (f) {
+    char *pp = getenv("PYTHONPATH");
+    if (pp) sprintf(ppbuf,"PYTHONPATH=%s:%s/lib:%s",fnbuf,fnbuf,pp);
+    else    sprintf(ppbuf,"PYTHONPATH=%s:%s/lib",fnbuf,fnbuf);
+    putenv(ppbuf);
   }
   }
   
   
-  // Set the PYTHONPATH and PATH
-  
-  char *pp = getenv("PYTHONPATH");
-  if (pp) sprintf(ppbuf,"PYTHONPATH=%s:%s/lib:%s",fnbuf,fnbuf,pp);
-  else    sprintf(ppbuf,"PYTHONPATH=%s:%s/lib",fnbuf,fnbuf);
-  putenv(ppbuf);
-  char *path = getenv("PATH");
-  if (path) sprintf(pabuf,"PATH=%s/bin;%s",fnbuf,path);
-  else      sprintf(pabuf,"PATH=%s/bin",fnbuf);
-  putenv(pabuf);
-  
   // Calculate MODARGV
   // Calculate MODARGV
+  
   modargc=0;
   modargc=0;
   modargv[modargc++]="python";
   modargv[modargc++]="python";
-  if (GENPYCODE) modargv[modargc++] = genpyc;
+  if (GENPYCODE) {
+    modargv[modargc++] = "-c";
+    modargv[modargc++] = "import direct.ffi.jGenPyCode";
+  }
   for (int i=1; i<argc; i++) modargv[modargc++] = argv[i];
   for (int i=1; i<argc; i++) modargv[modargc++] = argv[i];
   modargv[modargc] = 0;
   modargv[modargc] = 0;
   
   
   // Run it.
   // Run it.
+
   execv("/usr/bin/python", modargv);
   execv("/usr/bin/python", modargv);
 }
 }
 
 

+ 1 - 1
direct/src/ffi/jGenPyCode.py

@@ -2,7 +2,7 @@
 #
 #
 # This module should be invoked by a shell-script that says:
 # This module should be invoked by a shell-script that says:
 #
 #
-#    python direct\\src\\ffi\\jGenPyCode.py <arguments>
+#    python -c "import direct.ffi.jGenPyCode" <arguments>
 #
 #
 # Before invoking python, the shell-script may need to set
 # Before invoking python, the shell-script may need to set
 # these environment variables, to make sure that everything
 # these environment variables, to make sure that everything

+ 5 - 4
doc/doc/INSTALL-MK

@@ -181,12 +181,13 @@ BUILDING THE SOURCE TAR-BALL AND THE RPM
 If you are using Linux and you want to build an RPM, it is fairly easy
 If you are using Linux and you want to build an RPM, it is fairly easy
 to do so.  First, you need a panda source tar-ball.  If you do not
 to do so.  First, you need a panda source tar-ball.  If you do not
 already have one, build one using 'maketarball.py'.  You will need to
 already have one, build one using 'maketarball.py'.  You will need to
-specify a version number.
+give your version of panda a version number.  The version number can
+be any three integers separated by dots.
 
 
-	maketarball.py --v1 58 --v2 23 --v3 95
+	makepanda/maketarball.py 58.23.95
 
 
-This builds panda3d-58.23.95.tar.gz.  Once you have the tar-ball,
-it is easy to turn it into a binary RPM:
+This builds panda3d-58.23.95.tar.gz and panda3d-58-23-95.zip.  Once
+you have the tar-ball, it is easy to turn it into a binary RPM:
 
 
 	rpmbuild -tb panda3d-58.23.95.tar.gz
 	rpmbuild -tb panda3d-58.23.95.tar.gz
 
 

+ 34 - 32
doc/makepanda/makepanda.py

@@ -487,7 +487,7 @@ def parseopts(args):
             elif (option=="--prefix"): PREFIX=value
             elif (option=="--prefix"): PREFIX=value
             elif (option=="--compiler"): COMPILER=value
             elif (option=="--compiler"): COMPILER=value
             elif (option=="--directx-sdk"): DIRECTXSDK=value
             elif (option=="--directx-sdk"): DIRECTXSDK=value
-            elif (option=="--thirdparty"): THIRDPARTY=value
+            elif (option=="--thirdparty"): THIRDPARTY=value+"/"
             elif (option=="--optimize"): OPTIMIZE=value
             elif (option=="--optimize"): OPTIMIZE=value
             elif (option=="--quiet"): VERBOSE-=1
             elif (option=="--quiet"): VERBOSE-=1
             elif (option=="--verbose"): VERBOSE+=1
             elif (option=="--verbose"): VERBOSE+=1
@@ -585,11 +585,12 @@ if sys.platform == "win32":
         elif (os.path.isdir("C:/Python25")): PythonSDK = "C:/Python25"
         elif (os.path.isdir("C:/Python25")): PythonSDK = "C:/Python25"
         else: sys.exit("Cannot find the python SDK")
         else: sys.exit("Cannot find the python SDK")
 else:
 else:
-    if   (os.path.isdir("/usr/include/python2.2")): PythonSDK = "/usr/include/python2.2"
-    elif (os.path.isdir("/usr/include/python2.3")): PythonSDK = "/usr/include/python2.3"
+    if   (os.path.isdir("/usr/include/python2.5")): PythonSDK = "/usr/include/python2.5"
     elif (os.path.isdir("/usr/include/python2.4")): PythonSDK = "/usr/include/python2.4"
     elif (os.path.isdir("/usr/include/python2.4")): PythonSDK = "/usr/include/python2.4"
-    elif (os.path.isdir("/usr/include/python2.5")): PythonSDK = "/usr/include/python2.5"
+    elif (os.path.isdir("/usr/include/python2.3")): PythonSDK = "/usr/include/python2.3"
+    elif (os.path.isdir("/usr/include/python2.2")): PythonSDK = "/usr/include/python2.2"
     else: sys.exit("Cannot find the python SDK")
     else: sys.exit("Cannot find the python SDK")
+    # this is so that the user can find out which version of python was used.
 
 
 ########################################################################
 ########################################################################
 ##
 ##
@@ -875,7 +876,7 @@ ALLTARGETS=[]
 global CxxIncludeCache
 global CxxIncludeCache
 CxxIncludeCache = {}
 CxxIncludeCache = {}
 
 
-iCachePath=PREFIX+"/makepanda-icache"
+iCachePath=PREFIX+"/tmp/makepanda-icache"
 try: icache = open(iCachePath,'rb')
 try: icache = open(iCachePath,'rb')
 except: icache = 0
 except: icache = 0
 if (icache!=0):
 if (icache!=0):
@@ -1064,8 +1065,8 @@ def CopyAllFiles(dstdir,srcdir):
 
 
 def CopyTree(dstdir,srcdir):
 def CopyTree(dstdir,srcdir):
     if (os.path.isdir(dstdir)): return 0
     if (os.path.isdir(dstdir)): return 0
-    if (COMPILER=="MSVC7"): cmd = "xcopy.exe /I/Y/E/Q \""+srcdir+"\" \""+dstdir+"\""
-    if (COMPILER=="LINUXA"): cmd = "cp --recursive --force "+srcdir+" "+dstdir
+    if (COMPILER=="MSVC7"): cmd = 'xcopy.exe /I/Y/E/Q "' + srcdir + '" "' + dstdir+ '"'
+    if (COMPILER=="LINUXA"): cmd = 'cp --recursive --force "' + srcdir + '" "' + dstdir + '"'
     oscmd(cmd)
     oscmd(cmd)
     updatefiledate(dstdir)
     updatefiledate(dstdir)
 
 
@@ -1105,11 +1106,10 @@ def CompileFlex(pre,dst,src,dashi):
             if (dashi): oslocalcmd(PREFIX+"/tmp", flexFullPath+" -i -P" + pre + " -olex.yy.c " + fn)
             if (dashi): oslocalcmd(PREFIX+"/tmp", flexFullPath+" -i -P" + pre + " -olex.yy.c " + fn)
             else:       oslocalcmd(PREFIX+"/tmp", flexFullPath+"    -P" + pre + " -olex.yy.c " + fn)
             else:       oslocalcmd(PREFIX+"/tmp", flexFullPath+"    -P" + pre + " -olex.yy.c " + fn)
             replaceInFile(PREFIX+'/tmp/lex.yy.c', dst, '#include <unistd.h>', '')
             replaceInFile(PREFIX+'/tmp/lex.yy.c', dst, '#include <unistd.h>', '')
-            #WriteFile(wdst, ReadFile("built\\tmp\\lex.yy.c").replace("#include <unistd.h>",""))
         if (COMPILER=="LINUXA"):
         if (COMPILER=="LINUXA"):
             if (dashi): oslocalcmd(PREFIX+"/tmp", "flex -i -P" + pre + " -olex.yy.c " + fn)
             if (dashi): oslocalcmd(PREFIX+"/tmp", "flex -i -P" + pre + " -olex.yy.c " + fn)
             else:       oslocalcmd(PREFIX+"/tmp", "flex    -P" + pre + " -olex.yy.c " + fn)
             else:       oslocalcmd(PREFIX+"/tmp", "flex    -P" + pre + " -olex.yy.c " + fn)
-            oscmd('cp built/tmp/lex.yy.c '+dst)
+            oscmd('cp "'+PREFIX+'/tmp/lex.yy.c" "'+dst+'"')
         updatefiledate(dst)
         updatefiledate(dst)
 
 
 ########################################################################
 ########################################################################
@@ -1158,10 +1158,10 @@ def CompileC(obj=0,src=0,ipath=[],opts=[]):
             if (OPTIMIZE==2): cmd = cmd + " /D_DEBUG /Zc:forScope /MDd /Zi /RTCs /GS "
             if (OPTIMIZE==2): cmd = cmd + " /D_DEBUG /Zc:forScope /MDd /Zi /RTCs /GS "
             if (OPTIMIZE==3): cmd = cmd + " /Zc:forScope /MD /O2 /Ob2 /G6 /Zi /DFORCE_INLINING "
             if (OPTIMIZE==3): cmd = cmd + " /Zc:forScope /MD /O2 /Ob2 /G6 /Zi /DFORCE_INLINING "
             if (OPTIMIZE==4): cmd = cmd + " /Zc:forScope /MD /O2 /Ob2 /G6 /GL /Zi /DFORCE_INLINING /DNDEBUG "
             if (OPTIMIZE==4): cmd = cmd + " /Zc:forScope /MD /O2 /Ob2 /G6 /GL /Zi /DFORCE_INLINING /DNDEBUG "
-            cmd = cmd + " /Fd\"" + wobj[:-4] + ".pdb\""
+            cmd = cmd + ' /Fd"' + wobj[:-4] + '.pdb"'
             building = buildingwhat(opts)
             building = buildingwhat(opts)
             if (building): cmd = cmd + " /DBUILDING_"+building
             if (building): cmd = cmd + " /DBUILDING_"+building
-            cmd = cmd + " /EHsc /Zm300 /DWIN32_VC /DWIN32 /W3 \"" + fullsrc + "\""
+            cmd = cmd + ' /EHsc /Zm300 /DWIN32_VC /DWIN32 /W3 "' + fullsrc + '"'
             oscmd(cmd)
             oscmd(cmd)
             updatefiledate(wobj)
             updatefiledate(wobj)
 
 
@@ -1170,8 +1170,8 @@ def CompileC(obj=0,src=0,ipath=[],opts=[]):
         if (older(wobj, dep)):
         if (older(wobj, dep)):
             if VERBOSE >= 0:
             if VERBOSE >= 0:
                 checkIfNewDir(ipath[1])
                 checkIfNewDir(ipath[1])
-            if (src[-2:]==".c"): cmd = "gcc -c -o "+wobj
-            else:                cmd = "g++ -ftemplate-depth-30 -c -o "+wobj
+            if (src[-2:]==".c"): cmd = 'gcc -c -o "' + wobj + '"'
+            else:                cmd = 'g++ -ftemplate-depth-30 -c -o "' + wobj + '"'
             cmd = cmd + ' -I"' + PythonSDK + '"'
             cmd = cmd + ' -I"' + PythonSDK + '"'
             if (PkgSelected(opts,"VRPN")):     cmd = cmd + ' -I"' + THIRDPARTY + 'vrpn/include"'
             if (PkgSelected(opts,"VRPN")):     cmd = cmd + ' -I"' + THIRDPARTY + 'vrpn/include"'
             if (PkgSelected(opts,"FFTW")):     cmd = cmd + ' -I"' + THIRDPARTY + 'fftw/include"'
             if (PkgSelected(opts,"FFTW")):     cmd = cmd + ' -I"' + THIRDPARTY + 'fftw/include"'
@@ -1187,7 +1187,7 @@ def CompileC(obj=0,src=0,ipath=[],opts=[]):
             if (OPTIMIZE==4): cmd = cmd + " -O2"
             if (OPTIMIZE==4): cmd = cmd + " -O2"
             building = buildingwhat(opts)
             building = buildingwhat(opts)
             if (building): cmd = cmd + " -DBUILDING_" + building
             if (building): cmd = cmd + " -DBUILDING_" + building
-            cmd = cmd + " " + fullsrc
+            cmd = cmd + ' "' + fullsrc + '"'
             oscmd(cmd)
             oscmd(cmd)
             updatefiledate(wobj)
             updatefiledate(wobj)
 
 
@@ -1242,7 +1242,7 @@ def Interrogate(ipath=0, opts=0, outd=0, outc=0, src=0, module=0, library=0, fil
         if (x[:9]=="BUILDING_"): building = x[9:]
         if (x[:9]=="BUILDING_"): building = x[9:]
     if (older(outc, dep) or older(outd, dep)):
     if (older(outc, dep) or older(outd, dep)):
         if (COMPILER=="MSVC7"):
         if (COMPILER=="MSVC7"):
-            cmd = dotdots + PREFIX+"/bin/interrogate.exe"
+            cmd = '"' + dotdots + PREFIX+'/bin/interrogate.exe"'
             cmd = cmd + ' -DCPPPARSER -D__STDC__=1 -D__cplusplus -longlong __int64 -D_X86_ -DWIN32_VC -D_WIN32'
             cmd = cmd + ' -DCPPPARSER -D__STDC__=1 -D__cplusplus -longlong __int64 -D_X86_ -DWIN32_VC -D_WIN32'
             cmd = cmd + ' -D"_declspec(param)=" -D_near -D_far -D__near -D__far -D__stdcall'
             cmd = cmd + ' -D"_declspec(param)=" -D_near -D_far -D__near -D__far -D__stdcall'
             if (OPTIMIZE==1): cmd = cmd + ' '
             if (OPTIMIZE==1): cmd = cmd + ' '
@@ -1252,7 +1252,7 @@ def Interrogate(ipath=0, opts=0, outd=0, outc=0, src=0, module=0, library=0, fil
             cmd = cmd + ' -S"' + dotdots + PREFIX+'/include/parser-inc"'
             cmd = cmd + ' -S"' + dotdots + PREFIX+'/include/parser-inc"'
             cmd = cmd + ' -I"' + dotdots + PREFIX+'/python/include"'
             cmd = cmd + ' -I"' + dotdots + PREFIX+'/python/include"'
         if (COMPILER=="LINUXA"):
         if (COMPILER=="LINUXA"):
-            cmd = dotdots + PREFIX+"/bin/interrogate"
+            cmd = '"' + dotdots + PREFIX + '/bin/interrogate"'
             cmd = cmd + ' -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__i386__ -D__const=const'
             cmd = cmd + ' -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__i386__ -D__const=const'
             if (OPTIMIZE==1): cmd = cmd + ' '
             if (OPTIMIZE==1): cmd = cmd + ' '
             if (OPTIMIZE==2): cmd = cmd + ' '
             if (OPTIMIZE==2): cmd = cmd + ' '
@@ -1260,7 +1260,7 @@ def Interrogate(ipath=0, opts=0, outd=0, outc=0, src=0, module=0, library=0, fil
             if (OPTIMIZE==4): cmd = cmd + ' '
             if (OPTIMIZE==4): cmd = cmd + ' '
             cmd = cmd + ' -S"' + dotdots + PREFIX+'/include/parser-inc" -S"/usr/include"'
             cmd = cmd + ' -S"' + dotdots + PREFIX+'/include/parser-inc" -S"/usr/include"'
             cmd = cmd + ' -I"' + dotdots + PREFIX+'/python/include"'
             cmd = cmd + ' -I"' + dotdots + PREFIX+'/python/include"'
-        cmd = cmd + " -oc "+dotdots+outc+" -od "+dotdots+outd
+        cmd = cmd + ' -oc "' + dotdots + outc + '" -od "' + dotdots + outd + '"'
         cmd = cmd + ' -fnames -string -refcount -assert -python'
         cmd = cmd + ' -fnames -string -refcount -assert -python'
         for x in ipath: cmd = cmd + ' -I"' + dotdots + x + '"'
         for x in ipath: cmd = cmd + ' -I"' + dotdots + x + '"'
         if (building): cmd = cmd + " -DBUILDING_"+building
         if (building): cmd = cmd + " -DBUILDING_"+building
@@ -1295,10 +1295,10 @@ def InterrogateModule(outc=0, module=0, library=0, files=0):
         if VERBOSE >= 1:
         if VERBOSE >= 1:
             print "Generating Python-stub cxx file for %s"%(library,)
             print "Generating Python-stub cxx file for %s"%(library,)
         if (COMPILER=="MSVC7"):
         if (COMPILER=="MSVC7"):
-                cmd = PREFIX+"/bin/interrogate_module.exe "
+                cmd = '"' + PREFIX + '/bin/interrogate_module.exe" '
         if (COMPILER=="LINUXA"):
         if (COMPILER=="LINUXA"):
-                cmd = PREFIX+"/bin/interrogate_module "
-        cmd = cmd + " -oc \"" + outc + '" -module "' + module + '" -library "' + library + '" -python '
+                cmd = '"' + PREFIX + '/bin/interrogate_module" '
+        cmd = cmd + ' -oc "' + outc + '" -module "' + module + '" -library "' + library + '" -python '
         for x in files: cmd = cmd + ' "' + x + '" '
         for x in files: cmd = cmd + ' "' + x + '" '
         oscmd(cmd)
         oscmd(cmd)
         updatefiledate(outc)
         updatefiledate(outc)
@@ -1319,9 +1319,9 @@ def CompileLIB(lib=0, obj=[], opts=[]):
         wobj = xpaths(PREFIX+"/tmp/",obj,"")
         wobj = xpaths(PREFIX+"/tmp/",obj,"")
         ALLTARGETS.append(wlib)
         ALLTARGETS.append(wlib)
         if (older(wlib, wobj)):
         if (older(wlib, wobj)):
-            cmd = 'lib.exe /nologo /OUT:'+wlib
+            cmd = 'lib.exe /nologo /OUT:"' + wlib + '"'
             if (OPTIMIZE==4): cmd = cmd + " /LTCG "
             if (OPTIMIZE==4): cmd = cmd + " /LTCG "
-            for x in wobj: cmd=cmd+" "+x
+            for x in wobj: cmd=cmd+' "'+x+'"'
             oscmd(cmd)
             oscmd(cmd)
             updatefiledate(wlib)
             updatefiledate(wlib)
 
 
@@ -1330,8 +1330,8 @@ def CompileLIB(lib=0, obj=[], opts=[]):
         wobj = []
         wobj = []
         for x in obj: wobj.append(PREFIX+"/tmp/" + x[:-4] + ".o")
         for x in obj: wobj.append(PREFIX+"/tmp/" + x[:-4] + ".o")
         if (older(wlib, wobj)):
         if (older(wlib, wobj)):
-            cmd = "ar cru " + wlib
-            for x in wobj: cmd=cmd+" "+x
+            cmd = 'ar cru "' + wlib + '"'
+            for x in wobj: cmd=cmd+' "'+x+'"'
             oscmd(cmd)
             oscmd(cmd)
             updatefiledate(wlib)
             updatefiledate(wlib)
 
 
@@ -1368,10 +1368,10 @@ def CompileLink(dll=0, obj=[], opts=[], xdep=[]):
             cmd = cmd + " /MAP /MAPINFO:EXPORTS /MAPINFO:LINES /fixed:no /incremental:no /stack:4194304 "
             cmd = cmd + " /MAP /MAPINFO:EXPORTS /MAPINFO:LINES /fixed:no /incremental:no /stack:4194304 "
             if (opts.count("NOLIBCI")): cmd = cmd + " /NODEFAULTLIB:LIBCI.LIB "
             if (opts.count("NOLIBCI")): cmd = cmd + " /NODEFAULTLIB:LIBCI.LIB "
             if (opts.count("MAXEGGDEF")): cmd = cmd + ' /DEF:pandatool/src/maxegg/MaxEgg.def'
             if (opts.count("MAXEGGDEF")): cmd = cmd + ' /DEF:pandatool/src/maxegg/MaxEgg.def'
-            cmd = cmd + " /OUT:\"" + dll + "\" /IMPLIB:\"" + lib + "\" /MAP:NUL"
-            cmd = cmd + " /LIBPATH:\""+PREFIX+"/python/libs\" "
+            cmd = cmd + ' /OUT:"' + dll + '" /IMPLIB:"' + lib + '" /MAP:NUL'
+            cmd = cmd + ' /LIBPATH:"' + PREFIX + '/python/libs" '
             for x in wobj: cmd = cmd + ' "' + x + '"'
             for x in wobj: cmd = cmd + ' "' + x + '"'
-            if (dll[-4:]==".exe"): cmd = cmd + " built/tmp/pandaIcon.res"
+            if (dll[-4:]==".exe"): cmd = cmd + ' "' + PREFIX + '/tmp/pandaIcon.res"'
             if (opts.count("D3D8") or opts.count("D3D9") or opts.count("DXDRAW") or opts.count("DXSOUND") or opts.count("DXGUID")):
             if (opts.count("D3D8") or opts.count("D3D9") or opts.count("DXDRAW") or opts.count("DXSOUND") or opts.count("DXGUID")):
                 cmd = cmd + ' /LIBPATH:"' + DIRECTXSDK + 'lib/x86"'
                 cmd = cmd + ' /LIBPATH:"' + DIRECTXSDK + 'lib/x86"'
                 cmd = cmd + ' /LIBPATH:"' + DIRECTXSDK + 'lib"'
                 cmd = cmd + ' /LIBPATH:"' + DIRECTXSDK + 'lib"'
@@ -1454,13 +1454,13 @@ def CompileLink(dll=0, obj=[], opts=[], xdep=[]):
             elif (suffix==".lib"): wobj.append(PREFIX+"/lib/"+x[:-4]+".a")
             elif (suffix==".lib"): wobj.append(PREFIX+"/lib/"+x[:-4]+".a")
             else: sys.exit("unknown suffix in object list.")
             else: sys.exit("unknown suffix in object list.")
         if (older(wdll, wobj+xdep)):
         if (older(wdll, wobj+xdep)):
-            if (dll[-4:]==".exe"): cmd = "g++ -o " + wdll + " -L" + PREFIX + "/lib"
-            else:                  cmd = "g++ -shared -o " + wdll + " -L" + PREFIX + "/lib"
+            if (dll[-4:]==".exe"): cmd = 'g++ -o "' + wdll + '" -L"' + PREFIX + '/lib"'
+            else:                  cmd = 'g++ -shared -o "' + wdll + '" -L"' + PREFIX + '/lib"'
             for x in obj:
             for x in obj:
                 suffix = x[-4:]
                 suffix = x[-4:]
-                if   (suffix==".obj"): cmd = cmd + " " + PREFIX + "/tmp/"+x[:-4]+".o"
-                elif (suffix==".dll"): cmd = cmd + " -l" + x[3:-4]
-                elif (suffix==".lib"): cmd = cmd + " " + PREFIX + "/lib/"+x[:-4]+".a"
+                if   (suffix==".obj"): cmd = cmd + ' "' + PREFIX + '/tmp/' + x[:-4] + '.o"'
+                elif (suffix==".dll"): cmd = cmd + ' -l' + x[3:-4]
+                elif (suffix==".lib"): cmd = cmd + ' "' + PREFIX + '/lib/' + x[:-4] + '.a"'
             if (PkgSelected(opts,"FMOD")):     cmd = cmd + ' -L"' + THIRDPARTY + 'fmod/lib" -lfmod-3.74'
             if (PkgSelected(opts,"FMOD")):     cmd = cmd + ' -L"' + THIRDPARTY + 'fmod/lib" -lfmod-3.74'
             if (PkgSelected(opts,"NVIDIACG")):
             if (PkgSelected(opts,"NVIDIACG")):
                 cmd = cmd + ' -L"' + THIRDPARTY + 'nvidiacg/lib" '
                 cmd = cmd + ' -L"' + THIRDPARTY + 'nvidiacg/lib" '
@@ -1587,6 +1587,8 @@ conf = conf.replace("NVERSION",str(NVERSION))
 
 
 ConditionalWriteFile(PREFIX+'/include/checkPandaVersion.h',conf)
 ConditionalWriteFile(PREFIX+'/include/checkPandaVersion.h',conf)
 
 
+ConditionalWriteFile(PREFIX + "/tmp/pythonversion", os.path.basename(PythonSDK))
+
 ##########################################################################################
 ##########################################################################################
 #
 #
 # If running under windows, compile up the icon.
 # If running under windows, compile up the icon.

+ 27 - 17
doc/makepanda/maketarball.py

@@ -100,32 +100,42 @@ The Panda3D engine.
 %build
 %build
 makepanda/makepanda.py --version VERSION --everything
 makepanda/makepanda.py --version VERSION --everything
 %install
 %install
+PYTHONV=`cat built/tmp/pythonversion`
 rm -rf $RPM_BUILD_ROOT
 rm -rf $RPM_BUILD_ROOT
-PANDA=$RPM_BUILD_ROOT/usr/share/panda3d
-mkdir -p $PANDA
+mkdir -p $RPM_BUILD_ROOT/usr/bin
+mkdir -p $RPM_BUILD_ROOT/usr/include
+mkdir -p $RPM_BUILD_ROOT/usr/lib
+mkdir -p $RPM_BUILD_ROOT/usr/share/panda3d
+mkdir -p $RPM_BUILD_ROOT/usr/lib/$PYTHONV/lib-dynload
 mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
 mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
 mkdir -p $RPM_BUILD_ROOT/usr/bin
 mkdir -p $RPM_BUILD_ROOT/usr/bin
-cp --recursive built/bin     $PANDA/bin
-cp --recursive built/lib     $PANDA/lib
-cp --recursive built/etc     $PANDA/etc
-cp --recursive built/include $PANDA/include
-cp --recursive direct        $PANDA/direct
-cp built/direct/__init__.py  $PANDA/direct/__init__.py
-cp --recursive models        $PANDA/models
-cp --recursive samples       $PANDA/samples
-cp --recursive SceneEditor   $PANDA/SceneEditor
-cp --recursive Config.prc    $PANDA/Config.prc
-cp --recursive LICENSE       $PANDA/LICENSE
-echo "/usr/share/panda3d/lib" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/panda3d.conf
-for x in $PANDA/bin/* ; do
+
+sed -e 's@$THIS_PRC_DIR/[.]@/usr/share/panda3d@' < doc/Config.prc > $RPM_BUILD_ROOT/etc/Config.prc
+
+cp --recursive built/lib     $RPM_BUILD_ROOT/usr/lib/panda3d
+cp --recursive built/include $RPM_BUILD_ROOT/usr/include/panda3d
+cp --recursive direct        $RPM_BUILD_ROOT/usr/lib/$PYTHONV/direct
+cp --recursive built/pandac  $RPM_BUILD_ROOT/usr/lib/$PYTHONV/pandac
+cp built/direct/__init__.py  $RPM_BUILD_ROOT/usr/lib/$PYTHONV/direct/__init__.py
+cp --recursive models        $RPM_BUILD_ROOT/usr/share/panda3d/models
+cp --recursive samples       $RPM_BUILD_ROOT/usr/share/panda3d/samples
+cp --recursive SceneEditor   $RPM_BUILD_ROOT/usr/lib/$PYTHONV/SceneEditor
+cp doc/LICENSE               $RPM_BUILD_ROOT/usr/lib/panda3d/LICENSE
+cp doc/LICENSE               $RPM_BUILD_ROOT/usr/share/panda3d/LICENSE
+cp doc/LICENSE               $RPM_BUILD_ROOT/usr/include/panda3d/LICENSE
+echo "/usr/lib/panda3d" >    $RPM_BUILD_ROOT/etc/ld.so.conf.d/panda3d.conf
+cp built/bin/*               $RPM_BUILD_ROOT/usr/bin/
+
+for x in built/lib/* ; do
   base=`basename $x`
   base=`basename $x`
-  ln -sf /usr/share/panda3d/bin/$base $RPM_BUILD_ROOT/usr/bin
+  ln -sf /usr/lib/panda3d/$base $RPM_BUILD_ROOT/usr/lib/$PYTHONV/lib-dynload/$base
 done
 done
-for x in $PANDA/direct/src/* ; do
+for x in $RPM_BUILD_ROOT/usr/lib/$PYTHONV/direct/src/* ; do
   if [ `basename $x` != extensions ] ; then
   if [ `basename $x` != extensions ] ; then
     python -c "import compileall; compileall.compile_dir('$x')"
     python -c "import compileall; compileall.compile_dir('$x')"
   fi
   fi
 done
 done
+
 %post
 %post
 /sbin/ldconfig
 /sbin/ldconfig
 %postun
 %postun