diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-03-05 17:47:33 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-03-05 17:55:54 +0200 |
commit | 583bedefc2a247d2cfd32d1b4a0abbe3e2015c70 (patch) | |
tree | 36c387fe06c0c200e36bb2681b51e7fd254ad8f3 | |
parent | ea036da1c8028ec91bd9a1b1d6ad978f4f03a748 (diff) |
Move to meson build
Meson makes it much easier to handle cross builds compared to manually
written makefiles. The makefile is kept to avoid build breakages, with a
message now printed to warn that is is deprecated.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | meson.build | 50 |
3 files changed, 53 insertions, 0 deletions
@@ -1,2 +1,3 @@ *.o +build/ yavta @@ -5,6 +5,8 @@ CFLAGS ?= -O2 -W -Wall -Iinclude LDFLAGS ?= LIBS := -lrt +$(warning WARNING: Makefile support is deprecated, please switch to meson) + %.o : %.c $(CC) $(CFLAGS) -c -o $@ $< diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..e07659d --- /dev/null +++ b/meson.build @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: CC0-1.0 + +project('yavta', 'c', + meson_version : '>= 0.40', + version : '0.0.0', + default_options : [ + 'werror=true', + 'warning_level=2', + ], + license : 'GPL 2.0+') + +# +# Configure the build environment +# +cc = meson.get_compiler('c') + +cc_arguments = [ + '-Wshadow', +] + +if cc.get_id() == 'clang' + # Turn _FORTIFY_SOURCE by default on optimised builds (as it requires -O1 + # or higher). This is needed on clang only as gcc enables it by default. + if get_option('optimization') != '0' + cc_arguments += [ + '-D_FORTIFY_SOURCE=2', + ] + endif +endif + +add_project_arguments(cc_arguments, language : 'c') + +# +# yavta +# +yavta_dependencies = [] + +if not cc.has_function('clock_gettime') + # On glibc older than 2.17, clock_gettime is provided by time.h and -lrt + yavta_dependencies += [cc.find_library('rt')] +endif + +yavta_sources = files([ + 'yavta.c', +]) + +yavta = executable('yavta', yavta_sources, + include_directories : include_directories('include'), + dependencies : yavta_dependencies, + install : true) |