File emacs.spec of Package emacs

#
# spec file for package emacs
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%bcond_without  autoconf
%if 0%{?suse_version} >= 1550
%bcond_without  mailutils
%else
%bcond_with     mailutils
%endif
%bcond_without  cairo
%bcond_with     tex4pdf
%if 0%{?suse_version} >= 1550
%bcond_without  nativecomp
%else
%bcond_with     nativecomp
%endif
%if 0%{?suse_version} >= 1550 || (0%{?suse_version} >= 1500 && 0%{?sle_version} >= 150500)
%bcond_without  tree_sitter
%else
%bcond_with     tree_sitter
%endif

Name:           emacs
%if %{with autoconf}
BuildRequires:  autoconf
BuildRequires:  automake
%endif
BuildRequires:  alsa-devel
%if %{with cairo}
BuildRequires:  cairo-devel
%endif
BuildRequires:  fdupes
BuildRequires:  fontconfig-devel
BuildRequires:  fonts-config
BuildRequires:  freetype2-devel
BuildRequires:  giflib-devel
BuildRequires:  git
BuildRequires:  gpm-devel
BuildRequires:  gtk3-devel
# Used for installtion of info pages as well as to
# detect if the page info.info is part of that package
BuildRequires:  info
BuildRequires:  krb5-devel
BuildRequires:  libacl-devel
BuildRequires:  libgnutls-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libotf-devel
BuildRequires:  libpng-devel
BuildRequires:  librsvg-devel
%if 0%{?suse_version} > 1310
BuildRequires:  pkgconfig(libseccomp)
%endif
BuildRequires:  libselinux-devel
BuildRequires:  libtiff-devel
BuildRequires:  libxml2-devel
%if 0%{?suse_version} > 1320
BuildRequires:  pkgconfig(jansson) >= 2.7
%endif
BuildRequires:  m17n-lib-devel
BuildRequires:  pkgconfig(libudev)
%if %{with mailutils}
BuildRequires:  mailutils
BuildRequires:  mailutils-devel
%endif
BuildRequires:  makeinfo
BuildRequires:  ncurses-devel
%if 0%{?suse_version} >= 1500
BuildRequires:  user(games)
%endif
BuildRequires:  systemd-rpm-macros
%if %{with tex4pdf}
BuildRequires:  texlive-collection-basic
BuildRequires:  texlive-collection-langcyrillic
BuildRequires:  texlive-collection-langczechslovak
BuildRequires:  texlive-collection-langpolish
BuildRequires:  texlive-lh
%endif
%if %{with tree_sitter}
BuildRequires:  pkgconfig(tree-sitter)
%endif
BuildRequires:  update-alternatives
BuildRequires:  update-desktop-files
BuildRequires:  xz
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(com_err)
BuildRequires:  pkgconfig(dbus-1)
BuildRequires:  pkgconfig(fontconfig)
%if 0%{?suse_version} < 1550
BuildRequires:  pkgconfig(gconf-2.0)
%endif
BuildRequires:  pkgconfig(gio-2.0)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(gsettings-desktop-schemas)
%if 0%{?suse_version} > 1320
BuildRequires:  pkgconfig(harfbuzz)
%endif
BuildRequires:  pkgconfig(ice)
%if %{with tex4pdf}
BuildRequires:  tex(babel.sty)
BuildRequires:  tex(fontenc.sty)
BuildRequires:  tex(geometry.sty)
BuildRequires:  tex(german.sty)
BuildRequires:  tex(graphicx.sty)
BuildRequires:  tex(ifpdf.sty)
BuildRequires:  tex(inputenc.sty)
BuildRequires:  tex(multicol.sty)
BuildRequires:  tex(supertabular.sty)
BuildRequires:  tex(t2aenc.def)
BuildRequires:  tex(tabularx.sty)
BuildRequires:  tex(verbatim.sty)
%endif
%if 0%{?suse_version} >= 1500
BuildRequires:  pkgconfig(libacl)
%else
BuildRequires:  libacl-devel
%endif
%if 0%{?suse_version} > 1320
BuildRequires:  pkgconfig(jansson)
%endif
BuildRequires:  pkgconfig(json)
BuildRequires:  pkgconfig(lcms2)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(libwebpdemux) >= 0.6.0
BuildRequires:  pkgconfig(pango)
BuildRequires:  pkgconfig(sm)
%if 0%{?suse_version} > 1310
%ifnarch ppc
BuildRequires:  pkgconfig(webkit2gtk-4.0) >= 2.12
%endif
%endif
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(x11-xcb)
%if 0%{?suse_version} > 1310
BuildRequires:  pkgconfig(xaw3d)
%else
BuildRequires:  xaw3d-devel
%endif
BuildRequires:  pkgconfig(xcb)
BuildRequires:  pkgconfig(xfixes)
BuildRequires:  pkgconfig(xft)
BuildRequires:  pkgconfig(xinerama)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(xpm)
BuildRequires:  pkgconfig(xrandr)
BuildRequires:  pkgconfig(xrender)
%if 0%{?suse_version} > 1310
BuildRequires:  pkgconfig(xshmfence)
%endif
BuildRequires:  pkgconfig(xt)
BuildRequires:  pkgconfig(xxf86vm)
%if %{with nativecomp}
BuildRequires:  libgccjit0-devel
%endif
URL:            http://www.gnu.org/software/emacs/
Version:        29.1
Release:        0
Summary:        GNU Emacs Base Package
License:        GPL-3.0-or-later
Group:          Productivity/Text/Editors
Provides:       nxml-mode = 20041004
Obsoletes:      nxml-mode < 20041004
Provides:       epg = 1.0.0
Obsoletes:      epg < 1.0.0
Requires:       emacs-info = %{version}
Requires:       emacs_program = %{version}-%{release}
Requires:       etags
%if %{with mailutils}
Requires:       mailutils
%endif
Requires(pre):  fileutils
%if 0%{?suse_version} >= 1500
Requires(pre):  group(games)
Requires(pre):  user(games)
%endif
Source:         http://ftp.gnu.org/gnu/emacs/emacs-%{version}.tar.xz
Source2:        site-lisp.tar.bz2
Source3:        dot.gnu-emacs
Source4:        emacs-rpmlintrc
Source5:        emacs.sh
Source6:        http://ftp.gnu.org/gnu/emacs/emacs-%{version}.tar.xz.sig
# https://ftp.gnu.org/gnu/gnu-keyring.gpg
Source7:        %{name}.keyring
Source8:        emacs-27.2-pdf.tar.xz
Patch:          emacs-27.1.dif
Patch5:         emacs-24.4-ps-bdf.patch
Patch7:         emacs-24.1-ps-mule.patch
Patch12:        emacs-24.3-x11r7.patch
Patch25:        emacs-26.1-xft4x11.patch
Patch29:        emacs-27.1-Xauthority4server.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{expand: %%global include_info %(test -s /usr/share/info/info.info* && echo 0 || echo 1)}
%{expand: %%global _exec_prefix %(type -p pkg-config &>/dev/null && pkg-config --variable prefix x11 || echo /usr/X11R6)}
%if "%_exec_prefix" == "/usr/X11R6"
%define _x11lib     %{_exec_prefix}/%{_lib}
%define _x11data    %{_exec_prefix}/lib/X11
%define _libx11     %{_x11data}
%define _x11inc     %{_exec_prefix}/include
%else
%define _x11lib     %{_libdir}
%define _x11data    %{_datadir}/X11
%define _libx11     %{_exec_prefix}/lib/X11
%define _x11inc     %{_includedir}
%endif
%if %{undefined ext_el}
%define ext_el      .gz
%endif
%define info_files auth autotype bovine calc ccmode cl dbus dired-x ebrowse ede ediff edt efaq eglot eieio eintr elisp emacs-gnutls emacs-mime emacs epa erc ert eshell eudc eww flymake forms gnus htmlfontify idlwave ido info mairix-el message mh-e modus-themes newsticker nxml-mode octave-mode org pcl-cvs pgg rcirc reftex remember sasl sc semantic ses sieve smtpmail speedbar srecode todo-mode tramp transient url use-package vhdl-mode vip viper vtable widget wisent woman

