New function to return GNUSTEP_SYSTEM_ROOT. SHould be used throughout.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11136 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2001-10-14 02:49:10 +00:00
parent 969a3b6621
commit 652989b5c8
8 changed files with 550 additions and 583 deletions

View file

@ -1,3 +1,17 @@
2001-10-13 Adam Fedor <fedor@gnu.org>
* Headers/gnustep/base/NSPathUtilities.h (GSSystemRootDirectory):
New function.
* Source/GNUmakefile: Define GNUSTEP_LOCAL_ROOT and
GNUSTEP_NETWORK_ROOT paths on compile line.
* Source/NSUser.m (setupPathNames): Use compiled in paths as backup
if environment variables not found.
(GSStandardPathPrefixes): Make sure a non-nil result is returned.
(GSSystemRootDirectory). Implement.
* Source/NSDistributedNotificationCenter.m (_connect): Use it to
find gdnc.
* Source/NSPortNameServer.m (initialize): Use it to find gdomap.
2001-10-13 Richard Frith-Macdonald <rfm@gnu.org> 2001-10-13 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSFFCallInvocation.m: Change #import to #include * Source/GSFFCallInvocation.m: Change #import to #include
@ -105,7 +119,7 @@
2001-09-19 Adam Fedor <fedor@gnu.org> 2001-09-19 Adam Fedor <fedor@gnu.org>
* configure.in: But CPPFLAGS in quotes * configure.in: Put CPPFLAGS in quotes
2001-09-14 Adam Fedor <fedor@gnu.org> 2001-09-14 Adam Fedor <fedor@gnu.org>

View file

@ -37,7 +37,9 @@
* to use the defaults belonging to the new user. * to use the defaults belonging to the new user.
*/ */
GS_EXPORT void GSSetUserName(NSString *name); GS_EXPORT void GSSetUserName(NSString *name);
GS_EXPORT NSArray *GSStandardPathPrefixes(void);
GS_EXPORT NSString *GSSystemRootDirectory(void);
GS_EXPORT NSArray *GSStandardPathPrefixes(void);
#endif #endif
GS_EXPORT NSString *NSUserName(); GS_EXPORT NSString *NSUserName();
GS_EXPORT NSString *NSHomeDirectory(); GS_EXPORT NSString *NSHomeDirectory();

View file

@ -44,6 +44,8 @@ LIBRARY_NAME=libgnustep-base
# the installing person may set it on the `make' command line. # the installing person may set it on the `make' command line.
GNUSTEP_INSTALL_PREFIX=$(GNUSTEP_SYSTEM_ROOT) GNUSTEP_INSTALL_PREFIX=$(GNUSTEP_SYSTEM_ROOT)
DEFS= -DGNUSTEP_INSTALL_PREFIX=$(GNUSTEP_INSTALL_PREFIX) \ DEFS= -DGNUSTEP_INSTALL_PREFIX=$(GNUSTEP_INSTALL_PREFIX) \
-DGNUSTEP_LOCAL_ROOT=$(GNUSTEP_LOCAL_ROOT) \
-DGNUSTEP_NETWORK_ROOT=$(GNUSTEP_NETWORK_ROOT) \
-DGNUSTEP_TARGET_DIR=\"$(GNUSTEP_TARGET_DIR)\" \ -DGNUSTEP_TARGET_DIR=\"$(GNUSTEP_TARGET_DIR)\" \
-DGNUSTEP_TARGET_CPU=\"$(GNUSTEP_TARGET_CPU)\" \ -DGNUSTEP_TARGET_CPU=\"$(GNUSTEP_TARGET_CPU)\" \
-DGNUSTEP_TARGET_OS=\"$(GNUSTEP_TARGET_OS)\" \ -DGNUSTEP_TARGET_OS=\"$(GNUSTEP_TARGET_OS)\" \

View file

