File astyle.spec of Package astyle

#
# spec file for package astyle
#
# Copyright (c) 2020 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/
#


%define sover   3
Name:           astyle
Version:        3.1
Release:        0
Summary:        Source Code Indenter, Formatter, and Beautifier for C, C++, C# and Java
License:        MIT
URL:            http://astyle.sourceforge.net/
Source:         https://downloads.sourceforge.net/project/%{name}/%{name}/%{name}%20%{version}/%{name}_%{version}_linux.tar.gz
BuildRequires:  gcc-c++
BuildRequires:  java-devel
BuildRequires:  pkgconfig

%description
Artistic Style is a source code indenter, formatter, and beautifier for the C,
C++, C# and Java programming languages. It automatically re-indents and
re-formats C / C++ / C# / Java source files. It can be used from a command
line, or it can be incorporated as classes in another C++ program.

%package        devel
Summary:        C/C++/C# headers for lib%{name}
Requires:       lib%{name}%{sover} = %{version}

%description devel
This package contains C/C++/C# headers for lib%{name}.

%package -n lib%{name}%{sover}
Summary:        C/C++/C# bindings for %{name}

%description -n lib%{name}%{sover}
This package contains C/C++/C# bindings for %{name}.

%package -n lib%{name}j%{sover}
Summary:        Java bindings for %{name}

%description -n lib%{name}j%{sover}
This package contains Java bindings for %{name}.

%prep
%autosetup -n %{name}

%build
if [ \! -x $JAVA_HOME/bin/javac ] && echo $JAVA_HOME | grep jre ; then
  echo WTF IS SETTING \$JAVA_HOME TO JRE \!?
  JAVA_HOME=$(echo $JAVA_HOME | sed -e s/jre/java/g)
fi
export CFLAGS="%{optflags} -I $JAVA_HOME/include/linux"
export CXXFLAGS="%{optflags}"
%make_build -C build/gcc astyled
%make_build -C build/gcc shared %{?_smp_mflags}
# javaall = java + javadebug
%make_build -C build/gcc java %{?_smp_mflags}

%install
install -Dpm 0755 build/gcc/bin/%{name}d \
  %{buildroot}%{_bindir}/%{name}
chmod -x doc/* *.md
install -d -m 0755 %{buildroot}%{_libdir} %{buildroot}%{_includedir}
install -m 0644 build/gcc/bin/libastyle.so.* %{buildroot}%{_libdir}
install -m 0644 src/astyle.h %{buildroot}%{_includedir}
install -m 0644 build/gcc/bin/libastylej.so.* %{buildroot}%{_libdir}
(cd %{buildroot}%{_libdir}; ln -s libastylej.so.* libastylej.so; ln -s libastyle.so.* libastyle.so)

# creates support file for pkg-config
mkdir -p %{buildroot}/%{_libdir}/pkgconfig
tee %{buildroot}/%{_libdir}/pkgconfig/astyle.pc << "EOF"
prefix=%{_prefix}
exec_prefix=${prefix}
libdir=${exec_prefix}/%{_lib}
includedir=${prefix}/include

Name: astyle
Description: Source Code Indenter, Formatter, and Beautifier for C, C++, C#
Version: %{version}
Libs: -L${libdir} -lastyle
Cflags: -I${includedir}
EOF

%post -n lib%{name}%{sover} -p /sbin/ldconfig
%postun -n lib%{name}%{sover} -p /sbin/ldconfig

%files
%license LICENSE.md
%doc README.md doc/
%{_bindir}/%{name}

%files devel
%{_includedir}/astyle.h
%{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/%{name}.pc

%files -n lib%{name}%{sover}
%{_libdir}/lib%{name}.so.%{sover}*

%files -n lib%{name}j%{sover}
# does this go here?
%{_libdir}/lib%{name}j.so
%{_libdir}/lib%{name}j.so.%{sover}*

%changelog
openSUSE Build Service is sponsored by