From edfda78355c5528eee489fa8a7f9c73bf8e734f2 Mon Sep 17 00:00:00 2001 From: Adrian Robert Date: Tue, 15 Jul 2008 18:15:18 +0000 Subject: merging Emacs.app (NeXTstep port) --- lib-src/.gitignore | 1 + lib-src/ChangeLog | 10 +++++++ lib-src/Makefile.in | 32 +++++++++++++++++++++++ lib-src/mac-fix-env.m | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib-src/make-docfile.c | 11 +++++++- 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 lib-src/mac-fix-env.m (limited to 'lib-src') diff --git a/lib-src/.gitignore b/lib-src/.gitignore index 67ce7f736b5..f1128dd36fc 100644 --- a/lib-src/.gitignore +++ b/lib-src/.gitignore @@ -11,6 +11,7 @@ etags fakemail getopt.h hexl +mac-fix-env make-docfile movemail obj diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 6347c3a8e5a..20a16c1640c 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,13 @@ +2008-07-15 Adrian Robert + + * .cvsignore: Add mac-fix-env. + * mac-fix-env.m: New file, automatically update + ~/.MacOSX/environment.plist on OS X systems to expose environment + variables inside Emacs started from icon. + * Makefile.in: Add -universal to CFLAGS on OS X, add mac-fix-env to + programs to build. + * make-docfile.c: Add .m to list of file extensions. + 2008-07-12 Dan Nicolaescu * movemail.c (main): Use int instead of WAITTYPE. diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 08e83126b73..9b537ecfbea 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -144,6 +144,23 @@ MOVE_FLAGS= #define NOT_C_CODE #include "../src/config.h" +#if defined(COCOA) +/* Build these programs as universal binaries. */ +CFLAGS := $(CFLAGS) -universal +/* Add mac-fix-env for OS X systems running NS version. */ +INSTALLABLES = etags${EXEEXT} ctags${EXEEXT} emacsclient${EXEEXT} b2m${EXEEXT} ebrowse${EXEEXT} mac-fix-env${EXEEXT} +#endif + +/* Some platforms that the GNUstep port runs on put strip options in + INSTALL_PROGRAM which cause errors. But, not being sure all other + platforms are setting this, we will only use the alternative + INSTALL_SCRIPT variable on GNUstep/Cocoa builds. */ +#ifndef HAVE_NS +INSTALL_SCRIPT = @INSTALL_PROGRAM@ +#else +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +#endif + /* Some machines don\'t find the standard C libraries in the usual place. */ #ifndef ORDINARY_LINK #ifndef LIB_STANDARD_LIBSRC @@ -253,12 +270,22 @@ CPP_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \ BASE_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \ -I. -I../src -I${srcdir} -I${srcdir}/../src ${CPPFLAGS} ${CFLAGS} +.SUFFIXES: .m + /* This is the default compilation command. But we should never rely on it, because some make version failed to find it for getopt.o. Using an explicit command made it work. */ .c.o: ${CC} -c ${CPP_CFLAGS} $< +#ifdef HAVE_NS +.m.o: +#ifdef GNUSTEP + $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString $< +#else + $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< +#endif +#endif all: ${DONT_INSTALL} ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS} @@ -455,3 +482,8 @@ update-game-score${EXEEXT}: update-game-score.o $(GETOPTDEPS) update-game-score.o: ${srcdir}/update-game-score.c ../src/config.h $(GETOPT_H) $(CC) -c ${CPP_CFLAGS} ${srcdir}/update-game-score.c \ -DHAVE_SHARED_GAME_DIR="\"$(gamedir)\"" + +#if defined(COCOA) +mac-fix-env: ${srcdir}/mac-fix-env.m + $(CC) -o mac-fix-env ${srcdir}/mac-fix-env.m -prebind -framework Foundation +#endif diff --git a/lib-src/mac-fix-env.m b/lib-src/mac-fix-env.m new file mode 100644 index 00000000000..01798e56f49 --- /dev/null +++ b/lib-src/mac-fix-env.m @@ -0,0 +1,71 @@ +/* mac-fix-env: A small utility to pick up the shell environment on MacOS X + and insert it into the file ~/.MacOSX/environment.plist + creating if necessary. + Copyright (C) 1989, 1993, 2005, 2008 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. + + usage: + Run from command line (in Terminal) once or whenever path changes: + + /Applications/Emacs.app/Contents/MacOS/bin/mac-fix-env + + (change initial part to where you installed Emacs). +*/ + +#import +#include + +int main(int argc, char *argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSMutableDictionary *envPlist; + NSString *file = [[NSHomeDirectory() + stringByAppendingPathComponent:@".MacOSX"] + stringByAppendingPathComponent:@"environment.plist"]; + NSString *path = [NSString stringWithCString: getenv("PATH")]; + + envPlist = [[NSDictionary dictionaryWithContentsOfFile: file] mutableCopy]; + if (envPlist == nil) + { + // create + NSString *dir = [file stringByDeletingLastPathComponent]; + envPlist = [NSMutableDictionary dictionaryWithCapacity: 5]; + + if ([[NSFileManager defaultManager] fileExistsAtPath: dir] == NO) + { + if ([[NSFileManager defaultManager] createDirectoryAtPath:dir + attributes:nil]==NO) + { + NSLog(@":\nCould not create directory at '%@'; aborting.",dir); + return 1; + } + } + } + + [envPlist setObject: path forKey: @"PATH"]; + + if ([envPlist writeToFile: file atomically: YES] == NO) + { + NSLog(@":\nCould not write file at '%@'; aborting.", file); + return 1; + } + + NSLog(@":\nWrote file to '%@'.\nPlease inspect it to make sure PATH is correct.", file); + return 0; +} diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 81071047446..945a92076d2 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -533,7 +533,7 @@ write_c_args (out, func, buf, minargs, maxargs) } /* Read through a c file. If a .o file is named, - the corresponding .c file is read instead. + the corresponding .c or .m file is read instead. Looks for DEFUN constructs such as are defined in ../src/lisp.h. Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */ @@ -555,6 +555,15 @@ scan_c_file (filename, mode) infile = fopen (filename, mode); + if (infile == NULL && extension == 'o') + { + /* try .m */ + filename[strlen (filename) - 1] = 'm'; + infile = fopen (filename, mode); + if (infile == NULL) + filename[strlen (filename) - 1] = 'c'; /* don't confuse people */ + } + /* No error if non-ex input file */ if (infile == NULL) { -- cgit v1.2.1