File gnustep-base.spec of Package gnustep-base

# spec file for package gnustep-base
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
# 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

Name:           gnustep-base
Summary:        GNUstep Base library package
Version:        1.24.9
Release:        0
License:        LGPL-2.1+ and GPL-3.0+
Group:          System/GUI/Other
Source:         %{name}-%{version}.tar.gz
Source2:        %{name}-rpmlintrc
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

#SUSE specfile docs say prereq is deprecated and it causes the build to fail on Fedora 
#However the RPM macros doc says it must be used if various other macros
#e.g. fillup_and_insserv are use. This change is a test for Fedora
%if 0%{?suse_version}
PreReq:         %insserv_prereq
#PreReq:         permissions

BuildRequires:  gcc-objc
BuildRequires:  gmp-devel
BuildRequires:  gnustep-make
BuildRequires:  gnutls
BuildRequires:  libffi-devel >= 3.0.9
BuildRequires:  libicu-devel
BuildRequires:  libxml2-devel >= 2.3.0
BuildRequires:  libxslt-devel
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  zlib-devel

#Handle different package names on fedora and suse
%if 0%{?suse_version}
BuildRequires: avahi-compat-mDNSResponder-devel
BuildRequires: libgnutls-devel
%if 0%{?fedora}
BuildRequires:  avahi-compat-libdns_sd
BuildRequires:  avahi-compat-libdns_sd-devel
BuildRequires:  gnutls-devel
BuildRequires:  texi2html
BuildRequires:  texinfo-tex

%if 0%{?suse_version} > 1030 || 0%{?fedora_version} > 8
BuildRequires:  fdupes

%define         gnustep_sh
%define         gs_config        /etc/GNUstep/GNUstep.conf
%define         init_dir         /etc/init.d
%define         gs_sysinit       %{init_dir}/gdomap
%define         gs_daemon        gdomap
%define         profile_dir      /etc/profile.d
%define         gs_userstart
%define         gs_makefiles     %{_datadir}/GNUstep/Makefiles
%define         gs_library       %{_libdir}/GNUstep

The GNUstep Base Library is a powerful fast library of general-
purpose, non-graphical Objective C classes, inspired by the superb
OpenStep API but implementing Apple and GNU additions to the API
as well.  It includes, for example, classes for unicode strings,
arrays, dictionaries, sets, byte streams, typed coders, invocations,
notifications, notification dispatchers, scanners, tasks, files,
networking, threading, remote object messaging support (distributed
objects), event loops, loadable bundles, attributed unicode strings,
xml, mime, user defaults. This package includes development headers
too. It was configured for the FHS file system layout, customised
for SUSE.

%package devel
Summary:        Devel package for GNUstep Base Library
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
This package contains include files for developing applications
using the GNUstep Base Library.

%setup -q
find . -type f -name "*.swp" -delete

# Source GNUstep environment variables. This is done unconditionally
# to ensure that the values appropriate to this build get defined,
# irrespective of what happened to be in force for the build system.
. %{gs_config}
. ${GNUSTEP_MAKEFILES}/%{gnustep_sh}

# Configure and make.
%if 0%{?fedora}
ffi_include=$(pkg-config --cflags-only-I libffi | sed -e 's/^\-\I//')
CPPFLAGS="-Wno-unused" \
%configure  --libdir=%{_libdir} --enable-ffi \
  --with-ffi-include=$ffi_include \
%if 0%{?suse_version}
%ifarch aarch64 armv6hl
# Disable getting the command line arguments from /proc as this is broken in the qemu setup
CPPFLAGS="-Wno-unused" \
%configure  --libdir=%{_libdir} --enable-ffi \
  --with-installation-domain=SYSTEM \
%if 0%{?suse_version} >= 1200
CPPFLAGS="-Wno-unused" \
%configure  --libdir=%{_libdir} --enable-ffi \
CPPFLAGS="-Wno-unused" \
%configure  --libdir=%{_libdir} --enable-ffi \
  --with-installation-domain=SYSTEM \
make %{?_smp_mflags}

# Source GNUstep environment variables. This is done unconditionally
# to ensure that the values appropriate to this build get defined,
# irrespective of what happened to be in force for the build system.
. %{gs_config}
. ${GNUSTEP_MAKEFILES}/%{gnustep_sh}

# Install into RPM "build root" directory.
make -e DESTDIR=%{buildroot} \

%if 0%{?fedora}
# Rename pl to pllist to fix naming conflict
mv %{buildroot}%{_bindir}/pl %{buildroot}%{_bindir}/pllist

rm -f Examples/.cvsignore
rm -f Examples/.gdbinit

# We need a modified GNUstep.conf, because the DTDs are install not
# on their real destination

    %{_sysconfdir}/GNUstep/GNUstep.conf >GNUstep.conf

export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
export GNUSTEP_CONFIG_FILE=$(pwd)/GNUstep.conf


# Create startup/shutdown script for gdomap service.
# Note this version of the code is designed to fit in
# with SuSE linux's version of sys V init.

install -d %{buildroot}%{init_dir}
cat > %{buildroot}%{gs_sysinit} << "EOF"
# GNUstep daemons
# Provides:          %{gs_daemon}
# Required-Start:    $syslog $local_fs $remote_fs
# Should-Start:
# Required-Stop:     $syslog $local_fs $remote_fs
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: %{gs_daemon} service
# Description:       Start up the %{gs_daemon} service
#       used by GNUstep applications.