%description
Basic package for the GNU Emacs editor. Requires emacs-x11 or
emacs-nox.

%package     -n emacs-nox
Requires(post): fileutils
Requires:       emacs = %{version}-%{release}
Provides:       emacs_program = %{version}-%{release}
Summary:        GNU Emacs-nox: An Emacs Binary without X Window System Support
Group:          Productivity/Text/Editors

%description -n emacs-nox
Eight Megabytes And Constantly Swapping. Call it

emacs-nox

Love it or leave it.

%package     -n emacs-x11
Requires(post): fileutils
Requires:       emacs = %{version}-%{release}
Provides:       emacs_program = %{version}-%{release}
Requires:       efont-unicode
Requires:       ifnteuro
Requires:       xorg-x11-fonts
Requires:       xorg-x11-fonts-core
Enhances:       libX11-6
Summary:        GNU Emacs: Emacs binary with X Window System Support
Group:          Productivity/Text/Editors

%description -n emacs-x11
Call it

Emacs

Love it or leave it. This is the Emacs binary with X Window System
Support.

%package     -n emacs-el
Requires:       emacs = %{version}-%{release}
Provides:       emacs-devel = %{version}-%{release}
Summary:        Several Lisp Files for GNU Emacs
Group:          Development/Libraries/Other
BuildArch:      noarch

%description -n emacs-el
Several Lisp files not needed for running GNU Emacs. Most of these
files are pre-byte compiled and therefore not necessary.

%package     -n emacs-info
Summary:        Info files for GNU Emacs
Group:          Documentation/Other
%if 0%{?suse_version} <= 1500
Requires(post): %install_info_prereq
Requires(preun):%install_info_prereq
%endif
BuildArch:      noarch

%description -n emacs-info
This package contains all the Info files for GNU Emacs. These files can
be read online with GNU Emacs. They describe Emacs and some of its
modes.

%package     -n etags
Summary:        Generate Tag Files for Use with Emacs
Group:          Development/Tools/Navigators
Requires(post): coreutils update-alternatives
Requires(preun):coreutils update-alternatives
Provides:       ctags:/usr/bin/etags

%description -n etags
ETags generates tag files from source code in Pascal, Cobol, Ada, Perl,
LaTeX, Scheme, Emacs Lisp/Common Lisp, Postscript, Erlang, Python, Prolog,
and most assembler-like syntaxes.

%prep
%setup -q -b 2
%patch5  -p0
%patch7  -p0
%patch12 -p0
%patch25 -p0
%patch   -p0
%if %{without tex4pdf}
pushd etc/refcards/
    tar --use-compress-program=xz -xf %{S:8}
popd
%endif

%build
%if %{without autoconf}
# We don't want to run autoconf
if test configure.ac -nt aclocal.m4 -o m4/gnulib-comp.m4 -nt aclocal.m4 ; then
    sleep 1
    touch aclocal.m4
fi
if test configure.ac -nt configure -o aclocal.m4 -nt configure ; then
    sleep 1
    touch configure
fi
if test configure.ac -nt src/stamp-h.in -o aclocal.m4 -nt src/stamp-h.in ; then
    sleep 1
    touch src/stamp-h.in
fi
if test aclocal.m4 -nt lib/Makefile.in -o lib/Makefile.am -nt lib/Makefile.in -o lib/gnulib.mk -nt lib/Makefile.in ; then
    sleep 1
    touch lib/Makefile.in
