summary refs log tree commit diff
path: root/pkgs/applications/editors/emacs-24
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/editors/emacs-24')
-rw-r--r--pkgs/applications/editors/emacs-24/darwin-new-sections.patch50
-rw-r--r--pkgs/applications/editors/emacs-24/default.nix18
-rw-r--r--pkgs/applications/editors/emacs-24/macport.nix100
3 files changed, 161 insertions, 7 deletions
diff --git a/pkgs/applications/editors/emacs-24/darwin-new-sections.patch b/pkgs/applications/editors/emacs-24/darwin-new-sections.patch
new file mode 100644
index 000000000000..dfd72fe3f511
--- /dev/null
+++ b/pkgs/applications/editors/emacs-24/darwin-new-sections.patch
@@ -0,0 +1,50 @@
+http://bazaar.launchpad.net/~naesten/emacs/nextstep-stuff/revision/108961
+
+diff -ru emacs-24.3-orig/src/unexmacosx.c emacs-24.3/src/unexmacosx.c
+--- emacs-24.3-orig/src/unexmacosx.c	2013-01-01 21:37:17.000000000 +0100
++++ emacs-24.3/src/unexmacosx.c	2014-08-09 18:39:52.000000000 +0200
+@@ -838,7 +838,7 @@
+ 	  if (!(sectp->addr <= (unsigned long)my_edata
+ 		&& my_size <= sectp->size))
+ 	    unexec_error ("my_edata is not in section %s", SECT_DATA);
+-	  if (!unexec_write (sectp->offset, (void *) sectp->addr, my_size))
++          if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size))
+ 	    unexec_error ("cannot write section %s", SECT_DATA);
+ 	  if (!unexec_copy (sectp->offset + my_size, old_file_offset + my_size,
+ 			    sectp->size - my_size))
+@@ -880,6 +880,27 @@
+ 	  if (!unexec_write (header_offset, sectp, sizeof (struct section)))
+ 	    unexec_error ("cannot write section %.16s's header", sectp->sectname);
+ 	}
++      else if (strncmp (sectp->sectname, "__bss", 5) == 0
++	       || strncmp (sectp->sectname, "__pu_bss", 8) == 0)
++	{
++	  sectp->flags = S_REGULAR;
++	  
++	  /* These sections are produced by GCC 4.6+.
++
++	     FIXME: We possibly ought to clear uninitialized local
++	     variables in statically linked libraries like for
++	     SECT_BSS (__bss) above, but setting up the markers we
++	     need in lastfile.c would be rather messy.  See
++	     darwin_output_aligned_bss () in gcc/config/darwin.c for
++	     the root of the problem, keeping in mind that the
++	     sections are numbered by their alignment in GCC 4.6, but
++	     by log2(alignment) in GCC 4.7.  */
++
++	  if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size))
++	    unexec_error ("cannot copy section %.16s", sectp->sectname);
++	  if (!unexec_write (header_offset, sectp, sizeof (struct section)))
++	    unexec_error ("cannot write section %.16s's header", sectp->sectname);
++	}
+       else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0
+ 	       || strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0
+ 	       || strncmp (sectp->sectname, "__got", 16) == 0
+@@ -891,6 +912,7 @@
+ 	       || strncmp (sectp->sectname, "__program_vars", 16) == 0
+ 	       || strncmp (sectp->sectname, "__mod_init_func", 16) == 0
+ 	       || strncmp (sectp->sectname, "__mod_term_func", 16) == 0
++	       || strncmp (sectp->sectname, "__static_data", 16) == 0
+ 	       || strncmp (sectp->sectname, "__objc_", 7) == 0)
+ 	{
+ 	  if (!unexec_copy (sectp->offset, old_file_offset, sectp->size))
diff --git a/pkgs/applications/editors/emacs-24/default.nix b/pkgs/applications/editors/emacs-24/default.nix
index 18e263dae67e..329fa3a5626e 100644
--- a/pkgs/applications/editors/emacs-24/default.nix
+++ b/pkgs/applications/editors/emacs-24/default.nix
@@ -1,8 +1,8 @@
 { stdenv, fetchurl, ncurses, x11, libXaw, libXpm, Xaw3d
 , pkgconfig, gtk, libXft, dbus, libpng, libjpeg, libungif
-, libtiff, librsvg, texinfo, gconf, libxml2, imagemagick, gnutls
+, libtiff, librsvg, texinfo, gconf, libxml2, imagemagick, openssl
 , alsaLib, cairo
-, withX ? true
+, withX ? !stdenv.isDarwin, withGTK ? true
 }:
 
 assert (libXft != null) -> libpng != null;	# probably a bug
@@ -18,20 +18,24 @@ stdenv.mkDerivation rec {
     sha256 = "1385qzs3bsa52s5rcncbrkxlydkw0ajzrvfxgv8rws5fx512kakh";
   };
 
+  patches = [ ./darwin-new-sections.patch ];
+
   buildInputs =
-    [ ncurses gconf libxml2 gnutls alsaLib pkgconfig texinfo ]
+    [ ncurses gconf libxml2 openssl alsaLib pkgconfig texinfo ]
     ++ stdenv.lib.optional stdenv.isLinux dbus
     ++ stdenv.lib.optionals withX
       [ x11 libXaw Xaw3d libXpm libpng libjpeg libungif libtiff librsvg libXft
-        imagemagick gtk ]
-    ++ stdenv.lib.optional stdenv.isDarwin cairo;
+        imagemagick gtk gconf ]
+    ++ stdenv.lib.optional (stdenv.isDarwin && withX) cairo;
 
   configureFlags =
