2021-11-09 10:51:44 +03:00
CARGO ?= cargo
d e f i n e t o _ u p p e r
$(shell echo "$(1)" | tr '[ : lower :]' '[:upper :]')
e n d e f
i f e q ( $( BUILD_MODE ) , r e l e a s e )
CARGO_BUILD_ARGS += --release
2022-02-28 13:57:56 +03:00
DEBUG_LIBPATH :=
e l s e
DEBUG_LIBPATH := "-L./target/debug" ,
2021-11-09 10:51:44 +03:00
e n d i f
2022-02-28 13:57:56 +03:00
d e f i n e p a c k a g e _ t e m p l a t e
sed -r \
-e 's/\{\{PRODUCT\}\}/$(1)/g;' \
-e 's/\{\{LIBRARY\}\}/$(2)/g;' \
-e 's|\{\{DEBUG_LIBPATH\}\}|$(DEBUG_LIBPATH)|g;' \
Proxmox/Lib/template.pm \
>Proxmox/Lib/$( 1) .pm
e n d e f
2021-11-09 10:51:44 +03:00
.PHONY : all
all :
i f e q ( $( BUILD_TARGET ) , p v e )
$( MAKE) pve
e l s e i f e q ( $( BUILD_TARGET ) , p m g )
2022-03-01 11:51:59 +03:00
$( MAKE) pmg
2021-11-09 10:51:44 +03:00
e l s e
2022-03-01 11:51:59 +03:00
@echo "Run one of"
@echo " - make pve"
@echo " - make pmg"
2021-11-09 10:51:44 +03:00
e n d i f
.PHONY : pve pmg
pve pmg :
@PERLMOD_PRODUCT= $( call to_upper,$@ ) \
2022-02-23 17:15:32 +03:00
$( CARGO) build $( CARGO_BUILD_ARGS) -p $@ -rs
2021-11-09 10:51:44 +03:00
2022-02-28 13:57:56 +03:00
.PHONY : gen
gen :
$( call package_template,PMG,pmg_rs)
$( call package_template,PVE,pve_rs)
perl ./scripts/genpackage.pl Common Proxmox::RS::CalendarEvent
perl ./scripts/genpackage.pl PVE \
PVE::RS::APT::Repositories \
PVE::RS::OpenId \
PVE::RS::TFA
perl ./scripts/genpackage.pl PMG \
PMG::RS::APT::Repositories \
PMG::RS::Acme \
PMG::RS::CSR \
PMG::RS::OpenId \
PMG::RS::TFA
2021-11-09 10:51:44 +03:00
build :
2022-02-28 13:57:56 +03:00
rm -rf build
2021-11-09 10:51:44 +03:00
mkdir build
echo system >build/rust-toolchain
2022-02-28 13:57:56 +03:00
cp -a ./scripts ./build
2022-03-01 11:51:59 +03:00
cp -a ./common ./build
2021-11-09 11:43:32 +03:00
cp -a ./pve-rs ./build
2021-11-26 16:55:15 +03:00
cp -a ./pmg-rs ./build
2022-02-28 13:57:56 +03:00
cp -a ./Proxmox ./build
$( MAKE) BUILD_MODE = release -C build -f ../Makefile gen
mkdir -p ./build/pve-rs/Proxmox/Lib
mv ./build/Proxmox/Lib/PVE.pm ./build/pve-rs/Proxmox/Lib/PVE.pm
mkdir -p ./build/pmg-rs/Proxmox/Lib
mv ./build/Proxmox/Lib/PMG.pm ./build/pmg-rs/Proxmox/Lib/PMG.pm
mv ./build/PVE ./build/pve-rs
mv ./build/PMG ./build/pmg-rs
2022-03-01 11:51:59 +03:00
mv ./build/Proxmox ./build/common/pkg
# So the common packages end up in ./build, rather than ./build/common
mv ./build/common/pkg ./build/common-pkg
2021-11-09 10:51:44 +03:00
pve-deb : build
cd ./build/pve-rs && dpkg-buildpackage -b -uc -us
touch $@
2021-11-26 16:55:15 +03:00
pmg-deb : build
cd ./build/pmg-rs && dpkg-buildpackage -b -uc -us
touch $@
2021-11-09 10:51:44 +03:00
2022-03-01 11:51:59 +03:00
common-deb : build
cd ./build/common-pkg && dpkg-buildpackage -b -uc -us
touch $@
2021-11-10 13:58:03 +03:00
%-upload : %-deb
cd build; \
dcmd --deb lib$* -rs-perl*.changes \
| grep -v '.changes$$' \
| tar -cf " $@ .tar " -T-; \
cat " $@ .tar " | ssh -X repoman@repo.proxmox.com upload --product $* --dist bullseye
2021-11-09 10:51:44 +03:00
.PHONY : clean
clean :
cargo clean
rm -rf ./build ./PVE ./PMG ./pve-deb ./pmg-deb