fi
if test -s autogen.sh ; then
    mv autogen.sh autogen.sh.no
    ln -sf /bin/true autogen.sh
fi
%else
autoreconf -fiv -I $PWD -I $PWD/m4
%endif

  cflags ()
  {
      local flag=$1; shift
      local var=$1; shift
      test -n "${flag}" -a -n "${var}" || return
      case "${!var}" in
      *${flag}*) return
      esac
      case "$flag" in
      -Wl,*)
	  set -o noclobber
	  echo 'int main () { return 0; }' > ldtest.c
	  if ${CC:-gcc} -Werror $flag -o /dev/null -xc ldtest.c > /dev/null 2>&1 ; then
	      eval $var=\${$var:+\$$var\ }$flag
	  fi
	  set +o noclobber
	  rm -f ldtest.c
	  ;;
      *)
	  if ${CC:-gcc} -Werror $flag -S -o /dev/null -xc /dev/null > /dev/null 2>&1 ; then
	      eval $var=\${$var:+\$$var\ }$flag
	  fi
	  if ${CXX:-g++} -Werror $flag -S -o /dev/null -xc++ /dev/null > /dev/null 2>&1 ; then
	      eval $var=\${$var:+\$$var\ }$flag
	  fi
      esac
  }

VERSION=%{version}
%ifarch noarch
    SYS="--build=%{_build_cpu}-suse-%{_build_os}
"
%else
    SYS="--build=%{_target_cpu}-suse-%{_build_os}
"
%endif
 CFLAGS="${RPM_OPT_FLAGS} -D_GNU_SOURCE -DGDK_DISABLE_DEPRECATION_WARNINGS -DGLIB_DISABLE_DEPRECATION_WARNINGS"
LDFLAGS=
  cflags -pipe                   CFLAGS
  cflags -Wno-pointer-sign       CFLAGS
  cflags -Wno-unused-variable    CFLAGS
  cflags -Wno-unused-label       CFLAGS
  cflags -Wl,-O2		 LDFLAGS
%ifarch ia64
 CFLAGS=$(echo "${CFLAGS}"|sed -r 's/-O[0-9]?/-O1/g')
%endif
  SMALL="-DSYSTEM_PURESIZE_EXTRA=25000 \
	 -DSITELOAD_PURESIZE_EXTRA=10000 \
"
  LARGE="-DSYSTEM_PURESIZE_EXTRA=55000 \
	 -DSITELOAD_PURESIZE_EXTRA=10000 \
"
   SMALL= LARGE=
   LANG=POSIX; LC_CTYPE=en_US.UTF-8
export CC CFLAGS LANG LC_CTYPE LDFLAGS
 PREFIX="--prefix=%{_prefix} \
	 --mandir=%{_mandir} \
	 --infodir=%{_infodir} \
	 --datadir=%{_datadir} \
	 --localstatedir=%{_localstatedir} \
	 --sharedstatedir=%{_localstatedir}/lib \
	 --libexecdir=%{_prefix}/lib \
	 --enable-locallisppath=%{_datadir}/emacs/%{version}/site-lisp:%{_datadir}/emacs/site-lisp
"
DESKTOP="--with-x \
	 --with-xim \
	 --with-sound \
	 --with-xpm \
	 --with-jpeg \
	 --with-tiff \
	 --with-gif \
	 --with-png \
	 --with-rsvg \
	 --with-dbus \
	 --with-xft \
%if %{with tree_sitter}
	 --with-tree-sitter \
%endif
"
    GTK="${DESKTOP} \
	 --with-x-toolkit=gtk3 \
	 --with-toolkit-scroll-bars \
	 --x-includes=%{_x11inc} \
	 --x-libraries=%{_x11lib} \
	 --with-libotf \
	 --with-m17n-flt \
%if %{with cairo}
	 --with-cairo \
%endif
%if 0%{?suse_version} > 1310
%ifnarch ppc
	 --with-xwidgets \
%endif
%endif
%if %{with nativecomp}
         --with-native-compilation \
%endif
"
    X11="${DESKTOP} \
	 --with-x-toolkit=lucid \
	 --with-toolkit-scroll-bars \
	 --x-includes=%{_x11inc} \
	 --x-libraries=%{_x11lib} \
	 --without-libotf \
	 --without-m17n-flt \
"
  NOX11="--without-x \
	 --without-xim \
	 --without-sound \
	 --without-xpm \
	 --without-jpeg \
	 --without-tiff \
	 --without-gif \
	 --without-png \
	 --without-rsvg \
	 --without-dbus \
	 --without-xft \
	 --without-libotf \
	 --without-m17n-flt \
	 --without-harfbuzz \
	 --without-tree-sitter \
"
   COMP="--disable-build-details \
%if %{with mailutils}
	 --without-pop
	 --with-mailutils
%else
	 --with-pop \
%endif
	 --without-hesiod \
	 --with-gameuser=:games \
	 --with-kerberos \
	 --with-kerberos5 \
	 --with-file-notification=inotify \
	 --with-modules \
	 --enable-autodepend \
	 --with-gpm \
	 --with-file-notification=gfile \
"
if (($(getconf LONG_BIT) < 62))
then
    COMP="${COMP} --with-wide-int"
fi

##OIFS="$IFS"; IFS=.
##set -- $(gcc -dumpversion 2>/dev/null)
##(($1 > 4 || ($1 == 4 && $2 > 4))) && COMP="$COMP --enable-link-time-optimization"
##IFS="$OIFS"

CFLAGS="$CFLAGS $SMALL -DPDMP_BASE='\"emacs-nox\"'" ./configure ${COMP} ${PREFIX} ${NOX11} ${SYS} --with-dumping=pdumper
%make_build bootstrap V=1
make -C lisp/ updates compile V=1
for i in $(find site-lisp/ -name '*.el'); do
    EMACSLOADPATH='' src/emacs -batch -q --no-site -f batch-byte-compile $i
