- /* Logic:
- 1. Try the SDCCDIR environment variable.
- 2. If (1) fails, and if the argv[0] includes a path, attempt to find the include
- and library paths with respect to that. Note that under win32
- argv[0] is always the full path to the program.
- 3. If (1) and (2) fail, fall back to the compile time defaults.
-
- Detecting assumes the same layout as when configured. If the
- directories have been further moved about then discovery will
- fail.
- */
-
- /* Some input cases:
- "c:\fish\sdcc\bin\sdcc"
- "../bin/sdcc"
- "/home/fish/bin/sdcc"
-
- Note that ./sdcc is explicitly not supported as there isn't
- enough information.
- */
- /* bindir is handled differently to the lib and include directories.
- It's rather unfortunate, but required due to the different
- install and development layouts. Logic is different as well.
- Sigh.
+ char *p;
+ char buf[PATH_MAX];
+
+ /*
+ * Search logic:
+ *
+ * 1. - $SDCC_INCLUDE
+ * 2. - $SDCC_HOME/PREFIX2DATA_DIR/INCLUDE_DIR_SUFFIX
+ * 2. - path(argv[0])/BIN2DATA_DIR/INCLUDE_DIR_SUFFIX
+ * 3. - DATADIR/INCLUDE_DIR_SUFFIX (only on *nix)