Import upstream version 1.0.3
Debian Janitor
1 year, 2 months ago
0 | 0 | Changelog for libmawk |
1 | 1 | ~~~~~~~~~~~~~~~~~~~~~ |
2 | ||
3 | libmawk 1.0.3 (released: 2021-07-21, r1328) | |
4 | [build] -Fix: move fstool detection from target to host - needed only for installation | |
5 | [build] -Fix: suppress warning on non-existing optional /local/nofork | |
6 | [build] -Fix: make install over a new version over an old version shouldn't fail on lib symlink creation | |
7 | [build] -Add: no-fork configure-time option | |
8 | [vio] -Fix: missing extern caused multiple definitions of the same variable for vio_fifo | |
2 | 9 | |
3 | 10 | libmawk 1.0.2 (released: 2019-06-22, r1318) |
4 | 11 | [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 |
0 | Release notes for libmawk 1.0.2 | |
0 | Release notes for libmawk 1.0.3 | |
1 | 1 | |
2 | Minor bugfix release; fixes C function call with uninitialized | |
3 | variables and make uninstall. | |
2 | Minor bugfix release (missing extern and build system fixes). Adds | |
3 | compile time option for no-fork. | |
4 | 4 | |
5 | 5 |
0 | 0000. packaging and fawk | |
1 | - packaging: | |
2 | - rename example manpage to have libmawk prefix | |
3 | - make sure example manpage .TH has no space and matches the name | |
4 | - fawk | |
5 | - implement the . array syntax | |
6 | - array in array (for orig implementation only?) | |
7 | - isarray() | |
8 | - textblock | |
9 | - vararg? | |
10 | ||
11 | ||
0 | 12 | packging: |
1 | 13 | - manual page headers use the wrong section |
2 | 14 | |
45 | 57 | |
46 | 58 | 3.0 extend arrays |
47 | 59 | - array copy |
48 | - array in array (for orig implementation only?) | |
60 | ||
49 | 61 | - length(array) as in gawk? POSIX: length() works on strings only |
50 | 62 | update test_3rd funlen accordingly! |
51 | 63 |
100 | 100 | /* Runs when things should be detected for the host system */ |
101 | 101 | int hook_detect_host() |
102 | 102 | { |
103 | require("fstools/chmodx", 0, 1); | |
104 | require("fstools/cp", 0, 1); | |
105 | require("fstools/rm", 0, 1); | |
106 | require("fstools/ln", 0, 1); | |
107 | require("fstools/mkdir", 0, 1); | |
108 | ||
103 | 109 | return 0; |
104 | 110 | } |
105 | 111 | |
144 | 150 | require("cc/soname", 0, 0); |
145 | 151 | require("cc/rdynamic", 0, 0); |
146 | 152 | require("cc/pragma_message", 0, 0); |
147 | require("fstools/chmodx", 0, 1); | |
148 | require("fstools/cp", 0, 1); | |
149 | require("fstools/rm", 0, 1); | |
150 | require("fstools/ln", 0, 1); | |
151 | require("fstools/mkdir", 0, 1); | |
152 | 153 | require("sys/types/size_t/includes", 0, 0); |
153 | 154 | require("libs/fs/realpath/presents", 0, 0); |
154 | 155 | require("libs/env/putenv", 0, 1); |
74 | 74 | value++; |
75 | 75 | |
76 | 76 | if (strcmp(key, "without") == 0) { |
77 | char *tmp, *end; | |
77 | char *tmp; | |
78 | 78 | if (*value != '/') { |
79 | 79 | const char **r, *roots[] = {"target", "host", "runtime", NULL}; |
80 | 80 | for(r = roots; *r != NULL; r++) { |
82 | 82 | break; |
83 | 83 | if (istrue(d)) { |
84 | 84 | free(tmp); |
85 | return USER_WITHOUT; | |
85 | return (fn_wrap_t *)USER_WITHOUT; | |
86 | 86 | } |
87 | 87 | while(*sep != '/') |
88 | 88 | sep--; |
135 | 135 | |
136 | 136 | if (get(name) == NULL) { |
137 | 137 | w = get_wrap(name, &wild, &missing); |
138 | if (w == USER_WITHOUT) { | |
138 | if (w == (fn_wrap_t *)USER_WITHOUT) { | |
139 | 139 | if (fatal) { |
140 | 140 | error("Node %s is required by the software but disabled by the user using --without\n", name); |
141 | 141 | abort(); |
35 | 35 | dep_add("cc/destructor", find_destructor); |
36 | 36 | dep_add("cc/rdynamic", find_rdynamic); |
37 | 37 | dep_add("cc/soname", find_soname); |
38 | dep_add("cc/so_undefined", find_so_undefined); | |
38 | 39 | dep_add("cc/wlrpath", find_wlrpath); |
39 | 40 | dep_add("cc/wloutimplib", find_cc_wloutimplib); |
40 | 41 | dep_add("cc/wloutputdef", find_cc_wloutputdef); |
94 | 95 | dep_add("libs/fs/getwd/*", find_fs_getwd); |
95 | 96 | dep_add("libs/fs/mkdir/*", find_fs_mkdir); |
96 | 97 | dep_add("libs/fs/_mkdir/*", find_fs__mkdir); |
98 | dep_add("libs/fs/utime/*", find_fs_utime); | |
99 | dep_add("libs/fs/_utime/*", find_fs__utime); | |
100 | dep_add("libs/fs/_utime64/*", find_fs__utime64); | |
97 | 101 | dep_add("libs/fs/mkdtemp/*", find_fs_mkdtemp); |
98 | 102 | dep_add("libs/fs/mmap/*", find_fs_mmap); |
99 | 103 | dep_add("libs/fsmount/next_dev/*", find_fsmount_next_dev); |
104 | 108 | dep_add("libs/fs/statfs/*", find_fs_statfs); |
105 | 109 | dep_add("libs/fs/statvfs/*", find_fs_statvfs); |
106 | 110 | dep_add("libs/fs/flock/*", find_fs_flock); |
111 | dep_add("libs/fs/makedev/*", find_fs_makedev); | |
107 | 112 | |
108 | 113 | dep_add("libs/io/pipe/*", find_io_pipe); |
114 | dep_add("libs/io/pipe2/*", find_io_pipe2); | |
115 | dep_add("libs/io/_pipe/*", find_io__pipe); | |
109 | 116 | dep_add("libs/io/dup2/*", find_io_dup2); |
110 | 117 | dep_add("libs/io/fileno/*", find_io_fileno); |
111 | 118 | dep_add("libs/io/lseek/*", find_io_lseek); |
14 | 14 | int find_declspec_dllexport(const char *name, int logdepth, int fatal); |
15 | 15 | int find_rdynamic(const char *name, int logdepth, int fatal); |
16 | 16 | int find_soname(const char *name, int logdepth, int fatal); |
17 | int find_so_undefined(const char *name, int logdepth, int fatal); | |
17 | 18 | int find_wlrpath(const char *name, int logdepth, int fatal); |
18 | 19 | int find_cc_wloutimplib(const char *name, int logdepth, int fatal); |
19 | 20 | int find_cc_wloutputdef(const char *name, int logdepth, int fatal); |
54 | 55 | int find_fs_getwd(const char *name, int logdepth, int fatal); |
55 | 56 | int find_fs_mkdir(const char *name, int logdepth, int fatal); |
56 | 57 | int find_fs__mkdir(const char *name, int logdepth, int fatal); |
58 | int find_fs_utime(const char *name, int logdepth, int fatal); | |
59 | int find_fs__utime(const char *name, int logdepth, int fatal); | |
60 | int find_fs__utime64(const char *name, int logdepth, int fatal); | |
57 | 61 | int find_fs_mkdtemp(const char *name, int logdepth, int fatal); |
58 | 62 | int find_fs_mmap(const char *name, int logdepth, int fatal); |
59 | 63 | int find_fsmount_next_dev(const char *name, int logdepth, int fatal); |
64 | 68 | int find_fs_statfs(const char *name, int logdepth, int fatal); |
65 | 69 | int find_fs_statvfs(const char *name, int logdepth, int fatal); |
66 | 70 | int find_fs_flock(const char *name, int logdepth, int fatal); |
71 | int find_fs_makedev(const char *name, int logdepth, int fatal); | |
67 | 72 | |
68 | 73 | /* printf */ |
69 | 74 | int find_printf_x(const char *name, int logdepth, int fatal); |
124 | 129 | |
125 | 130 | /* find_io.c */ |
126 | 131 | int find_io_pipe(const char *name, int logdepth, int fatal); |
132 | int find_io_pipe2(const char *name, int logdepth, int fatal); | |
133 | int find_io__pipe(const char *name, int logdepth, int fatal); | |
127 | 134 | int find_io_dup2(const char *name, int logdepth, int fatal); |
128 | 135 | int find_io_fileno(const char *name, int logdepth, int fatal); |
129 | 136 | int find_io_lseek(const char *name, int logdepth, int fatal); |
644 | 644 | return 1; |
645 | 645 | } |
646 | 646 | |
647 | int find_so_undefined(const char *name, int logdepth, int fatal) | |
648 | { | |
649 | static const char *test_c = | |
650 | NL "#include <stdio.h>" | |
651 | NL "void intentionally_undefined_symbol(void);" | |
652 | NL "int main() {" | |
653 | NL " intentionally_undefined_symbol();" | |
654 | NL " puts(\"OK\");" | |
655 | NL " return 0;" | |
656 | NL "}" | |
657 | NL ; | |
658 | const char **t, *try_ldflags[] = { | |
659 | "", | |
660 | "-undefined dynamic_lookup", /* OSX + clang */ | |
661 | NULL | |
662 | }; | |
663 | ||
664 | require("cc/cc", logdepth, fatal); | |
665 | require("cc/ldflags_dynlib", logdepth, fatal); | |
666 | ||
667 | report("Checking for so_undefined... "); | |
668 | logprintf(logdepth, "find_so_undefined: trying to find so_undefined...\n"); | |
669 | logdepth++; | |
670 | ||
671 | for(t = try_ldflags; *t != NULL; t++) { | |
672 | const char *fpic; | |
673 | char *ldf, *oname = ".o", *libname_dyn, *cflags_c; | |
674 | int res1, res2; | |
675 | ||
676 | fpic = get("cc/fpic"); | |
677 | if (fpic == NULL) fpic = ""; | |
678 | ||
679 | cflags_c = str_concat(" ", "-c", fpic, NULL); | |
680 | ||
681 | libname_dyn = (char *)get("sys/ext_dynlib"); | |
682 | ldf = str_concat(" ", get("cc/ldflags_dynlib"), *t, NULL); | |
683 | res1 = compile_code(logdepth, test_c, &oname, NULL, cflags_c, NULL); | |
684 | res2 = compile_file(logdepth, oname, &libname_dyn, NULL, NULL, ldf); | |
685 | unlink(libname_dyn); | |
686 | unlink(oname); | |
687 | free(libname_dyn); | |
688 | free(oname); | |
689 | free(cflags_c); | |
690 | ||
691 | if ((res1 == 0) && (res2 == 0)) { | |
692 | put(name, *t); | |
693 | report("OK (%s)\n", *t); | |
694 | return 0; | |
695 | } | |
696 | } | |
697 | ||
698 | report("Not found.\n"); | |
699 | return 1; | |
700 | } | |
701 | ||
647 | 702 | |
648 | 703 | int find_wlrpath(const char *name, int logdepth, int fatal) |
649 | 704 | { |
691 | 746 | NL "#include <stdlib.h>" |
692 | 747 | NL "#include <stdio.h>" |
693 | 748 | NL "#include %s" |
749 | NL "#ifndef RTLD_NOW" | |
750 | NL "#define RTLD_NOW RTLD_LAZY" /* on old BSD and probably on SunOS */ | |
751 | NL "#endif" | |
694 | 752 | NL "int main() {" |
695 | 753 | NL " void *handle = NULL;" |
696 | 754 | NL " void (*func)() = NULL;" |
698 | 756 | NL |
699 | 757 | NL " handle = dlopen(\"%s\", RTLD_NOW);" |
700 | 758 | NL " if (handle == NULL) {" |
701 | NL " printf(\"dlopen fails: \", dlerror());" | |
759 | NL " printf(\"dlopen fails: %%s\", dlerror());" | |
702 | 760 | NL " return 1;" |
703 | 761 | NL " }" |
704 | 762 | NL " func = dlsym(handle, \"hello\");" |
705 | 763 | NL " if (func == NULL) {" |
706 | NL " printf(\"dlsym fails: \", dlerror());" | |
764 | NL " printf(\"dlsym fails: %%s\", dlerror());" | |
707 | 765 | NL " return 1;" |
708 | 766 | NL " }" |
709 | 767 | NL " func();" |
742 | 800 | libname_dyn = libname = (char *)get("sys/ext_dynlib"); |
743 | 801 | if ((compile_code(logdepth, test_lib, &oname, NULL, cflags_c, NULL) != 0) || |
744 | 802 | (compile_file(logdepth, oname, &libname_dyn, NULL, NULL, concated_ldflags) != 0)) { |
745 | report("FAILED (compiling dynlib)\n"); | |
803 | report("('%s': nope) ", concated_ldflags); | |
746 | 804 | } |
747 | 805 | else { |
748 | 806 | sprintf(test_host_app, test_host, ld_include, libname_dyn); |
777 | 835 | |
778 | 836 | 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; |
779 | 837 | if (try_dynlib(logdepth, NULL, concat_nodes("-shared", "cc/rdynamic", "libs/ldl", NULL), "cc/ldflags_dynlib", "-shared", NULL, get("libs/ldl"))) return 0; |
838 | if (try_dynlib(logdepth, NULL, concat_nodes("-G", "libs/ldl", NULL), "cc/ldflags_dynlib", "-G", NULL, get("libs/ldl"))) return 0; /* xlc (on AIX) */ | |
780 | 839 | report("Not found.\n"); |
781 | 840 | return 1; |
782 | 841 | } |
91 | 91 | char *test_c = |
92 | 92 | NL "#include <stdlib.h>" |
93 | 93 | NL "#include <stdio.h>" |
94 | NL "#include <string.h>" | |
94 | 95 | NL "int main() {" |
95 | 96 | NL " DIR *dirp;" |
96 | 97 | NL " struct dirent *dp;" |
396 | 397 | { |
397 | 398 | char *test_c = |
398 | 399 | NL "#include <unistd.h>" |
400 | NL "#include <stdio.h>" | |
399 | 401 | NL "int main() {" |
400 | 402 | NL " char b[1024];" |
401 | 403 | NL " if (getcwd(b, sizeof(b)) != NULL)" |
418 | 420 | { |
419 | 421 | char *test_c = |
420 | 422 | NL "#include <stdlib.h>" |
423 | NL "#include <stdio.h>" | |
421 | 424 | NL "int main() {" |
422 | 425 | NL " char b[1024];" |
423 | 426 | NL " if (_getcwd(b, sizeof(b)) != NULL)" |
441 | 444 | { |
442 | 445 | char *test_c = |
443 | 446 | NL "#include <unistd.h>" |
447 | NL "#include <stdio.h>" | |
444 | 448 | NL "int main() {" |
445 | 449 | NL " char b[8192];" |
446 | 450 | NL " if (getwd(b) != NULL)" |
573 | 577 | |
574 | 578 | rmdir(dir); |
575 | 579 | return try_fail(logdepth, "libs/fs/_mkdir"); |
580 | } | |
581 | ||
582 | static int find_utime_impl(const char *name, int logdepth, int fatal, | |
583 | const char* key, const char* funcname, const char* typename) | |
584 | { | |
585 | char test_c[1024+4096]; | |
586 | const char *test_c_templ = | |
587 | NL "void puts_OK();" | |
588 | NL "int main(int argc, char* argv[])" | |
589 | NL "{" | |
590 | NL " struct %s buf;" | |
591 | NL " buf.actime = buf.modtime = 1610958044;" | |
592 | NL " if (%s(\"%s\", &buf) == 0)" | |
593 | NL " puts_OK();" | |
594 | NL " return 0;" | |
595 | NL "}" | |
596 | NL "#include <stdio.h>" | |
597 | NL "void puts_OK()" | |
598 | NL "{" | |
599 | NL " puts(\"OK\");" | |
600 | NL "}" | |
601 | NL; | |
602 | ||
603 | const char* includes[] = | |
604 | { | |
605 | /* *NIX */ | |
606 | "#include <sys/types.h>\n#include <utime.h>", | |
607 | ||
608 | /* windoz */ | |
609 | "#include <sys/utime.h>", | |
610 | ||
611 | NULL | |
612 | }; | |
613 | const char** inc; | |
614 | char* tmpf; | |
615 | ||
616 | tmpf = tempfile_new(".txt"); | |
617 | sprintf(test_c, test_c_templ, typename, funcname, tmpf); | |
618 | ||
619 | require("cc/cc", logdepth, fatal); | |
620 | ||
621 | report("Checking for %s... ", funcname); | |
622 | logprintf(logdepth, "find_fs_%s: trying to find %s()...\n", funcname, funcname); | |
623 | logdepth++; | |
624 | ||
625 | for (inc=includes; *inc; ++inc) | |
626 | { | |
627 | if (try_icl(logdepth, key, test_c, *inc, NULL, NULL)) | |
628 | { | |
629 | unlink(tmpf); | |
630 | free(tmpf); | |
631 | return 0; | |
632 | } | |
633 | } | |
634 | ||
635 | unlink(tmpf); | |
636 | free(tmpf); | |
637 | ||
638 | return try_fail(logdepth, key); | |
639 | } | |
640 | ||
641 | int find_fs_utime(const char *name, int logdepth, int fatal) | |
642 | { | |
643 | return find_utime_impl(name, logdepth, fatal, | |
644 | "libs/fs/utime", "utime", "utimbuf"); | |
645 | } | |
646 | ||
647 | int find_fs__utime(const char *name, int logdepth, int fatal) | |
648 | { | |
649 | return find_utime_impl(name, logdepth, fatal, | |
650 | "libs/fs/_utime", "_utime", "_utimbuf"); | |
651 | } | |
652 | ||
653 | int find_fs__utime64(const char *name, int logdepth, int fatal) | |
654 | { | |
655 | return find_utime_impl(name, logdepth, fatal, | |
656 | "libs/fs/_utime64", "_utime64", "__utimbuf64"); | |
576 | 657 | } |
577 | 658 | |
578 | 659 | int find_fs_mkdtemp(const char *name, int logdepth, int fatal) |
805 | 886 | if (try_icl(logdepth, key, test_c, "#include <sys/file.h>", NULL, NULL)) return 0; |
806 | 887 | return try_fail(logdepth, key); |
807 | 888 | } |
889 | ||
890 | int find_fs_makedev(const char *name, int logdepth, int fatal) | |
891 | { | |
892 | const char *key = "libs/fs/makedev"; | |
893 | const char *test_c = | |
894 | NL "#include <stdio.h>" | |
895 | NL "int main() {" | |
896 | NL " if (1 == major(makedev(1, 2)) && 2 == minor(makedev(1, 2)))" | |
897 | NL " puts(\"OK\");" | |
898 | NL " return 0;" | |
899 | NL "}" | |
900 | NL; | |
901 | const char *includes[] = { | |
902 | "#include <sys/sysmacros.h>", | |
903 | NULL | |
904 | }; | |
905 | const char **i; | |
906 | ||
907 | require("cc/cc", logdepth, fatal); | |
908 | ||
909 | report("Checking for makedev()... "); | |
910 | logprintf(logdepth, "find_fs_makedev: trying to find makedev...\n"); | |
911 | logdepth++; | |
912 | ||
913 | for (i = includes; *i != NULL; i++) | |
914 | if (try_icl(logdepth, key, test_c, *i, NULL, NULL)) | |
915 | return 0; | |
916 | return try_fail(logdepth, key); | |
917 | } |
261 | 261 | expected = src; |
262 | 262 | else |
263 | 263 | expected++; |
264 | ||
265 | logprintf(logdepth, "test_ar path_sep='%s' expected='%s' result='%s'\n", path_sep, expected, result); | |
264 | 266 | |
265 | 267 | ret = strncmp(expected, result, strlen(expected)) == 0; |
266 | 268 | if (ret) { |
23 | 23 | #include <stdio.h> |
24 | 24 | #include <string.h> |
25 | 25 | #include <ctype.h> |
26 | #include <unistd.h> | |
26 | 27 | #include "libs.h" |
27 | 28 | #include "log.h" |
28 | 29 | #include "db.h" |
32 | 33 | { |
33 | 34 | char *test_c = |
34 | 35 | NL "#include <unistd.h>" |
36 | NL "#include <stdio.h>" | |
35 | 37 | NL "int main() {" |
36 | 38 | NL " int fd[2];" |
37 | 39 | NL " if (pipe(fd) == 0)" |
46 | 48 | logprintf(logdepth, "find_io_pipe: trying to find pipe(2)...\n"); |
47 | 49 | logdepth++; |
48 | 50 | |
49 | ||
50 | if (try_icl(logdepth, "libs/io/pipe", test_c, NULL, NULL, NULL)) return 0; | |
51 | if (try_icl(logdepth, "libs/io/pipe", test_c, "#include <unistd.h>\n", NULL, NULL)) return 0; | |
51 | 52 | return try_fail(logdepth, "libs/io/pipe"); |
53 | } | |
54 | ||
55 | int find_io_pipe2(const char *name, int logdepth, int fatal) | |
56 | { | |
57 | const char *test_c = | |
58 | NL "#include <unistd.h>" | |
59 | NL "#include <stdio.h>" | |
60 | NL "int main() {" | |
61 | NL " int fd[2];" | |
62 | NL " if (pipe2(fd, 0) == 0)" | |
63 | NL " puts(\"OK\");" | |
64 | NL " return 0;" | |
65 | NL "}" | |
66 | NL; | |
67 | ||
68 | require("cc/cc", logdepth, fatal); | |
69 | ||
70 | report("Checking for pipe2(2)... "); | |
71 | logprintf(logdepth, "find_io_pipe2: trying to find pipe2(2)...\n"); | |
72 | logdepth++; | |
73 | ||
74 | if (try_icl(logdepth, "libs/io/pipe2", test_c, "#include <unistd.h>\n", NULL, NULL)) return 0; | |
75 | return try_fail(logdepth, "libs/io/pipe2"); | |
76 | } | |
77 | ||
78 | int find_io__pipe(const char *name, int logdepth, int fatal) | |
79 | { | |
80 | const char *test_c = | |
81 | NL "#include <stdio.h>" | |
82 | NL "int main() {" | |
83 | NL " int fd[2];" | |
84 | NL " if (_pipe(fd, 1024, _O_BINARY) == 0)" | |
85 | NL " puts(\"OK\");" | |
86 | NL " return 0;" | |
87 | NL "}" | |
88 | NL; | |
89 | ||
90 | require("cc/cc", logdepth, fatal); | |
91 | ||
92 | report("Checking for _pipe()... "); | |
93 | logprintf(logdepth, "find_io__pipe: trying to find _pipe()...\n"); | |
94 | logdepth++; | |
95 | ||
96 | if (try_icl(logdepth, "libs/io/_pipe", test_c, "#include <io.h>\n#include <fcntl.h>\n", NULL, NULL)) return 0; | |
97 | return try_fail(logdepth, "libs/io/_pipe"); | |
52 | 98 | } |
53 | 99 | |
54 | 100 | int find_io_dup2(const char *name, int logdepth, int fatal) |
80 | 126 | char *test_c_ = |
81 | 127 | NL "#include <stdio.h>" |
82 | 128 | NL "int main() {" |
83 | NL no_implicit(int, "%s", "%s") | |
129 | /* NOTE: can not check for implicit declaration as fileno() may be a macro (e.g. on MINIX3) */ | |
84 | 130 | NL " if (%s(stdout) >= 0)" |
85 | 131 | NL " puts(\"OK\"); " |
86 | 132 | NL " return 0;" |
94 | 140 | logdepth++; |
95 | 141 | |
96 | 142 | /* UNIX */ |
97 | sprintf(test_c, test_c_, "fileno", "fileno", "fileno"); | |
143 | sprintf(test_c, test_c_, "fileno"); | |
144 | if (try_icl(logdepth, "libs/io/fileno", test_c, NULL, NULL, NULL)) { | |
145 | put("libs/io/fileno/call", "fileno"); | |
146 | return 0; | |
147 | } | |
148 | ||
149 | sprintf(test_c, test_c_, "fileno"); | |
98 | 150 | if (try_icl(logdepth, "libs/io/fileno", test_c, "#include <unistd.h>\n", NULL, NULL)) { |
99 | 151 | put("libs/io/fileno/call", "fileno"); |
100 | 152 | return 0; |
101 | 153 | } |
102 | 154 | |
103 | sprintf(test_c, test_c_, "fileno", "fileno", "fileno"); | |
155 | sprintf(test_c, test_c_, "fileno"); | |
104 | 156 | if (try_icl(logdepth, "libs/io/fileno", test_c, "#define _XOPEN_SOURCE\n#include <unistd.h>\n", NULL, NULL)) { |
105 | 157 | put("libs/io/fileno/call", "fileno"); |
106 | 158 | return 0; |
107 | 159 | } |
108 | 160 | |
109 | 161 | /* windows */ |
110 | sprintf(test_c, test_c_, "_fileno", "_fileno", "_fileno"); | |
162 | sprintf(test_c, test_c_, "_fileno"); | |
111 | 163 | if (try_icl(logdepth, "libs/io/fileno", test_c, "#include <stdio.h>\n", NULL, NULL)) { |
112 | 164 | put("libs/io/fileno/call", "_fileno"); |
113 | 165 | return 0; |
150 | 202 | for (inc = incs, fn = fns; *fn; ++inc, ++fn) { |
151 | 203 | sprintf(test_c, test_c_template, tmpf, *fn, *fn, *fn); |
152 | 204 | if (try_icl(logdepth, NODE, test_c, *inc, NULL, NULL)) { |
205 | unlink(tmpf); | |
206 | free(tmpf); | |
153 | 207 | put(NODE "/call", *fn); |
154 | 208 | return 0; |
155 | 209 | } |
156 | 210 | } |
157 | 211 | |
212 | unlink(tmpf); | |
213 | free(tmpf); | |
158 | 214 | return try_fail(logdepth, NODE); |
159 | 215 | #undef NODE |
160 | 216 | } |
58 | 58 | char *test_c = |
59 | 59 | NL "#include <stdio.h>" |
60 | 60 | NL "#include <dlfcn.h>" |
61 | NL "#ifndef RTLD_NOW" | |
62 | NL "#define RTLD_NOW RTLD_LAZY" /* on old BSD and probably on SunOS */ | |
63 | NL "#endif" | |
61 | 64 | NL "int main() {" |
62 | 65 | NL " void *handle;" |
63 | 66 | NL " handle = dlopen(\"/this file does not exist.\", RTLD_NOW);" |
76 | 79 | NL " return 0;" |
77 | 80 | NL "}" |
78 | 81 | NL; |
82 | ||
83 | s = (char *)get("libs/ldl/presents"); | |
84 | if (s != NULL) | |
85 | return !istrue(s); | |
79 | 86 | |
80 | 87 | require("cc/cc", logdepth, fatal); |
81 | 88 | |
93 | 100 | if (try_icl(logdepth, NULL, test_c, NULL, NULL, NULL)) { |
94 | 101 | put("libs/ldl", ""); |
95 | 102 | put("libs/ldl/includes", "#include <dlfcn.h>\\n"); |
103 | put("libs/ldl/presents", strue); | |
96 | 104 | report("OK ()\n"); |
97 | 105 | return 0; |
98 | 106 | } |
99 | 107 | if (try_icl(logdepth, NULL, test_c, NULL, NULL, "-ldl")) { |
100 | 108 | put("libs/ldl", "-ldl"); |
101 | 109 | put("libs/ldl/includes", "#include <dlfcn.h>\\n"); |
110 | put("libs/ldl/presents", strue); | |
102 | 111 | report("OK (-ldl)\n"); |
103 | 112 | return 0; |
104 | 113 | } |
126 | 135 | /* check at normal system installation */ |
127 | 136 | put("libs/ldl", "-ldl-compat"); |
128 | 137 | put("libs/ldl/includes", "#include <dl-compat.h>\\n"); |
138 | put("libs/ldl/presents", strue); | |
129 | 139 | report("OK (-ldl-compat)\n"); |
130 | 140 | return 0; |
131 | 141 | } |
136 | 146 | if (try_icl(logdepth, NULL, test_c, NULL, NULL, s)) { |
137 | 147 | put("libs/ldl", ldl); |
138 | 148 | put("libs/ldl/includes", "#include <dlfcn.h>\\n"); |
149 | put("libs/ldl/presents", strue); | |
139 | 150 | report("OK (%s)\n", ldl); |
140 | 151 | free(s); |
141 | 152 | return 0; |
142 | 153 | } |
143 | 154 | free(s); |
144 | 155 | } |
156 | put("libs/ldl/presents", sfalse); | |
145 | 157 | report("Not found\n"); |
146 | 158 | return 1; |
147 | 159 | } |
175 | 187 | { |
176 | 188 | char *test_c = |
177 | 189 | NL "#include <errno.h>" |
190 | NL "#include <stdio.h>" | |
178 | 191 | NL "int main() {" |
179 | 192 | NL " errno = 0;" |
180 | 193 | NL " puts(\"OK\");" |
273 | 273 | put("sys/path_sep", "\\\\\\\\"); |
274 | 274 | else |
275 | 275 | put("sys/path_sep", "\\"); |
276 | put("sys/path_sep_escaped", "\\\\"); | |
276 | 277 | return 1; |
277 | 278 | } |
278 | 279 | tmp = get("sys/tmp"); |
306 | 307 | require("sys/shell", logdepth, fatal); |
307 | 308 | |
308 | 309 | put("sys/path_sep", "/"); |
310 | put("sys/path_sep_escaped", "/"); | |
309 | 311 | |
310 | 312 | report("Detecting temp dir..."); |
311 | 313 | logprintf(logdepth, "Finding temp dir (current working directory)...\n"); |
337 | 339 | put("sys/tmp", usertmp); |
338 | 340 | report("using user supplied temp dir '%s' for cross-compilation\n", usertmp); |
339 | 341 | logprintf(logdepth, "using user supplied temp dir '%s' for cross-compilation\n", usertmp); |
342 | logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep")); | |
340 | 343 | } |
341 | 344 | return 0; |
342 | 345 | } |
351 | 354 | |
352 | 355 | report(" validated %s\n", get("sys/tmp")); |
353 | 356 | logprintf(logdepth, "Detected temp dir '%s'\n", get("sys/tmp")); |
357 | logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep")); | |
354 | 358 | return 0; |
355 | 359 | } |
356 | 360 | |
357 | 361 | put("sys/tmp", ""); |
358 | 362 | report("using temp dir fallback .\n"); |
359 | 363 | logprintf(logdepth, "all temp directories failed, using . as tmp\n"); |
364 | logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep")); | |
360 | 365 | return 0; |
361 | 366 | } |
362 | 367 |
36 | 36 | char *test_c_recursive = |
37 | 37 | NL "#define _GNU_SOURCE 1 /* Needed for recursive thread-locking */" |
38 | 38 | NL "#include <pthread.h>" |
39 | NL "#include <stdio.h>" | |
39 | 40 | NL "pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;" |
40 | 41 | NL "int main() {" |
41 | 42 | NL " pthread_attr_t a;" |
47 | 48 | |
48 | 49 | char *test_c_simple = |
49 | 50 | NL "#include <pthread.h>" |
51 | NL "#include <stdio.h>" | |
50 | 52 | NL "int main() {" |
51 | 53 | NL " pthread_attr_t a;" |
52 | 54 | NL " if (pthread_attr_init(&a) == 0)" |
31 | 31 | { |
32 | 32 | char *test_c = |
33 | 33 | NL "#include <unistd.h>" |
34 | NL "#include <stdio.h>" | |
34 | 35 | NL "int main() {" |
35 | 36 | NL " if (usleep(1) == 0)" |
36 | 37 | NL " puts(\"OK\");" |
52 | 53 | int find_time_Sleep(const char *name, int logdepth, int fatal) |
53 | 54 | { |
54 | 55 | char *test_c = |
56 | NL "#include <stdio.h>" | |
55 | 57 | NL "int main() {" |
56 | 58 | NL " Sleep(1);" |
57 | 59 | NL " puts(\"OK\");" |
74 | 76 | { |
75 | 77 | char *test_c = |
76 | 78 | NL "#include <stdlib.h>" |
79 | NL "#include <stdio.h>" | |
77 | 80 | NL "int main() {" |
78 | 81 | NL " struct timeval tv;" |
79 | 82 | NL " if (gettimeofday(&tv, NULL) == 0)" |
97 | 100 | int find_time_ftime(const char *name, int logdepth, int fatal) |
98 | 101 | { |
99 | 102 | char *test_c = |
103 | NL "#include <stdio.h>" | |
100 | 104 | NL "int main() {" |
101 | 105 | NL " struct timeb tb;" |
102 | 106 | NL " if (ftime(&tb) == 0)" |
92 | 92 | { |
93 | 93 | char *test_c = |
94 | 94 | NL "#include <stdint.h>" |
95 | NL "#include <stdio.h>" | |
95 | 96 | NL "int main() {" |
96 | 97 | NL " if (sizeof(uint8_t) == 1)" |
97 | 98 | NL " puts(\"OK\");" |
276 | 277 | |
277 | 278 | for(include = first_include; *include != NULL; include++) { |
278 | 279 | sprintf(test_c, test_c_include, define, *include, typ); |
279 | if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && (strncmp(out, "OK", 2) == 0)) { | |
280 | if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && out != NULL && (strncmp(out, "OK", 2) == 0)) { | |
280 | 281 | report("Found; "); |
281 | 282 | logprintf(logdepth+1, "include %s works\n", *include); |
282 | 283 | sprintf(nodeend, "includes"); |
77 | 77 | {"[Bb][Ss][Dd]", "BSD", "UNIX", sys_unix}, |
78 | 78 | {"SunOS", "SunOS", "UNIX", sys_unix}, |
79 | 79 | {"OSF1", "OSF", "UNIX", sys_unix}, /* TODO: note the difference in cflags for debugging ("-ms -g") */ |
80 | {"AIX", "AIX", "UNIX", sys_unix}, | |
80 | 81 | {"IRIX", "IRIX", "UNIX", sys_unix}, |
81 | 82 | {"SunOS", "SunOS", "UNIX", sys_unix}, |
82 | 83 | {"[Mm]inix", "Minix", "UNIX", sys_unix}, |
286 | 287 | uname_guess("sys/system_name", uname, system_names); |
287 | 288 | |
288 | 289 | /* on windows, overwrite the path sep with the right amount of \ (the tmp finder may have left / in it) */ |
289 | if (strcmp(class, "WIN32") == 0) { | |
290 | if ((strcmp(class, "WIN32") == 0) || (strcmp(class, "win32") == 0)) { | |
290 | 291 | int eats = istrue(get("sys/shell_eats_backslash")); |
291 | 292 | |
292 | 293 | if (eats) |
293 | 294 | put("sys/path_sep", "\\\\\\\\"); |
294 | 295 | else |
295 | 296 | put("sys/path_sep", "\\"); |
297 | ||
298 | put("sys/path_sep_escaped", "\\\\"); | |
296 | 299 | } |
297 | 300 | |
298 | 301 | return 0; |
71 | 71 | |
72 | 72 | int compile_file_raw(int logdepth, const char *fn_input, char **fn_output, const char *cc, const char *cflags, const char *ldflags) |
73 | 73 | { |
74 | char cmd[2048]; | |
74 | char *cmdline; | |
75 | 75 | char *cc_esc, *fn_input_esc, *fn_output_esc, *temp_out_esc, *temp_out; |
76 | 76 | int ret; |
77 | 77 | |
88 | 88 | fn_output_esc = shell_escape_dup(*fn_output); |
89 | 89 | temp_out_esc = shell_escape_dup(temp_out); |
90 | 90 | |
91 | 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); | |
91 | cmdline = str_concat("", | |
92 | get("/host/sys/shell"), " \"", cc_esc, " ", cflags, " ", fn_input_esc, " ", \ | |
93 | ldflags, " -o ", fn_output_esc, " 2>&1\" >", temp_out_esc, NULL); | |
92 | 94 | |
93 | 95 | free(cc_esc); |
94 | 96 | free(fn_input_esc); |
95 | 97 | free(fn_output_esc); |
96 | 98 | free(temp_out_esc); |
97 | 99 | |
98 | logprintf(logdepth, "compile: '%s'\n", cmd); | |
99 | ret = system(cmd); | |
100 | logprintf(logdepth, "compile: '%s'\n", cmdline); | |
101 | ret = system(cmdline); | |
102 | free(cmdline); | |
100 | 103 | log_merge(logdepth + 1, temp_out); |
101 | 104 | #ifndef KEEP_TEST_SRCS |
102 | 105 | unlink(temp_out); |
29 | 29 | { |
30 | 30 | char cmd[256]; |
31 | 31 | |
32 | assert(strlen(pkgname) < sizeof(cmd) - 64); | |
32 | if (strlen(confname) + strlen(pkgname) > sizeof(cmd) - 16) { | |
33 | logprintf(logdepth, "run_gen_config(): confname and/or pkgname too long\n"); | |
34 | return -1; | |
35 | } | |
33 | 36 | |
34 | 37 | if (cflags != NULL) { |
35 | 38 | sprintf(cmd, "%s --cflags %s", confname, pkgname); |
81 | 84 | char cmd[256]; |
82 | 85 | const char *confname = pkg_config_name(); |
83 | 86 | |
84 | assert(strlen(pkgname) < sizeof(cmd) - 64); | |
87 | if (strlen(confname) + strlen(pkgname) > sizeof(cmd) - 16) { | |
88 | logprintf(logdepth, "run_pkg_config_modversion(): confname and/or pkgname too long\n"); | |
89 | return -1; | |
90 | } | |
85 | 91 | |
86 | 92 | if (modversion != NULL) { |
87 | 93 | sprintf(cmd, "%s --modversion %s", confname, pkgname); |
139 | 139 | char *rincludes, *rcflags, *rldflags; /* real */ |
140 | 140 | char *dbincludes = NULL, *dbcflags = NULL, *dbldflags = NULL; /* what to add in the db at the end */ |
141 | 141 | |
142 | if ((prefix == NULL) ? 0 : strlen(prefix) + strlen(db_cwd) > sizeof(apath)-32) { | |
143 | report("ERROR: no room for try_icl_() - prefix is probably too long.\n"); | |
144 | return -1; | |
145 | } | |
146 | ||
142 | 147 | /* load uincludes, uclfags, uldflags and uprefix - LOAD() inserts the u */ |
143 | l = sprintf(apath, "/arg/icl/%s/", prefix); apath_end = apath+l; | |
144 | LOAD(includes); | |
145 | LOAD(cflags); | |
146 | LOAD(ldflags); | |
147 | LOAD(prefix); | |
148 | l = sprintf(apath, "/arg/icl/%s/%s/", db_cwd, prefix); apath_end = apath+l; | |
149 | LOAD(includes); | |
150 | LOAD(cflags); | |
151 | LOAD(ldflags); | |
152 | LOAD(prefix); | |
148 | if (prefix != NULL) { /* prefix == NULL means non-standard icl; caller sets non-standard nodes, the user can't affect that */ | |
149 | l = sprintf(apath, "/arg/icl/%s/", prefix); apath_end = apath+l; | |
150 | LOAD(includes); | |
151 | LOAD(cflags); | |
152 | LOAD(ldflags); | |
153 | LOAD(prefix); | |
154 | l = sprintf(apath, "/arg/icl/%s/%s/", db_cwd, prefix); apath_end = apath+l; | |
155 | LOAD(includes); | |
156 | LOAD(cflags); | |
157 | LOAD(ldflags); | |
158 | LOAD(prefix); | |
159 | } | |
153 | 160 | |
154 | 161 | /* special case: all three specified by the user - ignore what the detector wanted, but run only once per node prefix */ |
155 | 162 | if ((uincludes != NULL) && (ucflags != NULL) && (uldflags != NULL)) { |
200 | 207 | rcflags = str_concat("", prfx, "-I", uprefix, "/include ", rcflags, NULL); |
201 | 208 | if (old != cflags) free(old); |
202 | 209 | |
210 | /* add -I to the db too */ | |
211 | old = dbcflags; | |
212 | dbcflags = str_concat("", "-I", uprefix, "/include ", dbcflags, NULL); | |
213 | free(old); | |
214 | ||
215 | ||
203 | 216 | old = rldflags; |
204 | 217 | if ((rldflags != NULL) && (*rldflags == '^')) { |
205 | 218 | rldflags++; |
209 | 222 | prfx = ""; |
210 | 223 | rldflags = str_concat("", prfx, "-L", uprefix, "/lib ", rldflags, NULL); |
211 | 224 | if (old != ldflags) free(old); |
225 | ||
226 | /* add -L to the db too */ | |
227 | old = dbldflags; | |
228 | dbldflags = str_concat("", "-L", uprefix, "/lib ", dbldflags, NULL); | |
229 | free(old); | |
212 | 230 | } |
213 | 231 | |
214 | 232 | res = try_icl__(logdepth, prefix, test_c_in, rincludes, rcflags, rldflags, dbincludes, dbcflags, dbldflags, run, accept_res); |
333 | 351 | { |
334 | 352 | char path[1024]; |
335 | 353 | |
354 | if (strlen(key) > sizeof(path)-32) { | |
355 | report("ERROR: no room for import_icl() - key is probably too long.\n"); | |
356 | return -1; | |
357 | } | |
358 | ||
336 | 359 | switch(*key) { |
337 | 360 | case 'l': sprintf(path, "/arg/icl/%s/ldflags", key+8); break; |
338 | 361 | case 'c': sprintf(path, "/arg/icl/%s/cflags", key+7); break; |
341 | 364 | default: |
342 | 365 | return 1; |
343 | 366 | } |
344 | printf("path='%s' fn='%s'\n", path, fn); | |
345 | 367 | return put(path, fn) == NULL; |
346 | 368 | } |
347 | 369 | |
370 | 392 | NL "}" |
371 | 393 | NL; |
372 | 394 | |
395 | if (strlen(fieldn) + strlen(structn) + strlen(test_c_in) + 32 >= sizeof(test_c)) { | |
396 | report("ERROR: no room for try_icl_sfield() - struct or field name is probably too long.\n"); | |
397 | return -1; | |
398 | } | |
399 | ||
373 | 400 | sprintf(test_c, test_c_in, structn, fieldn); |
374 | 401 | |
375 | 402 | res = try_icl_(logdepth, prefix, test_c, includes, cflags, ldflags, 1, field_accept_res); |
33 | 33 | int find_math_isnan(const char *name, int logdepth, int fatal) |
34 | 34 | { |
35 | 35 | char *test_c = |
36 | NL "#include <stdio.h>" | |
36 | 37 | NL "int main() {" |
37 | 38 | NL " if (!isnan(1.0))" |
38 | 39 | NL " puts(\"OK\");" |
59 | 60 | int find_math_isinf(const char *name, int logdepth, int fatal) |
60 | 61 | { |
61 | 62 | char *test_c = |
63 | NL "#include <stdio.h>" | |
62 | 64 | NL "int main() {" |
63 | 65 | NL " if (!isinf(1.0))" |
64 | 66 | NL " puts(\"OK\");" |
86 | 88 | int find_math_isfinite(const char *name, int logdepth, int fatal) |
87 | 89 | { |
88 | 90 | char *test_c = |
91 | NL "#include <stdio.h>" | |
89 | 92 | NL "int main() {" |
90 | 93 | NL " if (isfinite(1.0))" |
91 | 94 | NL " puts(\"OK\");" |
113 | 116 | int find_math_isnormal(const char *name, int logdepth, int fatal) |
114 | 117 | { |
115 | 118 | char *test_c = |
119 | NL "#include <stdio.h>" | |
116 | 120 | NL "int main() {" |
117 | 121 | NL " if (isnormal(1.0))" |
118 | 122 | NL " puts(\"OK\");" |
144 | 148 | int find_math_nan(const char *name, int logdepth, int fatal) |
145 | 149 | { |
146 | 150 | char *test_c = |
151 | NL "#include <stdio.h>" | |
147 | 152 | NL "int main() {" |
148 | 153 | NL " if (nan(\"foo\") != 0.0)" |
149 | 154 | NL " puts(\"OK\");" |
173 | 178 | char *test_c_temp = |
174 | 179 | NL "#include <stdlib.h>" |
175 | 180 | NL "#include <stdio.h>" |
181 | NL "#include <string.h>" | |
176 | 182 | NL "%s" |
177 | 183 | NL |
178 | 184 | NL "double s2d(const char *s)" |
32 | 32 | static int test_mathf(const char *name, int logdepth, int fatal, const char *fname, const char *cond) |
33 | 33 | { |
34 | 34 | char *test_c_template = |
35 | NL "#include <stdio.h>" | |
35 | 36 | NL "float one=1.0, zero=0.0;" |
36 | 37 | NL "int main() {" |
37 | 38 | NL " if (%s)" |
33 | 33 | int find_math_minpack(const char *name, int logdepth, int fatal) |
34 | 34 | { |
35 | 35 | char *test_c = |
36 | NL "#include <stdio.h>" | |
36 | 37 | NL "int main() {" |
37 | 38 | NL " int one=1;" |
38 | 39 | NL " if (dpmpar_(&one) != 0.0)" |
0 | 0 | /* |
1 | 1 | scconfig - parser generator detection |
2 | Copyright (C) 2009 Tibor Palinkas | |
2 | Copyright (C) 2009,2020 Tibor Palinkas | |
3 | 3 | |
4 | 4 | This library is free software; you can redistribute it and/or |
5 | 5 | modify it under the terms of the GNU Lesser General Public |
74 | 74 | return 1; |
75 | 75 | } |
76 | 76 | |
77 | int find_parsgen_bison(const char *name, int logdepth, int fatal) | |
78 | { | |
79 | const char *test_bison = | |
77 | static const char *test_yacc = | |
80 | 78 | NL "%union { char *str; double num;}" |
81 | NL "%%" | |
82 | 79 | NL "%token <str> TOK1;" |
83 | 80 | NL "%token <num> TOK2;" |
81 | NL "%%" | |
84 | 82 | NL "root: one | two;" |
85 | 83 | NL "one: TOK1;" |
86 | 84 | NL "two: TOK2;" |
87 | 85 | NL ; |
86 | ||
87 | int find_parsgen_bison(const char *name, int logdepth, int fatal) | |
88 | { | |
88 | 89 | char *out, *temp_in, *temp_in_esc, *cmd; |
89 | 90 | int ret; |
90 | 91 | char *bisfile, *s; |
94 | 95 | logprintf(logdepth, "find_bison: trying to find bison...\n"); |
95 | 96 | logdepth++; |
96 | 97 | |
97 | temp_in = tempfile_dump(test_bison, ".y"); | |
98 | temp_in = tempfile_dump(test_yacc, ".y"); | |
98 | 99 | bisfile = malloc(strlen(temp_in) + 32); |
99 | 100 | strcpy(bisfile, temp_in); |
100 | 101 | s = strrchr(bisfile+1, '.'); |
131 | 132 | return 1; |
132 | 133 | } |
133 | 134 | |
135 | int find_parsgen_byaccic(const char *name, int logdepth, int fatal) | |
136 | { | |
137 | char *out, *temp_in, *temp_in_esc, *cmd; | |
138 | int ret; | |
139 | char *bisfile, *s; | |
140 | (void) fatal; /* not used */ | |
141 | ||
142 | report("Checking for byaccic... "); | |
143 | logprintf(logdepth, "find_byaccic: trying to find byaccic...\n"); | |
144 | logdepth++; | |
145 | ||
146 | temp_in = tempfile_dump(test_yacc, ".y"); | |
147 | bisfile = malloc(strlen(temp_in) + 32); | |
148 | strcpy(bisfile, temp_in); | |
149 | s = strrchr(bisfile+1, '.'); | |
150 | strcpy(s, ".tab.c"); | |
151 | if (is_file(bisfile)) { | |
152 | report("ERROR: %s exists, and I don't dare to delete it. Can't test byaccic, please remove the file by hand.\n", bisfile); | |
153 | 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); | |
154 | exit(1); | |
155 | } | |
156 | temp_in_esc = shell_escape_dup(temp_in); | |
157 | cmd = malloc(strlen(temp_in_esc)*2 + 32); | |
158 | sprintf(cmd, "byaccic -o %s %s", bisfile, temp_in_esc); | |
159 | free(temp_in_esc); | |
160 | ||
161 | ret = run(logdepth, cmd, &out); | |
162 | remove(temp_in); | |
163 | free(temp_in); | |
164 | if (out != NULL) | |
165 | free(out); | |
166 | ||
167 | if (is_file(bisfile)) { | |
168 | remove(bisfile); | |
169 | if (ret == 0) { | |
170 | put("parsgen/byaccic", "byaccic"); | |
171 | put("parsgen/byaccic/presents", strue); | |
172 | report("Found.\n"); | |
173 | return 0; | |
174 | } | |
175 | } | |
176 | ||
177 | put("parsgen/byaccic/presents", sfalse); | |
178 | report("Not found.\n"); | |
179 | return 1; | |
180 | } | |
181 | ||
182 | int find_parsgen_ureglex(const char *name, int logdepth, int fatal) | |
183 | { | |
184 | const char *test_ureglex = | |
185 | NL "rule blank" | |
186 | NL "regex [ \t\r]+" | |
187 | NL "code" | |
188 | NL " ULX_IGNORE;" | |
189 | NL "rulestring 3D_DXF return 0;" | |
190 | NL ; | |
191 | char *out, *temp_in, *temp_in_esc, *cmd; | |
192 | int ret; | |
193 | char *lexfile = "lex.yy.c"; | |
194 | (void) fatal; /* not used */ | |
195 | ||
196 | report("Checking for ureglex... "); | |
197 | logprintf(logdepth, "find_ureglex: trying to find ureglex...\n"); | |
198 | logdepth++; | |
199 | ||
200 | if (is_file(lexfile)) { | |
201 | report("ERROR: %s exists, and I don't dare to delete it. Can't test ureglex, please remove the file by hand.\n", lexfile); | |
202 | 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); | |
203 | exit(1); | |
204 | } | |
205 | temp_in = tempfile_dump(test_ureglex, ".lex"); | |
206 | temp_in_esc = shell_escape_dup(temp_in); | |
207 | cmd = malloc(strlen(temp_in_esc) + 32); | |
208 | sprintf(cmd, "ureglex -l %s -c %s", temp_in_esc, lexfile); | |
209 | free(temp_in_esc); | |
210 | ret = run(logdepth, cmd, &out); | |
211 | remove(temp_in); | |
212 | free(temp_in); | |
213 | if (out != NULL) | |
214 | free(out); | |
215 | ||
216 | if (is_file(lexfile)) { | |
217 | remove(lexfile); | |
218 | if (ret == 0) { | |
219 | put("parsgen/ureglex", "ureglex"); | |
220 | put("parsgen/ureglex/presents", strue); | |
221 | report("Found.\n"); | |
222 | return 0; | |
223 | } | |
224 | } | |
225 | ||
226 | put("parsgen/ureglex/presents", sfalse); | |
227 | report("Not found.\n"); | |
228 | return 1; | |
229 | } | |
230 | ||
134 | 231 | void deps_parsgen_init() |
135 | 232 | { |
136 | 233 | dep_add("parsgen/flex/*", find_parsgen_flex); |
137 | 234 | dep_add("parsgen/bison/*", find_parsgen_bison); |
138 | } | |
235 | dep_add("parsgen/byaccic/*", find_parsgen_byaccic); | |
236 | dep_add("parsgen/ureglex/*", find_parsgen_ureglex); | |
237 | } |
473 | 473 | tmpasm_t *child; |
474 | 474 | |
475 | 475 | fn = tmpasm_arg2str(ctx, argv[n], 0); |
476 | path = scc_path(ud, fn); | |
476 | if (*fn != '/') | |
477 | path = scc_path(ud, fn); | |
478 | else | |
479 | path = strclone(fn); | |
477 | 480 | fin = fopen(path, "r"); |
478 | 481 | if (fin == NULL) { |
479 | 482 | tmpasm_runtime_error(ctx, -8, path); |
8 | 8 | all: |
9 | 9 | |
10 | 10 | install: |
11 | @fstools/mkdir@ $(LIBPATH) | |
11 | @/host/fstools/mkdir@ $(LIBPATH) | |
12 | 12 | @] |
13 | 13 | foreach /local/n in /local/libs |
14 | print [@ @fstools/cp@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk | |
14 | print [@ @/host/fstools/cp@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk | |
15 | 15 | @] |
16 | 16 | end |
17 | 17 | |
18 | 18 | print [@ |
19 | 19 | linstall: |
20 | @fstools/mkdir@ $(LIBPATH) | |
20 | @/host/fstools/mkdir@ $(LIBPATH) | |
21 | 21 | @] |
22 | 22 | foreach /local/n in /local/libs |
23 | print [@ @fstools/ln@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk | |
23 | print [@ @/host/fstools/ln@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk | |
24 | 24 | @] |
25 | 25 | end |
26 | 26 | |
28 | 28 | uninstall: |
29 | 29 | @] |
30 | 30 | foreach /local/n in /local/libs |
31 | print [@ @fstools/rm@ $(LIBPATH)/@/local/n@.awk | |
31 | print [@ @/host/fstools/rm@ $(LIBPATH)/@/local/n@.awk | |
32 | 32 | @] |
33 | 33 | end |
34 | 34 |
141 | 141 | $(CP) $(PWD)/man/example.7libmawk $(MAN7DIR)/example.7libmawk |
142 | 142 | $(CHMOD) 0644 $(MAWKMAN) |
143 | 143 | $(CP) $(PWD)/libmawk.so $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3) |
144 | rm $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2) $(LIBARCHDIR)/libmawk.so.$(SOVER1) 2>/dev/null ; true | |
144 | rm $(LIBARCHDIR)/libmawk.so $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2) $(LIBARCHDIR)/libmawk.so.$(SOVER1) 2>/dev/null ; true | |
145 | 145 | ln -s libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3) $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2) |
146 | 146 | ln -s libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3) $(LIBARCHDIR)/libmawk.so.$(SOVER1) |
147 | 147 | ln -s libmawk.so.$(SOVER1) $(LIBARCHDIR)/libmawk.so |
36 | 36 | |
37 | 37 | #----------------- scconfig detected ---------------------------------- |
38 | 38 | CC = @cc/cc@ |
39 | CFLAGS = @cc/cflags@ @cc/fpic@ -I.. -I. $(CFLAGS_APP) | |
39 | CFLAGS = @cc/cflags@ @cc/fpic@ @?/local/nofork@ -I.. -I. $(CFLAGS_APP) | |
40 | 40 | LDFLAGS = @cc/ldflags@ |
41 | 41 | LDFLAGS_SO = @/local/soname@ |
42 | 42 | LDFLAGS_RDYNAMIC = @cc/rdynamic@ |
43 | 43 | |
44 | CHMODX = @fstools/chmodx@ | |
44 | CHMODX = @/host/fstools/chmodx@ | |
45 | 45 | CHMOD = chmod |
46 | MKDIR = @fstools/mkdir@ | |
47 | CP=@fstools/cp@ | |
48 | SYMLINK=@fstools/ln@ | |
46 | MKDIR = @/host/fstools/mkdir@ | |
47 | CP=@/host/fstools/cp@ | |
48 | SYMLINK=@/host/fstools/ln@ | |
49 | 49 | @] |
50 | 50 | |
51 | 51 | switch /local/numeric |
16 | 16 | #include <string.h> |
17 | 17 | #include <unistd.h> |
18 | 18 | #include <sys/types.h> |
19 | #ifndef MAWK_NO_FORK | |
19 | 20 | #include <sys/wait.h> |
21 | #endif | |
20 | 22 | #include "mawk.h" |
21 | 23 | #include "files.h" |
22 | 24 | #include "memory.h" |
8 | 8 | ********************************************/ |
9 | 9 | #include "vio_fifo.h" |
10 | 10 | #include "memory.h" |
11 | ||
12 | const mawk_vio_imp_t mawk_vio_fifo_imp; | |
11 | 13 | |
12 | 14 | mawk_vio_t *mawk_vio_fifo_open(mawk_state_t *MAWK, const char *name, mawk_vio_open_mode_t mode) |
13 | 15 | { |
13 | 13 | int eof_from_app; /* 1 if there won't be more from the app or the app won't accept more data */ |
14 | 14 | } mawk_vio_fifo_t; |
15 | 15 | |
16 | const mawk_vio_imp_t mawk_vio_fifo_imp; | |
16 | extern const mawk_vio_imp_t mawk_vio_fifo_imp; | |
17 | 17 | |
18 | 18 | mawk_vio_t *mawk_vio_fifo_open(mawk_state_t *MAWK, const char *name, mawk_vio_open_mode_t mode); |
19 | 19 |