done
cp src/emacs emacs-nox
cp src/emacs.pdmp emacs-nox.pdmp
make distclean
#
CFLAGS="$CFLAGS $LARGE -DPDMP_BASE='\"emacs-x11\"'" ./configure ${COMP} ${PREFIX} ${X11} ${SYS} --with-dumping=pdumper
%make_build
cp src/emacs emacs-x11
cp src/emacs.pdmp emacs-x11.pdmp
make distclean
#
CFLAGS="$CFLAGS $LARGE -DPDMP_BASE='\"emacs-gtk\"'" ./configure ${COMP} ${PREFIX} ${GTK} ${SYS} --with-dumping=pdumper
%make_build

%if %{with tex4pdf}
#
make -C etc/refcards/
%endif

#
pushd ../site-lisp/
EMACSLOADPATH='' ../emacs-%{version}/src/emacs -batch -q --no-site -f batch-byte-compile *.el
rm -vf site-start.elc
rm -vf site-start.el.orig
popd

%install
#
PATH=/sbin:$PATH
##
VERSION=%{version}
eval $(sed -rn "/^configuration=/p" config.log)
sed -ri 's@/usr/lib/X11/fonts@/usr/share/fonts@g;s@(/usr/)local/(info|share|lib)@\1\2@;s@\$VERSION@%{version}@g;s@\$ARCH@'${configuration}'@g' doc/man/emacs.1
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_prefix}/lib/emacs/%{version}/${configuration}
install -m 0755 emacs-nox %{buildroot}%{_bindir}
install -m 0755 emacs-x11 %{buildroot}%{_bindir}
make install DESTDIR=%{buildroot} systemdunitdir=%{_userunitdir}
path_exec=$(sed -n 's/^#define PATH_EXEC "\(.*\)"/\1/p' src/epaths.h)
fingerprint=$(./emacs-nox --fingerprint)
echo $path_exec/emacs-$fingerprint.pdmp > nox.lst
install -m 644 emacs-nox.pdmp %{buildroot}$path_exec/emacs-$fingerprint.pdmp
fingerprint=$(./emacs-x11 --fingerprint)
echo $path_exec/emacs-$fingerprint.pdmp > x11.lst
install -m 644 emacs-x11.pdmp %{buildroot}$path_exec/emacs-$fingerprint.pdmp
fingerprint=$(src/emacs --fingerprint)
echo $path_exec/emacs-$fingerprint.pdmp >> x11.lst
mv %{buildroot}/usr/bin/emacs %{buildroot}/usr/bin/emacs-gtk
rm -vf %{buildroot}%{_prefix}/lib/emacs/%{version}/${configuration}/emacs.pdmp
install -p %{S:5} %{buildroot}/usr/bin/emacs
chmod 0755        %{buildroot}/usr/bin/emacs
tar cf - `find site-lisp/ -name '*.el'  -o -name '*.elc'` | \
tar -x -f - -C %{buildroot}%{_datadir}/emacs/%{version}/
mkdir -p %{buildroot}%{_docdir}/emacs
ln -sf %{_datadir}/emacs/%{version}/etc %{buildroot}%{_docdir}/emacs/doc
find %{buildroot}%{_datadir}/emacs/%{version}/ -name '*,v' -o -name '*.orig' | xargs -r rm -f
#for f in %{buildroot}%{_infodir}/* ; do
#    case "$f" in
#	*.gz)			;;
#	*/dir)	rm -f ${f}	;;
#	*)	test -e  ${f}.gz && rm ${f}.gz
#		gzip -9f ${f}
#    esac
#done
info_found=$(cd %{buildroot}%{_infodir}; echo *.gz | sed -e 's/\.info\.gz//g')
if test "$info_found" != "%info_files"
then
  echo Please update info_files >&2
  exit 1
fi
rm -vf %{buildroot}%{_infodir}/dir
#
pushd ../
mkdir -p %{buildroot}/etc/skel
install -m 0644 %{S:3} %{buildroot}/etc/skel/.gnu-emacs
mkdir -p %{buildroot}%{_datadir}/emacs/site-lisp/site-start.d
tar cf - site-lisp/ | tar xvvf - -C %{buildroot}%{_datadir}/emacs/
chmod -R a+r %{buildroot}%{_datadir}/emacs/site-lisp/
popd
(cd %{buildroot}
 find usr/share/emacs/site-lisp/ -type f	\
      \( -name site-start.el -printf "%%%%config " , \
	 -printf "/%%p\n" \)
) | sort > site-lisp.lst
#
# cleanup
#
unelc ()
{
    local elc=$1
    local elz=${elc%%.elc}.el.gz
    rm -vf $elc
    if test -n "$elz" -a -e "$elz" ; then
	gunzip "$elz"
    fi
}
unelc  %{buildroot}%{_datadir}/emacs/%{version}/site-lisp/term/func-keys.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/site-lisp/term/gnome.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/site-lisp/term/kvt.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/site-lisp/term/linux.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/site-lisp/term/locale.elc
find %{buildroot}%{_datadir}/emacs/%{version}/etc/ -name '*[a-z].[16]' | \
    xargs gzip -9f
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/COPYING
ln -sf ../etc/COPYING \
       %{buildroot}%{_datadir}/emacs/%{version}/lisp/COPYING
