From 69724a8ba74dab7e2f07ecdc90dd36a4afcd082c Mon Sep 17 00:00:00 2001 From: sam Date: Fri, 19 Sep 2003 08:54:08 +0000 Subject: [PATCH] * Added -no-undefined to all plugins' LDFLAGS. * Disabled most of the unix plugin code under Windows. * Replaced remaining index/rindex calls with strchr/strrchr. * Updated the Win32 build. git-svn-id: svn://svn.zoy.org/elk/trunk@164 55e467fa-43c5-0310-a8a2-de718669efc6 --- build-win32 | 9 +++++---- configure.ac | 4 ++-- lib/unix/Makefile.am | 2 +- lib/unix/fdescr.c | 22 +++++++++++++++++++--- lib/unix/file.c | 16 +++++++++++++--- lib/unix/misc.c | 2 ++ lib/unix/passwd.c | 20 ++++++++++++++++++-- lib/unix/process.c | 10 +++++++--- lib/unix/signal.c | 15 +++++++++++++++ lib/unix/system.c | 2 +- lib/unix/unix.h | 4 +++- lib/unix/wait.c | 2 ++ lib/xlib/Makefile.am | 2 +- lib/xwidgets/Makefile.am | 4 ++-- lib/xwidgets/motif/Makefile.am | 2 +- lib/xwidgets/xaw/Makefile.am | 2 +- 16 files changed, 93 insertions(+), 25 deletions(-) diff --git a/build-win32 b/build-win32 index 0632a33..780e0f9 100755 --- a/build-win32 +++ b/build-win32 @@ -13,10 +13,11 @@ rm -Rf "${DIRNAME}" rm -f "${DIRNAME}.zip" mkdir "${DIRNAME}" -# To build for win32, I use ./configure --host=i586-mingw32msvc -(cd src && make && cp elk.exe "${DESTDIR}") -(cd scm && make install DESTDIR="${DESTDIR}" datadir="/") -mv "${DESTDIR}/elk" "${DESTDIR}/scm" +# To build for win32, I use: +# ./configure --host=i586-mingw32msvc --prefix=/ --bindir=/ --libdir=/ +# make pkglibdir=/lib pkgdatadir=/scm +make install DESTDIR="${DESTDIR}" pkglibdir=/lib pkgdatadir=/scm +cp "src/.libs/libelk-0.dll" "${DESTDIR}" # Pack the directory zip "${DIRNAME}.zip" `find "${DIRNAME}"` diff --git a/configure.ac b/configure.ac index 7cf61df..4132a81 100644 --- a/configure.ac +++ b/configure.ac @@ -383,7 +383,7 @@ AC_DEFINE(ANSI_CPP, 1, [FIXME HARD]) # The UNIX extension likes to know which of the following system calls, # library functions, and include files are supported by the system. -AC_CHECK_HEADERS(utime.h sys/wait.h) +AC_CHECK_HEADERS(utime.h sys/utime.h sys/wait.h dirent.h) AC_CHECK_FUNCS(waitpid wait3 wait4 vfork uname gethostname gettimeofday ftime) AC_CHECK_FUNCS(mktemp tmpnam tempnam getcwd getwd rename regcomp) @@ -410,7 +410,7 @@ AC_DEFINE_UNQUOTED(LIB_DIR, "${prefix}/lib/elk", [Plugins directory]) #define FIND_AOUT defined(USE_LD) || defined(CAN_DUMP) || defined(INIT_OBJECTS) AC_DEFINE(FIND_AOUT, 1, [FIXME HARD]) -AC_CHECK_HEADERS(pwd.h sys/resource.h) +AC_CHECK_HEADERS(pwd.h grp.h sys/resource.h) dnl dnl Check for available compiler features diff --git a/lib/unix/Makefile.am b/lib/unix/Makefile.am index 69c343d..9a196a1 100644 --- a/lib/unix/Makefile.am +++ b/lib/unix/Makefile.am @@ -19,7 +19,7 @@ unix_la_SOURCES = \ unix.c \ wait.c \ $(NULL) -unix_la_LDFLAGS = -module -avoid-version +unix_la_LDFLAGS = -module -avoid-version -no-undefined unix_la_LIBADD = $(top_builddir)/src/libelk.la extensions_HEADERS = unix.h diff --git a/lib/unix/fdescr.c b/lib/unix/fdescr.c index 7e7abcb..8852995 100644 --- a/lib/unix/fdescr.c +++ b/lib/unix/fdescr.c @@ -62,7 +62,9 @@ static SYMDESCR Fcntl_Flags[] = { #ifdef O_SYNCIO { "syncio", O_SYNCIO }, #endif +#ifdef O_NDELAY { "ndelay", O_NDELAY }, +#endif #ifdef O_NONBLOCK { "nonblock", O_NONBLOCK }, #endif @@ -91,15 +93,19 @@ static Object P_Close(Object fd) { } static Object P_Close_On_Exec(int argc, Object *argv) { - int flags, fd; + int flags = 0, fd; fd = Get_Integer(argv[0]); +#ifndef WIN32 if ((flags = fcntl(fd, F_GETFD, 0)) == -1) Raise_System_Error("fcntl(F_GETFD): ~E"); +#endif if (argc == 2) { Check_Type(argv[1], T_Boolean); +#ifndef WIN32 if (fcntl(fd, F_SETFD, Truep(argv[1])) == -1) Raise_System_Error("fcntl(F_SETFD): ~E"); +#endif } return flags & 1 ? True : False; } @@ -113,14 +119,18 @@ static Object P_Dup(int argc, Object *argv) { } static Object P_Filedescriptor_Flags(int argc, Object *argv) { - int flags, fd; + int flags = 0, fd; fd = Get_Integer(argv[0]); +#ifndef WIN32 if ((flags = fcntl(fd, F_GETFL, 0)) == -1) Raise_System_Error("fcntl(F_GETFL): ~E"); +#endif if (argc == 2) { +#ifndef WIN32 if (fcntl(fd, F_SETFL, Symbols_To_Bits(argv[1], 1, Fcntl_Flags)) == -1) Raise_System_Error("fcntl(F_SETFL): ~E"); +#endif } return Bits_To_Symbols((unsigned long)flags, 1, Fcntl_Flags); } @@ -223,7 +233,11 @@ static Object P_Open(int argc, Object *argv) { static Object P_Pipe() { int fd[2]; +#ifdef WIN32 + if (_pipe(fd, 256, O_BINARY) == -1) +#else if (pipe(fd) == -1) +#endif Raise_System_Error("~E"); return Integer_Pair(fd[0], fd[1]); } @@ -267,12 +281,14 @@ static Object P_Writex(int argc, Object *argv) { } static Object P_Ttyname(Object fd) { - char *ret; + char *ret = NULL; +#ifndef WIN32 extern char *ttyname(); Disable_Interrupts; ret = ttyname(Get_Integer(fd)); Enable_Interrupts; +#endif return ret ? Make_String(ret, strlen(ret)) : False; } diff --git a/lib/unix/file.c b/lib/unix/file.c index b032ace..ad6d983 100644 --- a/lib/unix/file.c +++ b/lib/unix/file.c @@ -34,13 +34,15 @@ #ifdef HAVE_UTIME_H # include +#elif HAVE_SYS_UTIME_H +# include #else struct utimbuf { time_t actime, modtime; }; #endif -#ifdef HAVE_DIRENT +#ifdef HAVE_DIRENT_H # include #else # include @@ -78,26 +80,32 @@ static Object P_Chmod(Object fn, Object mode) { } static Object P_Chown(Object fn, Object uid, Object gid) { +#ifndef WIN32 if (chown(Get_Strsym(fn), Get_Integer(uid), Get_Integer(gid)) == -1) Raise_System_Error1("~s: ~E", fn); +#endif return Void; } static Object P_Link(Object fn1, Object fn2) { +#ifndef WIN32 if (link(Get_Strsym(fn1), Get_Strsym(fn2)) == -1) Raise_System_Error2("(~s ~s): ~E", fn1, fn2); +#endif return Void; } static Object P_Mkdir(Object fn, Object mode) { +#ifndef WIN32 if (mkdir(Get_Strsym(fn), Get_Integer(mode)) == -1) Raise_System_Error1("~s: ~E", fn); +#endif return Void; } static Object P_Read_Directory(Object fn) { DIR *d; -#ifdef HAVE_DIRENT +#ifdef HAVE_DIRENT_H struct dirent *dp; #else struct direct *dp; @@ -155,7 +163,7 @@ static Object General_Stat(Object obj, Object ret, int l) { Object x; struct stat st; char *s, *fn = NULL; - int fd = -1, result; + int fd = -1, result = 0; GC_Node; Check_Result_Vector(ret, 11); @@ -268,9 +276,11 @@ static Object P_Utime(int argc, Object *argv) { ut.actime = (time_t)Get_Unsigned_Long(argv[1]); ut.modtime = (time_t)Get_Unsigned_Long(argv[2]); } +#ifndef WIN32 if (utime(Get_Strsym(argv[0]), argc == 1 ? (struct utimbuf *)0 : &ut) == -1) Raise_System_Error1("~s: ~E", argv[0]); +#endif return Void; } diff --git a/lib/unix/misc.c b/lib/unix/misc.c index af43e26..11b3019 100644 --- a/lib/unix/misc.c +++ b/lib/unix/misc.c @@ -32,6 +32,7 @@ #include +#ifndef WIN32 static Object P_Getpass(Object prompt) { char *ret; extern char *getpass(); @@ -47,3 +48,4 @@ static Object P_Getpass(Object prompt) { void elk_init_unix_misc() { Def_Prim(P_Getpass, "unix-getpass", 1, 1, EVAL); } +#endif diff --git a/lib/unix/passwd.c b/lib/unix/passwd.c index 6b1a251..4149de3 100644 --- a/lib/unix/passwd.c +++ b/lib/unix/passwd.c @@ -31,10 +31,15 @@ #include "unix.h" #include -#include -#include +#ifdef HAVE_PWD_H +# include +#endif +#ifdef HAVE_GRP_H +# include +#endif static Object P_Get_Passwd(int argc, Object *argv) { +#ifndef WIN32 struct passwd *p; Object arg, x; @@ -77,24 +82,30 @@ static Object P_Get_Passwd(int argc, Object *argv) { VECTOR(argv[0])->data[5] = x; x = Make_String(p->pw_shell, strlen(p->pw_shell)); VECTOR(argv[0])->data[6] = x; +#endif return Void; } static Object P_Rewind_Passwd() { +#ifndef WIN32 Disable_Interrupts; setpwent(); Enable_Interrupts; +#endif return Void; } static Object P_End_Passwd() { +#ifndef WIN32 Disable_Interrupts; endpwent(); Enable_Interrupts; +#endif return Void; } static Object P_Get_Group(int argc, Object *argv) { +#ifndef WIN32 char **pp; struct group *p; Object arg, member, x; @@ -140,20 +151,25 @@ static Object P_Get_Group(int argc, Object *argv) { x = P_Reverse(x); GC_Unlink; VECTOR(argv[0])->data[3] = x; +#endif return Void; } static Object P_Rewind_Group() { +#ifndef WIN32 Disable_Interrupts; setgrent(); Enable_Interrupts; +#endif return Void; } static Object P_End_Group() { +#ifndef WIN32 Disable_Interrupts; endgrent(); Enable_Interrupts; +#endif return Void; } diff --git a/lib/unix/process.c b/lib/unix/process.c index 539869e..69be56f 100644 --- a/lib/unix/process.c +++ b/lib/unix/process.c @@ -32,8 +32,11 @@ #include #include -#include +#ifdef HAVE_SYS_TIMES_H +# include +#endif +#ifndef WIN32 /* "extern" in front of the next declaration causes the Ultrix 4.2 linker * to fail when dynamically loading unix.o (but omitting it does no longer * work with modern C compilers): @@ -50,7 +53,7 @@ static Object P_Environ() { GC_Link2(ret, cell); for (ep = environ; *ep; ep++) { cell = Cons(Null, Null); - p = index(*ep, '='); + p = strchr(*ep, '='); if (p) *p++ = 0; else p = c+1; @@ -343,7 +346,7 @@ err: } if (fgets(buf, max, fp) == 0) goto err; - if (p = index(buf, '\n')) *p = '\0'; + if (p = strchr(buf, '\n')) *p = '\0'; (void)pclose(fp); #endif #endif @@ -374,3 +377,4 @@ void elk_init_unix_process() { Def_Prim(P_Umask, "unix-umask", 1, 1, EVAL); Def_Prim(P_Working_Directory, "unix-working-directory", 0, 0, EVAL); } +#endif diff --git a/lib/unix/signal.c b/lib/unix/signal.c index 872dc33..d99ed02 100644 --- a/lib/unix/signal.c +++ b/lib/unix/signal.c @@ -33,17 +33,27 @@ static Object Sym_Exit, Sym_Default, Sym_Ignore; static SYMDESCR Signal_Syms[] = { +#ifdef SIGALRM { "sigalrm", SIGALRM }, +#endif #ifdef SIGBUS { "sigbus", SIGBUS }, #endif { "sigfpe", SIGFPE }, +#ifdef SIGHUP { "sighup", SIGHUP }, +#endif { "sigill", SIGILL }, { "sigint", SIGINT }, +#ifdef SIGKILL { "sigkill", SIGKILL }, +#endif +#ifdef SIGPIPE { "sigpipe", SIGPIPE }, +#endif +#ifdef SIGQUIT { "sigquit", SIGQUIT }, +#endif { "sigsegv", SIGSEGV }, { "sigterm", SIGTERM }, #ifdef SIGABRT @@ -179,6 +189,7 @@ static SYMDESCR Signal_Syms[] = { }; static Object P_Kill(Object pid, Object sig) { +#ifndef WIN32 int t, s; if ((t = TYPE(sig)) == T_Fixnum || t == T_Bignum) @@ -189,6 +200,7 @@ static Object P_Kill(Object pid, Object sig) { Wrong_Type_Combination(sig, "symbol or integer"); if (kill(Get_Integer(pid), s) == -1) Raise_System_Error("~E"); +#endif return Void; } @@ -197,8 +209,11 @@ static Object P_List_Signals() { } static Object P_Pause() { +#ifndef WIN32 pause(); Fatal_Error("pause() returned unexpectedly"); +#endif + return Void; } #if defined(HAVE_SIGPROCMASK) || defined(HAVE_SIGBLOCK) diff --git a/lib/unix/system.c b/lib/unix/system.c index a1d8f29..647843e 100644 --- a/lib/unix/system.c +++ b/lib/unix/system.c @@ -192,7 +192,7 @@ static Object P_System_Info(Object ret) { GC_Link(ret); x = Make_String(p, strlen(p)); VECTOR(ret)->data[0] = x; strcpy(systype, SYSTEMTYPE); - if ((p = index(systype, '-')) && (q = index(p+1, '-'))) { + if ((p = strchr(systype, '-')) && (q = strchr(p+1, '-'))) { *p++ = 0; *q = 0; } else p = "?"; x = Make_String(systype, strlen(systype)); VECTOR(ret)->data[1] = x; diff --git a/lib/unix/unix.h b/lib/unix/unix.h index 22daf4b..ba9befa 100644 --- a/lib/unix/unix.h +++ b/lib/unix/unix.h @@ -34,7 +34,9 @@ #include #include #include -#include +#ifdef HAVE_SYS_WAIT_H +# include +#endif #include #include diff --git a/lib/unix/wait.c b/lib/unix/wait.c index f6bba90..1ac5f85 100644 --- a/lib/unix/wait.c +++ b/lib/unix/wait.c @@ -77,6 +77,7 @@ static SYMDESCR Wait_Flags[] = { static Object General_Wait(Object ret, Object ruret, int haspid, int pid, int options) { +#ifndef WIN32 int retpid, st, code; char *status; #ifdef WAIT_RUSAGE @@ -137,6 +138,7 @@ static Object General_Wait(Object ret, Object ruret, VECTOR(ruret)->data[1] = x; #endif GC_Unlink; +#endif return Void; } diff --git a/lib/xlib/Makefile.am b/lib/xlib/Makefile.am index 01ddedf..1973c40 100644 --- a/lib/xlib/Makefile.am +++ b/lib/xlib/Makefile.am @@ -34,7 +34,7 @@ xlib_la_SOURCES = \ xobjects.c \ $(NULL) xlib_la_CFLAGS = @X_CFLAGS@ -xlib_la_LDFLAGS = -module -avoid-version +xlib_la_LDFLAGS = -module -avoid-version -no-undefined xlib_la_LIBADD = $(top_builddir)/src/libelk.la @X_LIBS@ extensions_HEADERS = xlib.h diff --git a/lib/xwidgets/Makefile.am b/lib/xwidgets/Makefile.am index 44b80c8..1074525 100644 --- a/lib/xwidgets/Makefile.am +++ b/lib/xwidgets/Makefile.am @@ -18,12 +18,12 @@ endif xaw_xt_la_SOURCES = $(SOURCES_XT) xaw_xt_la_CFLAGS = -I$(srcdir)/../xlib @XAW_CFLAGS@ -xaw_xt_la_LDFLAGS = -module -avoid-version +xaw_xt_la_LDFLAGS = -module -avoid-version -no-undefined xaw_xt_la_LIBADD = $(top_builddir)/src/libelk.la @XAW_LIBS@ motif_xt_la_SOURCES = $(SOURCES_XT) motif_xt_la_CFLAGS = -I$(srcdir)/../xlib @MOTIF_CFLAGS@ -motif_xt_la_LDFLAGS = -module -avoid-version +motif_xt_la_LDFLAGS = -module -avoid-version -no-undefined motif_xt_la_LIBADD = $(top_builddir)/src/libelk.la @MOTIF_LIBS@ extensions_HEADERS = xt.h diff --git a/lib/xwidgets/motif/Makefile.am b/lib/xwidgets/motif/Makefile.am index 4ad73a3..bc1a116 100644 --- a/lib/xwidgets/motif/Makefile.am +++ b/lib/xwidgets/motif/Makefile.am @@ -12,7 +12,7 @@ endif nodist_motif_widgets_la_SOURCES = $(SOURCES_C) motif_widgets_la_SOURCES = init.c motif_widgets_la_CFLAGS = -I$(srcdir)/../../xlib @MOTIF_CFLAGS@ -motif_widgets_la_LDFLAGS = -module -avoid-version -u XmIsMotifWMRunning +motif_widgets_la_LDFLAGS = -module -avoid-version -no-undefined -u XmIsMotifWMRunning motif_widgets_la_LIBADD = $(top_builddir)/src/libelk.la @MOTIF_LIBS@ .d.c: diff --git a/lib/xwidgets/xaw/Makefile.am b/lib/xwidgets/xaw/Makefile.am index e98e7e6..1e03576 100644 --- a/lib/xwidgets/xaw/Makefile.am +++ b/lib/xwidgets/xaw/Makefile.am @@ -12,7 +12,7 @@ endif nodist_xaw_widgets_la_SOURCES = $(SOURCES_C) xaw_widgets_la_SOURCES = init.c xaw_widgets_la_CFLAGS = -I$(srcdir)/../../xlib @XAW_CFLAGS@ -xaw_widgets_la_LDFLAGS = -module -avoid-version +xaw_widgets_la_LDFLAGS = -module -avoid-version -no-undefined xaw_widgets_la_LIBADD = $(top_builddir)/src/libelk.la @XAW_LIBS@ .d.c: