]> git.proxmox.com Git - proxmox-backup-qemu.git/blob - Makefile
buildsys: always pre-clean for deb target
[proxmox-backup-qemu.git] / Makefile
1 include /usr/share/dpkg/default.mk
2
3 PACKAGE = libproxmox-backup-qemu0
4 BUILDDIR = $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
5
6 ARCH:=$(DEB_HOST_ARCH)
7 export GITVERSION:=$(shell git rev-parse HEAD)
8
9 MAIN_DEB=$(PACKAGE)_$(DEB_VERSION)_$(ARCH).deb
10 OTHER_DEBS = \
11 $(PACKAGE)-dev_$(DEB_VERSION)_$(ARCH).deb \
12 $(PACKAGE)-dbgsym_$(DEB_VERSION)_$(ARCH).deb
13 DEBS=$(MAIN_DEB) $(OTHER_DEBS)
14
15 DESTDIR=
16
17 TARGETDIR := target/debug
18
19 ifeq ($(BUILD_MODE), release)
20 CARGO_BUILD_ARGS += --release
21 TARGETDIR := target/release
22 endif
23
24 .PHONY: all build
25 # source target
26 all: build
27
28 # source target
29 build: $(TARGETDIR)/libproxmox_backup_qemu.so
30 $(TARGETDIR)/libproxmox_backup_qemu.so: Cargo.toml src/
31 cargo build $(CARGO_BUILD_ARGS)
32
33 # source / packaging target
34 .PHONY: install
35 install: $(TARGETDIR)/libproxmox_backup_qemu.so
36 install -D -m 0755 $(TARGETDIR)/libproxmox_backup_qemu.so $(DESTDIR)/usr/lib/libproxmox_backup_qemu.so.0
37 cd $(DESTDIR)/usr/lib/; ls *; ln -s libproxmox_backup_qemu.so.0 libproxmox_backup_qemu.so
38
39 .PHONY: test
40 test: current-api.h proxmox-backup-qemu.h
41 diff -I 'PROXMOX_BACKUP_QEMU_VERSION' -up current-api.h proxmox-backup-qemu.h
42
43 # packaging target
44 $(BUILDDIR): submodule
45 rm -rf $@ $@.tmp && mkdir $@.tmp
46 cp -a submodules debian Makefile .cargo Cargo.toml build.rs src header-preamble.c current-api.h $@.tmp/
47 mv $@.tmp $@
48
49 submodule:
50 [ -e submodules/proxmox-backup/Cargo.toml ] || git submodule update --init --recursive
51
52 .PHONY: deb
53 deb: $(OTHER_DEBS)
54 $(OTHER_DEBS): $(MAIN_DEB)
55 $(MAIN_DEB): $(BUILDDIR)
56 cd $(BUILDDIR); dpkg-buildpackage -b -us -uc
57 lintian $(DEBS)
58
59 proxmox-backup-qemu.h: $(TARGETDIR)/libproxmox_backup_qemu.so
60
61 simpletest: simpletest.c proxmox-backup-qemu.h
62 gcc simpletest.c -o simpletest -lc -Wl,-rpath=./$(TARGETDIR) -L ./$(TARGETDIR) -l proxmox_backup_qemu
63
64 distclean: clean
65 clean:
66 cargo clean
67 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes Cargo.lock proxmox-backup-qemu.h build
68
69 .PHONY: dinstall
70 dinstall: $(DEBS)
71 dpkg -i $(DEBS)
72
73 .PHONY: upload
74 upload: $(DEBS)
75 # check if working directory is clean
76 git diff --exit-code --stat && git diff --exit-code --stat --staged
77 tar cf - $(DEBS) | ssh -X repoman@repo.proxmox.com upload --product pve --dist bullseye