File emacs.spec of Package emacs-pgtk-nativecomp-git

#
# spec file for package emacs
#
# Copyright (c) 2021 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

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:  gcc10-libgccjit-devel
BuildRequires:  giflib-devel
BuildRequires:  git
BuildRequires:  gpm-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
BuildRequires:  libselinux-devel
BuildRequires:  libtiff-devel
BuildRequires:  libxml2-devel
BuildRequires:  pkgconfig(libudev)
%if %{with mailutils}
BuildRequires:  mailutils
BuildRequires:  mailutils-devel
%endif
BuildRequires:  makeinfo
BuildRequires:  ncurses-devel
BuildRequires:  systemd-rpm-macros
BuildRequires:  update-alternatives
BuildRequires:  update-desktop-files
BuildRequires:  xz
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(com_err)
BuildRequires:  pkgconfig(dbus-1)
BuildRequires:  pkgconfig(fontconfig)
BuildRequires:  pkgconfig(gconf-2.0)
BuildRequires:  pkgconfig(gio-2.0)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(gsettings-desktop-schemas)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(harfbuzz)
BuildRequires:  pkgconfig(ice)
BuildRequires:  pkgconfig(jansson)
BuildRequires:  pkgconfig(json)
BuildRequires:  pkgconfig(lcms2)
BuildRequires:  pkgconfig(libacl)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(pango)
BuildRequires:  pkgconfig(sm)
BuildRequires:  pkgconfig(webkit2gtk-4.0) >= 2.12
BuildRequires:  pkgconfig(xft)
BuildRequires:  pkgconfig(xpm)
BuildRequires:  user(games)
URL:            http://www.gnu.org/software/emacs/
Version:        28.0.50
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
# required to compile 3rd party lisp at runtime
Requires:       gcc10-libgccjit-devel
%if %{with mailutils}
Requires:       mailutils
%endif
Requires(pre):  fileutils
Requires(pre):  group(games)
Requires(pre):  user(games)
Source:         https://github.com/flatwhatson/emacs/emacs-%{version}.tar.xz
Source2:        site-lisp.tar.bz2
Source3:        dot.gnu-emacs
Source4:        emacs-rpmlintrc
Source5:        emacs.sh
Patch:          emacs-28.0.dif
# Currently disabled
Patch2:         emacs-24.4-glibc.patch
Patch4:         emacs-24.3-asian-print.patch
Patch5:         emacs-24.4-ps-bdf.patch
Patch7:         emacs-24.1-ps-mule.patch
Patch8:         emacs-24.4-nonvoid.patch
Patch22:        pdump.patch
Patch26:        emacs-27.1-pdftex.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{expand: %%global include_info %(test -s /usr/share/info/info.info* && echo 0 || echo 1)}
%define info_files emacs eintr elisp auth autotype bovine calc ccmode cl dbus dired-x ebrowse ede ediff edt eieio emacs-mime epa erc ert eshell eudc efaq eww flymake forms gnus emacs-gnutls htmlfontify idlwave ido info.info mairix-el message mh-e modus-themes newsticker nxml-mode octave-mode org pcl-cvs pgg rcirc remember reftex sasl sc semantic ses sieve smtpmail speedbar srecode todo-mode tramp url vhdl-mode vip viper widget wisent woman

%description
Basic package for the GNU Emacs editor. Requires emacs-pgtk 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-pgtk
Requires(post): fileutils
Requires:       emacs = %{version}-%{release}
Provides:       emacs_program = %{version}-%{release}
Requires:       efont-unicode
Requires:       xorg-x11-fonts
Requires:       xorg-x11-fonts-core
Summary:        GNU Emacs: Emacs binary with GTK Support
Group:          Productivity/Text/Editors

%description -n emacs-pgtk
Call it

Emacs