. /etc/rc.status
. %{gs_config}

case "${1}" in
        echo -n "Starting %{gs_daemon}: "
        startproc ${GNUSTEP_SYSTEM_TOOLS}/%{gs_daemon}

	# Remember status and be verbose
	rc_status -v

        echo -n "Stopping %{gs_daemon}: "
        killproc ${GNUSTEP_SYSTEM_TOOLS}/%{gs_daemon}

	# Remember status and be verbose
	rc_status -v

        ${0} stop
        ${0} start

	# Remember status and be quiet

	echo -n "Checking for service %{gs_daemon} "
        checkproc ${GNUSTEP_SYSTEM_TOOLS}/%{gs_daemon}
	rc_status -v

        echo "Usage: %{gs_sysinit} {start|stop|status|restart|reload}"
        exit 1
chmod 755 %{buildroot}%{gs_sysinit}
install -d %{buildroot}%{_sbindir}
ln -sf ../../%{gs_sysinit} %{buildroot}%{_sbindir}/rc%{gs_daemon}

# Create scripts to source GNUstep environment variables,
# start up user GNUstep services gdnc & gpbs, and update cache
# of services and applications, on user login.
mkdir -p %{buildroot}%{profile_dir}
cat > %{buildroot}%{profile_dir}/%{gs_userstart} << "EOF"
. %{gs_config}

function runtool {
local toolpath=${GNUSTEP_SYSTEM_TOOLS}/${1}

# Check whether the tool exists
if [ -x ${toolpath} ]
    # Check whether the tool is already running for this user
    if ! ps -U $(id -u) -o cmd --no-headers | grep -q "^${toolpath}\>"
unset toolpath

if [ -d ${HOME}/${GNUSTEP_USER_DIR} ]

    # Start up the GNUstep Distributed Notification Center daemon
    runtool gdnc

    # Start up the GNUstep PasteBoard Server daemon, if we're running X
    [ ${DISPLAY} ] && runtool gpbs

    # Start up the GNUstep Sound daemon if we have portaudio sound
    if portaudiolib=$(/sbin/ldconfig -p | grep '^[[:space:]]*[[:space:]]') \
       && [ -e $(echo ${portaudiolib} | sed 's/^.*=>[[:space:]]*\([^[:space:]]*\)$/\1/') ]
        runtool gnustep_sndd
    unset portaudiolib

    # Run 'make_services' in background if possible. We run it in a subshell;
    # otherwise, shells with job control (like bash) output an annoying
    # message when make_services is done, while we want it to happen silently.

    [ -x "${GNUSTEP_SYSTEM_TOOLS}/make_services" ] \
      && ("${GNUSTEP_SYSTEM_TOOLS}/make_services" &)

chmod 755 %{buildroot}%{profile_dir}/%{gs_userstart}

# save discspace: symlink duplicates
%if 0%{?suse_version} > 1030 || 0%{?fedora_version} > 8
%fdupes -s %{buildroot}

# Comment out checks because they break building on some systems. The NSOperation test seems to loop infinite.
#make check

#if 0%{?suse_version} > 1140
#set_permissions %{_bindir}/%{gs_daemon}
if [ "${1}" = "1" ]; then
    # Path to GNUstep libraries was added to in gnustep-make.
    # Run ldconfig to add gnustep-base libraries to the library cache.

    # Add lines for %{gs_daemon} into /etc/services, if not already there
    grep -q '^%{gs_daemon}' /etc/services \
        || (echo -e "%{gs_daemon}\t\t538/tcp\t\t\t\t# GNUstep distributed objects" >> /etc/services  \
        && echo -e "%{gs_daemon}\t\t538/udp\t\t\t\t# GNUstep distributed objects" >> /etc/services)

    # Add the %{gs_daemon} service. Note this is not started
    # automatically - the user will need to start it using YaST2.
%if %{defined suse_version}
    %{fillup_and_insserv -fy %{gs_daemon}}
    #Fedora only
    /sbin/chkconfig --add %{gs_daemon}
    #Apparently we can do all dist with this - just not yet
    #%service_add %{gs_daemon}

#if 0%{?suse_version} > 1100
#verify_permissions -e %{_bindir}/%{gs_daemon}

if [ "${1}" = "0" ]; then
    # Stop the gdomap service
%if 0%{?suse_version}
    %stop_on_removal %{gs_daemon}
    #Fedora only
    if [ “$1” = 0 ] ; then service %{gs_daemon} stop >/dev/null 2>&1
    /sbin/chkconfig --del %{gs_daemon}
    #For the future
    #%service_del_preun %{gs_daemon}

    # Remove lines for gdomap from /etc/services
    mv -f /etc/services /etc/services.orig
    grep -v "^%{gs_daemon}[[:space:]]*538" /etc/services.orig > /etc/services
    rm -f /etc/services.orig

%if 0%{?suse_version}
    %restart_on_update %{gs_daemon}
    if [ “$1” -ge 1 ] ; then
    service %{gs_daemon} condrestart >/dev/null 2>&1
   #For the future
   #%service_del_postun %{gs_daemon}

rm -rf %{buildroot}

#verify(not mode) %attr(6755,root,root) %{_bindir}/%{gs_daemon}
%if 0%{?suse_version}
%config(noreplace) %{profile_dir}/%{gs_userstart}
%config %{gs_sysinit}

%files devel
%defattr (-, root, root)