rm -f %{buildroot}%{_datadir}/emacs/%{version}/lisp/gnus/.dir-locals.el
#
fdupes -q -r -1 %{buildroot}%{_datadir}/emacs/%{version}/etc/images/icons/ %{buildroot}%{_datadir}/icons/ |\
xargs -n 2 | while read first second; do
    case "${first}" in
    *emacs/%{version}/etc/*)
	target=$second
	file=$first
	;;
    *)  target=$first
	file=$second
    esac
    ln -sf ${file#%{buildroot}} ${target}
done
# install desktop file
test -e etc/emacs.desktop || exit 1
echo 'X-KDE-StartupNotify=false' >> etc/emacs.desktop
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/etc/emacs.desktop
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/etc/emacsclient.desktop
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/etc/emacs-mail.desktop
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/etc/emacsclient-mail.desktop
cp etc/images/icons/hicolor/32x32/apps/emacs.png $RPM_SOURCE_DIR/emacs.png
%suse_update_desktop_file -r -i emacs TextEditor Utility
%suse_update_desktop_file -r -i emacs TextEditor
%suse_update_desktop_file -r -i emacsclient TextEditor
%suse_update_desktop_file -r -i emacs-mail Email
%suse_update_desktop_file -r -i emacsclient-mail Email
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
ln -sf %{_sysconfdir}/alternatives/ctags		%{buildroot}%{_bindir}/ctags
ln -sf %{_sysconfdir}/alternatives/ctags.1%{ext_man}	%{buildroot}%{_mandir}/man1/ctags.1%{ext_man}
ln -sf %{_bindir}/gnuctags				%{buildroot}%{_sysconfdir}/alternatives/ctags
ln -sf %{_mandir}/man1/gnuctags.1%{ext_man}		%{buildroot}%{_sysconfdir}/alternatives/ctags.1%{ext_man}

%pre
test -L usr/bin/emacs && rm -f usr/bin/emacs || true

%post -n emacs-nox
if test -e usr/share/emacs/site-lisp/auctex/font-latex.elc ; then
  owd=$(pwd)
  cd usr/share/emacs/site-lisp/auctex || exit 1
  emacs -batch -no-site-file -no-init-file --eval '(setq load-path (cons "." load-path)
    byte-compile-warnings nil
    TeX-lisp-directory "<none>"
    TeX-auto-global "<none>")' -f batch-byte-compile font-latex.el > /dev/null 2>&1
  cd $owd
fi

%post -n emacs-x11
if test -e usr/share/emacs/site-lisp/auctex/font-latex.elc ; then
  owd=$(pwd)
  cd usr/share/emacs/site-lisp/auctex || exit 1
  emacs -batch -no-site-file -no-init-file --eval '(setq load-path (cons "." load-path)
    byte-compile-warnings nil
    TeX-lisp-directory "<none>"
    TeX-auto-global "<none>")' -f batch-byte-compile font-latex.el > /dev/null 2>&1
  cd $owd
fi

%if 0%{?suse_version} <= 1500
%post info
for f in %info_files; do
  test "$f" = "info.info" && continue
  test -e "$f" || f="${f}.info"
  %install_info --info-dir=%{_infodir} "%{_infodir}/$f%{ext_info}"
done

%preun info
for f in %info_files; do
  test "$f" = "info.info" && continue
  test -e "$f" || f="${f}.info"
  %install_info_delete --info-dir=%{_infodir} "%{_infodir}/$f%{ext_info}"
done
%endif

%post -n etags
test -L %{_bindir}/ctags || rm -f %{_bindir}/ctags
%{_sbindir}/update-alternatives --quiet --force --install \
	  %{_bindir}/ctags			ctags	%{_bindir}/gnuctags 10 \
  --slave %{_mandir}/man1/ctags.1%{ext_man}	ctags.1	%{_mandir}/man1/gnuctags.1%{ext_man}
%{_sbindir}/update-alternatives --auto ctags

%preun -n etags
if test $1 -eq 0 ; then
    %{_sbindir}/update-alternatives --quiet --remove ctags %{_bindir}/gnuctags
fi

%files -f site-lisp.lst -n emacs
%defattr(-, root, root)
%config /etc/skel/.gnu-emacs
%{_bindir}/ebrowse
%{_bindir}/emacs
%{_bindir}/emacsclient
%{_includedir}/emacs-module.h
%dir %{_prefix}/lib/emacs/
%dir %{_prefix}/lib/emacs/%{version}/
%dir %{_prefix}/lib/emacs/%{version}/*-suse-linux*/
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/hexl
%if %{without mailutils}
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/movemail
%endif
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/rcs2log
%if 0
%attr(04755,games,games) %{_prefix}/lib/emacs/%{version}/*-suse-linux*/update-game-score
%else
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/update-game-score
%endif
%if 0%{?suse_version} > 1320
%{_userunitdir}/emacs.service
%endif
%dir %{_datadir}/doc/packages/emacs/
%{_datadir}/doc/packages/emacs/doc
%dir %{_datadir}/emacs/
%dir %{_datadir}/emacs/%{version}/
%dir %{_datadir}/emacs/%{version}/etc/
%doc %{_datadir}/emacs/%{version}/etc/AUTHORS
%doc %{_datadir}/emacs/%{version}/etc/*-NEWS
%doc %{_datadir}/emacs/%{version}/etc/COPYING
%doc %{_datadir}/emacs/%{version}/etc/DEBUG
%doc %{_datadir}/emacs/%{version}/etc/DEVEL.HUMOR
%doc %{_datadir}/emacs/%{version}/etc/DISTRIB
%{_datadir}/emacs/%{version}/etc/DOC
%doc %{_datadir}/emacs/%{version}/etc/ETAGS.EBNF
%doc %{_datadir}/emacs/%{version}/etc/ETAGS.README
%doc %{_datadir}/emacs/%{version}/etc/HELLO
%doc %{_datadir}/emacs/%{version}/etc/HISTORY
%doc %{_datadir}/emacs/%{version}/etc/JOKES
%doc %{_datadir}/emacs/%{version}/etc/MACHINES
%{_datadir}/emacs/%{version}/etc/NEWS
%doc %{_datadir}/emacs/%{version}/etc/NEWS.*
%doc %{_datadir}/emacs/%{version}/etc/NEXTSTEP
%doc %{_datadir}/emacs/%{version}/etc/PROBLEMS
%doc %{_datadir}/emacs/%{version}/etc/README
%doc %{_datadir}/emacs/%{version}/etc/TERMS
%doc %{_datadir}/emacs/%{version}/etc/TODO
%dir %{_datadir}/emacs/%{version}/etc/charsets/
%{_datadir}/emacs/%{version}/etc/charsets/*.map
%doc %{_datadir}/emacs/%{version}/etc/charsets/README
%{_datadir}/emacs/%{version}/etc/*.txt
%dir %{_datadir}/emacs/%{version}/etc/e/
%doc %{_datadir}/emacs/%{version}/etc/e/README
%{_datadir}/emacs/%{version}/etc/e/eterm-color
%{_datadir}/emacs/%{version}/etc/e/eterm-color.ti
%{_datadir}/emacs/%{version}/etc/e/eterm-direct
%{_datadir}/emacs/%{version}/etc/edt-user.el
%{_datadir}/emacs/%{version}/etc/emacs-buffer.gdb
%{_datadir}/emacs/%{version}/etc/emacs.icon
%{_datadir}/emacs/%{version}/etc/emacs.metainfo.xml
%{_datadir}/emacs/%{version}/etc/emacs.service
%{_datadir}/emacs/%{version}/etc/emacs_lldb.py
%dir %{_datadir}/emacs/%{version}/etc/forms/
%doc %{_datadir}/emacs/%{version}/etc/forms/README
%{_datadir}/emacs/%{version}/etc/forms/*.dat
%{_datadir}/emacs/%{version}/etc/forms/*.el
%{_datadir}/emacs/%{version}/etc/future-bug
%dir %{_datadir}/emacs/%{version}/etc/gnus/
%{_datadir}/emacs/%{version}/etc/gnus/gnus-setup.ast
%{_datadir}/emacs/%{version}/etc/gnus/news-server.ast
%dir %{_datadir}/emacs/%{version}/etc/images/
%doc %{_datadir}/emacs/%{version}/etc/images/README
%{_datadir}/emacs/%{version}/etc/images/*.bmp
%{_datadir}/emacs/%{version}/etc/images/*.pbm
%{_datadir}/emacs/%{version}/etc/images/*.xpm
%{_datadir}/emacs/%{version}/etc/images/*.png
%{_datadir}/emacs/%{version}/etc/images/*.svg
%dir %{_datadir}/emacs/%{version}/etc/images/custom/
%doc %{_datadir}/emacs/%{version}/etc/images/custom/README
%{_datadir}/emacs/%{version}/etc/images/custom/*.pbm
%{_datadir}/emacs/%{version}/etc/images/custom/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/ezimage/
%doc %{_datadir}/emacs/%{version}/etc/images/ezimage/README
%{_datadir}/emacs/%{version}/etc/images/ezimage/*.pbm
%{_datadir}/emacs/%{version}/etc/images/ezimage/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/gnus/
%doc %{_datadir}/emacs/%{version}/etc/images/gnus/README
%{_datadir}/emacs/%{version}/etc/images/gnus/*.pbm
%{_datadir}/emacs/%{version}/etc/images/gnus/*.xbm
%{_datadir}/emacs/%{version}/etc/images/gnus/*.xpm
%{_datadir}/emacs/%{version}/etc/images/gnus/*.png
%{_datadir}/emacs/%{version}/etc/images/gnus/*.svg
%dir %{_datadir}/emacs/%{version}/etc/images/gud/
%doc %{_datadir}/emacs/%{version}/etc/images/gud/README
%{_datadir}/emacs/%{version}/etc/images/gud/*.pbm
%{_datadir}/emacs/%{version}/etc/images/gud/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/icons/
%doc %{_datadir}/emacs/%{version}/etc/images/icons/README
%{_datadir}/emacs/%{version}/etc/images/icons/allout-widgets/
%{_datadir}/emacs/%{version}/etc/images/icons/hicolor/
%dir %{_datadir}/emacs/%{version}/etc/images/low-color/
%doc %{_datadir}/emacs/%{version}/etc/images/low-color/README
%{_datadir}/emacs/%{version}/etc/images/low-color/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/mail/
%doc %{_datadir}/emacs/%{version}/etc/images/mail/README
%{_datadir}/emacs/%{version}/etc/images/mail/*.pbm
%{_datadir}/emacs/%{version}/etc/images/mail/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/mpc/
%doc %{_datadir}/emacs/%{version}/etc/images/mpc/README
%{_datadir}/emacs/%{version}/etc/images/mpc/*.pbm
%{_datadir}/emacs/%{version}/etc/images/mpc/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/newsticker/
%doc %{_datadir}/emacs/%{version}/etc/images/newsticker/README
%{_datadir}/emacs/%{version}/etc/images/newsticker/rss-feed.*
%{_datadir}/emacs/%{version}/etc/images/newsticker/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/smilies/
%doc %{_datadir}/emacs/%{version}/etc/images/smilies/README
%{_datadir}/emacs/%{version}/etc/images/smilies/*.pbm
%{_datadir}/emacs/%{version}/etc/images/smilies/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/smilies/grayscale/
%doc %{_datadir}/emacs/%{version}/etc/images/smilies/grayscale/README
%{_datadir}/emacs/%{version}/etc/images/smilies/grayscale/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/smilies/medium/
%doc %{_datadir}/emacs/%{version}/etc/images/smilies/medium/README
%{_datadir}/emacs/%{version}/etc/images/smilies/medium/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/tabs/
%doc %{_datadir}/emacs/%{version}/etc/images/tabs/README
%{_datadir}/emacs/%{version}/etc/images/tabs/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/tree-widget/
%dir %{_datadir}/emacs/%{version}/etc/images/tree-widget/default/
%doc %{_datadir}/emacs/%{version}/etc/images/tree-widget/default/README
%{_datadir}/emacs/%{version}/etc/images/tree-widget/default/*.png
%{_datadir}/emacs/%{version}/etc/images/tree-widget/default/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/images/tree-widget/folder/
%doc %{_datadir}/emacs/%{version}/etc/images/tree-widget/folder/README
%{_datadir}/emacs/%{version}/etc/images/tree-widget/folder/*.png
%{_datadir}/emacs/%{version}/etc/images/tree-widget/folder/*.xpm
%dir %{_datadir}/emacs/%{version}/etc/nxml/
%doc %{_datadir}/emacs/%{version}/etc/nxml/README
%{_datadir}/emacs/%{version}/etc/nxml/*.xml
%{_datadir}/emacs/%{version}/etc/*.ps
%{_datadir}/emacs/%{version}/etc/*.xml
%dir %{_datadir}/emacs/%{version}/etc/org/
%doc %{_datadir}/emacs/%{version}/etc/org/README
%{_datadir}/emacs/%{version}/etc/org/*.xml
%dir %{_datadir}/emacs/%{version}/etc/org/csl
%doc %{_datadir}/emacs/%{version}/etc/org/csl/README
%{_datadir}/emacs/%{version}/etc/org/csl/*.csl
%{_datadir}/emacs/%{version}/etc/org/csl/*.xml
%{_datadir}/emacs/%{version}/etc/package-keyring.gpg
%{_datadir}/emacs/%{version}/etc/publicsuffix.txt.gz
%dir %{_datadir}/emacs/%{version}/etc/refcards/
%{_datadir}/emacs/%{version}/etc/refcards/Makefile
%doc %{_datadir}/emacs/%{version}/etc/refcards/README
%doc %{_datadir}/emacs/%{version}/etc/refcards/*.pdf
%doc %{_datadir}/emacs/%{version}/etc/refcards/*.tex
%doc %{_datadir}/emacs/%{version}/etc/refcards/*.eps
%doc %{_datadir}/emacs/%{version}/etc/refcards/*.sty
%dir %{_datadir}/emacs/%{version}/etc/schema/
%doc %{_datadir}/emacs/%{version}/etc/schema/README
%{_datadir}/emacs/%{version}/etc/schema/*.rnc
%{_datadir}/emacs/%{version}/etc/schema/*.xml
%{_datadir}/emacs/%{version}/etc/ses-example.ses
%{_datadir}/emacs/%{version}/etc/spook.lines
%dir %{_datadir}/emacs/%{version}/etc/srecode/
%{_datadir}/emacs/%{version}/etc/srecode/*.srt
%dir %{_datadir}/emacs/%{version}/etc/themes/
%{_datadir}/emacs/%{version}/etc/themes/*.el
%dir %{_datadir}/emacs/%{version}/etc/tutorials/
%{_datadir}/emacs/%{version}/etc/tutorials/TUTORIAL
%{_datadir}/emacs/%{version}/etc/tutorials/TUTORIAL.*
%{_datadir}/emacs/%{version}/etc/w32-feature.el
%{_datadir}/emacs/%{version}/etc/yow.lines
%dir %{_datadir}/emacs/%{version}/lisp/
%{_datadir}/emacs/%{version}/lisp/COPYING
%doc %{_datadir}/emacs/%{version}/lisp/README
%dir %{_datadir}/emacs/%{version}/lisp/calc/
%dir %{_datadir}/emacs/%{version}/lisp/calendar/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/ede/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/analyze/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/bovine/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/decorate/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/symref/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/wisent/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/srecode/
%dir %{_datadir}/emacs/%{version}/lisp/emacs-lisp/
%dir %{_datadir}/emacs/%{version}/lisp/emulation/
%dir %{_datadir}/emacs/%{version}/lisp/erc/
%dir %{_datadir}/emacs/%{version}/lisp/eshell/
%dir %{_datadir}/emacs/%{version}/lisp/gnus/
%dir %{_datadir}/emacs/%{version}/lisp/image/
%dir %{_datadir}/emacs/%{version}/lisp/international/
%dir %{_datadir}/emacs/%{version}/lisp/language/
%dir %{_datadir}/emacs/%{version}/lisp/leim/
%dir %{_datadir}/emacs/%{version}/lisp/leim/ja-dic/
%dir %{_datadir}/emacs/%{version}/lisp/leim/quail/
%dir %{_datadir}/emacs/%{version}/lisp/mail/
%dir %{_datadir}/emacs/%{version}/lisp/mh-e/
%dir %{_datadir}/emacs/%{version}/lisp/net/
%dir %{_datadir}/emacs/%{version}/lisp/nxml/
%dir %{_datadir}/emacs/%{version}/lisp/obsolete/
%dir %{_datadir}/emacs/%{version}/lisp/org/
%dir %{_datadir}/emacs/%{version}/lisp/play/
%dir %{_datadir}/emacs/%{version}/lisp/progmodes/
%dir %{_datadir}/emacs/%{version}/lisp/term/
%doc %{_datadir}/emacs/%{version}/lisp/term/README
%dir %{_datadir}/emacs/%{version}/lisp/textmodes/
%dir %{_datadir}/emacs/%{version}/lisp/use-package/
%dir %{_datadir}/emacs/%{version}/lisp/url/
%dir %{_datadir}/emacs/%{version}/lisp/vc/
%dir %{_datadir}/emacs/%{version}/site-lisp/
%dir %{_datadir}/emacs/%{version}/site-lisp/term/
%{_datadir}/emacs/%{version}/lisp/*.el
%{_datadir}/emacs/%{version}/lisp/*.elc
%{_datadir}/emacs/%{version}/lisp/*/*.el
%{_datadir}/emacs/%{version}/lisp/*/*.elc
%{_datadir}/emacs/%{version}/lisp/*/*/*.elc
%{_datadir}/emacs/%{version}/lisp/*/*/*/*.elc
%{_datadir}/emacs/%{version}/site-lisp/*.el
%{_datadir}/emacs/%{version}/site-lisp/*/*.el
%dir %{_datadir}/emacs/site-lisp/
%dir %{_datadir}/emacs/site-lisp/site-start.d/
%{_mandir}/man1/*.1%{ext_man}
%exclude %{_mandir}/man1/*tags.1%{ext_man}
%dir %attr(775,games,games) %{_localstatedir}/games/emacs
%attr(660,games,games) %{_localstatedir}/games/emacs/snake-scores
%attr(660,games,games) %{_localstatedir}/games/emacs/tetris-scores

%files       -n emacs-nox -f nox.lst
%defattr(-, root, root)
%{_bindir}/emacs-nox
%dir %{_prefix}/lib/emacs/
%dir %{_prefix}/lib/emacs/%{version}/
%dir %{_prefix}/lib/emacs/%{version}/*-suse-linux*/

