From 3b4a8b46b87358a09b0307fd1e042f385bc76ed0 Mon Sep 17 00:00:00 2001 From: Martin Belanger Date: Tue, 21 Dec 2021 15:36:38 -0500 Subject: [PATCH] Replacing make by meson. This involves replacing all Makefiles by meson.build files. Also the top-level configure script now simply invokes meson. The top-level Makefile is just a wrapper for meson. It supports the following operations: make make test make install make clean # Remove build artifacts but keep configuration make purge # Remove build artifacts and configuration Signed-off-by: Martin Belanger --- .github/workflows/make.yml | 35 ------ Makefile | 110 ++++++------------ Makefile.quiet | 10 -- configure | 230 ------------------------------------- doc/Makefile | 20 ---- examples/Makefile | 18 --- libnvme/Makefile | 20 ---- src/Makefile | 96 ---------------- test/Makefile | 32 ------ 9 files changed, 35 insertions(+), 536 deletions(-) delete mode 100644 .github/workflows/make.yml delete mode 100644 Makefile.quiet delete mode 100755 configure delete mode 100644 doc/Makefile delete mode 100644 examples/Makefile delete mode 100644 libnvme/Makefile delete mode 100644 src/Makefile delete mode 100644 test/Makefile diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml deleted file mode 100644 index 92f803c4..00000000 --- a/.github/workflows/make.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: libnvme CI - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [ master ] - pull_request: - branches: [ master ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - # Install required libraries - - name: install libraries - run: sudo apt-get install libjson-c-dev - - # Build library - - name: Build libnvme - run: make clean && make && make clean - diff --git a/Makefile b/Makefile index d416c2db..0f15d30d 100644 --- a/Makefile +++ b/Makefile @@ -1,79 +1,39 @@ -NAME=libnvme -SPECFILE=$(NAME).spec -VERSION=$(shell awk '/Version:/ { print $$2 }' $(SPECFILE)) -TAG = $(NAME)-$(VERSION) -RPMBUILD=$(shell `which rpmbuild >&/dev/null` && echo "rpmbuild" || echo "rpm") - -INSTALL=install - -default: all - -python: all - @$(MAKE) -C libnvme python - -all: $(NAME).pc - @$(MAKE) -C src - @$(MAKE) -C test - @$(MAKE) -C examples - -runtests: all - @$(MAKE) -C test runtests -runtests-loop: - @$(MAKE) -C test runtests-loop - -config-host.mak: configure - @if [ ! -e "$@" ]; then \ - echo "Running configure ..."; \ - ./configure; \ - else \ - echo "$@ is out-of-date, running configure"; \ - sed -n "/.*Configured with/s/[^:]*: //p" "$@" | sh; \ - fi - -ifneq ($(MAKECMDGOALS),clean) -include config-host.mak -endif - -SED_PROCESS = \ - sed -e "s%@prefix@%$(prefix)%g" \ - -e "s%@libdir@%$(libdir)%g" \ - -e "s%@includedir@%$(includedir)%g" \ - -e "s%@NAME@%$(NAME)%g" \ - -e "s%@VERSION@%$(VERSION)%g" \ - $< >$@ - -%.pc: %.pc.in config-host.mak $(SPECFILE) - $(SED_PROCESS) - -install: $(NAME).pc - @$(MAKE) -C src install prefix=$(DESTDIR)$(prefix) includedir=$(DESTDIR)$(includedir) libdir=$(DESTDIR)$(libdir) - $(INSTALL) -D -m 644 $(NAME).pc $(DESTDIR)$(libdir)/pkgconfig/$(NAME).pc - $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man2 - $(INSTALL) -m 644 doc/man/*.2 $(DESTDIR)$(mandir)/man2 - -install-tests: - @$(MAKE) -C test install prefix=$(DESTDIR)$(prefix) datadir=$(DESTDIR)$(datadir) - -install-python: - @$(MAKE) -C libnvme install prefix=$(DESTDIR)$(prefix) - +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of libnvme. +# Copyright (c) 2021 Dell Inc. +# +# Authors: Martin Belanger +# +NAME := libnvme +.DEFAULT_GOAL := ${NAME} +BUILD-DIR := .build + +${BUILD-DIR}: + meson $@ + @echo "Configuration located in: $@" + @echo "-------------------------------------------------------" + +.PHONY: ${NAME} +${NAME}: ${BUILD-DIR} + ninja -C ${BUILD-DIR} + +.PHONY: clean clean: - @rm -f config-host.mak config-host.h cscope.out $(NAME).pc - @$(MAKE) -C src clean - @$(MAKE) -C test clean - @$(MAKE) -C examples clean - -cscope: - @cscope -b -R - -tag-archive: - @git tag $(TAG) +ifneq ("$(wildcard ${BUILD-DIR})","") + ninja -C ${BUILD-DIR} -t $@ +endif -create-archive: - @git archive --prefix=$(NAME)-$(VERSION)/ -o $(NAME)-$(VERSION).tar.gz $(TAG) - @echo "The final archive is ./$(NAME)-$(VERSION).tar.gz." +.PHONY: purge +purge: +ifneq ("$(wildcard ${BUILD-DIR})","") + rm -rf ${BUILD-DIR} +endif -archive: clean tag-archive create-archive +.PHONY: install dist +install dist: ${BUILD-DIR} + cd ${BUILD-DIR} && meson $@ -srpm: create-archive - $(RPMBUILD) --define "_sourcedir `pwd`" --define "_srcrpmdir `pwd`" --nodeps -bs $(SPECFILE) +.PHONY: test +test: ${BUILD-DIR} + ninja -C ${BUILD-DIR} $@ diff --git a/Makefile.quiet b/Makefile.quiet deleted file mode 100644 index 8eac349a..00000000 --- a/Makefile.quiet +++ /dev/null @@ -1,10 +0,0 @@ -ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V - QUIET_CC = @echo ' ' CC $@; - QUIET_LINK = @echo ' ' LINK $@; - QUIET_AR = @echo ' ' AR $@; - QUIET_RANLIB = @echo '' RANLIB $@; -endif -endif - - diff --git a/configure b/configure deleted file mode 100755 index d67ed8e5..00000000 --- a/configure +++ /dev/null @@ -1,230 +0,0 @@ -#!/bin/sh -# -# -if test ! -z "$TMPDIR" ; then - TMPDIR1="${TMPDIR}" -elif test ! -z "$TEMPDIR" ; then - TMPDIR1="${TEMPDIR}" -else - TMPDIR1="/tmp" -fi - -cc=gcc -ld=ld - -for opt do - optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') - case "$opt" in - --help|-h) show_help=yes - ;; - --prefix=*) prefix="$optarg" - ;; - --includedir=*) includedir="$optarg" - ;; - --libdir=*) libdir="$optarg" - ;; - --mandir=*) mandir="$optarg" - ;; - --datadir=*) datadir="$optarg" - ;; - --disable-uuid) disable_uuid=1 - ;; - --disable-json) disable_json=1 - ;; - *) - echo "ERROR: unkown option $opt" - echo "Try '$0 --help' for more information" - exit 1 - ;; - esac -done - -if test -z "$prefix"; then - prefix=/usr -fi -if test -z "$includedir"; then - includedir="$prefix/include" -fi -if test -z "$libdir"; then - libdir="$prefix/lib" -fi -if test -z "$mandir"; then - mandir="$prefix/man" -fi -if test -z "$datadir"; then - datadir="$prefix/share" -fi - -if test "$show_help" = "yes"; then -cat < $config_h < $config_host_mak <> config.log - $cc "$@" >> config.log 2>&1 || return $? - # Test passed. If this is an --enable-werror build, rerun - # the test with -Werror and bail out if it fails. This - # makes warning-generating-errors in configure test code - # obvious to developers. - if test "$werror" != "yes"; then - return 0 - fi - # Don't bother rerunning the compile if we were already using -Werror - case "$*" in - *-Werror*) - return 0 - ;; - esac - echo $cc -Werror "$@" >> config.log - $cc -Werror "$@" >> config.log 2>&1 && return $? - echo "ERROR: configure test passed without -Werror but failed with -Werror." - echo "This is probably a bug in the configure script. The failing command" - echo "will be at the bottom of config.log." - fatal "You can run configure with --disable-werror to bypass this check." -} - -compile_object() { - do_cc $CFLAGS -c -o $TMPO $TMPC -} - -compile_prog() { - local_cflags="$1" - local_ldflags="$2 $LIBS" - echo "Compiling test case $3" >> config.log - do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags -} - -feature_not_found() { - feature=$1 - packages=$2 - - echo "" - echo "ERROR: $feature package requirements not met" - if test ! -z "$packages" ; then - echo "ERROR: needs $packages installed" - fi - fatal "" -} - -has() { - type "$1" >/dev/null 2>&1 -} - -output_mak() { - echo "$1=$2" >> $config_host_mak -} - -output_sym() { - output_mak "$1" "y" - echo "#define $1" >> $config_h -} - -print_and_output_mak() { - print_config "$1" "$2" - output_mak "$1" "$2" -} - -print_and_output_mak "prefix" "$prefix" -print_and_output_mak "includedir" "$includedir" -print_and_output_mak "libdir" "$libdir" -print_and_output_mak "mandir" "$mandir" -print_and_output_mak "datadir" "$datadir" - -########################################## -# check for libuuid -libuuid="no" -if [ -z "$disable_uuid" ] ; then - ${ld} -o /dev/null -luuid >/dev/null 2>&1 - if [ $? -eq 0 ]; then - libuuid="yes" - fi -fi -print_config "libuuid" "${libuuid}" - -########################################## -# check for libjson-c -libjsonc="no" -if [ -z "$disable_json" ] ; then - if pkg-config --atleast-version=0.13 json-c; then - libjsonc="yes" - fi -fi -print_config "libjson-c" "${libjsonc}" - -########################################## -# check for c++ -cpp="no" -which g++ > /dev/null 2> /dev/null -if [ $? -eq 0 ]; then - cpp="yes" -fi -print_config "cpp" "${cpp}" - - -if test "$libuuid" = "yes"; then - output_sym "CONFIG_LIBUUID" - echo "override LIBS += -luuid" >> $config_host_mak - echo "override LIB_DEPENDS += uuid" >> $config_host_mak -fi -if test "$libjsonc" = "yes"; then - output_sym "CONFIG_JSONC" - echo "override LIBS += -ljson-c" >> $config_host_mak - echo "override LIB_DEPENDS += json-c" >> $config_host_mak -fi -if test "$cpp" = "yes"; then - output_mak "CONFIG_CPLUSPLUS" "y" -fi diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index d4bb2cbb..00000000 --- a/doc/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index 4916494d..00000000 --- a/examples/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -CFLAGS ?= -g -O2 -override CFLAGS += -Wall -D_GNU_SOURCE -I .. -I ../src -L ../src -I../ccan --include "config.h" - -include ../Makefile.quiet - -ifneq ($(MAKECMDGOALS),clean) -include ../config-host.mak -endif - -all_targets += telemetry-listen display-tree display-columnar discover-loop - -all: $(all_targets) - -%: %.c ../src/libnvme.a - $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lnvme $(LIBS) - -clean: - rm -f $(all_targets) diff --git a/libnvme/Makefile b/libnvme/Makefile deleted file mode 100644 index 5f264073..00000000 --- a/libnvme/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -.DEFAULT_GOAL := python - -SWIG ?= swig -PYTHON ?= python3 - -prefix ?= /usr - -nvme_swig := nvme.i - -nvme_wrap.c: $(nvme_swig) - $(SWIG) -python -py3 -outdir . $< - -python: nvme_wrap.c setup.py - $(PYTHON) setup.py build - -install: - $(PYTHON) setup.py install --prefix=$(prefix) - -clean: - rm -rf nvme_wrap.c nvme.py build diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 4af6551a..00000000 --- a/src/Makefile +++ /dev/null @@ -1,96 +0,0 @@ -NAME=libnvme -SPECFILE=$(NAME).spec -VERSION=$(shell awk '/Version:/ { print $$2 }' $(SPECFILE)) - -ifneq ($(MAKECMDGOALS),clean) -include ../config-host.mak -endif - -prefix ?= /usr -includedir ?= $(prefix)/include -libdir ?= $(prefix)/lib - -CCANDIR=../ccan/ - -CFLAGS ?= -g -fomit-frame-pointer -O2 -I/usr/include -Invme/ -I$(CCANDIR) -I.. -include ../config.h -D_GNU_SOURCE -override CFLAGS += -Wall -fPIC -SO_CFLAGS=-shared $(CFLAGS) -L_CFLAGS=$(CFLAGS) -LINK_FLAGS= -L /usr/lib64 -LINK_FLAGS+=$(LDFLAGS) -ENABLE_SHARED ?= 1 -SED ?= sed -INSTALL ?= install - -soname=$(NAME).so.1 -minor=0 -micro=1 -libname=$(soname).$(minor).$(micro) -all_targets += $(NAME).a - -ifeq ($(ENABLE_SHARED),1) -all_targets += $(libname) -endif - -include ../Makefile.quiet - -all: $(all_targets) - -$(CCANDIR)ccan-config.h: $(CCANDIR)tools/configurator/configurator - $< > $@ -$(CCANDIR)tools/configurator/configurator: CFLAGS = -D_GNU_SOURCE - -libccan_headers := $(wildcard $(CCANDIR)ccan/*/*.h) -libccan_srcs := $(wildcard $(CCANDIR)ccan/*/*.c) -libccan_objs := $(patsubst %.c,%.ol,$(libccan_srcs)) -libccan_sobjs := $(patsubst %.c,%.os,$(libccan_srcs)) - -$(libccan_objs) $(libccan_sobjs): $(libccan_headers) $(CCANDIR)ccan-config.h - -libnvme_priv := nvme/private.h -libnvme_api := libnvme.h nvme/types.h nvme/linux.h nvme/ioctl.h nvme/filters.h nvme/tree.h nvme/util.h nvme/fabrics.h nvme/log.h -libnvme_srcs := nvme/linux.c nvme/ioctl.c nvme/filters.c nvme/fabrics.c nvme/util.c nvme/tree.c nvme/log.c nvme/cleanup.c -ifeq ($(CONFIG_JSONC),y) -override LDFLAGS += $(shell pkg-config --libs json-c) -override CFLAGS += $(shell pkg-config --cflags json-c) -override libnvme_srcs += nvme/json.c -endif -libnvme_objs := $(patsubst %.c,%.ol,$(libnvme_srcs)) -libnvme_sobjs := $(patsubst %.c,%.os,$(libnvme_srcs)) - -$(libnvme_objs) $(libnvme_sobjs): $(libnvme_api) $(libnvme_priv) $(libccan_objs) - -%.os: %.c - $(QUIET_CC)$(CC) $(SO_CFLAGS) -c -o $@ $< - -%.ol: %.c - $(QUIET_CC)$(CC) $(L_CFLAGS) -c -o $@ $< - -AR ?= ar -RANLIB ?= ranlib - -libnvme.a: $(libnvme_objs) $(libccan_objs) - @rm -f libnvme.a - $(QUIET_AR)$(AR) r libnvme.a $^ - $(QUIET_RANLIB)$(RANLIB) libnvme.a - -$(libname): $(libnvme_sobjs) $(libccan_sobjs) libnvme.map - $(QUIET_CC)$(CC) $(SO_CFLAGS) -Wl,--version-script=libnvme.map -Wl,-soname=$(soname) -o $@ $(libnvme_sobjs) $(libccan_sobjs) $(LINK_FLAGS) $(LIBS) - -install: $(all_targets) - $(INSTALL) -D -m 644 libnvme.a $(libdir)/libnvme.a - for i in $(libnvme_api); do $(INSTALL) -D -m 644 $$i $(includedir)/$$i; done -ifeq ($(ENABLE_SHARED),1) - $(INSTALL) -D -m 755 $(libname) $(libdir)/$(libname) - ln -sf $(libname) $(libdir)/$(soname) - ln -sf $(libname) $(libdir)/libnvme.so -endif - -$(libnvme_objs): $(libnvme_api) $(libnvme_private) -$(libccan_objs): $(libccan_headers) $(CCANDIR)ccan-config.h - -clean: - rm -f $(all_targets) $(libnvme_objs) $(libnvme_sobjs) $(libccan_objs) $(libccan_sobjs) $(soname).new - rm -f $(CCANDIR)ccan-config.h - rm -f $(CCANDIR)tools/configurator/configurator - rm -f *.so* *.a *.o diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index 90e89e0b..00000000 --- a/test/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -CFLAGS ?= -g -O2 -override CFLAGS += -Wall -D_GNU_SOURCE -L../src/ -I .. -I../src/ -I../ccan --include "config.h" - -include ../Makefile.quiet - -ifneq ($(MAKECMDGOALS),clean) -include ../config-host.mak -else -CONFIG_CPLUSPLUS=y -endif - -c_targets += test register zns - -ifdef CONFIG_CPLUSPLUS -cpp_targets += cpp -else -cpp_targets += -endif - -all_targets += $(c_targets) $(cpp_targets) -all: $(all_targets) - -CXXFLAGS ?= -lstdc++ - -%: %.cc ../src/libnvme.a - $(QUIET_CC)$(CXX) $(CFLAGS) $(LDFLAGS) $(CXXFLAGS) -o $@ $< -lnvme $(LIBS) - -%: %.c ../src/libnvme.a - $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lnvme $(LIBS) - -clean: - rm -f $(all_targets) -- 2.50.1