2024-02-22 17:31:51 +03:00
#include /usr/share/dpkg/pkg-info.mk
2021-11-09 08:56:38 +01:00
PACKAGE = libpve-rs-perl
export PERLMOD_PRODUCT = PVE
ARCH := $( shell dpkg-architecture -qDEB_BUILD_ARCH)
export GITVERSION := $( shell git rev-parse HEAD)
PERL_INSTALLVENDORARCH != perl -MConfig -e 'print $$Config{installvendorarch};'
PERL_INSTALLVENDORLIB != perl -MConfig -e 'print $$Config{installvendorlib};'
2023-05-17 09:37:31 +02:00
MAIN_DEB = $( PACKAGE) _$( DEB_VERSION) _$( ARCH) .deb
DBGSYM_DEB = $( PACKAGE) -dbgsym_$( DEB_VERSION) _$( ARCH) .deb
2021-11-09 08:56:38 +01:00
DEBS = $( MAIN_DEB) $( DBGSYM_DEB)
2023-05-17 09:37:31 +02:00
DSC = $( PACKAGE) _$( DEB_VERSION_UPSTREAM_REVISION) .dsc
BUILDDIR ?= $( PACKAGE) -$( DEB_VERSION_UPSTREAM)
2021-11-09 08:56:38 +01:00
DESTDIR =
2022-03-21 14:08:07 +01:00
PM_DIR := PVE
2021-11-09 08:56:38 +01:00
2023-05-09 11:29:05 +02:00
PERLMOD_GENPACKAGE := /usr/lib/perlmod/genpackage.pl \
--lib= pve_rs \
--lib-tag= proxmox \
--lib-package= Proxmox::Lib::PVE \
2023-12-18 10:20:58 +01:00
--lib-prefix= PVE \
--include-file= Fixup.pm
2023-05-09 11:29:05 +02:00
PERLMOD_PACKAGES := \
PVE::RS::APT::Repositories \
PVE::RS::OpenId \
PVE::RS::ResourceScheduling::Static \
PVE::RS::TFA
2024-06-03 13:55:37 +02:00
PERLMOD_PACKAGE_FILES := $( addsuffix .pm,$( subst ::,/,$( PERLMOD_PACKAGES) ) )
2021-11-09 08:56:38 +01:00
i f e q ( $( BUILD_MODE ) , r e l e a s e )
2022-03-06 14:26:11 +03:00
CARGO_BUILD_ARGS += --release --offline
2022-11-15 13:35:23 +01:00
TARGET_DIR = release
e l s e
TARGET_DIR = debug
2021-11-09 08:56:38 +01:00
e n d i f
2023-05-09 11:29:05 +02:00
all : PVE
2021-11-09 08:56:38 +01:00
cargo build $( CARGO_BUILD_ARGS)
2022-11-15 13:35:23 +01:00
mkdir -p test/Proxmox/Lib
sed -r -e \
2023-12-18 10:39:30 +01:00
's@^sub libfile.*$$@sub libfile { "$(shell pwd)/target/$(TARGET_DIR)/libpve_rs.so"; }@' \
2022-11-15 13:35:23 +01:00
Proxmox/Lib/PVE.pm >test/Proxmox/Lib/PVE.pm
2021-11-09 08:56:38 +01:00
2024-06-03 13:55:37 +02:00
Proxmox : Proxmox /Lib /PVE .pm
PVE : $( PERLMOD_PACKAGE_FILES )
Proxmox/Lib/PVE.pm $(PERLMOD_PACKAGE_FILES) & : Fixup .pm
2023-05-09 11:29:05 +02:00
$( PERLMOD_GENPACKAGE) $( PERLMOD_PACKAGES)
2021-11-09 08:56:38 +01:00
2022-11-15 13:35:23 +01:00
check : all
$( MAKE) -C test test
2021-11-09 08:56:38 +01:00
.PHONY : install
2024-06-03 13:55:37 +02:00
install : target /release /libpve_rs .so Proxmox /Lib /PVE .pm $( PERLMOD_PACKAGE_FILES )
2021-11-09 08:56:38 +01:00
install -d -m755 $( DESTDIR) $( PERL_INSTALLVENDORARCH) /auto
install -m644 target/release/libpve_rs.so $( DESTDIR) $( PERL_INSTALLVENDORARCH) /auto/libpve_rs.so
2022-03-21 14:08:07 +01:00
install -d -m755 $( DESTDIR) $( PERL_INSTALLVENDORLIB)
install -d -m755 $( DESTDIR) $( PERL_INSTALLVENDORLIB) /Proxmox/Lib
install -m644 Proxmox/Lib/PVE.pm $( DESTDIR) $( PERL_INSTALLVENDORLIB) /Proxmox/Lib/PVE.pm
find $( PM_DIR) \! -type d -print -exec install -Dm644 '{}' $( DESTDIR) $( PERL_INSTALLVENDORLIB) '/{}' ';'
2021-11-09 08:56:38 +01:00
clean :
2023-12-07 09:51:02 +01:00
rm -rf PVE Proxmox
2021-11-09 08:56:38 +01:00
cargo clean
2023-05-18 11:59:07 +02:00
rm -f *.deb *.dsc *.tar.* *.build *.buildinfo *.changes Cargo.lock
2023-05-17 09:37:31 +02:00
rm -rf $( PACKAGE) -[ 0-9] */
2021-11-09 08:56:38 +01:00
.PHONY : dinstall
2023-05-17 09:37:31 +02:00
dinstall : $( DEBS )
dpkg -i $( DEBS)
2021-11-09 08:56:38 +01:00
.PHONY : upload
2023-05-16 14:28:25 +02:00
upload : UPLOAD_DIST ?= $( DEB_DISTRIBUTION )
2023-05-17 09:37:31 +02:00
upload : $( DEBS )
2021-11-09 08:56:38 +01:00
# check if working directory is clean
git diff --exit-code --stat && git diff --exit-code --stat --staged
2023-05-17 09:37:31 +02:00
tar cf - $( DEBS) | ssh -X repoman@repo.proxmox.com upload --product pve --dist $( DEB_DISTRIBUTION)
2024-06-20 12:20:42 +02:00
$(BUILDDIR) : src debian test common /src Cargo .toml Makefile .cargo /config .toml
2023-05-17 09:37:31 +02:00
rm -rf $( BUILDDIR) $( BUILDDIR) .tmp
mkdir $( BUILDDIR) .tmp
mkdir $( BUILDDIR) .tmp/common
2023-12-18 10:18:46 +01:00
cp -a -t $( BUILDDIR) .tmp src debian test Cargo.toml Makefile .cargo Fixup.pm
2023-05-17 09:37:31 +02:00
cp -a -t $( BUILDDIR) .tmp/common common/src
mv $( BUILDDIR) .tmp $( BUILDDIR)
2023-05-16 14:28:25 +02:00
2023-05-17 15:57:02 +02:00
.PHONY : deb
deb : $( DEBS )
$(DEBS) : $( BUILDDIR )
cd $( BUILDDIR) ; PATH = "/usr/local/bin:/usr/bin" dpkg-buildpackage -b -us -uc
lintian $( DEBS)
2023-05-16 14:28:25 +02:00
.PHONY : dsc
2023-05-17 09:37:31 +02:00
dsc : $( DSC )
$(DSC) : $( BUILDDIR )
cd $( BUILDDIR) ; PATH = "/usr/local/bin:/usr/bin" dpkg-buildpackage -S -us -uc -d
lintian $( DSC)
2023-05-16 14:28:25 +02:00
sbuild : $( DSC )
sbuild $( DSC)