%files       -n emacs-x11 -f x11.lst
%defattr(-, root, root)
%{_bindir}/emacs-x11
%{_bindir}/emacs-gtk
%if 0%{suse_version} < 1320
%dir %{_datadir}/metainfo/
%endif
%dir %{_prefix}/lib/emacs/
%dir %{_prefix}/lib/emacs/%{version}/
%dir %{_prefix}/lib/emacs/%{version}/*-suse-linux*/
%if %{with nativecomp}
%{_prefix}/lib/emacs/%{version}/native-lisp
%endif
%{_datadir}/metainfo/emacs.metainfo.xml
%{_datadir}/applications/emacs.desktop
%{_datadir}/applications/emacsclient.desktop
%{_datadir}/applications/emacs-mail.desktop
%{_datadir}/applications/emacsclient-mail.desktop
%{_datadir}/icons/hicolor/*/apps/emacs.png
%{_datadir}/icons/hicolor/*/apps/emacs.ico
%{_datadir}/icons/hicolor/*/apps/emacs.svg
%{_datadir}/icons/hicolor/scalable/mimetypes/*.svg
%{_datadir}/pixmaps/emacs.png

%files       -n emacs-info
%defattr(-, root, root)
%doc %{_infodir}/*%{ext_info}
%if 0%{?include_info} == 0
%exclude %{_infodir}/info.info%{ext_info}
%endif

%files       -n emacs-el
%defattr(-, root, root)
%dir %{_datadir}/emacs/
%dir %{_datadir}/emacs/%{version}/
%dir %{_datadir}/emacs/%{version}/lisp/
%dir %{_datadir}/emacs/%{version}/lisp/calc/
%dir %{_datadir}/emacs/%{version}/lisp/calendar/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/ede/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/analyze/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/bovine/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/decorate/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/symref/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/semantic/wisent/
%dir %{_datadir}/emacs/%{version}/lisp/cedet/srecode/
%dir %{_datadir}/emacs/%{version}/lisp/emacs-lisp/
%dir %{_datadir}/emacs/%{version}/lisp/emulation/
%dir %{_datadir}/emacs/%{version}/lisp/erc/
%dir %{_datadir}/emacs/%{version}/lisp/eshell/
%dir %{_datadir}/emacs/%{version}/lisp/gnus/
%dir %{_datadir}/emacs/%{version}/lisp/image/
%dir %{_datadir}/emacs/%{version}/lisp/international/
%dir %{_datadir}/emacs/%{version}/lisp/language/
%dir %{_datadir}/emacs/%{version}/lisp/leim/
%dir %{_datadir}/emacs/%{version}/lisp/leim/ja-dic/
%dir %{_datadir}/emacs/%{version}/lisp/leim/quail/
%dir %{_datadir}/emacs/%{version}/lisp/mail/
%dir %{_datadir}/emacs/%{version}/lisp/mh-e/
%dir %{_datadir}/emacs/%{version}/lisp/net/
%dir %{_datadir}/emacs/%{version}/lisp/nxml/
%dir %{_datadir}/emacs/%{version}/lisp/obsolete/
%dir %{_datadir}/emacs/%{version}/lisp/org/
%dir %{_datadir}/emacs/%{version}/lisp/play/
%dir %{_datadir}/emacs/%{version}/lisp/progmodes/
%dir %{_datadir}/emacs/%{version}/lisp/term/
%dir %{_datadir}/emacs/%{version}/lisp/textmodes/
%dir %{_datadir}/emacs/%{version}/lisp/use-package/
%dir %{_datadir}/emacs/%{version}/lisp/url/
%dir %{_datadir}/emacs/%{version}/lisp/vc/
%{_datadir}/emacs/%{version}/lisp/*.el.gz
%{_datadir}/emacs/%{version}/lisp/*/*.el.gz
%{_datadir}/emacs/%{version}/lisp/*/*/*.el.gz
%{_datadir}/emacs/%{version}/lisp/*/*/*/*.el.gz

%files -n etags
%defattr(-,root,root)
%doc etc/ETAGS.EBNF
%doc etc/ETAGS.README
%{_bindir}/etags
%{_bindir}/gnuctags
%{_mandir}/man1/etags.1%{ext_man}
%{_mandir}/man1/gnuctags.1%{ext_man}
%ghost %{_bindir}/ctags
%ghost %{_sysconfdir}/alternatives/ctags
%ghost %{_mandir}/man1/ctags.1%{ext_man}
%ghost %{_sysconfdir}/alternatives/ctags.1%{ext_man}

%changelog
openSUSE Build Service is sponsored by