public File[] getEnvironmentIncludePath() {
   if (includePath == null) {
     //
     //   construct default include path from machine id and version id
     //
     String[] defaultInclude = new String[1];
     StringBuffer buf = new StringBuffer("/lib/");
     buf.append(GccProcessor.getMachine());
     buf.append('/');
     buf.append(GccProcessor.getVersion());
     buf.append("/include");
     defaultInclude[0] = buf.toString();
     //
     //   read specs file and look for -istart and -idirafter
     //
     String[] specs = GccProcessor.getSpecs();
     String[][] optionValues =
         GccProcessor.parseSpecs(specs, "*cpp:", new String[] {"-isystem ", "-idirafter "});
     //
     //   if no entries were found, then use a default path
     //
     if (optionValues[0].length == 0 && optionValues[1].length == 0) {
       optionValues[0] =
           new String[] {"/usr/local/include", "/usr/include", "/usr/include/win32api"};
     }
     //
     //  remove mingw entries.
     //    For MinGW compiles this will mean the
     //      location of the sys includes will be
     //      wrong in dependencies.xml
     //      but that should have no significant effect
     for (int i = 0; i < optionValues.length; i++) {
       for (int j = 0; j < optionValues[i].length; j++) {
         if (optionValues[i][j].indexOf("mingw") > 0) {
           optionValues[i][j] = null;
         }
       }
     }
     //
     //   if cygwin then
     //     we have to prepend location of gcc32
     //       and .. to start of absolute filenames to
     //       have something that will exist in the
     //       windows filesystem
     if (GccProcessor.isCygwin()) {
       GccProcessor.convertCygwinFilenames(optionValues[0]);
       GccProcessor.convertCygwinFilenames(optionValues[1]);
       GccProcessor.convertCygwinFilenames(defaultInclude);
     }
     int count = CUtil.checkDirectoryArray(optionValues[0]);
     count += CUtil.checkDirectoryArray(optionValues[1]);
     count += CUtil.checkDirectoryArray(defaultInclude);
     includePath = new File[count];
     int index = 0;
     for (int i = 0; i < optionValues.length; i++) {
       for (int j = 0; j < optionValues[i].length; j++) {
         if (optionValues[i][j] != null) {
           includePath[index++] = new File(optionValues[i][j]);
         }
       }
     }
     for (int i = 0; i < defaultInclude.length; i++) {
       if (defaultInclude[i] != null) {
         includePath[index++] = new File(defaultInclude[i]);
       }
     }
   }
   return (File[]) includePath.clone();
 }
Example #2
0
 /** Returns library path. */
 public File[] getLibraryPath() {
   if (libDirs == null) {
     //
     //   construct gcc lib path from machine and version
     //
     StringBuffer buf = new StringBuffer("/lib/gcc-lib/");
     buf.append(GccProcessor.getMachine());
     buf.append('/');
     buf.append(GccProcessor.getVersion());
     //
     //   build default path from gcc and system /lib and /lib/w32api
     //
     String[] impliedLibPath = new String[] {buf.toString(), "/lib/w32api", "/lib"};
     //
     //     read gcc specs file for other library paths
     //
     String[] specs = GccProcessor.getSpecs();
     String[][] libpaths = GccProcessor.parseSpecs(specs, "*link:", new String[] {"%q"});
     String[] libpath;
     if (libpaths[0].length > 0) {
       libpath = new String[libpaths[0].length + 3];
       int i = 0;
       for (; i < libpaths[0].length; i++) {
         libpath[i] = libpaths[0][i];
       }
       libpath[i++] = buf.toString();
       libpath[i++] = "/lib/w32api";
       libpath[i++] = "/lib";
     } else {
       //
       //   if a failure to find any matches then
       //      use some default values for lib path entries
       libpath =
           new String[] {
             "/usr/local/lib/mingw",
             "/usr/local/lib",
             "/usr/lib/w32api",
             "/usr/lib/mingw",
             "/usr/lib",
             buf.toString(),
             "/lib/w32api",
             "/lib"
           };
     }
     for (int i = 0; i < libpath.length; i++) {
       if (libpath[i].indexOf("mingw") >= 0) {
         libpath[i] = null;
       }
     }
     //
     //   if cygwin then
     //     we have to prepend location of gcc32
     //       and .. to start of absolute filenames to
     //       have something that will exist in the
     //       windows filesystem
     if (GccProcessor.isCygwin()) {
       GccProcessor.convertCygwinFilenames(libpath);
     }
     //
     //  check that remaining entries are actual directories
     //
     int count = CUtil.checkDirectoryArray(libpath);
     //
     //   populate return array with remaining entries
     //
     libDirs = new File[count];
     int index = 0;
     for (int i = 0; i < libpath.length; i++) {
       if (libpath[i] != null) {
         libDirs[index++] = new File(libpath[i]);
       }
     }
   }
   return libDirs;
 }