diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | Src/Modules/termcap.c | 2 | ||||
-rw-r--r-- | Src/Modules/termcap.mdd | 12 | ||||
-rw-r--r-- | Src/Modules/terminfo.c | 2 | ||||
-rw-r--r-- | Src/Modules/terminfo.mdd | 12 | ||||
-rw-r--r-- | aczsh.m4 | 81 | ||||
-rw-r--r-- | configure.in | 84 |
7 files changed, 139 insertions, 63 deletions
diff --git a/ChangeLog b/ChangeLog index 4bddff7c8..023fdce7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ + +2001-02-02 Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru> + + * 13431: aczsh.m4,configure.in,Src/Modules/termcap.c, + Src/Modules/termcap.mdd,Src/Modules/terminfo.c, + Src/Modules/terminfo.mdd,Src/mkmakemod.sh: hopefully better + check for shared libraries. Link in termcap/terminfo statically + if shared libtermcap/libcurses unavailable + 2001-02-13 Sven Wischnowsky <wischnow@zsh.org> * 13462: Src/Modules/zpty.c: try to make the -t option of zpty diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c index 8f5f650f9..9c72bf27f 100644 --- a/Src/Modules/termcap.c +++ b/Src/Modules/termcap.c @@ -33,7 +33,7 @@ /* echotc: output a termcap */ /**/ -int +static int bin_echotc(char *name, char **argv, char *ops, int func) { char *s, buf[2048], *t, *u; diff --git a/Src/Modules/termcap.mdd b/Src/Modules/termcap.mdd index 5f88a9662..89f939ff8 100644 --- a/Src/Modules/termcap.mdd +++ b/Src/Modules/termcap.mdd @@ -1,5 +1,15 @@ name=zsh/termcap -link=either + +link='if test "x$ac_cv_func_tgetent" = xyes; then + if test "x$zsh_cv_shared_tgetent" = xyes; then + echo either + else + echo static + fi + else + echo no; + fi +' load=yes autobins="echotc" diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c index 512f4b474..7eb47bdb3 100644 --- a/Src/Modules/terminfo.c +++ b/Src/Modules/terminfo.c @@ -36,7 +36,7 @@ static Param terminfo_pm; /* echoti: output a terminfo capability */ /**/ -int +static int bin_echoti(char *name, char **argv, char *ops, int func) { char *s, *t; diff --git a/Src/Modules/terminfo.mdd b/Src/Modules/terminfo.mdd index 251281742..dd01bed3a 100644 --- a/Src/Modules/terminfo.mdd +++ b/Src/Modules/terminfo.mdd @@ -1,5 +1,15 @@ name=zsh/terminfo -link='if test "x$ac_cv_func_tigetstr" = xyes; then echo either; else echo no; fi' + +link='if test "x$ac_cv_func_tigetstr" = xyes; then + if test "x$zsh_cv_shared_tigetstr" = xyes; then + echo either + else + echo static + fi + else + echo no; + fi +' load=yes autobins="echoti" diff --git a/aczsh.m4 b/aczsh.m4 index b32ed9fca..83738311d 100644 --- a/aczsh.m4 +++ b/aczsh.m4 @@ -111,32 +111,59 @@ main() dnl -dnl zsh_SYS_DYNAMIC_BROKEN -dnl Check whether static/shared library linking is broken. +dnl zsh_SHARED_FUNCTION +dnl +dnl This is just a frontend to zsh_SHARED_SYMBOL +dnl +dnl Usage: zsh_SHARED_FUNCTION(name[,rettype[,paramtype]]) +dnl + +AC_DEFUN(zsh_SHARED_FUNCTION, +[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1 [(]ifelse([$3], ,[ ],[$3])[)], $1)]) + +dnl +dnl zsh_SHARED_VARIABLE +dnl +dnl This is just a frontend to zsh_SHARED_SYMBOL +dnl +dnl Usage: zsh_SHARED_VARIABLE(name[,type]) +dnl + +AC_DEFUN(zsh_SHARED_VARIABLE, +[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1, [&$1])]) + +dnl +dnl zsh_SHARED_SYMBOL +dnl Check whether symbol is available in static or shared library dnl dnl On some systems, static modifiable library symbols (such as environ) dnl may appear only in statically linked libraries. If this is the case, dnl then two shared libraries that reference the same symbol, each linked dnl with the static library, could be given distinct copies of the symbol. -dnl If this is the case then dynamic linking is FUBAR. +dnl +dnl Usage: zsh_SHARED_SYMBOL(name,declaration,address) +dnl Sets zsh_cv_shared_$1 cache variable to yes/no dnl -AC_DEFUN(zsh_SYS_DYNAMIC_BROKEN, -[AC_CACHE_CHECK([if static/shared library linking is broken], -zsh_cv_sys_dynamic_broken, +AC_DEFUN(zsh_SHARED_SYMBOL, +[AC_CACHE_CHECK([if $1 is available in shared libraries], +zsh_cv_shared_$1, [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then us=_ else us= fi echo ' - extern char **environ; - void *symlist1[[]] = { - (void *)&environ, - (void *)0 - }; +void *zsh_getaddr1() +{ +#ifdef __CYGWIN__ + __attribute__((__dllimport__)) +#endif + extern $2; + return $3; +}; ' > conftest1.c -sed 's/symlist1/symlist2/' < conftest1.c > conftest2.c +sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 && $DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 2>&5 && $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&5 2>&5 && @@ -172,25 +199,33 @@ char *zsh_gl_sym_addr ; main() { void *handle1, *handle2; - void **symlist1, **symlist2; + void *(*zsh_getaddr1)(), *(*zsh_getaddr2)(); + void *sym1, *sym2; handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL); if(!handle1) exit(1); handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL); if(!handle2) exit(1); - symlist1 = (void **) dlsym(handle1, "${us}symlist1"); - symlist2 = (void **) dlsym(handle2, "${us}symlist2"); - if(!symlist1 || !symlist2) exit(1); - for(; *symlist1; symlist1++, symlist2++) - if(*symlist1 != *symlist2) - exit(1); + zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1"); + zsh_getaddr2 = (void *(*)()) dlsym(handle2, "${us}zsh_getaddr2"); + sym1 = zsh_getaddr1(); + sym2 = zsh_getaddr2(); + if(!sym1 || !sym2) exit(1); + if(sym1 != sym2) exit(1); + dlclose(handle1); + handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL); + if(!handle1) exit(1); + zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1"); + sym1 = zsh_getaddr1(); + if(!sym1) exit(1); + if(sym1 != sym2) exit(1); exit(0); } -], [zsh_cv_sys_dynamic_broken=no], -[zsh_cv_sys_dynamic_broken=yes], -[zsh_cv_sys_dynamic_broken=yes] +], [zsh_cv_shared_$1=yes], +[zsh_cv_shared_$1=no], +[zsh_cv_shared_$1=no] ) else - zsh_cv_sys_dynamic_broken=yes + zsh_cv_shared_$1=no fi ]) ]) diff --git a/configure.in b/configure.in index da5fb5e90..c31190af1 100644 --- a/configure.in +++ b/configure.in @@ -493,7 +493,9 @@ dnl ------------------- dnl On some systems, modules need to be linked against libc explicitly, dnl in case they require objects that exist only in the static version dnl and might not be compiled into the zsh executable. -AC_CHECK_LIB(c, printf) +dnl On ReliantUNIX -lc better be the last library, else funny things +dnl may happen. +AC_CHECK_LIB(c, printf, [LIBS="$LIBS -lc"]) AC_CHECK_LIB(m, pow) @@ -557,37 +559,6 @@ elif test $zsh_cv_decl_ospeed_must_define = yes; then AC_DEFINE(MUST_DEFINE_OSPEED) fi -dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer) -dnl Some termcaps reportedly accept a zero buffer, but then dump core -dnl in tgetstr(). -dnl Under Cygwin test program crashes but exit code is still 0. So, -dnl we test for a file that porgram should create -AC_CACHE_CHECK(if tgetent accepts NULL, -zsh_cv_func_tgetent_accepts_null, -[AC_TRY_RUN([ -main() -{ - int i = tgetent((char*)0,"vt100"); - if (i > 0) { - char tbuf[1024], *u; - u = tbuf; - tgetstr("cl", &u); - creat("conftest.tgetent", 0640); - } - exit(!i || i == -1); -} -], - if test -f conftest.tgetent; then - zsh_cv_func_tgetent_accepts_null=yes - else - zsh_cv_func_tgetent_accepts_null=no - fi, - zsh_cv_func_tgetent_accepts_null=no, - zsh_cv_func_tgetent_accepts_null=no)]) -if test $zsh_cv_func_tgetent_accepts_null = yes; then - AC_DEFINE(TGETENT_ACCEPTS_NULL) -fi - dnl -------------- dnl CHECK TYPEDEFS dnl -------------- @@ -845,9 +816,40 @@ AC_CHECK_FUNCS(strftime difftime gettimeofday \ putenv getenv \ brk sbrk \ pathconf sysconf \ - tigetflag tigetnum tigetstr) + tgetent tigetflag tigetnum tigetstr) AC_FUNC_STRCOLL +dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer) +dnl Some termcaps reportedly accept a zero buffer, but then dump core +dnl in tgetstr(). +dnl Under Cygwin test program crashes but exit code is still 0. So, +dnl we test for a file that porgram should create +AC_CACHE_CHECK(if tgetent accepts NULL, +zsh_cv_func_tgetent_accepts_null, +[AC_TRY_RUN([ +main() +{ + int i = tgetent((char*)0,"vt100"); + if (i > 0) { + char tbuf[1024], *u; + u = tbuf; + tgetstr("cl", &u); + creat("conftest.tgetent", 0640); + } + exit(!i || i == -1); +} +], + if test -f conftest.tgetent; then + zsh_cv_func_tgetent_accepts_null=yes + else + zsh_cv_func_tgetent_accepts_null=no + fi, + zsh_cv_func_tgetent_accepts_null=no, + zsh_cv_func_tgetent_accepts_null=no)]) +if test $zsh_cv_func_tgetent_accepts_null = yes; then + AC_DEFINE(TGETENT_ACCEPTS_NULL) +fi + AC_FUNC_MMAP if test x$ac_cv_func_mmap_fixed_mapped = xyes; then AC_CHECK_FUNCS(munmap msync) @@ -1471,7 +1473,10 @@ elif test "x$ac_cv_cygwin" = xyes; then zsh_cv_sys_dynamic_execsyms="${zsh_cv_sys_dynamic_execsyms=no}" zsh_cv_sys_dynamic_strip_exe="${zsh_cv_sys_dynamic_strip_exe=yes}" zsh_cv_sys_dynamic_strip_lib="${zsh_cv_sys_dynamic_strip_lib=yes}" - zsh_cv_sys_dynamic_broken="${zsh_cv_sys_dynamic_broken=no}" + # + # THAT SUCKS! and must be changed + # + zsh_cv_shared_environ="${zsh_cv_shared_environ=yes}" LINKMODS=LINKMODS MOD_EXPORT="__attribute__((__dllexport__))" MOD_IMPORT_VARIABLE="__attribute__((__dllimport__))" @@ -1616,8 +1621,15 @@ main() fi if test "x$dynamic" = xyes; then - zsh_SYS_DYNAMIC_BROKEN - test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no + zsh_SHARED_VARIABLE([environ], [char **]) + test "$zsh_cv_shared_environ" = yes || dynamic=no +dnl test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no + if test "$ac_cv_func_tgetent" = yes; then + zsh_SHARED_FUNCTION([tgetent]) + fi + if test "$ac_cv_func_tigetstr" = yes; then + zsh_SHARED_FUNCTION([tigetstr]) + fi fi if test "x$dynamic" = xyes; then |