%undefine _debugsource_packages
%global __prelink_undo_cmd %{nil}

Name:           codelite
Version:        15.0.1
Release:        2
License:        GPLv2+ and Apache-2.0 and MIT and BSL-1.0
Group:          Development/Tools
Summary:        CodeLite is a powerful open-source, cross platform code editor for C/C++
URL:            http://codelite.sourceforge.net
Source:         http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
Requires:       libssh clang clang-tools-extra SDL
BuildRequires:	gcc gcc-c++ wxGTK3-devel cmake clang-devel lldb-devel libssh-devel hunspell-devel sqlite-devel libXtst-devel
# Filter out these false-alarms from 'requires', as the package itself supplies them!
%{?filter_setup:
%filter_from_requires libcodeliteu.so; libpluginu.so; libwxscintillau.so; libwxsqlite3u.so;
%filter_setup
}

%description
CodeLite uses a sophisticated, yet intuitive interface which allows 
users to easily create, build and debug complex projects.

%prep
%setup -q

%build
mkdir -p build_release
export PATH=/usr/libexec/wxGTK31/:$PATH
# workaround for a pango/harfbuzz issue: see https://gitlab.kitware.com/cmake/cmake/issues/19531
(cd build_release && CXXFLAGS="-isystem /usr/include/harfbuzz" cmake -G "Unix Makefiles" -DCOPY_WX_LIBS=1 -DAUTOGEN_REVISION=0 ..)
(cd build_release && make %{?_smp_mflags})

%install
%{__rm} -rf $RPM_BUILD_ROOT
(cd build_release && make DESTDIR=$RPM_BUILD_ROOT install)

# Avoid erroring out because fedora >29 doesn't want ambiguous python shebangs
sed -i "s|#!/usr/bin/python|#!/usr/bin/$(echo $(readlink -qn /usr/bin/python))|" %{buildroot}%{_bindir}/codelite_open_helper.py


mkdir -p $RPM_BUILD_ROOT%{_datadir}/mime/packages/
cp -p %{name}.xml $RPM_BUILD_ROOT%{_datadir}/mime/packages/



#cp -p $RPM_BUILD_ROOT%{_datadir}/%{name}/images/cubes.png $RPM_BUILD_ROOT%{_datadir}/%{name}/images/codelite.png # Without this line, no icon was displayed in the kde menu or taskbar

mkdir -p $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/32x32/mimetypes/
cp -p $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/32x32/apps/codelite.png $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/32x32/mimetypes/application-x-%{name}-workspace.png
cp -p $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/32x32/apps/codelite.png $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/32x32/mimetypes/application-x-%{name}-project.png


%find_lang %{name}

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%files -f %{name}.lang
%doc AUTHORS LICENSE COPYING 
%{_bindir}/codelite
%{_bindir}/codelite_indexer
%{_bindir}/codelite_cppcheck
%{_bindir}/codelite_fix_files
%{_bindir}/codelite_exec
%{_bindir}/codelite_kill_children
%{_bindir}/codelite_xterm
%{_bindir}/codelite-terminal
%{_bindir}/codelite-cc
%{_bindir}/codelite-echo
%{_bindir}/codelite-lldb
%{_bindir}/codelite-make
%{_bindir}/codelite-lsp-helper
%{_bindir}/codelite_open_helper.py
%{_datadir}/codelite
%{_datadir}/applications/codelite.desktop
%{_datadir}/mime/packages/%{name}.xml
%{_datadir}/icons/hicolor/32x32/mimetypes/application-x-%{name}-workspace.png
%{_datadir}/icons/hicolor/32x32/mimetypes/application-x-%{name}-project.png
%{_datadir}/icons/hicolor/32x32/apps/codelite.png
%{_datadir}/icons/hicolor/32x32@2x/apps/codelite.png
%{_datadir}/icons/hicolor/64x64/apps/codelite.png
%{_datadir}/icons/hicolor/64x64@2x/apps/codelite.png
%{_datadir}/icons/hicolor/128x128/apps/codelite.png
%{_datadir}/icons/hicolor/128x128@2x/apps/codelite.png
%{_datadir}/icons/hicolor/256x256/apps/codelite.png
%{_datadir}/icons/hicolor/256x256@2x/apps/codelite.png
%{_libdir}/%{name}
%{_mandir}/man1/codelite.1*
%{_mandir}/man1/codelite-make.1*
%{_mandir}/man1/codelite_fix_files.1*

%post
update-mime-database %{_datadir}/mime &> /dev/null || :
update-desktop-database &> /dev/null || :
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%postun
update-mime-database %{_datadir}/mime &> /dev/null || :
update-desktop-database &> /dev/null || :
if [ $1 -eq 0 ] ; then
    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi

%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

%changelog
* Wed Apr 27 2022 tanyulong <tanyulong@kylinos.cn> - 15.0.1-2
- modify license warning

* Thu Jan 06 2022 tanyulong <tanyulong@kylinos.cn> - 15.0.1-1
- init for openEuler