+ addSetHead (&pipeSet, yyin);
+ }
+
+ return 0;
+}
+
+/* Set bin paths */
+static void
+setBinPaths(const char *argv0)
+{
+ char *p;
+ char buf[PATH_MAX];
+
+ /*
+ * Search logic:
+ *
+ * 1. - $SDCCDIR/PREFIX2BIN_DIR
+ * 2. - path(argv[0])
+ * 3. - $PATH
+ */
+
+ /* do it in reverse mode, so that addSetHead() can be used
+ instead of slower addSet() */
+
+ if ((p = getBinPath(argv0)) != NULL)
+ addSetHead(&binPathSet, Safe_strdup(p));
+
+ if ((p = getenv(SDCC_DIR_NAME)) != NULL) {
+ SNPRINTF(buf, sizeof buf, "%s" PREFIX2BIN_DIR, p);
+ addSetHead(&binPathSet, Safe_strdup(buf));
+ }
+
+ if (options.printSearchDirs) {
+ printf("programs:\n");
+ fputStrSet(stdout, binPathSet);
+ }
+}
+
+/* Set system include path */
+static void
+setIncludePath(void)
+{
+ char *p;
+
+ /*
+ * Search logic:
+ *
+ * 1. - $SDCC_INCLUDE
+ * 2. - $SDCC_HOME/PREFIX2DATA_DIR/INCLUDE_DIR_SUFFIX
+ * 3. - path(argv[0])/BIN2DATA_DIR/INCLUDE_DIR_SUFFIX
+ * 4. - DATADIR/INCLUDE_DIR_SUFFIX (only on *nix)
+ */
+
+ includeDirsSet = appendStrSet(dataDirsSet, NULL, INCLUDE_DIR_SUFFIX);
+
+ if ((p = getenv(SDCC_INCLUDE_NAME)) != NULL)
+ addSetHead(&includeDirsSet, p);
+
+ if (options.printSearchDirs) {
+ printf("includedir:\n");
+ fputStrSet(stdout, includeDirsSet);
+ }
+}
+
+/* Set system lib path */
+static void
+setLibPath(void)
+{
+ char *p;
+
+ /*
+ * Search logic:
+ *
+ * 1. - $SDCC_LIB
+ * 2. - $SDCC_HOME/PREFIX2DATA_DIR/LIB_DIR_SUFFIX/<model>
+ * 3. - path(argv[0])/BIN2DATA_DIR/LIB_DIR_SUFFIX/<model>
+ * 4. - DATADIR/LIB_DIR_SUFFIX/<model> (only on *nix)
+ */
+
+ libDirsSet = appendStrSet(dataDirsSet, NULL, LIB_DIR_SUFFIX);
+
+ if ((p = getenv(SDCC_LIB_NAME)) != NULL)
+ addSetHead(&libDirsSet, p);
+
+ if (options.printSearchDirs) {
+ printf("libdir:\n");
+ fputStrSet(stdout, libDirsSet);
+ }
+}
+
+/* Set data path */
+static void
+setDataPaths(const char *argv0)
+{
+ char *p;
+ char buf[PATH_MAX];
+
+ /*
+ * Search logic:
+ *
+ * 1. - $SDCC_HOME/PREFIX2DATA_DIR
+ * 2. - path(argv[0])/BIN2DATA_DIR
+ * 3. - DATADIR (only on *nix)
+ */
+
+ if ((p = getenv(SDCC_DIR_NAME)) != NULL) {
+ SNPRINTF(buf, sizeof buf, "%s" PREFIX2DATA_DIR, p);
+ addSet(&dataDirsSet, Safe_strdup(buf));
+ }
+
+ if ((p = getBinPath(argv0)) != NULL) {
+ SNPRINTF(buf, sizeof buf, "%s" BIN2DATA_DIR, p);
+ addSet(&dataDirsSet, Safe_strdup(buf));
+ }
+
+#ifdef _WIN32
+ if (peekSet(dataDirsSet) == NULL) {
+ /* this should never happen... */
+ wassertl(0, "Can't get binary path");
+ }
+#else
+ addSet(&dataDirsSet, Safe_strdup(DATADIR));
+#endif
+
+ if (options.printSearchDirs) {
+ printf("datadir:\n");
+ fputStrSet(stdout, dataDirsSet);
+ }
+
+ setIncludePath();
+ setLibPath();
+}
+
+static void
+initValues (void)
+{
+ populateMainValues (_baseValues);
+ setMainValue ("port", port->target);
+ setMainValue ("objext", port->linker.rel_ext);
+ setMainValue ("asmext", port->assembler.file_ext);
+
+ setMainValue ("dstfilename", dstFileName);
+ setMainValue ("fullsrcfilename", fullSrcFileName ? fullSrcFileName : "fullsrcfilename");
+
+ if (options.cc_only && fullDstFileName)
+ /* compile + assemble and -o given: -o specifies name of object file */
+ {
+ setMainValue ("objdstfilename", fullDstFileName);