Blob Blame History Raw
Name: pasdoc
Summary: Documentation tool for Pascal and Object Pascal source code

# The readme says simply "GNU GPL 2", but license headers in code files
# say "version 2 of the License, or (at your option) any later version".
License: GPLv2+

%global with_gui 1
%global with_tools 1
%global with_tests 1

Version: 0.16.0
Release: 7%{?dist}

Source0: %{URL}/archive/v%{version}/pasdoc-%{version}.tar.gz

# Submitted upstream:
Source10: %{name}.man

Source30: %{name}-gui.desktop
Source31: %{name}-gui.metainfo.xml

# The test runner script always rebuilds the program from scratch
# before actually performing any tests.
Patch0: 0000-adapt-test-runner.patch

# Edit the project configuration files to enable DWARF3 debuginfo
Patch1: 0001-enable-dwarf3-debuginfo.patch

ExclusiveArch: %{fpc_arches}

BuildRequires: fpc

%if 0%{?with_gui}
BuildRequires: desktop-file-utils
BuildRequires: lazarus
BuildRequires: libappstream-glib

%if 0%{?with_tests}
BuildRequires: %{_bindir}/diff
BuildRequires: %{_bindir}/xmllint

PasDoc is a documentation tool for Pascal and Object Pascal source code.
Documentation is generated from comments found in the source code, or from
external files. Numerous formatting @-tags are supported. Many output formats
are supported, including HTML and LaTeX.

%if 0%{?with_gui}
%package gui
Summary: Graphical user interface for the PasDoc documentation generator
Requires: hicolor-icon-theme

%description gui
PasDoc is a documentation tool for Pascal and Object Pascal source code.

This package provides a graphical user interface for PasDoc, allowing to
generate documentation files from previously annotated source code.

%if 0%{?with_tools}
%package tools
Summary: Helper tools for PasDoc

%description tools
Helper tools useful for analyzing Pascal code
and embedding files (both text and binary) inside Pascal sources.

%autosetup -p1

# The upsteam source contains a Makefile, but it sets many compiler options
# such as range checking code, optimization level, and so on.
# Instead of using the Makefile, let's compile manually,
# so that Fedora's default settings for FPC are applied.
mkdir -p build/bin build/obj
%global fpc_flags -g -gl -gw3 -O3 -Mobjfpc -Sh -FE./build/bin -FU./build/obj

fpc %{fpc_flags} \
	-Fu./source/component \
	-Fu./source/component/tipue \
	-Fu./source/console \
	-Fi./source/component \
	-Fi./source/component/images \

# Build the unit test app
%if 0%{?with_tests}
	fpc %{fpc_flags} "./tests/fpcunit/test_pasdoc.lpr"
	mv ./build/bin/test_pasdoc ./tests/

# Build the helper tools
%if 0%{?with_tools}
	for TOOL in pascal_pre_proc file_to_pascal_data file_to_pascal_string; do
		fpc %{fpc_flags} "./source/tools/${TOOL}.dpr"

# Build the gui
%if 0%{?with_gui}
	lazbuild --add-package-link ./source/packages/lazarus/pasdoc_package.lpk
	lazbuild --recursive ./source/gui/pasdoc_gui.lpi

install -m 755 -d %{buildroot}%{_bindir}
install -m 755 -t %{buildroot}%{_bindir} ./build/bin/*

install -m 755 -d "${MANDIR}"
install -m 644 -p '%{SOURCE10}' "${MANDIR}/%{name}.1"

# Install man pages for tools.
# file_to_pascal_data and file_to_pascal_string are almost the same,
# so the single man page covers them both.
%if 0%{?with_tools}
install -m 644 -p '%{SOURCE20}' "${MANDIR}/pascal_pre_proc.1"
install -m 644 -p '%{SOURCE21}' "${MANDIR}/file_to_pascal_data.1"
ln -sr "${MANDIR}"/file_to_pascal_{data,string}.1

%if 0%{?with_gui}
install -m 755 ./source/gui/pasdoc_gui %{buildroot}%{_bindir}/%{name}-gui

for SIZE in 16 32 64 128 256; do
	# Icon files use zero-padded three-digit numbers in their names
	PADSIZ="$(printf '%%03d' "${SIZE}")"

	install -m 755 -d "${ICON_DIR}"
	install -m 644 -p \
		"./source/gui/icons/PasDoc${PADSIZ}.png" \

install -m 755 -d %{buildroot}%{_datadir}/applications
install -m 644 -p -t %{buildroot}%{_datadir}/applications '%{SOURCE30}'

install -m 755 -d %{buildroot}%{_metainfodir}
install -m 644 -p -t %{buildroot}%{_metainfodir} '%{SOURCE31}'

%if 0%{?with_tests}
export PASDOC_BIN="$(pwd)/build/bin/pasdoc"
export USE_DIFF_TO_COMPARE="true"

cd tests/
./test_pasdoc -a

%if 0%{?with_gui}
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/%{name}-gui.metainfo.xml
desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}-gui.desktop

%license LICENSE

%if 0%{?with_tools}
%files tools
%license LICENSE

%if 0%{?with_gui}
%files gui
%doc source/gui/HISTORY
%doc source/gui/README
%doc source/gui/TODO
%license LICENSE

* Thu Jan 19 2023 Fedora Release Engineering <> - 0.16.0-7
- Rebuilt for

* Fri Jul 22 2022 Fedora Release Engineering <> - 0.16.0-6
- Rebuilt for

* Thu Jan 20 2022 Fedora Release Engineering <> - 0.16.0-5
- Rebuilt for

* Mon Jan 10 2022 Artur Frenszek-Iwicki <> - 0.16.0-4
- Fix license tag (GPLv2 -> GPLv2-or-later)
- Generate DWARF3 debuginfo instead of DWARF2
- Don't install the 512px icon (upstream lied, it's actually 480px)
- Add an AppStream metainfo file for the GUI

* Sun Nov 14 2021 Artur Frenszek-Iwicki <> - 0.16.0-3
- Add man pages for all the executables (apart from the gui)
- Don't require the main package in gui subpackage
  (the GUI is an independent program, not just a frontend for the console)
- Move the tools to a separate subpackage (not required by pasdoc to run)
- Preserve timestamps when installing files
- Add %%doc files to the gui subpackage

* Tue Sep 21 2021 Artur Frenszek-Iwicki <> - 0.16.0-2
- Build the GUI (as a sub-package)
- Build and run the test suite

* Wed Sep 15 2021 Artur Frenszek-Iwicki <> - 0.16.0-1
- Initial packaging