diff --git a/dtool/Config.pp b/dtool/Config.pp index 22c93e3add..f5e059d845 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -76,13 +76,19 @@ #endif // What is the default install directory for all trees in the Panda -// suite? You may also override this for a particular tree by -// defining a variable name like DTOOL_INSTALL or PANDA_INSTALL. This -// variable will have no effect when you are using the cttools to -// control your attachment to the trees; in this case, the install -// directory for each tree will by default be the root of the tree -// itself (although this may be overridden). -#define INSTALL_DIR /usr/local/panda +// suite? The default value for this variable is provided by +// ppremake; on Unix machines it is the value of --prefix passed in to +// the configure script, and on Windows machines the default is +// hardcoded to C:\Panda3d. + +// You may also override this for a particular tree by defining a +// variable name like DTOOL_INSTALL or PANDA_INSTALL. This variable +// will have no effect when you are using the cttools to control your +// attachment to the trees; in this case, the install directory for +// each tree will by default be the root of the tree itself (although +// this may be overridden). + +// #define INSTALL_DIR /usr/local/panda // If you intend to use Panda only as a Python module, you may find // the following define useful (but you should put in the correct path diff --git a/dtool/Package.pp b/dtool/Package.pp index 0096833d17..cf2162abcc 100644 --- a/dtool/Package.pp +++ b/dtool/Package.pp @@ -80,7 +80,16 @@ #set PPREMAKE_CONFIG $[unixfilename $[PPREMAKE_CONFIG]] #print Reading $[PPREMAKE_CONFIG] #include $[PPREMAKE_CONFIG] + +#elif $[wildcard $[unixfilename $[INSTALL_DIR]]/Config.pp] + // If the PPREMAKE_CONFIG variable is not, but there exists a + // Config.pp in the compiled-in INSTALL_DIR, use that one by default. + #set PPREMAKE_CONFIG $[unixfilename $[INSTALL_DIR]]/Config.pp + #print Reading $[PPREMAKE_CONFIG] + #include $[PPREMAKE_CONFIG] + #else + // Otherwise, just carry on without it. #print Environment variable PPREMAKE_CONFIG not set; using defaults. #endif diff --git a/ppremake/config_msvc.h b/ppremake/config_msvc.h index 1867a060d0..92b8367836 100644 --- a/ppremake/config_msvc.h +++ b/ppremake/config_msvc.h @@ -79,9 +79,12 @@ /* Name of package */ #define PACKAGE "ppremake" +/* The default value of INSTALL_DIR within ppremake. */ +#define INSTALL_DIR C:\\Panda3d + /**************** UPDATE VERSION NUMBER HERE **************** ** Also be sure to change the version number ** ** at the beginning of configure.in. ** **************** ****************/ -#define VERSION "1.13" +#define VERSION "1.14" /**************** UPDATE VERSION NUMBER HERE ****************/ diff --git a/ppremake/configure.in b/ppremake/configure.in index 13a74b92a6..4cf0651428 100644 --- a/ppremake/configure.in +++ b/ppremake/configure.in @@ -5,7 +5,7 @@ dnl **************** UPDATE VERSION NUMBER HERE **************** dnl ** Also be sure to change the version number ** dnl ** at the end of config_msvc.h. ** dnl **************** **************** -AM_INIT_AUTOMAKE(ppremake, 1.13) +AM_INIT_AUTOMAKE(ppremake, 1.14) dnl **************** UPDATE VERSION NUMBER HERE **************** AM_CONFIG_HEADER(config.h) @@ -20,6 +20,7 @@ AC_CANONICAL_HOST if test "${CXXFLAGS+set}" != set -a "${CFLAGS+set}" = set; then CXXFLAGS=$CFLAGS fi +CPPFLAGS="${CPPFLAGS} -DINSTALL_DIR="'$(prefix)' # Save these variables for later, so we can easily append to them or # change them. @@ -84,5 +85,4 @@ AC_DEFINE_UNQUOTED(PLATFORM, "$PLATFORM", [The platform ppremake is compiled for. This primarily controls the initial setting of the PLATFORM ppremake variable.]) - AC_OUTPUT(Makefile) diff --git a/ppremake/filename.cxx b/ppremake/filename.cxx index df64a041e1..2b49e1248a 100644 --- a/ppremake/filename.cxx +++ b/ppremake/filename.cxx @@ -1159,7 +1159,42 @@ find_on_searchpath(const DSearchPath &searchpath) { //////////////////////////////////////////////////////////////////// bool Filename:: scan_directory(vector_string &contents) const { -#if defined(HAVE_GLOB_H) +#if defined(WIN32_VC) + // Use FindFirstFile()/FindNextFile() to walk through the list of + // files in a directory. + size_t orig_size = contents.size(); + + string match; + if (empty()) { + match = "*.*"; + } else { + match = to_os_specific() + "\\*.*"; + } + WIN32_FIND_DATA find_data; + + HANDLE handle = FindFirstFile(match.c_str(), &find_data); + if (handle == INVALID_HANDLE_VALUE) { + if (GetLastError() == ERROR_NO_MORE_FILES) { + // No matching files is not an error. + return true; + } + return false; + } + + do { + string filename = find_data.cFileName; + if (filename != "." && filename != "..") { + contents.push_back(filename); + } + } while (FindNextFile(handle, &find_data)); + + bool scan_ok = (GetLastError() == ERROR_NO_MORE_FILES); + FindClose(handle); + + sort(contents.begin() + orig_size, contents.end()); + return scan_ok; + +#elif defined(HAVE_GLOB_H) // In some cases, particularly with NFS, it seems that opendir() // .. readdir() fails to properly read the entire directory ("Value // too large for defined data type"), but glob() succeeds. @@ -1175,10 +1210,12 @@ scan_directory(vector_string &contents) const { glob_t globbuf; int r = glob(dirname.c_str(), GLOB_ERR, NULL, &globbuf); +#ifdef GLOB_NOMATCH if (r != 0 && r != GLOB_NOMATCH) { perror(dirname.c_str()); return false; } +#endif size_t offset = dirname.size() - 1; for (int i = 0; globbuf.gl_pathv[i] != NULL; i++) { @@ -1221,41 +1258,6 @@ scan_directory(vector_string &contents) const { sort(contents.begin() + orig_size, contents.end()); return true; - -#elif defined(WIN32_VC) - // Use FindFirstFile()/FindNextFile() to walk through the list of - // files in a directory. - size_t orig_size = contents.size(); - - string match; - if (empty()) { - match = "*.*"; - } else { - match = to_os_specific() + "\\*.*"; - } - WIN32_FIND_DATA find_data; - - HANDLE handle = FindFirstFile(match.c_str(), &find_data); - if (handle == INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_NO_MORE_FILES) { - // No matching files is not an error. - return true; - } - return false; - } - - do { - string filename = find_data.cFileName; - if (filename != "." && filename != "..") { - contents.push_back(filename); - } - } while (FindNextFile(handle, &find_data)); - - bool scan_ok = (GetLastError() == ERROR_NO_MORE_FILES); - FindClose(handle); - - sort(contents.begin() + orig_size, contents.end()); - return scan_ok; #else // Don't know how to scan directories! diff --git a/ppremake/ppremake.cxx b/ppremake/ppremake.cxx index 9b900b9413..ae0d0e0cea 100644 --- a/ppremake/ppremake.cxx +++ b/ppremake/ppremake.cxx @@ -28,6 +28,8 @@ #include #include +#define STRINGIZE(x) #x + bool unix_platform = false; bool windows_platform = false; bool dry_run = false; @@ -71,6 +73,7 @@ usage() { " -h Display this page.\n" " -V Report the version of ppremake, and exit.\n" + " -I Report the compiled-in default for INSTALL_DIR, and exit.\n" " -v Turn on verbose output (may help in debugging .pp files).\n" " -vv Be very verbose (if you're getting desperate).\n" " -P Report the current platform name, and exit.\n\n" @@ -103,6 +106,12 @@ report_version() { << ".\n"; } +static void +report_install_dir() { + cerr << "Default value for INSTALL_DIR is " + << STRINGIZE(INSTALL_DIR) << ".\n"; +} + static void report_platform() { cerr << "ppremake built for default platform " << PLATFORM << ".\n"; @@ -223,7 +232,7 @@ main(int argc, char *argv[]) { string progname = argv[0]; extern char *optarg; extern int optind; - const char *optstr = "hVvPD:drnNp:c:s:"; + const char *optstr = "hVIvPD:drnNp:c:s:"; bool any_d = false; bool dependencies_stale = false; @@ -253,6 +262,11 @@ main(int argc, char *argv[]) { exit(0); break; + case 'I': + report_install_dir(); + exit(0); + break; + case 'v': ++verbose; break; @@ -339,6 +353,7 @@ main(int argc, char *argv[]) { global_scope.define_variable("PLATFORM", platform); global_scope.define_variable("PACKAGE_FILENAME", PACKAGE_FILENAME); global_scope.define_variable("SOURCE_FILENAME", SOURCE_FILENAME); + global_scope.define_variable("INSTALL_DIR", STRINGIZE(INSTALL_DIR)); if (got_ppremake_config) { // If this came in on the command line, define a variable as such. @@ -349,8 +364,11 @@ main(int argc, char *argv[]) { // Also, it's convenient to have a way to represent the literal tab // character, without actually putting a literal tab character in - // the source file. + // the source file. Similarly with some other special characters. global_scope.define_variable("TAB", "\t"); + global_scope.define_variable("SPACE", " "); + global_scope.define_variable("DOLLAR", "$"); + global_scope.define_variable("HASH", "#"); PPMain ppmain(&global_scope); if (!ppmain.read_source(".")) {