@ -30,6 +30,7 @@
#include <Foundation/NSArchiver.h> #include <Foundation/NSArchiver.h>
#include <Foundation/NSNotification.h> #include <Foundation/NSNotification.h>
#include <Foundation/NSDate.h> #include <Foundation/NSDate.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSRunLoop.h> #include <Foundation/NSRunLoop.h>
#include <Foundation/NSTask.h> #include <Foundation/NSTask.h>
#include <Foundation/NSDistributedNotificationCenter.h> #include <Foundation/NSDistributedNotificationCenter.h>
@ -40,9 +41,11 @@
* Macros to build text to start name server and to give an error * Macros to build text to start name server and to give an error
* message about it - they include installation path information. * message about it - they include installation path information.
*/ */
#define stringify_it(X) #X #define MAKE_GDNC_CMD [GSSystemRootDirectory() \
#define make_gdnc_cmd(X) stringify_it(X) "/Tools/gdnc" stringByAppendingPathComponent: @"Tools/gdnc"]
#define make_gdnc_err(X) "check that " stringify_it(X) "/Tools/gdnc is running." #define MAKE_GDNC_ERR [NSString stringWithFormat: \
@"check that %@/Tools/gdnc is running", \
GSSystemRootDirectory()]
/* /*
* Global variables for distributed notification center types. * Global variables for distributed notification center types.
@ -343,8 +346,7 @@ static NSDistributedNotificationCenter *defCenter = nil;
static NSString *cmd = nil; static NSString *cmd = nil;
if (cmd == nil) if (cmd == nil)
cmd = [NSString stringWithCString: cmd = MAKE_GDNC_CMD;
make_gdnc_cmd(GNUSTEP_INSTALL_PREFIX)];
NSLog(@"NSDistributedNotificationCenter failed to contact GDNC server.\n"); NSLog(@"NSDistributedNotificationCenter failed to contact GDNC server.\n");
NSLog(@"Attempting to start GDNC process - this will take several seconds.\n"); NSLog(@"Attempting to start GDNC process - this will take several seconds.\n");
@ -364,8 +366,8 @@ NSLog(@"Connection to GDNC server established.\n");
{ {
recursion = NO; recursion = NO;
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
format: @"unable to contact GDNC server - %s", format: @"unable to contact GDNC server - %@",
make_gdnc_err(GNUSTEP_INSTALL_PREFIX)]; MAKE_GDNC_ERR];
} }
} }
} }

View file

@ -37,6 +37,7 @@
#include <Foundation/NSTask.h> #include <Foundation/NSTask.h>
#include <Foundation/NSDate.h> #include <Foundation/NSDate.h>
#include <Foundation/NSTimer.h> #include <Foundation/NSTimer.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSPortNameServer.h> #include <Foundation/NSPortNameServer.h>
#include <Foundation/NSDebug.h> #include <Foundation/NSDebug.h>
#ifdef __MINGW__ #ifdef __MINGW__
@ -56,9 +57,13 @@
* Macros to build text to start name server and to give an error * Macros to build text to start name server and to give an error
* message about it - they include installation path information. * message about it - they include installation path information.
*/ */
#define MAKE_GDOMAP_CMD [GSSystemRootDirectory() \
stringByAppendingPathComponent: @"Tools/gdomap"]
#define MAKE_GDOMAP_ERR [NSString stringWithFormat: \
@"check that %@/Tools/gdomap is running", \
GSSystemRootDirectory()]
#define stringify_it(X) #X #define stringify_it(X) #X
#define make_gdomap_cmd(X) stringify_it(X) "/Tools/gdomap"
#define make_gdomap_err(X) "check that " stringify_it(X) "/Tools/gdomap is running and owned by root."
#define make_gdomap_port(X) stringify_it(X) #define make_gdomap_port(X) stringify_it(X)
/* /*
@ -536,8 +541,7 @@ typedef enum {
serverPort = RETAIN([NSString stringWithCString: serverPort = RETAIN([NSString stringWithCString:
make_gdomap_port(GDOMAP_PORT_OVERRIDE)]); make_gdomap_port(GDOMAP_PORT_OVERRIDE)]);
#endif #endif
launchCmd = [NSString stringWithCString: launchCmd = MAKE_GDOMAP_CMD;
make_gdomap_cmd(GNUSTEP_INSTALL_PREFIX)];
portClass = [GSTcpPort class]; portClass = [GSTcpPort class];
} }
} }

View file

@ -46,6 +46,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h> #include <stdio.h>
#define stringify(X) #X
static NSString *theUserName = nil; static NSString *theUserName = nil;
void void
@ -234,14 +236,25 @@ setupPathNames()
* resources. Use fprintf to avoid recursive calls. * resources. Use fprintf to avoid recursive calls.
*/ */
warned = YES; warned = YES;
gnustep_system_root = [NSString stringWithCString:
stringify(GNUSTEP_INSTALL_PREFIX)];
RETAIN(gnustep_system_root);
fprintf (stderr, fprintf (stderr,
"Warning - GNUSTEP_SYSTEM_ROOT is not set " "Warning - GNUSTEP_SYSTEM_ROOT is not set "
"- using /usr/GNUstep/System as a default\n"); "- using %s\n", [gnustep_system_root lossyCString]);
gnustep_system_root = @"/usr/GNUstep/System";
} }
gnustep_local_root = [env objectForKey: @"GNUSTEP_LOCAL_ROOT"]; gnustep_local_root = [env objectForKey: @"GNUSTEP_LOCAL_ROOT"];
TEST_RETAIN (gnustep_local_root); TEST_RETAIN (gnustep_local_root);
if (gnustep_local_root == nil)
{
gnustep_local_root = [NSString stringWithCString:
stringify(GNUSTEP_LOCAL_ROOT)];
if ([gnustep_local_root length] == 0)
gnustep_local_root = nil;
else
RETAIN(gnustep_local_root);
}
if (gnustep_local_root == nil) if (gnustep_local_root == nil)
{ {
if ([[gnustep_system_root lastPathComponent] isEqual: if ([[gnustep_system_root lastPathComponent] isEqual:
@ -270,6 +283,15 @@ setupPathNames()
gnustep_network_root = [env objectForKey: gnustep_network_root = [env objectForKey:
@"GNUSTEP_NETWORK_ROOT"]; @"GNUSTEP_NETWORK_ROOT"];
TEST_RETAIN (gnustep_network_root); TEST_RETAIN (gnustep_network_root);
if (gnustep_network_root == nil)
{
gnustep_network_root = [NSString stringWithCString:
stringify(GNUSTEP_NETWORK_ROOT)];
if ([gnustep_network_root length] == 0)
gnustep_network_root = nil;
else
RETAIN(gnustep_network_root);
}
if (gnustep_network_root == nil) if (gnustep_network_root == nil)
{ {
if ([[gnustep_system_root lastPathComponent] isEqual: if ([[gnustep_system_root lastPathComponent] isEqual:
@ -324,7 +346,28 @@ setupPathNames()
} }
} }
/** Returns a string containing the path to the GNUstep system
installation directory. This function is gaurenteed to return a non-nil
answer (unless something is seriously wrong, in which case the application
will probably crash anyway) */
NSString *
GSSystemRootDirectory(void)
{
if (gnustep_system_root == nil)
{
setupPathNames();
}
return gnustep_system_root;
}
/** Returns an array of strings which contain paths that should be in
the standard search order for resources, etc. If the environment
variable GNUSTEP_PATHPREFIX_LIST is set. It returns the list of
paths set in that variable. Otherwise, it returns the user, local,
network, and system paths, in that order This function is
gaurenteed to return a non-nil answer (unless something is
seriously wrong, in which case the application will probably crash
anyway) */
NSArray * NSArray *
GSStandardPathPrefixes(void) GSStandardPathPrefixes(void)
{ {
@ -334,15 +377,21 @@ GSStandardPathPrefixes(void)
env = [[NSProcessInfo processInfo] environment]; env = [[NSProcessInfo processInfo] environment];
prefixes = [env objectForKey: @"GNUSTEP_PATHPREFIX_LIST"]; prefixes = [env objectForKey: @"GNUSTEP_PATHPREFIX_LIST"];
if (prefixes != 0) if (prefixes != nil)
{ {
#if defined(__WIN32__) #if defined(__WIN32__)
prefixArray = [prefixes componentsSeparatedByString: @";"]; prefixArray = [prefixes componentsSeparatedByString: @";"];
#else #else
prefixArray = [prefixes componentsSeparatedByString: @":"]; prefixArray = [prefixes componentsSeparatedByString: @":"];
#endif #endif
if ([prefixArray count] <= 1)
{
/* This probably means there was some parsing error, but who
knows. Play it safe though... */
prefixArray = nil;
}
} }
else if (prefixes == nil)
{ {
NSString *strings[4]; NSString *strings[4];
NSString *str; NSString *str;

1025
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -57,7 +57,6 @@ AC_EXEEXT
case "$target_os" in case "$target_os" in
freebsd*) CPPFLAGS="$CPPFLAGS -I/usr/local/include" freebsd*) CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LIBS="$LIBS -L/usr/local/lib";; LIBS="$LIBS -L/usr/local/lib";;
darwin1.3*) CPPFLAGS="$CPPFLAGS -force_cpusubtype_ALL";;
esac esac