diff --git a/ChangeLog b/ChangeLog index 9a8d7fc65..32a7988ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2000-09-13 Adam Fedor + * Remove dependance on Source/Foundation link, additional MINGW ports. + * Makefile.postamble (header-links): Remove Source/Foundation link. + * Source/Makefile.preamble (HEADER_DIR): New variable. + (ADDITIONAL_INCLUDE_DIRS): Include ../Headers. + * Source/GNUmakefile (GENERATED_HEADERS): Change Foundation + to $(HEADER_DIR). + * Source/Makefile.postamble: Likewise. + + * Source/GSTcpPost.m: Update to handle MINGW (mostly copied from + gdomap.c). + * Source/NSFileManager.m (-findNextFile): Check if lstat, + geteuid implemented. + * Source/NSHost.m: Change includes for MINGW. + * Source/NSPipe.m (init): Port to MINGW. + * configure.in: Do preface.h substitutions here. * Source/Makefile.postamble (preface.h): Remove target. diff --git a/Headers/gnustep/base/config.h.in b/Headers/gnustep/base/config.h.in index 93d9cea3b..caa5f0b50 100644 --- a/Headers/gnustep/base/config.h.in +++ b/Headers/gnustep/base/config.h.in @@ -69,6 +69,9 @@ /* Define if you have the getcwd function. */ #undef HAVE_GETCWD +/* Define if you have the geteuid function. */ +#undef HAVE_GETEUID + /* Define if you have the inet_aton function. */ #undef HAVE_INET_ATON diff --git a/Headers/gnustep/base/preface.h.in b/Headers/gnustep/base/preface.h.in index 5702bf7e8..fb7996203 100644 --- a/Headers/gnustep/base/preface.h.in +++ b/Headers/gnustep/base/preface.h.in @@ -87,7 +87,7 @@ #include /* Hack to get rid of warning in GNU libc 2.0.3. */ #endif -/* The following group of lines maintained by the gstep-base src/Makefile */ +/* The following group of lines maintained by the gstep-base configure */ #define GNUSTEP_BASE_VERSION @VERSION@ #define GNUSTEP_BASE_MAJOR_VERSION @MAJOR_VERSION@ #define GNUSTEP_BASE_MINOR_VERSION @MINOR_VERSION@ diff --git a/Makefile.postamble b/Makefile.postamble index b40907d22..bbe0e65f6 100644 --- a/Makefile.postamble +++ b/Makefile.postamble @@ -65,6 +65,9 @@ before-all:: header-links # Things to do after distcleaning after-distclean:: rm -f config.status config.log config.cache TAGS config.mak + rm -f Headers/gnustep/base/config.h \ + Headers/gnustep/base/GSConfig.h \ + Headers/gnustep/base/preface.h cd Headers; rm -f Foundation cd Source; rm -f Foundation @@ -79,16 +82,12 @@ header-links: $(HEADER_LINK_DEPENDS) -rm -f Headers/Foundation/* -mkdir Headers/Foundation cp -f Headers/gnustep/base/*.h Headers/Foundation - -rm -f Source/Foundation/* - -mkdir Source/Foundation - cp -f Headers/gnustep/base/*.h Source/Foundation else header-links: $(HEADER_LINK_DEPENDS) -rm -f Headers/Foundation -rm -f Source/Foundation $(LN_S) gnustep/base Headers/Foundation - $(LN_S) ../Headers/gnustep/base Source/Foundation endif configure: configure.in diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 949062b7c..5d576a548 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -343,11 +343,11 @@ HEADERS_INSTALL = $(GNU_HEADERS) \ GENERATED_HFILES = \ dynamic-load.h \ -Foundation/preface.h \ -Foundation/o_array.h \ -Foundation/o_hash.h \ -Foundation/o_list.h \ -Foundation/o_map.h \ +$(HEADER_DIR)/preface.h \ +$(HEADER_DIR)/o_array.h \ +$(HEADER_DIR)/o_hash.h \ +$(HEADER_DIR)/o_list.h \ +$(HEADER_DIR)/o_map.h \ $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/mframe.h \ $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/config.h \ $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/GSConfig.h diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index 4ce75daba..52b6b2640 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -42,15 +42,57 @@ #include #include #include -#ifndef __MINGW__ #include /* for gethostname() */ -#include /* for inet_ntoa() */ + +#ifndef __MINGW__ +#include /* for MAXHOSTNAMELEN */ +#include +#include +#include /* for inet_ntoa() */ +#endif /* !__MINGW__ */ +#include +#include +#include /* for strchr() */ +#include /* for strchr() */ #include -#include +#ifdef __MINGW__ +#include +#include +#include +#include +#else +#include +#include +#include +#include #include #include +/* + * Stuff for setting the sockets into non-blocking mode. + */ +#ifdef __POSIX_SOURCE +#define NBLK_OPT O_NONBLOCK +#else +#define NBLK_OPT FNDELAY +#endif -extern int errno; +#include +#include +#if !defined(SIOCGIFCONF) || defined(__CYGWIN__) +#include +#ifndef SIOCGIFCONF +#include +#endif +#endif + +#if defined(__svr4__) +#include +#endif +#endif /* !__MINGW__ */ + +#ifdef __MINGW__ +#define close closesocket +#endif static BOOL multi_threaded = NO; @@ -70,24 +112,6 @@ static gsu32 maxDataLength = 10 * 1024 * 1024; #define GS_CONNECTION_MSG 0 #define NETBLOCK 8192 -/* - * Stuff for setting the sockets into non-blocking mode. - */ -#ifdef __POSIX_SOURCE -#define NBLK_OPT O_NONBLOCK -#else -#define NBLK_OPT FNDELAY -#endif - -#endif /* !__MINGW__ */ -#include /* for memset() and strchr() */ -#ifndef __MINGW__ -#include -#include -#include -#include -#endif /* !__MINGW__ */ - #ifndef INADDR_NONE #define INADDR_NONE -1 #endif @@ -340,12 +364,23 @@ static Class runLoopClass; { GSTcpHandle *handle; int e; +#ifdef __MINGW__ + unsigned long dummy; +#endif /* __MINGW__ */ if (d < 0) { NSLog(@"illegal descriptor (%d) for Tcp Handle", d); return nil; } +#ifdef __MINGW__ + dummy = 1; + if (ioctlsocket(udp_desc, FIONBIO, &dummy) < 0) + { + NSLog(@"unable to set non-blocking mode - %s", strerror(errno)); + return nil; + } +#else /* !__MINGW__ */ if ((e = fcntl(d, F_GETFL, 0)) >= 0) { e |= NBLK_OPT; @@ -355,6 +390,7 @@ static Class runLoopClass; return nil; } } +#endif else { NSLog(@"unable to get non-blocking mode - %s", strerror(errno)); @@ -375,6 +411,13 @@ static Class runLoopClass; { if (self == [GSTcpHandle class]) { +#ifdef __MINGW__ + WORD wVersionRequested; + WSADATA wsaData; + + wVersionRequested = MAKEWORD(2, 0); + WSAStartup(wVersionRequested, &wsaData); +#endif mutableArrayClass = [NSMutableArray class]; mutableDataClass = [NSMutableData class]; portMessageClass = [NSPortMessage class]; @@ -445,7 +488,11 @@ static Class runLoopClass; if (connect(desc, (struct sockaddr*)&sin, sizeof(sin)) < 0) { +#ifdef __MINGW__ + if (WSAGetLastError() != WSAEINPROGRESS) +#else if (errno != EINPROGRESS) +#endif { NSLog(@"unable to make connection to %s:%d - %s", inet_ntoa(sin.sin_addr), diff --git a/Source/Makefile.postamble b/Source/Makefile.postamble index 927c87f06..a2f09e365 100644 --- a/Source/Makefile.postamble +++ b/Source/Makefile.postamble @@ -103,8 +103,7 @@ after-uninstall:: # Things to do after distcleaning after-distclean:: - rm -f Foundation/config.h Foundation/GSConfig.h Foundation/dynamic-load.h \ - Foundation/preface.h mframe/mframe.h Foundation base \ + rm -f mframe/mframe.h Foundation \ NSNumber[0-9]*.m NSValue[0-9]*.m o_*_bas.m rm -rf $(GNUSTEP_TARGET_CPU) @@ -114,10 +113,6 @@ after-distclean:: # Things to do after checking # after-check:: -# Local links to the include files -Foundation: - $(LN_S) $(srcdir)/../Headers/gnustep/base Foundation - # Creation of NSValue and NSNumber concrete classes from templates $(NSVALUE_MFILES) : NSCTemplateValue.m rm -f $@ @@ -134,19 +129,19 @@ dynamic-load.h: ../config.status rm -f dynamic-load.h cp $(srcdir)/$(DYNAMIC_LINKER)-load.h dynamic-load.h -$(GNUSTEP_OBJ_DIR)/preface${OEXT}: Foundation/preface.h +$(GNUSTEP_OBJ_DIR)/preface${OEXT}: $(HEADER_DIR)/preface.h # # The config.h file is specific to a target # $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/config.h: ../config.status $(MKDIRS) $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) - -mv Foundation/config.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) + -mv $(HEADER_DIR)/config.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) -touch $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/config.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/GSConfig.h: ../config.status $(MKDIRS) $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) - -mv Foundation/GSConfig.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) + -mv $(HEADER_DIR)/GSConfig.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) -touch $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/GSConfig.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/mframe.h: mframe/config.status @@ -154,26 +149,26 @@ $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/mframe.h: mframe/config.status -mv mframe/mframe.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) -touch $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/mframe.h -Foundation/o_%_bas.h: Foundation/o_x_bas.h.in +$(HEADER_DIR)/o_%_bas.h: $(HEADER_DIR)/o_x_bas.h.in sed -e "s/@XX@/$*/g" $< > $@ -Foundation/o_%_cbs.h: Foundation/o_x_cbs.h.in +$(HEADER_DIR)/o_%_cbs.h: $(HEADER_DIR)/o_x_cbs.h.in sed -e "s/@YY@/$*/g" $< > $@ -o_%_bas.m: o_x_bas.m.in Foundation/o_%.h +o_%_bas.m: o_x_bas.m.in $(HEADER_DIR)/o_%.h sed -e "s/@XX@/$*/g" $< > $@ -o_%_cbs.m: o_x_cbs.m.in Foundation/o_%.h +o_%_cbs.m: o_x_cbs.m.in $(HEADER_DIR)/o_%.h sed -e "s/@YY@/$*/g" $< > $@ -$(GNUSTEP_OBJ_DIR)/o_array.o: o_array.m Foundation/o_array.h -Foundation/o_array.h: Foundation/o_array_bas.h Foundation/o_array_cbs.h Foundation/o_hash.h -$(GNUSTEP_OBJ_DIR)/o_hash.o: o_hash.m Foundation/o_hash.h -Foundation/o_hash.h: Foundation/o_hash_bas.h Foundation/o_hash_cbs.h -$(GNUSTEP_OBJ_DIR)/o_list.o: o_list.m Foundation/o_list.h -Foundation/o_list.h: Foundation/o_list_bas.h Foundation/o_list_cbs.h Foundation/o_array.h Foundation/o_hash.h -$(GNUSTEP_OBJ_DIR)/o_map.o: o_map.m Foundation/o_map.h -Foundation/o_map.h: Foundation/o_map_bas.h Foundation/o_map_cbs.h Foundation/o_hash.h +$(GNUSTEP_OBJ_DIR)/o_array.o: o_array.m $(HEADER_DIR)/o_array.h +$(HEADER_DIR)/o_array.h: $(HEADER_DIR)/o_array_bas.h $(HEADER_DIR)/o_array_cbs.h $(HEADER_DIR)/o_hash.h +$(GNUSTEP_OBJ_DIR)/o_hash.o: o_hash.m $(HEADER_DIR)/o_hash.h +$(HEADER_DIR)/o_hash.h: $(HEADER_DIR)/o_hash_bas.h $(HEADER_DIR)/o_hash_cbs.h +$(GNUSTEP_OBJ_DIR)/o_list.o: o_list.m $(HEADER_DIR)/o_list.h +$(HEADER_DIR)/o_list.h: $(HEADER_DIR)/o_list_bas.h $(HEADER_DIR)/o_list_cbs.h $(HEADER_DIR)/o_array.h $(HEADER_DIR)/o_hash.h +$(GNUSTEP_OBJ_DIR)/o_map.o: o_map.m $(HEADER_DIR)/o_map.h +$(HEADER_DIR)/o_map.h: $(HEADER_DIR)/o_map_bas.h $(HEADER_DIR)/o_map_cbs.h $(HEADER_DIR)/o_hash.h # # Files that include mframe.h will need a rebuild if it is changed. @@ -216,7 +211,7 @@ $(GNUSTEP_OBJ_DIR)/NSNotificationCenter.o \ $(GNUSTEP_OBJ_DIR)/NSRunLoop.o \ $(GNUSTEP_OBJ_DIR)/NSSerializer.o \ $(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \ - : Foundation/GSIArray.h Foundation/GSUnion.h + : $(HEADER_DIR)/GSIArray.h $(HEADER_DIR)/GSUnion.h # # Files that include GSIMap.h will need a rebuild if it is changed. @@ -227,7 +222,7 @@ $(GNUSTEP_OBJ_DIR)/NSGDictionary.o \ $(GNUSTEP_OBJ_DIR)/NSGSet.o \ $(GNUSTEP_OBJ_DIR)/NSNotificationCenter.o \ $(GNUSTEP_OBJ_DIR)/NSSerializer.o \ - : Foundation/GSIMap.h Foundation/GSUnion.h + : $(HEADER_DIR)/GSIMap.h $(HEADER_DIR)/GSUnion.h # # Files that include fast.x will need a rebuild if it is changed. @@ -244,7 +239,7 @@ $(GNUSTEP_OBJ_DIR)/NSObject.o \ $(GNUSTEP_OBJ_DIR)/NSSerializer.o \ $(GNUSTEP_OBJ_DIR)/NSString.o \ $(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \ - : Foundation/fast.x + : $(HEADER_DIR)/fast.x # # Files that include propList.h will need a rebuild if it is changed. @@ -266,7 +261,7 @@ $(GNUSTEP_OBJ_DIR)/NSGCString.o \ # NSGeometry.m needs a recompile if NSGeometry.h is changed. # $(GNUSTEP_OBJ_DIR)/NSGeometry.o \ - : Foundation/NSGeometry.h + : $(HEADER_DIR)/NSGeometry.h # diff --git a/Source/Makefile.preamble b/Source/Makefile.preamble index 691750d16..657947520 100644 --- a/Source/Makefile.preamble +++ b/Source/Makefile.preamble @@ -48,7 +48,7 @@ ADDITIONAL_OBJCFLAGS = ADDITIONAL_CFLAGS = # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS = -I../Headers/gnustep \ +ADDITIONAL_INCLUDE_DIRS = -I../Headers/gnustep -I../Headers \ -I./$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) # Additional LDFLAGS to pass to the linker @@ -74,4 +74,5 @@ ADDITIONAL_INSTALL_DIRS = $(GNUSTEP_HEADERS)/gnustep/base \ $(GNUSTEP_HEADERS)/gnustep/unicode \ $(GNUSTEP_HEADERS)/$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS) +HEADER_DIR=$(srcdir)/../Headers/gnustep/base diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index 40f5dd078..3bc31cbdd 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -224,6 +224,7 @@ static NSFileManager* defaultManager = nil; #if defined(__MINGW__) NSEnumerator *paths = [[path pathComponents] objectEnumerator]; NSString *subPath; + NSString *completePath = nil; while ((subPath = [paths nextObject])) { @@ -237,7 +238,7 @@ static NSFileManager* defaultManager = nil; { if (!isDir) NSLog(@"WARNING: during creation of directory %@:" - " sub path %@ exists, but is not a directory !", + @" sub path %@ exists, but is not a directory !", path, completePath); } else @@ -250,7 +251,7 @@ static NSFileManager* defaultManager = nil; } // change attributes of last directory - return [self changeFileAttributes:a ttributes atPath: path]; + return [self changeFileAttributes: attributes atPath: path]; #else const char *cpath; @@ -621,12 +622,12 @@ static NSFileManager* defaultManager = nil; contents: (NSData*)contents attributes: (NSDictionary*)attributes { - int len; - int written; const char *cpath = [self fileSystemRepresentationWithPath: path]; #if defined(__MINGW__) HANDLE fh; + DWORD written = 0; + DWORD len = [contents length]; fh = CreateFile(cpath, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); @@ -636,8 +637,6 @@ static NSFileManager* defaultManager = nil; } else { - DWORD len = [contents length]; - DWORD written = 0; if (len > 0) { @@ -651,6 +650,8 @@ static NSFileManager* defaultManager = nil; } #else int fd; + int len; + int written; fd = open (cpath, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd < 0) @@ -1352,6 +1353,7 @@ static NSFileManager* defaultManager = nil; if (_flags.isRecursive == YES) { // Do not follow links +#ifdef S_IFLNK if (!_flags.isFollowing) { if (lstat(cpath, &statbuf) != 0) @@ -1361,6 +1363,7 @@ static NSFileManager* defaultManager = nil; break; } else +#endif { if (stat(cpath, &statbuf) != 0) break; @@ -1749,11 +1752,13 @@ static NSFileManager* defaultManager = nil; if (stat(cpath, &statbuf) != 0) return nil; } +#ifdef S_IFLNK else { if (lstat(cpath, &statbuf) != 0) return nil; } +#endif values[0] = [NSNumber numberWithUnsignedLongLong: statbuf.st_size]; values[1] = [NSDate dateWithTimeIntervalSince1970: statbuf.st_mtime]; @@ -1845,10 +1850,12 @@ static NSFileManager* defaultManager = nil; * If we are running setuid to root - we need to specify the user * to be the owner of copied files. */ +#if HAVE_GETEUID if (geteuid() == 0 && [@"root" isEqualToString: u] == NO) { values[count++] = u; } +#endif } return [NSDictionary dictionaryWithObjects: values diff --git a/Source/NSHost.m b/Source/NSHost.m index d0ac4a77f..45af9c178 100644 --- a/Source/NSHost.m +++ b/Source/NSHost.m @@ -32,12 +32,11 @@ #include #include #include -#include -/* #include */ #if defined(__MINGW__) #include #else +#include #include #include #include diff --git a/Source/NSPipe.m b/Source/NSPipe.m index cdddf1b80..798943e25 100644 --- a/Source/NSPipe.m +++ b/Source/NSPipe.m @@ -48,6 +48,7 @@ self = [super init]; if (self) { +#ifndef __MINGW__ int p[2]; if (pipe(p) == 0) @@ -55,6 +56,15 @@ readHandle = [[NSFileHandle alloc] initWithFileDescriptor:p[0]]; writeHandle = [[NSFileHandle alloc] initWithFileDescriptor:p[1]]; } +#else + HANDLE readh, writeh; + + if (CreatePipe(&readh, &writeh, NULL, 0) != 0) + { + readHandle = [[NSFileHandle alloc] initWithNativeHandle: readh]; + writeHandle = [[NSFileHandle alloc] initWithNativeHandle: writeh]; + } +#endif } return self; } diff --git a/configure b/configure index 401c457b3..d10427c7d 100755 --- a/configure +++ b/configure @@ -2831,7 +2831,7 @@ else fi done -for ac_func in statvfs symlink readlink +for ac_func in statvfs symlink readlink geteuid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2838: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 6024e4821..c4c7f1c66 100644 --- a/configure.in +++ b/configure.in @@ -541,7 +541,7 @@ AC_CHECK_HEADERS(values.h) #-------------------------------------------------------------------- AC_CHECK_HEADERS(sys/stat.h sys/vfs.h sys/statfs.h sys/statvfs.h pwd.h grp.h) AC_CHECK_HEADERS(sys/mount.h sys/types.h) -AC_CHECK_FUNCS(statvfs symlink readlink) +AC_CHECK_FUNCS(statvfs symlink readlink geteuid) #-------------------------------------------------------------------- # These two headers (functions) needed by Time.m