Love it or leave it. This is the Emacs binary with GTK 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
Requires(post): %install_info_prereq
Requires(preun): %install_info_prereq
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
#%patch2  -p0 -b .glibc
%patch4  -p0 -b .print
%patch5  -p0 -b .psbdf
%patch7  -p0 -b .psmu
%patch8  -p0 -b .nvoid
%patch22 -p0 -b .pd
%patch26 -p0 -b .fmt

%patch   -p0 -b .0

%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
  }

  # remove reference to win32 info page
  info_found="$((sed -rn '\@^info:@{ s@.*/@@;s/\.info//p; }' doc/emacs/Makefile.in doc/lispintro/Makefile.in doc/lispref/Makefile.in ; sed -rn '\@^INFO_COMMON@,\@^$@{ s@.*=@@; s@[[:blank:]]+@ @g; :join; /\\$/{N; s/\s*\\\n//; b join;}; p}' ./doc/misc/Makefile.in)|xargs|sed -e 's,efaq-w32 ,,')"
  if test "$info_found" != "%info_files"
  then
      echo Please update info_files >&2
      exit 1
  fi
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 -Wl,-no-pie             LDFLAGS
  cflags -pipe                   CFLAGS
  cflags -Wno-pointer-sign       CFLAGS
  cflags -Wno-unused-variable    CFLAGS
  cflags -Wno-unused-label       CFLAGS
  cflags -fno-optimize-sibling-calls CFLAGS
  cflags -fno-PIE                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 \
"
   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
"
    GTK="--with-pgtk \
	 --with-x-toolkit=gtk3 \
	 --without-gconf \
	 --without-gsettings \
	 --with-sound \
	 --with-xpm \
	 --with-jpeg \
	 --with-tiff \
	 --with-gif \
	 --with-png \
	 --with-rsvg \
	 --with-dbus \
	 --with-xwidgets \
	 --with-toolkit-scroll-bars \
	 --with-libotf \
	 --without-m17n-flt \
%if %{with cairo}
	 --with-cairo \
%endif
"
  NOX11="--with-gpm \
	 --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 \
"
   COMP="--with-nativecomp \
         --enable-link-time-optimization \
         --disable-build-details \
	 --without-imagemagick
%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 \
"
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"

# new giflib5 does not have this function and it is unused anyway...
ac_cv_lib_gif_EGifPutExtensionLast=yes
export ac_cv_lib_gif_EGifPutExtensionLast

CFLAGS="$CFLAGS $SMALL -DPDMP_BASE='\"emacs-nox\"'" ./configure ${COMP} ${PREFIX} ${NOX11} ${SYS} --with-dumping=pdumper
make 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-gtk\"'" ./configure ${COMP} ${PREFIX} ${GTK} ${SYS} --with-dumping=pdumper
make %{?_smp_mflags} NATIVE_FULL_AOT=1
cp src/emacs emacs-gtk
cp src/emacs.pdmp emacs-gtk.pdmp

#

