summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@debian.org>2023-06-10 08:55:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-10 09:21:49 +0000
commit88837172f69eabc408ae3945d82e0270b8e07440 (patch)
treed6b7fa06694f45d25f54f6ea9ded93c981e51f6f /Makefile
parentInitial commit. (diff)
downloadnvme-stas-88837172f69eabc408ae3945d82e0270b8e07440.tar.xz
nvme-stas-88837172f69eabc408ae3945d82e0270b8e07440.zip
Adding upstream version 2.2.1.upstream/2.2.1
Signed-off-by: Benjamin Drung <bdrung@debian.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile111
1 files changed, 111 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1d67940
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,111 @@
+# Copyright (c) 2021, Dell Inc. or its subsidiaries. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+# See the LICENSE file for details.
+#
+# This file is part of NVMe STorage Appliance Services (nvme-stas).
+#
+# Authors: Martin Belanger <Martin.Belanger@dell.com>
+#
+.DEFAULT_GOAL := stas
+BUILD-DIR := .build
+DEB-PKG-DIR := ${BUILD-DIR}/deb-pkg
+RPM-BUILDROOT-DIR := ${BUILD-DIR}/rpmbuild
+
+ifneq (,$(strip $(filter $(MAKECMDGOALS),rpm deb dist)))
+ XTRA-MESON-OPTS := --wrap-mode=nodownload
+endif
+
+.PHONY: update-subprojects
+update-subprojects:
+ meson subprojects update
+
+${BUILD-DIR}:
+ BUILD_DIR=${BUILD-DIR} ./configure ${XTRA-MESON-OPTS}
+ @echo "Configuration located in: $@"
+ @echo "-------------------------------------------------------"
+
+.PHONY: stas
+stas: ${BUILD-DIR}
+ ninja -C ${BUILD-DIR}
+
+.PHONY: clean
+clean:
+ifneq ("$(wildcard ${BUILD-DIR})","")
+ ninja -C ${BUILD-DIR} -t clean
+endif
+
+.PHONY: purge
+purge:
+ifneq ("$(wildcard ${BUILD-DIR})","")
+ rm -rf ${BUILD-DIR}
+endif
+
+.PHONY: install
+install: stas
+ sudo meson $@ -C ${BUILD-DIR} --skip-subprojects
+
+.PHONY: uninstall
+uninstall: ${BUILD-DIR}
+ sudo ninja -C ${BUILD-DIR} uninstall
+
+.PHONY: dist
+dist: stas
+ meson $@ -C ${BUILD-DIR} --formats gztar
+
+.PHONY: test
+test: stas
+ meson $@ -C ${BUILD-DIR} --suite nvme-stas
+
+.PHONY: loc
+loc:
+ @cloc --by-file --exclude-dir=${BUILD-DIR},doc,subprojects,test,utils,debian,obj-x86_64-linux-gnu,.github --exclude-lang=Markdown,"NAnt script",XML,"Bourne Again Shell",make,"Bourne Shell",Meson,YAML,XSLT .
+
+.PHONY: loc-full
+loc-full:
+ @cloc --by-file --exclude-dir=${BUILD-DIR},subprojects,debian,obj-x86_64-linux-gnu,.github .
+
+.PHONY: black
+black:
+ black --diff --color --line-length 120 --skip-string-normalization --extend-exclude="(subprojects|debian|.build)" .
+
+# Coverage requirements:
+# pip install coverage
+.PHONY: coverage
+coverage: stas
+ cd ${BUILD-DIR} && ./coverage.sh
+
+################################################################################
+# Debian (*.deb)
+# Use "DEB_BUILD_OPTIONS=nocheck make deb" to skip unit testing.
+# This requires: sudo apt install -y debhelper dh-python
+ifeq (deb,$(strip $(MAKECMDGOALS)))
+ ifneq (SUCCESS,$(shell dpkg -s debhelper dh-python > /dev/null 2>&1 && echo "SUCCESS" || echo "FAIL"))
+ $(error Missing packages. Run -> "sudo apt install -y debhelper dh-python")
+ endif
+endif
+
+.PHONY: deb
+deb: ${BUILD-DIR}
+ mkdir -p ${DEB-PKG-DIR}
+ dpkg-buildpackage -us -uc
+ @mv ../nvme-stas_*.deb ${DEB-PKG-DIR}
+ @mv ../nvme-stas_*.buildinfo ${DEB-PKG-DIR}
+ @mv ../nvme-stas_*.changes ${DEB-PKG-DIR}
+ @mv ../nvme-stas_*.dsc ${DEB-PKG-DIR}
+ @mv ../nvme-stas_*.tar.gz ${DEB-PKG-DIR}
+ @echo "======================================================="
+ @echo "Debian packages located in: ${DEB-PKG-DIR}/"
+
+
+################################################################################
+# RedHat (*.rpm)
+${BUILD-DIR}/nvme-stas.spec: ${BUILD-DIR} nvme-stas.spec.in
+ meson --wrap-mode=nodownload --reconfigure ${BUILD-DIR}
+
+${RPM-BUILDROOT-DIR}: ${BUILD-DIR}/nvme-stas.spec
+ rpmbuild -ba $< --build-in-place --clean --nocheck --define "_topdir $(abspath ${BUILD-DIR}/rpmbuild)"
+ @echo "======================================================="
+ @echo "RPM packages located in: ${RPM-BUILDROOT-DIR}/"
+
+.PHONY: rpm
+rpm: ${RPM-BUILDROOT-DIR}