-    ( if withX then 
+    ( if withX && withGTK then
         [ "--with-x-toolkit=gtk" "--with-xft"]
+      else (if withX then
+        [ "--with-x-toolkit=lucid" "--with-xft" ]
       else
         [ "--with-x=no" "--with-xpm=no" "--with-jpeg=no" "--with-png=no"
-          "--with-gif=no" "--with-tiff=no" ] )
+          "--with-gif=no" "--with-tiff=no" ] ) )
     # On NixOS, help Emacs find `crt*.o'.
     ++ stdenv.lib.optional (stdenv ? glibc)
          [ "--with-crt-dir=${stdenv.glibc}/lib" ];
diff --git a/pkgs/applications/editors/emacs-24/macport.nix b/pkgs/applications/editors/emacs-24/macport.nix
new file mode 100644
index 000000000000..d9b32351040b
--- /dev/null
+++ b/pkgs/applications/editors/emacs-24/macport.nix
@@ -0,0 +1,100 @@
+{ stdenv, fetchurl, ncurses, pkgconfig, texinfo, libxml2, gnutls
+}:
+
+stdenv.mkDerivation rec {
+  emacsName = "emacs-24.3";
+  name = "${emacsName}-mac-4.8";
+
+  #builder = ./builder.sh;
+
+  src = fetchurl {
+    url = "mirror://gnu/emacs/${emacsName}.tar.xz";
+    sha256 = "1385qzs3bsa52s5rcncbrkxlydkw0ajzrvfxgv8rws5fx512kakh";
+  };
+
+  macportSrc = fetchurl {
+    url = "ftp://ftp.math.s.chiba-u.ac.jp/emacs/${name}.tar.gz";
+    sha256 = "194y341zrpjp75mc3099kjc0inr1d379wwsnav257bwsc967h8yx";
+  };
+
+  patches = [ ./darwin-new-sections.patch ];
+
+  buildInputs = [ ncurses pkgconfig texinfo libxml2 gnutls ];
+
+  postUnpack = ''
+    mv $emacsName $name
+    tar xzf $macportSrc
+    mv $name $emacsName
+  '';
+
+  preConfigure = ''
+    patch -p0 < patch-mac
+
+    # The search for 'tputs' will fail because it's in ncursesw within the
+    # ncurses package, yet Emacs' configure script only looks in ncurses.
+    # Further, we need to make sure that the -L option occurs before mention
+    # of the library, so that it finds it within the Nix store.
+    sed -i 's/tinfo ncurses/tinfo ncursesw/' configure
+    ncurseslib=$(echo ${ncurses}/lib | sed 's#/#\\/#g')
+    sed -i "s/OLIBS=\$LIBS/OLIBS=\"-L$ncurseslib \$LIBS\"/" configure
+    sed -i 's/LIBS="\$LIBS_TERMCAP \$LIBS"/LIBS="\$LIBS \$LIBS_TERMCAP"/' configure
+
+    configureFlagsArray=(
+      LDFLAGS=-L${ncurses}/lib
+      --with-xml2=yes
+      --with-gnutls=yes
+      --with-mac
+      --enable-mac-app=$out/Applications
+    )
+    makeFlagsArray=(
+      CFLAGS=-O3
+      LDFLAGS="-O3 -L${ncurses}/lib"
+    );
+  '';
+
+  postInstall = ''
+    cat >$out/share/emacs/site-lisp/site-start.el <<EOF
+    ;; nixos specific load-path
+    (when (getenv "NIX_PROFILES") (setq load-path
+                          (append (reverse (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/"))
+                             (split-string (getenv "NIX_PROFILES"))))
+                    load-path)))
+
+    ;; make tramp work for NixOS machines
+    (eval-after-load 'tramp '(add-to-list 'tramp-remote-path "/run/current-system/sw/bin"))
+    EOF
+  '';
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "GNU Emacs 24, the extensible, customizable text editor";
+    homepage    = http://www.gnu.org/software/emacs/;
+    license     = licenses.gpl3Plus;
+    maintainers = with maintainers; [ jwiegley ];
+    platforms   = platforms.darwin;
+
+    longDescription = ''
+      GNU Emacs is an extensible, customizable text editor—and more.  At its
+      core is an interpreter for Emacs Lisp, a dialect of the Lisp
+      programming language with extensions to support text editing.
+
+      The features of GNU Emacs include: content-sensitive editing modes,
+      including syntax coloring, for a wide variety of file types including
+      plain text, source code, and HTML; complete built-in documentation,
+      including a tutorial for new users; full Unicode support for nearly all
+      human languages and their scripts; highly customizable, using Emacs
+      Lisp code or a graphical interface; a large number of extensions that
+      add other functionality, including a project planner, mail and news
+      reader, debugger interface, calendar, and more.  Many of these
+      extensions are distributed with GNU Emacs; others are available
+      separately.
+
+      This is "Mac port" addition to GNU Emacs 24. This provides a native
+      GUI support for Mac OS X 10.4 - 10.9. Note that Emacs 23 and later
+      already contain the official GUI support via the NS (Cocoa) port for
+      Mac OS X 10.4 and later. So if it is good enough for you, then you
+      don't need to try this.
+    '';
+  };
+}