#
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-gtk %{buildroot}%{_bindir}
install -m 0644 emacs-nox.pdmp %{buildroot}%{_prefix}/lib/emacs/%{version}/${configuration}/
install -m 0644 emacs-gtk.pdmp %{buildroot}%{_prefix}/lib/emacs/%{version}/${configuration}/
make install DESTDIR=%{buildroot} systemdunitdir=%{_userunitdir}
rm -vf %{buildroot}/usr/bin/emacs
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
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
}
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/dired.el.dired
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/loaddefs.el.psbdf
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/ps-bdf.el.psbdf
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/ps-mule.el.print
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/ps-mule.el.mule
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/startup.el.iconic
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/textmodes/ispell.el.mule
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/term.el.term
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/etc/ETAGS.EBNF
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/etc/ETAGS.README
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/etc/refcards/*.fmt
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/elc.tar.gz
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/mail/sendmail.el.snd
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/ldefs-boot.el.psbdf
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/ps-mule.el.psmu
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/textmodes/ispell.el.psmu
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/files.el.CVE20075795
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/fast-lock.el.flc
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/obsolete/fast-lock.el.flc
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/loaddefs.el.flc
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/progmodes/python.el.python
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/textmodes/flyspell.el.flyspell
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/obsolete/spell.el.obsolate
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/cmuscheme.el.0
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/international/mule-cmds.el.0
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/net/ange-ftp.el.0
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/site-load.el.0
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/speedbar.el.0
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/textmodes/ispell.el.0
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/epg.el.gnupg
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/mouse.el.prime
rm -vf %{buildroot}%{_datadir}/emacs/%{version}/lisp/dynamic-setting.el.custfnt
unelc  %{buildroot}%{_datadir}/emacs/%{version}/lisp/bindings.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/lisp/cus-start.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/lisp/generic-x.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/lisp/site-load.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/lisp/skeleton.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/lisp/term/xterm.elc
unelc  %{buildroot}%{_datadir}/emacs/%{version}/site-lisp/subdirs.elc
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
unelc  %{buildroot}%{_datadir}/emacs/site-lisp/site-start.elc
unelc  %{buildroot}%{_datadir}/emacs/site-lisp/subdirs.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
cp etc/images/icons/hicolor/32x32/apps/emacs.png $RPM_SOURCE_DIR/emacs.png
%suse_update_desktop_file -r -i emacs TextEditor Utility
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-pgtk
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
/usr/lib/systemd/user/emacs.service
%dir %{_prefix}/lib/emacs/
%dir %{_prefix}/lib/emacs/%{version}/
%dir %{_prefix}/lib/emacs/%{version}/*-suse-linux*/
%dir %{_prefix}/lib/emacs/%{version}/native-lisp/
%dir %{_prefix}/lib/emacs/%{version}/native-lisp/%{version}-*/
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/hexl
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/update-game-score
%if %{without mailutils}
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/movemail
%endif
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/rcs2log
%{_prefix}/lib/emacs/%{version}/native-lisp/%{version}-*/*.eln
%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/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/edt-user.el
%{_datadir}/emacs/%{version}/etc/emacs-buffer.gdb
%{_datadir}/emacs/%{version}/etc/emacs.appdata.xml
%{_datadir}/emacs/%{version}/etc/emacs.icon
%{_datadir}/emacs/%{version}/etc/emacs.service
%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
%dir %{_datadir}/emacs/%{version}/etc/org/
%{_datadir}/emacs/%{version}/etc/org/*.xml
%doc %{_datadir}/emacs/%{version}/etc/org/README
%{_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/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/*/*/*.el
%{_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 %{_localstatedir}/games/
%dir %{_localstatedir}/games/emacs/
%{_localstatedir}/games/emacs/snake-scores
%{_localstatedir}/games/emacs/tetris-scores

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

%files       -n emacs-pgtk
%defattr(-, root, root)
%{_bindir}/emacs-gtk
%{_prefix}/lib/emacs/%{version}/*-suse-linux*/emacs-gtk.pdmp
%{_datadir}/applications/emacs.desktop
%{_datadir}/applications/emacsclient.desktop
%{_datadir}/emacs/%{version}/etc/org.gnu.emacs.defaults.gschema.valid
%{_datadir}/emacs/%{version}/etc/org.gnu.emacs.defaults.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnu.emacs.defaults.gschema.xml
%{_datadir}/icons/hicolor/128x128/apps/emacs.png
%{_datadir}/icons/hicolor/16x16/apps/emacs.png
%{_datadir}/icons/hicolor/24x24/apps/emacs.png
%{_datadir}/icons/hicolor/32x32/apps/emacs.png
%{_datadir}/icons/hicolor/48x48/apps/emacs.png
%{_datadir}/icons/hicolor/scalable/apps/emacs.ico
%{_datadir}/icons/hicolor/scalable/apps/emacs.svg
%{_datadir}/icons/hicolor/scalable/mimetypes/emacs-document.svg
%{_datadir}/icons/hicolor/scalable/mimetypes/emacs-document23.svg
%{_datadir}/metainfo/emacs.appdata.xml
%{_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/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