File p4c.spec of Package p4c
#
# spec file for package p4c
#
# Copyright (c) 2025 Eyad Issa
#
# 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/
#
%global p4runtime_rev v1.4.1
%global bpftool_rev 7.5.0
Name: p4c
Version: 1.2.5.9
Release: 0
Summary: A reference compiler for the P4 programming language
License: Apache-2.0
URL: https://github.com/p4lang/p4c
Source0: https://github.com/p4lang/p4c/archive/v%{version}/%{name}-%{version}.tar.gz
Source1: https://github.com/p4lang/p4runtime/archive/%{p4runtime_rev}/p4runtime-%{p4runtime_rev}.tar.gz
Source2: https://github.com/libbpf/bpftool/archive/v%{bpftool_rev}/bpftool-%{bpftool_rev}.tar.gz
BuildRequires: bison
BuildRequires: boost-devel
BuildRequires: bpftool
BuildRequires: cmake
BuildRequires: flex
BuildRequires: gcc-c++
BuildRequires: git
BuildRequires: ninja
BuildRequires: libboost_graph-devel
BuildRequires: libboost_iostreams-devel
BuildRequires: pkgconfig
BuildRequires: abseil-cpp-devel
BuildRequires: protobuf-devel
BuildRequires: pkgconfig(bdw-gc)
%description
P4C is a reference compiler for the P4 programming language. It
supports both P4-14 and P4-16 language versions. P4C is modular; it
provides a standard frontend and midend which can be combined with a
target-specific backend to create a complete P4 compiler.
%prep
%autosetup -p1
mkdir -p third_party/p4runtime
tar -xzf %{SOURCE1} --strip-components=1 -C third_party/p4runtime
mkdir -p third_party/bpftool
tar -xzf %{SOURCE2} --strip-components=1 -C third_party/bpftool
%build
%define __builder ninja
%cmake \
-DENABLE_GTESTS=OFF \
-DP4C_USE_PREINSTALLED_BDWGC=ON \
-DP4C_USE_PREINSTALLED_ABSEIL=ON \
-DENABLE_ABSEIL_STATIC=OFF \
-DP4C_USE_PREINSTALLED_PROTOBUF=ON \
-DFETCHCONTENT_SOURCE_DIR_P4RUNTIME=%{_builddir}/%{name}-%{version}/third_party/p4runtime \
-DFETCHCONTENT_SOURCE_DIR_BPFREPO=%{_builddir}/%{name}-%{version}/third_party/bpftool \
%{nil}
%cmake_build
%install
%cmake_install
%files
%doc README.md
%license LICENSE
%{_bindir}/p4*
%{_datadir}/p4c/
%changelog