From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Wed, 31 May 2023 17:31:31 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q4NnQ-004QrJ-Hg for lore@lore.pengutronix.de; Wed, 31 May 2023 17:31:31 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1q4NnN-0007CI-BW; Wed, 31 May 2023 17:31:29 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q4NnL-0007A0-T6; Wed, 31 May 2023 17:31:27 +0200 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1q4NnL-0049CQ-9S; Wed, 31 May 2023 17:31:27 +0200 Received: from afa by dude05.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1q4NnK-005uL0-2l; Wed, 31 May 2023 17:31:26 +0200 From: Ahmad Fatoum To: oss-tools@pengutronix.de Date: Wed, 31 May 2023 17:31:21 +0200 Message-Id: <20230531153125.1408092-2-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531153125.1408092-1-a.fatoum@pengutronix.de> References: <20230531153125.1408092-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [OSS-Tools] [PATCH 1/5] Add meson as build system X-BeenThere: oss-tools@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "OSS-Tools" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: oss-tools-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false This adds experimental support for building dt-utils with meson. The hope is that the alternative meson.build will be easier to maintain. Signed-off-by: Ahmad Fatoum --- .gitignore | 1 + README | 20 ++++++ check-news.sh | 82 ++++++++++++++++++++++++ meson.build | 159 ++++++++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 25 ++++++++ version-gen | 3 + version.h.in | 3 + 7 files changed, 293 insertions(+) create mode 100755 check-news.sh create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100755 version-gen create mode 100644 version.h.in diff --git a/.gitignore b/.gitignore index 5ee5535f544f..34df220d8723 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ Makefile.in /stamp-h1 /tags /TAGS +/build/ /fdtdump /src/libdt-utils.pc diff --git a/README b/README index 46b4ea9c1508..0b4e96d6002e 100644 --- a/README +++ b/README @@ -13,6 +13,26 @@ For questions, feedback, patches, please send a mail to Note: you must be subscribed to post to this mailing list. You can do so by sending an empty mail to . +Building from Sources +--------------------- + +Check out the latest git state: + + git clone https://github.com/barebox/dt-utils + cd dt-utils + +And then build using autotools: + + ./autogen.sh + ./configure + make + +There's also experimental support for building with meson. +The intention is to deprecate autotools eventually in its favor. To build: + + meson setup build + meson compile -C build + Contributing ------------ diff --git a/check-news.sh b/check-news.sh new file mode 100755 index 000000000000..e7e8fa6bb95d --- /dev/null +++ b/check-news.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +# Copyright (C) 2019 Red Hat, Inc. +# Author: Bastien Nocera +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +# Add to your top-level meson.build to check for an updated NEWS file +# when doing a "dist" release, similarly to automake's check-news: +# https://www.gnu.org/software/automake/manual/html_node/List-of-Automake-options.html +# +# Checks NEWS for the version number: +# meson.add_dist_script( +# find_program('check-news.sh').path(), +# '@0@'.format(meson.project_version()) +# ) +# +# Checks NEWS and data/foo.appdata.xml for the version number: +# meson.add_dist_script( +# find_program('check-news.sh').path(), +# '@0@'.format(meson.project_version()), +# 'NEWS', +# 'data/foo.appdata.xml' +# ) + +usage() +{ + echo "$0 VERSION [FILES...]" + exit 1 +} + +check_version() +{ + VERSION=$1 + # Look in the first 15 lines for NEWS files, but look + # everywhere for other types of files + if [ "$2" = "NEWS" ]; then + DATA=`sed 15q $SRC_ROOT/"$2"` + else + DATA=`cat $SRC_ROOT/"$2"` + fi + case "$DATA" in + *"$VERSION"*) + : + ;; + *) + echo "$2 not updated; not releasing" 1>&2; + exit 1 + ;; + esac +} + +SRC_ROOT=${MESON_DIST_ROOT:-"./"} + +if [ $# -lt 1 ] ; then usage ; fi + +VERSION=$1 +shift + +if [ $# -eq 0 ] ; then + check_version $VERSION 'NEWS' + exit 0 +fi + +for i in $@ ; do + check_version $VERSION "$i" +done + +exit 0 diff --git a/meson.build b/meson.build new file mode 100644 index 000000000000..22b522ea4d0e --- /dev/null +++ b/meson.build @@ -0,0 +1,159 @@ +# Copyright 2013-2023 The DT-Utils Authors +# Homepage: https://git.pengutronix.de/cgit/tools/dt-utils + +project( + 'dt-utils', + 'c', + version : '2021.03.0', + meson_version : '>=0.51', + default_options: [ + 'c_std=gnu11', + 'warning_level=2', + ], + license : 'GPL-2.0-only', +) + +cc = meson.get_compiler('c') + +conf = configuration_data() +# Statically define to be enabled to harmonize barebox' & dt-utils' code base. +conf.set10('CONFIG_MTD', true) +conf.set10('CONFIG_STATE', true) +conf.set10('CONFIG_STATE_BACKWARD_COMPATIBLE', get_option('state-backward-compatibility')) + +meson.add_dist_script( + find_program('check-news.sh').path(), + '@0@'.format(meson.project_version()) +) + +prefixdir = get_option('prefix') +if not prefixdir.startswith('/') + error('Prefix is not absolute: "@0@"'.format(prefixdir)) +endif +sysconfdir = join_paths(prefixdir, get_option('sysconfdir')) +conf.set('SYSCONFDIR', sysconfdir) +libexecdir = join_paths(prefixdir, get_option('libexecdir')) +conf.set('LIBEXECDIR', libexecdir) + +udevdep = dependency('libudev') + +c_flags = ''' + -fno-strict-aliasing + -ffunction-sections + -fdata-sections +'''.split() + +c_warn_flags = ''' + -Wmissing-declarations + -Wmissing-prototypes + -Wnested-externs + -Wno-sign-compare + -Wno-unused-parameter + -Wchar-subscripts + -Wstrict-prototypes + -Wshadow + -Wformat-security + -Wtype-limits + -Wno-pointer-sign + -Wno-shadow +'''.split() +c_flags += cc.get_supported_arguments(c_warn_flags) +add_project_arguments(c_flags, language : 'c') +# enable GNU extensions (required!) +add_project_arguments('-D_GNU_SOURCE', language : 'c') + +ld_flags = ''' + -Wl,--gc-sections + -Wl,--as-needed +'''.split() + +incdir = include_directories(['src/dt', 'src']) + +sources_libdt = files(''' + src/crc32.c + src/libdt.c + src/fdt.c +'''.split()) + +if get_option('barebox-state') + sources_barebox_state = files(''' + src/crypto/digest.c + src/crypto/hmac.c + src/crypto/sha1.c + src/crypto/sha2.c + src/keystore-blob.c + src/base64.c + src/barebox-state/backend_bucket_circular.c + src/barebox-state/backend_bucket_direct.c + src/barebox-state/backend_format_dtb.c + src/barebox-state/backend_format_raw.c + src/barebox-state/backend_storage.c + src/barebox-state/state.c + src/barebox-state/state_variables.c + src/barebox-state.c + '''.split()) +endif + +sources_dtblint = files(''' + src/dtblint.c + src/dtblint-imx-pinmux.c + src/dtblint.h +'''.split()) + +sources_fdtdump = files(''' +src/fdtdump.c +'''.split()) + +config_h = configure_file( + output : 'config.h', + configuration : conf +) +add_project_arguments('-include', meson.current_build_dir() / 'config.h', language : 'c') + +version_h = vcs_tag( + input : 'version.h.in', + output : 'version.h', +) +versiondep = declare_dependency(sources: version_h) + +meson.add_dist_script('version-gen', meson.project_version()) + +mapfile = 'src/libdt-utils.sym' +libdt_ld_flags = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) + +libdt = shared_library('dt-utils', + sources_libdt, + include_directories : incdir, + link_args : ld_flags + ['-Wl,--no-undefined', libdt_ld_flags], + link_depends : mapfile, + c_args : ['-include', meson.current_build_dir() / 'version.h'], + dependencies : [udevdep, versiondep], + gnu_symbol_visibility : 'default', + install : true) + +executable('barebox-state', + sources_barebox_state, + include_directories : incdir, + link_args : ld_flags, + c_args : ['-include', meson.current_build_dir() / 'version.h'], + dependencies : [versiondep], + link_with : libdt, + install : true) + +executable('fdtdump', + sources_fdtdump, + include_directories : incdir, + link_args : ld_flags, + c_args : ['-include', meson.current_build_dir() / 'version.h'], + dependencies : [versiondep], + link_with : libdt, + install : true) + +executable('dtblint', + sources_dtblint, + include_directories : incdir, + link_args : ld_flags, + c_args : ['-include', meson.current_build_dir() / 'version.h'], + dependencies : [versiondep], + link_with : libdt, + install : true) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000000..f80643aa6c73 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,25 @@ +# feature options +option( + 'state-backward-compatibility', + type : 'boolean', + value : 'false', + description : 'barebox-state: when using the "direct" storage backend, keep the on-disk format readable by barebox <= v2016.08.0') + +option( + 'lock-device', + type : 'boolean', + value : 'false', + description : 'lock device node instead of creating lockfile in /run') + +# build options +option( + 'barebox-state', + type : 'boolean', + value : 'true', + description : 'Build barebox-state utility') + +option( + 'tests', + type : 'boolean', + value : 'true', + description : 'Enable/Disable test suite') diff --git a/version-gen b/version-gen new file mode 100755 index 000000000000..bf77f50bc1e7 --- /dev/null +++ b/version-gen @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "$1" > "$MESON_DIST_ROOT/.tarball-version" diff --git a/version.h.in b/version.h.in new file mode 100644 index 000000000000..a0c0ce367ab7 --- /dev/null +++ b/version.h.in @@ -0,0 +1,3 @@ +#define PACKAGE_STRING "dt-utils @VCS_TAG@" + +#define PACKAGE_VERSION "@VCS_TAG@" -- 2.39.2