diff --git a/Changelog b/Changelog index 385859f..e549a0a 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,12 @@ Changelog for libmawk ~~~~~~~~~~~~~~~~~~~~~ + +libmawk 1.0.3 (released: 2021-07-21, r1328) + [build] -Fix: move fstool detection from target to host - needed only for installation + [build] -Fix: suppress warning on non-existing optional /local/nofork + [build] -Fix: make install over a new version over an old version shouldn't fail on lib symlink creation + [build] -Add: no-fork configure-time option + [vio] -Fix: missing extern caused multiple definitions of the same variable for vio_fifo libmawk 1.0.2 (released: 2019-06-22, r1318) [core] -Fix: C function calls with uninitialized variables: not sure if array or not, delay resolving it until all the script is parsed so we see if the symbol is an array diff --git a/Release_notes b/Release_notes index f602e88..311bb97 100644 --- a/Release_notes +++ b/Release_notes @@ -1,6 +1,6 @@ -Release notes for libmawk 1.0.2 +Release notes for libmawk 1.0.3 -Minor bugfix release; fixes C function call with uninitialized -variables and make uninstall. +Minor bugfix release (missing extern and build system fixes). Adds +compile time option for no-fork. diff --git a/doc/TODO b/doc/TODO index e1a3f18..02da809 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,3 +1,15 @@ +0000. packaging and fawk + - packaging: + - rename example manpage to have libmawk prefix + - make sure example manpage .TH has no space and matches the name + - fawk + - implement the . array syntax + - array in array (for orig implementation only?) + - isarray() + - textblock + - vararg? + + packging: - manual page headers use the wrong section @@ -46,7 +58,7 @@ 3.0 extend arrays - array copy - - array in array (for orig implementation only?) + - length(array) as in gawk? POSIX: length() works on strings only update test_3rd funlen accordingly! diff --git a/scconfig/hooks.c b/scconfig/hooks.c index cfab11f..601b120 100644 --- a/scconfig/hooks.c +++ b/scconfig/hooks.c @@ -101,6 +101,12 @@ /* Runs when things should be detected for the host system */ int hook_detect_host() { + require("fstools/chmodx", 0, 1); + require("fstools/cp", 0, 1); + require("fstools/rm", 0, 1); + require("fstools/ln", 0, 1); + require("fstools/mkdir", 0, 1); + return 0; } @@ -145,11 +151,6 @@ require("cc/soname", 0, 0); require("cc/rdynamic", 0, 0); require("cc/pragma_message", 0, 0); - require("fstools/chmodx", 0, 1); - require("fstools/cp", 0, 1); - require("fstools/rm", 0, 1); - require("fstools/ln", 0, 1); - require("fstools/mkdir", 0, 1); require("sys/types/size_t/includes", 0, 0); require("libs/fs/realpath/presents", 0, 0); require("libs/env/putenv", 0, 1); diff --git a/scconfig/src/default/arg.c b/scconfig/src/default/arg.c index b8f1558..9634fe9 100644 --- a/scconfig/src/default/arg.c +++ b/scconfig/src/default/arg.c @@ -75,7 +75,7 @@ value++; if (strcmp(key, "without") == 0) { - char *tmp, *end; + char *tmp; if (*value != '/') { const char **r, *roots[] = {"target", "host", "runtime", NULL}; for(r = roots; *r != NULL; r++) { diff --git a/scconfig/src/default/dep.c b/scconfig/src/default/dep.c index 1cc8aa9..8b17ecd 100644 --- a/scconfig/src/default/dep.c +++ b/scconfig/src/default/dep.c @@ -83,7 +83,7 @@ break; if (istrue(d)) { free(tmp); - return USER_WITHOUT; + return (fn_wrap_t *)USER_WITHOUT; } while(*sep != '/') sep--; @@ -136,7 +136,7 @@ if (get(name) == NULL) { w = get_wrap(name, &wild, &missing); - if (w == USER_WITHOUT) { + if (w == (fn_wrap_t *)USER_WITHOUT) { if (fatal) { error("Node %s is required by the software but disabled by the user using --without\n", name); abort(); diff --git a/scconfig/src/default/deps_default.c b/scconfig/src/default/deps_default.c index a086062..ad9a2ac 100644 --- a/scconfig/src/default/deps_default.c +++ b/scconfig/src/default/deps_default.c @@ -36,6 +36,7 @@ dep_add("cc/destructor", find_destructor); dep_add("cc/rdynamic", find_rdynamic); dep_add("cc/soname", find_soname); + dep_add("cc/so_undefined", find_so_undefined); dep_add("cc/wlrpath", find_wlrpath); dep_add("cc/wloutimplib", find_cc_wloutimplib); dep_add("cc/wloutputdef", find_cc_wloutputdef); @@ -95,6 +96,9 @@ dep_add("libs/fs/getwd/*", find_fs_getwd); dep_add("libs/fs/mkdir/*", find_fs_mkdir); dep_add("libs/fs/_mkdir/*", find_fs__mkdir); + dep_add("libs/fs/utime/*", find_fs_utime); + dep_add("libs/fs/_utime/*", find_fs__utime); + dep_add("libs/fs/_utime64/*", find_fs__utime64); dep_add("libs/fs/mkdtemp/*", find_fs_mkdtemp); dep_add("libs/fs/mmap/*", find_fs_mmap); dep_add("libs/fsmount/next_dev/*", find_fsmount_next_dev); @@ -105,8 +109,11 @@ dep_add("libs/fs/statfs/*", find_fs_statfs); dep_add("libs/fs/statvfs/*", find_fs_statvfs); dep_add("libs/fs/flock/*", find_fs_flock); + dep_add("libs/fs/makedev/*", find_fs_makedev); dep_add("libs/io/pipe/*", find_io_pipe); + dep_add("libs/io/pipe2/*", find_io_pipe2); + dep_add("libs/io/_pipe/*", find_io__pipe); dep_add("libs/io/dup2/*", find_io_dup2); dep_add("libs/io/fileno/*", find_io_fileno); dep_add("libs/io/lseek/*", find_io_lseek); diff --git a/scconfig/src/default/find.h b/scconfig/src/default/find.h index ae0bb93..05013d5 100644 --- a/scconfig/src/default/find.h +++ b/scconfig/src/default/find.h @@ -15,6 +15,7 @@ int find_declspec_dllexport(const char *name, int logdepth, int fatal); int find_rdynamic(const char *name, int logdepth, int fatal); int find_soname(const char *name, int logdepth, int fatal); +int find_so_undefined(const char *name, int logdepth, int fatal); int find_wlrpath(const char *name, int logdepth, int fatal); int find_cc_wloutimplib(const char *name, int logdepth, int fatal); int find_cc_wloutputdef(const char *name, int logdepth, int fatal); @@ -55,6 +56,9 @@ int find_fs_getwd(const char *name, int logdepth, int fatal); int find_fs_mkdir(const char *name, int logdepth, int fatal); int find_fs__mkdir(const char *name, int logdepth, int fatal); +int find_fs_utime(const char *name, int logdepth, int fatal); +int find_fs__utime(const char *name, int logdepth, int fatal); +int find_fs__utime64(const char *name, int logdepth, int fatal); int find_fs_mkdtemp(const char *name, int logdepth, int fatal); int find_fs_mmap(const char *name, int logdepth, int fatal); int find_fsmount_next_dev(const char *name, int logdepth, int fatal); @@ -65,6 +69,7 @@ int find_fs_statfs(const char *name, int logdepth, int fatal); int find_fs_statvfs(const char *name, int logdepth, int fatal); int find_fs_flock(const char *name, int logdepth, int fatal); +int find_fs_makedev(const char *name, int logdepth, int fatal); /* printf */ int find_printf_x(const char *name, int logdepth, int fatal); @@ -125,6 +130,8 @@ /* find_io.c */ int find_io_pipe(const char *name, int logdepth, int fatal); +int find_io_pipe2(const char *name, int logdepth, int fatal); +int find_io__pipe(const char *name, int logdepth, int fatal); int find_io_dup2(const char *name, int logdepth, int fatal); int find_io_fileno(const char *name, int logdepth, int fatal); int find_io_lseek(const char *name, int logdepth, int fatal); diff --git a/scconfig/src/default/find_cc.c b/scconfig/src/default/find_cc.c index cbb8cc0..83adf40 100644 --- a/scconfig/src/default/find_cc.c +++ b/scconfig/src/default/find_cc.c @@ -645,6 +645,61 @@ return 1; } +int find_so_undefined(const char *name, int logdepth, int fatal) +{ + static const char *test_c = + NL "#include " + NL "void intentionally_undefined_symbol(void);" + NL "int main() {" + NL " intentionally_undefined_symbol();" + NL " puts(\"OK\");" + NL " return 0;" + NL "}" + NL ; + const char **t, *try_ldflags[] = { + "", + "-undefined dynamic_lookup", /* OSX + clang */ + NULL + }; + + require("cc/cc", logdepth, fatal); + require("cc/ldflags_dynlib", logdepth, fatal); + + report("Checking for so_undefined... "); + logprintf(logdepth, "find_so_undefined: trying to find so_undefined...\n"); + logdepth++; + + for(t = try_ldflags; *t != NULL; t++) { + const char *fpic; + char *ldf, *oname = ".o", *libname_dyn, *cflags_c; + int res1, res2; + + fpic = get("cc/fpic"); + if (fpic == NULL) fpic = ""; + + cflags_c = str_concat(" ", "-c", fpic, NULL); + + libname_dyn = (char *)get("sys/ext_dynlib"); + ldf = str_concat(" ", get("cc/ldflags_dynlib"), *t, NULL); + res1 = compile_code(logdepth, test_c, &oname, NULL, cflags_c, NULL); + res2 = compile_file(logdepth, oname, &libname_dyn, NULL, NULL, ldf); + unlink(libname_dyn); + unlink(oname); + free(libname_dyn); + free(oname); + free(cflags_c); + + if ((res1 == 0) && (res2 == 0)) { + put(name, *t); + report("OK (%s)\n", *t); + return 0; + } + } + + report("Not found.\n"); + return 1; +} + int find_wlrpath(const char *name, int logdepth, int fatal) { @@ -692,6 +747,9 @@ NL "#include " NL "#include " NL "#include %s" + NL "#ifndef RTLD_NOW" + NL "#define RTLD_NOW RTLD_LAZY" /* on old BSD and probably on SunOS */ + NL "#endif" NL "int main() {" NL " void *handle = NULL;" NL " void (*func)() = NULL;" @@ -699,12 +757,12 @@ NL NL " handle = dlopen(\"%s\", RTLD_NOW);" NL " if (handle == NULL) {" - NL " printf(\"dlopen fails: \", dlerror());" + NL " printf(\"dlopen fails: %%s\", dlerror());" NL " return 1;" NL " }" NL " func = dlsym(handle, \"hello\");" NL " if (func == NULL) {" - NL " printf(\"dlsym fails: \", dlerror());" + NL " printf(\"dlsym fails: %%s\", dlerror());" NL " return 1;" NL " }" NL " func();" @@ -743,7 +801,7 @@ libname_dyn = libname = (char *)get("sys/ext_dynlib"); if ((compile_code(logdepth, test_lib, &oname, NULL, cflags_c, NULL) != 0) || (compile_file(logdepth, oname, &libname_dyn, NULL, NULL, concated_ldflags) != 0)) { - report("FAILED (compiling dynlib)\n"); + report("('%s': nope) ", concated_ldflags); } else { sprintf(test_host_app, test_host, ld_include, libname_dyn); @@ -778,6 +836,7 @@ if (try_dynlib(logdepth, NULL, concat_nodes("-dynamic -shared", "cc/rdynamic", "libs/ldl", NULL), "cc/ldflags_dynlib", "-dynamic -shared", NULL, get("libs/ldl"))) return 0; if (try_dynlib(logdepth, NULL, concat_nodes("-shared", "cc/rdynamic", "libs/ldl", NULL), "cc/ldflags_dynlib", "-shared", NULL, get("libs/ldl"))) return 0; + if (try_dynlib(logdepth, NULL, concat_nodes("-G", "libs/ldl", NULL), "cc/ldflags_dynlib", "-G", NULL, get("libs/ldl"))) return 0; /* xlc (on AIX) */ report("Not found.\n"); return 1; } diff --git a/scconfig/src/default/find_fscalls.c b/scconfig/src/default/find_fscalls.c index 7e990d2..7f43fec 100644 --- a/scconfig/src/default/find_fscalls.c +++ b/scconfig/src/default/find_fscalls.c @@ -92,6 +92,7 @@ char *test_c = NL "#include " NL "#include " + NL "#include " NL "int main() {" NL " DIR *dirp;" NL " struct dirent *dp;" @@ -397,6 +398,7 @@ { char *test_c = NL "#include " + NL "#include " NL "int main() {" NL " char b[1024];" NL " if (getcwd(b, sizeof(b)) != NULL)" @@ -419,6 +421,7 @@ { char *test_c = NL "#include " + NL "#include " NL "int main() {" NL " char b[1024];" NL " if (_getcwd(b, sizeof(b)) != NULL)" @@ -442,6 +445,7 @@ { char *test_c = NL "#include " + NL "#include " NL "int main() {" NL " char b[8192];" NL " if (getwd(b) != NULL)" @@ -574,6 +578,83 @@ rmdir(dir); return try_fail(logdepth, "libs/fs/_mkdir"); +} + +static int find_utime_impl(const char *name, int logdepth, int fatal, + const char* key, const char* funcname, const char* typename) +{ + char test_c[1024+4096]; + const char *test_c_templ = + NL "void puts_OK();" + NL "int main(int argc, char* argv[])" + NL "{" + NL " struct %s buf;" + NL " buf.actime = buf.modtime = 1610958044;" + NL " if (%s(\"%s\", &buf) == 0)" + NL " puts_OK();" + NL " return 0;" + NL "}" + NL "#include " + NL "void puts_OK()" + NL "{" + NL " puts(\"OK\");" + NL "}" + NL; + + const char* includes[] = + { + /* *NIX */ + "#include \n#include ", + + /* windoz */ + "#include ", + + NULL + }; + const char** inc; + char* tmpf; + + tmpf = tempfile_new(".txt"); + sprintf(test_c, test_c_templ, typename, funcname, tmpf); + + require("cc/cc", logdepth, fatal); + + report("Checking for %s... ", funcname); + logprintf(logdepth, "find_fs_%s: trying to find %s()...\n", funcname, funcname); + logdepth++; + + for (inc=includes; *inc; ++inc) + { + if (try_icl(logdepth, key, test_c, *inc, NULL, NULL)) + { + unlink(tmpf); + free(tmpf); + return 0; + } + } + + unlink(tmpf); + free(tmpf); + + return try_fail(logdepth, key); +} + +int find_fs_utime(const char *name, int logdepth, int fatal) +{ + return find_utime_impl(name, logdepth, fatal, + "libs/fs/utime", "utime", "utimbuf"); +} + +int find_fs__utime(const char *name, int logdepth, int fatal) +{ + return find_utime_impl(name, logdepth, fatal, + "libs/fs/_utime", "_utime", "_utimbuf"); +} + +int find_fs__utime64(const char *name, int logdepth, int fatal) +{ + return find_utime_impl(name, logdepth, fatal, + "libs/fs/_utime64", "_utime64", "__utimbuf64"); } int find_fs_mkdtemp(const char *name, int logdepth, int fatal) @@ -806,3 +887,32 @@ if (try_icl(logdepth, key, test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, key); } + +int find_fs_makedev(const char *name, int logdepth, int fatal) +{ + const char *key = "libs/fs/makedev"; + const char *test_c = + NL "#include " + NL "int main() {" + NL " if (1 == major(makedev(1, 2)) && 2 == minor(makedev(1, 2)))" + NL " puts(\"OK\");" + NL " return 0;" + NL "}" + NL; + const char *includes[] = { + "#include ", + NULL + }; + const char **i; + + require("cc/cc", logdepth, fatal); + + report("Checking for makedev()... "); + logprintf(logdepth, "find_fs_makedev: trying to find makedev...\n"); + logdepth++; + + for (i = includes; *i != NULL; i++) + if (try_icl(logdepth, key, test_c, *i, NULL, NULL)) + return 0; + return try_fail(logdepth, key); +} diff --git a/scconfig/src/default/find_fstools.c b/scconfig/src/default/find_fstools.c index 5dc894d..d2d230e 100644 --- a/scconfig/src/default/find_fstools.c +++ b/scconfig/src/default/find_fstools.c @@ -262,6 +262,8 @@ expected = src; else expected++; + + logprintf(logdepth, "test_ar path_sep='%s' expected='%s' result='%s'\n", path_sep, expected, result); ret = strncmp(expected, result, strlen(expected)) == 0; if (ret) { diff --git a/scconfig/src/default/find_io.c b/scconfig/src/default/find_io.c index c94a3d6..20aa2ad 100644 --- a/scconfig/src/default/find_io.c +++ b/scconfig/src/default/find_io.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "libs.h" #include "log.h" #include "db.h" @@ -33,6 +34,7 @@ { char *test_c = NL "#include " + NL "#include " NL "int main() {" NL " int fd[2];" NL " if (pipe(fd) == 0)" @@ -47,9 +49,53 @@ logprintf(logdepth, "find_io_pipe: trying to find pipe(2)...\n"); logdepth++; - - if (try_icl(logdepth, "libs/io/pipe", test_c, NULL, NULL, NULL)) return 0; + if (try_icl(logdepth, "libs/io/pipe", test_c, "#include \n", NULL, NULL)) return 0; return try_fail(logdepth, "libs/io/pipe"); +} + +int find_io_pipe2(const char *name, int logdepth, int fatal) +{ + const char *test_c = + NL "#include " + NL "#include " + NL "int main() {" + NL " int fd[2];" + NL " if (pipe2(fd, 0) == 0)" + NL " puts(\"OK\");" + NL " return 0;" + NL "}" + NL; + + require("cc/cc", logdepth, fatal); + + report("Checking for pipe2(2)... "); + logprintf(logdepth, "find_io_pipe2: trying to find pipe2(2)...\n"); + logdepth++; + + if (try_icl(logdepth, "libs/io/pipe2", test_c, "#include \n", NULL, NULL)) return 0; + return try_fail(logdepth, "libs/io/pipe2"); +} + +int find_io__pipe(const char *name, int logdepth, int fatal) +{ + const char *test_c = + NL "#include " + NL "int main() {" + NL " int fd[2];" + NL " if (_pipe(fd, 1024, _O_BINARY) == 0)" + NL " puts(\"OK\");" + NL " return 0;" + NL "}" + NL; + + require("cc/cc", logdepth, fatal); + + report("Checking for _pipe()... "); + logprintf(logdepth, "find_io__pipe: trying to find _pipe()...\n"); + logdepth++; + + if (try_icl(logdepth, "libs/io/_pipe", test_c, "#include \n#include \n", NULL, NULL)) return 0; + return try_fail(logdepth, "libs/io/_pipe"); } int find_io_dup2(const char *name, int logdepth, int fatal) @@ -81,7 +127,7 @@ char *test_c_ = NL "#include " NL "int main() {" - NL no_implicit(int, "%s", "%s") + /* NOTE: can not check for implicit declaration as fileno() may be a macro (e.g. on MINIX3) */ NL " if (%s(stdout) >= 0)" NL " puts(\"OK\"); " NL " return 0;" @@ -95,20 +141,26 @@ logdepth++; /* UNIX */ - sprintf(test_c, test_c_, "fileno", "fileno", "fileno"); + sprintf(test_c, test_c_, "fileno"); + if (try_icl(logdepth, "libs/io/fileno", test_c, NULL, NULL, NULL)) { + put("libs/io/fileno/call", "fileno"); + return 0; + } + + sprintf(test_c, test_c_, "fileno"); if (try_icl(logdepth, "libs/io/fileno", test_c, "#include \n", NULL, NULL)) { put("libs/io/fileno/call", "fileno"); return 0; } - sprintf(test_c, test_c_, "fileno", "fileno", "fileno"); + sprintf(test_c, test_c_, "fileno"); if (try_icl(logdepth, "libs/io/fileno", test_c, "#define _XOPEN_SOURCE\n#include \n", NULL, NULL)) { put("libs/io/fileno/call", "fileno"); return 0; } /* windows */ - sprintf(test_c, test_c_, "_fileno", "_fileno", "_fileno"); + sprintf(test_c, test_c_, "_fileno"); if (try_icl(logdepth, "libs/io/fileno", test_c, "#include \n", NULL, NULL)) { put("libs/io/fileno/call", "_fileno"); return 0; @@ -151,11 +203,15 @@ for (inc = incs, fn = fns; *fn; ++inc, ++fn) { sprintf(test_c, test_c_template, tmpf, *fn, *fn, *fn); if (try_icl(logdepth, NODE, test_c, *inc, NULL, NULL)) { + unlink(tmpf); + free(tmpf); put(NODE "/call", *fn); return 0; } } + unlink(tmpf); + free(tmpf); return try_fail(logdepth, NODE); #undef NODE } diff --git a/scconfig/src/default/find_libs.c b/scconfig/src/default/find_libs.c index 4ba66f1..41d87ca 100644 --- a/scconfig/src/default/find_libs.c +++ b/scconfig/src/default/find_libs.c @@ -59,6 +59,9 @@ char *test_c = NL "#include " NL "#include " + NL "#ifndef RTLD_NOW" + NL "#define RTLD_NOW RTLD_LAZY" /* on old BSD and probably on SunOS */ + NL "#endif" NL "int main() {" NL " void *handle;" NL " handle = dlopen(\"/this file does not exist.\", RTLD_NOW);" @@ -77,6 +80,10 @@ NL " return 0;" NL "}" NL; + + s = (char *)get("libs/ldl/presents"); + if (s != NULL) + return !istrue(s); require("cc/cc", logdepth, fatal); @@ -94,12 +101,14 @@ if (try_icl(logdepth, NULL, test_c, NULL, NULL, NULL)) { put("libs/ldl", ""); put("libs/ldl/includes", "#include \\n"); + put("libs/ldl/presents", strue); report("OK ()\n"); return 0; } if (try_icl(logdepth, NULL, test_c, NULL, NULL, "-ldl")) { put("libs/ldl", "-ldl"); put("libs/ldl/includes", "#include \\n"); + put("libs/ldl/presents", strue); report("OK (-ldl)\n"); return 0; } @@ -127,6 +136,7 @@ /* check at normal system installation */ put("libs/ldl", "-ldl-compat"); put("libs/ldl/includes", "#include \\n"); + put("libs/ldl/presents", strue); report("OK (-ldl-compat)\n"); return 0; } @@ -137,12 +147,14 @@ if (try_icl(logdepth, NULL, test_c, NULL, NULL, s)) { put("libs/ldl", ldl); put("libs/ldl/includes", "#include \\n"); + put("libs/ldl/presents", strue); report("OK (%s)\n", ldl); free(s); return 0; } free(s); } + put("libs/ldl/presents", sfalse); report("Not found\n"); return 1; } @@ -176,6 +188,7 @@ { char *test_c = NL "#include " + NL "#include " NL "int main() {" NL " errno = 0;" NL " puts(\"OK\");" diff --git a/scconfig/src/default/find_sys.c b/scconfig/src/default/find_sys.c index 79803cf..17fdbc3 100644 --- a/scconfig/src/default/find_sys.c +++ b/scconfig/src/default/find_sys.c @@ -274,6 +274,7 @@ put("sys/path_sep", "\\\\\\\\"); else put("sys/path_sep", "\\"); + put("sys/path_sep_escaped", "\\\\"); return 1; } tmp = get("sys/tmp"); @@ -307,6 +308,7 @@ require("sys/shell", logdepth, fatal); put("sys/path_sep", "/"); + put("sys/path_sep_escaped", "/"); report("Detecting temp dir..."); logprintf(logdepth, "Finding temp dir (current working directory)...\n"); @@ -338,6 +340,7 @@ put("sys/tmp", usertmp); report("using user supplied temp dir '%s' for cross-compilation\n", usertmp); logprintf(logdepth, "using user supplied temp dir '%s' for cross-compilation\n", usertmp); + logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep")); } return 0; } @@ -352,12 +355,14 @@ report(" validated %s\n", get("sys/tmp")); logprintf(logdepth, "Detected temp dir '%s'\n", get("sys/tmp")); + logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep")); return 0; } put("sys/tmp", ""); report("using temp dir fallback .\n"); logprintf(logdepth, "all temp directories failed, using . as tmp\n"); + logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep")); return 0; } diff --git a/scconfig/src/default/find_thread.c b/scconfig/src/default/find_thread.c index 4ab793b..d10e523 100644 --- a/scconfig/src/default/find_thread.c +++ b/scconfig/src/default/find_thread.c @@ -37,6 +37,7 @@ char *test_c_recursive = NL "#define _GNU_SOURCE 1 /* Needed for recursive thread-locking */" NL "#include " + NL "#include " NL "pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;" NL "int main() {" NL " pthread_attr_t a;" @@ -48,6 +49,7 @@ char *test_c_simple = NL "#include " + NL "#include " NL "int main() {" NL " pthread_attr_t a;" NL " if (pthread_attr_init(&a) == 0)" diff --git a/scconfig/src/default/find_time.c b/scconfig/src/default/find_time.c index 25a91a5..7076566 100644 --- a/scconfig/src/default/find_time.c +++ b/scconfig/src/default/find_time.c @@ -32,6 +32,7 @@ { char *test_c = NL "#include " + NL "#include " NL "int main() {" NL " if (usleep(1) == 0)" NL " puts(\"OK\");" @@ -53,6 +54,7 @@ int find_time_Sleep(const char *name, int logdepth, int fatal) { char *test_c = + NL "#include " NL "int main() {" NL " Sleep(1);" NL " puts(\"OK\");" @@ -75,6 +77,7 @@ { char *test_c = NL "#include " + NL "#include " NL "int main() {" NL " struct timeval tv;" NL " if (gettimeofday(&tv, NULL) == 0)" @@ -98,6 +101,7 @@ int find_time_ftime(const char *name, int logdepth, int fatal) { char *test_c = + NL "#include " NL "int main() {" NL " struct timeb tb;" NL " if (ftime(&tb) == 0)" diff --git a/scconfig/src/default/find_types.c b/scconfig/src/default/find_types.c index 05c0d84..38f0f2c 100644 --- a/scconfig/src/default/find_types.c +++ b/scconfig/src/default/find_types.c @@ -93,6 +93,7 @@ { char *test_c = NL "#include " + NL "#include " NL "int main() {" NL " if (sizeof(uint8_t) == 1)" NL " puts(\"OK\");" @@ -277,7 +278,7 @@ for(include = first_include; *include != NULL; include++) { sprintf(test_c, test_c_include, define, *include, typ); - if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && (strncmp(out, "OK", 2) == 0)) { + if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && out != NULL && (strncmp(out, "OK", 2) == 0)) { report("Found; "); logprintf(logdepth+1, "include %s works\n", *include); sprintf(nodeend, "includes"); diff --git a/scconfig/src/default/find_uname.c b/scconfig/src/default/find_uname.c index 6bf1d82..d6d4908 100644 --- a/scconfig/src/default/find_uname.c +++ b/scconfig/src/default/find_uname.c @@ -78,6 +78,7 @@ {"[Bb][Ss][Dd]", "BSD", "UNIX", sys_unix}, {"SunOS", "SunOS", "UNIX", sys_unix}, {"OSF1", "OSF", "UNIX", sys_unix}, /* TODO: note the difference in cflags for debugging ("-ms -g") */ + {"AIX", "AIX", "UNIX", sys_unix}, {"IRIX", "IRIX", "UNIX", sys_unix}, {"SunOS", "SunOS", "UNIX", sys_unix}, {"[Mm]inix", "Minix", "UNIX", sys_unix}, @@ -287,13 +288,15 @@ uname_guess("sys/system_name", uname, system_names); /* on windows, overwrite the path sep with the right amount of \ (the tmp finder may have left / in it) */ - if (strcmp(class, "WIN32") == 0) { + if ((strcmp(class, "WIN32") == 0) || (strcmp(class, "win32") == 0)) { int eats = istrue(get("sys/shell_eats_backslash")); if (eats) put("sys/path_sep", "\\\\\\\\"); else put("sys/path_sep", "\\"); + + put("sys/path_sep_escaped", "\\\\"); } return 0; diff --git a/scconfig/src/default/lib_compile.c b/scconfig/src/default/lib_compile.c index 12664fc..6f7dca4 100644 --- a/scconfig/src/default/lib_compile.c +++ b/scconfig/src/default/lib_compile.c @@ -72,7 +72,7 @@ int compile_file_raw(int logdepth, const char *fn_input, char **fn_output, const char *cc, const char *cflags, const char *ldflags) { - char cmd[2048]; + char *cmdline; char *cc_esc, *fn_input_esc, *fn_output_esc, *temp_out_esc, *temp_out; int ret; @@ -89,15 +89,18 @@ fn_output_esc = shell_escape_dup(*fn_output); temp_out_esc = shell_escape_dup(temp_out); - sprintf(cmd, "%s \"%s %s %s %s -o %s 2>&1\" >%s", get("/host/sys/shell"), cc_esc, cflags, fn_input_esc, ldflags, fn_output_esc, temp_out_esc); + cmdline = str_concat("", + get("/host/sys/shell"), " \"", cc_esc, " ", cflags, " ", fn_input_esc, " ", \ + ldflags, " -o ", fn_output_esc, " 2>&1\" >", temp_out_esc, NULL); free(cc_esc); free(fn_input_esc); free(fn_output_esc); free(temp_out_esc); - logprintf(logdepth, "compile: '%s'\n", cmd); - ret = system(cmd); + logprintf(logdepth, "compile: '%s'\n", cmdline); + ret = system(cmdline); + free(cmdline); log_merge(logdepth + 1, temp_out); #ifndef KEEP_TEST_SRCS unlink(temp_out); diff --git a/scconfig/src/default/lib_pkg_config.c b/scconfig/src/default/lib_pkg_config.c index 8f81220..7f1e7ab 100644 --- a/scconfig/src/default/lib_pkg_config.c +++ b/scconfig/src/default/lib_pkg_config.c @@ -30,7 +30,10 @@ { char cmd[256]; - assert(strlen(pkgname) < sizeof(cmd) - 64); + if (strlen(confname) + strlen(pkgname) > sizeof(cmd) - 16) { + logprintf(logdepth, "run_gen_config(): confname and/or pkgname too long\n"); + return -1; + } if (cflags != NULL) { sprintf(cmd, "%s --cflags %s", confname, pkgname); @@ -82,7 +85,10 @@ char cmd[256]; const char *confname = pkg_config_name(); - assert(strlen(pkgname) < sizeof(cmd) - 64); + if (strlen(confname) + strlen(pkgname) > sizeof(cmd) - 16) { + logprintf(logdepth, "run_pkg_config_modversion(): confname and/or pkgname too long\n"); + return -1; + } if (modversion != NULL) { sprintf(cmd, "%s --modversion %s", confname, pkgname); diff --git a/scconfig/src/default/lib_try.c b/scconfig/src/default/lib_try.c index e926a27..16586c7 100644 --- a/scconfig/src/default/lib_try.c +++ b/scconfig/src/default/lib_try.c @@ -140,17 +140,24 @@ char *rincludes, *rcflags, *rldflags; /* real */ char *dbincludes = NULL, *dbcflags = NULL, *dbldflags = NULL; /* what to add in the db at the end */ + if ((prefix == NULL) ? 0 : strlen(prefix) + strlen(db_cwd) > sizeof(apath)-32) { + report("ERROR: no room for try_icl_() - prefix is probably too long.\n"); + return -1; + } + /* load uincludes, uclfags, uldflags and uprefix - LOAD() inserts the u */ - l = sprintf(apath, "/arg/icl/%s/", prefix); apath_end = apath+l; - LOAD(includes); - LOAD(cflags); - LOAD(ldflags); - LOAD(prefix); - l = sprintf(apath, "/arg/icl/%s/%s/", db_cwd, prefix); apath_end = apath+l; - LOAD(includes); - LOAD(cflags); - LOAD(ldflags); - LOAD(prefix); + if (prefix != NULL) { /* prefix == NULL means non-standard icl; caller sets non-standard nodes, the user can't affect that */ + l = sprintf(apath, "/arg/icl/%s/", prefix); apath_end = apath+l; + LOAD(includes); + LOAD(cflags); + LOAD(ldflags); + LOAD(prefix); + l = sprintf(apath, "/arg/icl/%s/%s/", db_cwd, prefix); apath_end = apath+l; + LOAD(includes); + LOAD(cflags); + LOAD(ldflags); + LOAD(prefix); + } /* special case: all three specified by the user - ignore what the detector wanted, but run only once per node prefix */ if ((uincludes != NULL) && (ucflags != NULL) && (uldflags != NULL)) { @@ -201,6 +208,12 @@ rcflags = str_concat("", prfx, "-I", uprefix, "/include ", rcflags, NULL); if (old != cflags) free(old); + /* add -I to the db too */ + old = dbcflags; + dbcflags = str_concat("", "-I", uprefix, "/include ", dbcflags, NULL); + free(old); + + old = rldflags; if ((rldflags != NULL) && (*rldflags == '^')) { rldflags++; @@ -210,6 +223,11 @@ prfx = ""; rldflags = str_concat("", prfx, "-L", uprefix, "/lib ", rldflags, NULL); if (old != ldflags) free(old); + + /* add -L to the db too */ + old = dbldflags; + dbldflags = str_concat("", "-L", uprefix, "/lib ", dbldflags, NULL); + free(old); } res = try_icl__(logdepth, prefix, test_c_in, rincludes, rcflags, rldflags, dbincludes, dbcflags, dbldflags, run, accept_res); @@ -334,6 +352,11 @@ { char path[1024]; + if (strlen(key) > sizeof(path)-32) { + report("ERROR: no room for import_icl() - key is probably too long.\n"); + return -1; + } + switch(*key) { case 'l': sprintf(path, "/arg/icl/%s/ldflags", key+8); break; case 'c': sprintf(path, "/arg/icl/%s/cflags", key+7); break; @@ -342,7 +365,6 @@ default: return 1; } - printf("path='%s' fn='%s'\n", path, fn); return put(path, fn) == NULL; } @@ -371,6 +393,11 @@ NL "}" NL; + if (strlen(fieldn) + strlen(structn) + strlen(test_c_in) + 32 >= sizeof(test_c)) { + report("ERROR: no room for try_icl_sfield() - struct or field name is probably too long.\n"); + return -1; + } + sprintf(test_c, test_c_in, structn, fieldn); res = try_icl_(logdepth, prefix, test_c, includes, cflags, ldflags, 1, field_accept_res); diff --git a/scconfig/src/math/find_fpenan.c b/scconfig/src/math/find_fpenan.c index 064f4ac..7297746 100644 --- a/scconfig/src/math/find_fpenan.c +++ b/scconfig/src/math/find_fpenan.c @@ -34,6 +34,7 @@ int find_math_isnan(const char *name, int logdepth, int fatal) { char *test_c = + NL "#include " NL "int main() {" NL " if (!isnan(1.0))" NL " puts(\"OK\");" @@ -60,6 +61,7 @@ int find_math_isinf(const char *name, int logdepth, int fatal) { char *test_c = + NL "#include " NL "int main() {" NL " if (!isinf(1.0))" NL " puts(\"OK\");" @@ -87,6 +89,7 @@ int find_math_isfinite(const char *name, int logdepth, int fatal) { char *test_c = + NL "#include " NL "int main() {" NL " if (isfinite(1.0))" NL " puts(\"OK\");" @@ -114,6 +117,7 @@ int find_math_isnormal(const char *name, int logdepth, int fatal) { char *test_c = + NL "#include " NL "int main() {" NL " if (isnormal(1.0))" NL " puts(\"OK\");" @@ -145,6 +149,7 @@ int find_math_nan(const char *name, int logdepth, int fatal) { char *test_c = + NL "#include " NL "int main() {" NL " if (nan(\"foo\") != 0.0)" NL " puts(\"OK\");" @@ -174,6 +179,7 @@ char *test_c_temp = NL "#include " NL "#include " + NL "#include " NL "%s" NL NL "double s2d(const char *s)" diff --git a/scconfig/src/math/find_func.c b/scconfig/src/math/find_func.c index 40c60a9..d2d31d7 100644 --- a/scconfig/src/math/find_func.c +++ b/scconfig/src/math/find_func.c @@ -33,6 +33,7 @@ static int test_mathf(const char *name, int logdepth, int fatal, const char *fname, const char *cond) { char *test_c_template = + NL "#include " NL "float one=1.0, zero=0.0;" NL "int main() {" NL " if (%s)" diff --git a/scconfig/src/math/find_math.c b/scconfig/src/math/find_math.c index ac0ba5d..3cb8c6d 100644 --- a/scconfig/src/math/find_math.c +++ b/scconfig/src/math/find_math.c @@ -34,6 +34,7 @@ int find_math_minpack(const char *name, int logdepth, int fatal) { char *test_c = + NL "#include " NL "int main() {" NL " int one=1;" NL " if (dpmpar_(&one) != 0.0)" diff --git a/scconfig/src/parsgen/find_parsgen.c b/scconfig/src/parsgen/find_parsgen.c index 9aab1fe..02a7cba 100644 --- a/scconfig/src/parsgen/find_parsgen.c +++ b/scconfig/src/parsgen/find_parsgen.c @@ -1,6 +1,6 @@ /* scconfig - parser generator detection - Copyright (C) 2009 Tibor Palinkas + Copyright (C) 2009,2020 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -75,17 +75,18 @@ return 1; } -int find_parsgen_bison(const char *name, int logdepth, int fatal) -{ - const char *test_bison = +static const char *test_yacc = NL "%union { char *str; double num;}" - NL "%%" NL "%token TOK1;" NL "%token TOK2;" + NL "%%" NL "root: one | two;" NL "one: TOK1;" NL "two: TOK2;" NL ; + +int find_parsgen_bison(const char *name, int logdepth, int fatal) +{ char *out, *temp_in, *temp_in_esc, *cmd; int ret; char *bisfile, *s; @@ -95,7 +96,7 @@ logprintf(logdepth, "find_bison: trying to find bison...\n"); logdepth++; - temp_in = tempfile_dump(test_bison, ".y"); + temp_in = tempfile_dump(test_yacc, ".y"); bisfile = malloc(strlen(temp_in) + 32); strcpy(bisfile, temp_in); s = strrchr(bisfile+1, '.'); @@ -132,8 +133,106 @@ return 1; } +int find_parsgen_byaccic(const char *name, int logdepth, int fatal) +{ + char *out, *temp_in, *temp_in_esc, *cmd; + int ret; + char *bisfile, *s; + (void) fatal; /* not used */ + + report("Checking for byaccic... "); + logprintf(logdepth, "find_byaccic: trying to find byaccic...\n"); + logdepth++; + + temp_in = tempfile_dump(test_yacc, ".y"); + bisfile = malloc(strlen(temp_in) + 32); + strcpy(bisfile, temp_in); + s = strrchr(bisfile+1, '.'); + strcpy(s, ".tab.c"); + if (is_file(bisfile)) { + report("ERROR: %s exists, and I don't dare to delete it. Can't test byaccic, please remove the file by hand.\n", bisfile); + logprintf(logdepth, "ERROR: %s exists, and I don't dare to delete it. Can't test byaccic, please remove the file by hand.\n", bisfile); + exit(1); + } + temp_in_esc = shell_escape_dup(temp_in); + cmd = malloc(strlen(temp_in_esc)*2 + 32); + sprintf(cmd, "byaccic -o %s %s", bisfile, temp_in_esc); + free(temp_in_esc); + + ret = run(logdepth, cmd, &out); + remove(temp_in); + free(temp_in); + if (out != NULL) + free(out); + + if (is_file(bisfile)) { + remove(bisfile); + if (ret == 0) { + put("parsgen/byaccic", "byaccic"); + put("parsgen/byaccic/presents", strue); + report("Found.\n"); + return 0; + } + } + + put("parsgen/byaccic/presents", sfalse); + report("Not found.\n"); + return 1; +} + +int find_parsgen_ureglex(const char *name, int logdepth, int fatal) +{ + const char *test_ureglex = + NL "rule blank" + NL "regex [ \t\r]+" + NL "code" + NL " ULX_IGNORE;" + NL "rulestring 3D_DXF return 0;" + NL ; + char *out, *temp_in, *temp_in_esc, *cmd; + int ret; + char *lexfile = "lex.yy.c"; + (void) fatal; /* not used */ + + report("Checking for ureglex... "); + logprintf(logdepth, "find_ureglex: trying to find ureglex...\n"); + logdepth++; + + if (is_file(lexfile)) { + report("ERROR: %s exists, and I don't dare to delete it. Can't test ureglex, please remove the file by hand.\n", lexfile); + logprintf(logdepth, "ERROR: %s exists, and I don't dare to delete it. Can't test ureglex, please remove the file by hand.\n", lexfile); + exit(1); + } + temp_in = tempfile_dump(test_ureglex, ".lex"); + temp_in_esc = shell_escape_dup(temp_in); + cmd = malloc(strlen(temp_in_esc) + 32); + sprintf(cmd, "ureglex -l %s -c %s", temp_in_esc, lexfile); + free(temp_in_esc); + ret = run(logdepth, cmd, &out); + remove(temp_in); + free(temp_in); + if (out != NULL) + free(out); + + if (is_file(lexfile)) { + remove(lexfile); + if (ret == 0) { + put("parsgen/ureglex", "ureglex"); + put("parsgen/ureglex/presents", strue); + report("Found.\n"); + return 0; + } + } + + put("parsgen/ureglex/presents", sfalse); + report("Not found.\n"); + return 1; +} + void deps_parsgen_init() { dep_add("parsgen/flex/*", find_parsgen_flex); dep_add("parsgen/bison/*", find_parsgen_bison); -} + dep_add("parsgen/byaccic/*", find_parsgen_byaccic); + dep_add("parsgen/ureglex/*", find_parsgen_ureglex); +} diff --git a/scconfig/src/tmpasm/tmpasm_scconfig.c b/scconfig/src/tmpasm/tmpasm_scconfig.c index 5bfb6d3..f84a4fa 100644 --- a/scconfig/src/tmpasm/tmpasm_scconfig.c +++ b/scconfig/src/tmpasm/tmpasm_scconfig.c @@ -474,7 +474,10 @@ tmpasm_t *child; fn = tmpasm_arg2str(ctx, argv[n], 0); - path = scc_path(ud, fn); + if (*fn != '/') + path = scc_path(ud, fn); + else + path = strclone(fn); fin = fopen(path, "r"); if (fin == NULL) { tmpasm_runtime_error(ctx, -8, path); diff --git a/src/awklib/Makefile.in b/src/awklib/Makefile.in index fb80040..6e8283c 100644 --- a/src/awklib/Makefile.in +++ b/src/awklib/Makefile.in @@ -9,19 +9,19 @@ all: install: - @fstools/mkdir@ $(LIBPATH) + @/host/fstools/mkdir@ $(LIBPATH) @] foreach /local/n in /local/libs - print [@ @fstools/cp@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk + print [@ @/host/fstools/cp@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk @] end print [@ linstall: - @fstools/mkdir@ $(LIBPATH) + @/host/fstools/mkdir@ $(LIBPATH) @] foreach /local/n in /local/libs - print [@ @fstools/ln@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk + print [@ @/host/fstools/ln@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk @] end @@ -29,7 +29,7 @@ uninstall: @] foreach /local/n in /local/libs - print [@ @fstools/rm@ $(LIBPATH)/@/local/n@.awk + print [@ @/host/fstools/rm@ $(LIBPATH)/@/local/n@.awk @] end diff --git a/src/libmawk/Makefile b/src/libmawk/Makefile index e0692b1..c2e9087 100644 --- a/src/libmawk/Makefile +++ b/src/libmawk/Makefile @@ -142,7 +142,7 @@ $(CP) $(PWD)/man/example.7libmawk $(MAN7DIR)/example.7libmawk $(CHMOD) 0644 $(MAWKMAN) $(CP) $(PWD)/libmawk.so $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3) - rm $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2) $(LIBARCHDIR)/libmawk.so.$(SOVER1) 2>/dev/null ; true + rm $(LIBARCHDIR)/libmawk.so $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2) $(LIBARCHDIR)/libmawk.so.$(SOVER1) 2>/dev/null ; true ln -s libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3) $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2) ln -s libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3) $(LIBARCHDIR)/libmawk.so.$(SOVER1) ln -s libmawk.so.$(SOVER1) $(LIBARCHDIR)/libmawk.so diff --git a/src/libmawk/Makefile.conf.in b/src/libmawk/Makefile.conf.in index fb3dde6..9865d8d 100644 --- a/src/libmawk/Makefile.conf.in +++ b/src/libmawk/Makefile.conf.in @@ -37,16 +37,16 @@ #----------------- scconfig detected ---------------------------------- CC = @cc/cc@ -CFLAGS = @cc/cflags@ @cc/fpic@ -I.. -I. $(CFLAGS_APP) +CFLAGS = @cc/cflags@ @cc/fpic@ @?/local/nofork@ -I.. -I. $(CFLAGS_APP) LDFLAGS = @cc/ldflags@ LDFLAGS_SO = @/local/soname@ LDFLAGS_RDYNAMIC = @cc/rdynamic@ -CHMODX = @fstools/chmodx@ +CHMODX = @/host/fstools/chmodx@ CHMOD = chmod -MKDIR = @fstools/mkdir@ -CP=@fstools/cp@ -SYMLINK=@fstools/ln@ +MKDIR = @/host/fstools/mkdir@ +CP=@/host/fstools/cp@ +SYMLINK=@/host/fstools/ln@ @] switch /local/numeric diff --git a/src/libmawk/files_children.c b/src/libmawk/files_children.c index 645d047..2ac6876 100644 --- a/src/libmawk/files_children.c +++ b/src/libmawk/files_children.c @@ -17,7 +17,9 @@ #include #include #include +#ifndef MAWK_NO_FORK #include +#endif #include "mawk.h" #include "files.h" #include "memory.h" diff --git a/src/libmawk/vio_fifo.c b/src/libmawk/vio_fifo.c index 04a3a49..3e94514 100644 --- a/src/libmawk/vio_fifo.c +++ b/src/libmawk/vio_fifo.c @@ -9,6 +9,8 @@ ********************************************/ #include "vio_fifo.h" #include "memory.h" + +const mawk_vio_imp_t mawk_vio_fifo_imp; mawk_vio_t *mawk_vio_fifo_open(mawk_state_t *MAWK, const char *name, mawk_vio_open_mode_t mode) { diff --git a/src/libmawk/vio_fifo.h b/src/libmawk/vio_fifo.h index f170c22..a2d751d 100644 --- a/src/libmawk/vio_fifo.h +++ b/src/libmawk/vio_fifo.h @@ -14,7 +14,7 @@ int eof_from_app; /* 1 if there won't be more from the app or the app won't accept more data */ } mawk_vio_fifo_t; -const mawk_vio_imp_t mawk_vio_fifo_imp; +extern const mawk_vio_imp_t mawk_vio_fifo_imp; mawk_vio_t *mawk_vio_fifo_open(mawk_state_t *MAWK, const char *name, mawk_vio_open_mode_t mode);