# ALT Linux compatibility and enchancement macroses.
# Collected by Vitaly Lipatov <lav@etersoft.ru>
# TODO: split by distros' version (check by package's version?)
# 05.02.2006, 12.02.2006, 09.04.2006, 22.02.2008
#

# introduced in rpm 4.0.4-alt83
# https://bugzilla.altlinux.org/show_bug.cgi?id=13925
%autoreconf %__autoreconf

# introduced in rpm 4.0.4-alt55
#  + Add macros: %_desktopdir, %_pixmapsdir (#8767)
%_desktopdir %_datadir/applications
%_pixmapsdir %_datadir/pixmaps

# introduced in rpm 4.0.4-alt54
#  + Added %__autoreconf macro (#8307)
%__autoreconf autoreconf -fisv

# introduced in rpm 4.0.4-alt42
%_x11x11dir %{_x11dir}/lib/X11
%_pkgconfigdir %{_libdir}/pkgconfig

# from mdk
%makeinstall_std %make_install DESTDIR=%buildroot install

# 
%_omfdir %_datadir/omf

# add in rpm-build-python 0.33.1-alt1
# https://bugzilla.altlinux.org/show_bug.cgi?id=13941
%python_build	\
	%__python setup.py build
%python_install	\
	%__python setup.py install --skip-build --root=%buildroot
# TODO: need to be add
%python_check %__python setup.py check
# ALT Linux compatibility and enchancement macroses.
# Collected by Vitaly Lipatov <lav@etersoft.ru>
# TODO: split by distros' version (check by package's version?)
# TODO: can we use ifdef here?
# 05.02.2006, 12.02.2006
#
# These macros are not defined yet in Sisyphus (12.02.2006)

# for discussion:
%make_install_std %makeinstall_std

# If macros is component related (like kde, java, perl), use name like %name_somedir
# If macros for some dir, use name like %_omfdir

%kde_docdir %_docdir/HTML
%gtk_docdir %_datadir/gtk-doc/html
%java_dir %_datadir/java
%java_docdir %_datadir/javadoc

%_kdedocdir %_docdir/HTML
%_gtkdocdir %_datadir/gtk-doc/html
%_javadir %_datadir/java
%_javadocdir %_datadir/javadoc

%_rpmmacrosdir %_sysconfdir/rpm/macros.d
# various for prev. distro...

%rpmcflags %optflags
# due error on SUSE
#%rpmldflags %nil
%rpmcxxflags %optflags

%_aclocaldir %_datadir/aclocal

# Normalize source file permissions
%fix_permissions \
find ./ -type d -print0 | xargs -0 chmod 0775 \
find ./ -type f -print0 | xargs -0 chmod 0664

# Prepare cmake build (since rpm-build-compat 1.4)
%cmake \
mkdir build; cd build; \
cmake .. \\\
    -DCMAKE_INSTALL_PREFIX=%prefix \\\
    -DLIB_DESTINATION=%_lib \\\
  %if "%_lib" == "lib64" \
    -DLIB_SUFFIX="64" \\\
  %else \
    -DLIB_SUFFIX="" \\\
  %endif \
    -DCMAKE_SKIP_RPATH:BOOL=yes \\\
    -DCMAKE_C_FLAGS:STRING='%optflags' \\\
    -DCMAKE_CXX_FLAGS:STRING='%optflags' \
cd -

# Remove unneeded repository info (since rpm-build-compat 1.5)
%remove_repo_info \
find ./ -type d -name .svn -print0 | xargs -0 --no-run-if-empty rm -rf {} \; \
find ./ -type d -name CVS -print0 | xargs -0 --no-run-if-empty rm -rf {} \;

# Subsys dir placed in various dirs
%_locksubsysdir %_var/lock/subsys
# Start service only after manual install
# this case is never run due no tty under rpm process install
# 1 - 1st install, 2 - update package
%start_service() \
        false && [ -z "$DURING_INSTALL" ] && [ "$1" = "1" ] && %_initdir/%{1} start || : \
%nil

# PLD compatibility
%groupadd /usr/sbin/groupadd -r -f
%useradd /usr/sbin/useradd -r
#%userremove userdel
#%groupremove groupdel

