Thomas Heijligen | 90fa815 | 2021-09-25 13:39:42 +0200 | [diff] [blame] | 1 | # |
| 2 | # This file is part of the flashrom project. |
| 3 | # |
| 4 | # This program is free software; you can redistribute it and/or modify |
| 5 | # it under the terms of the GNU General Public License as published by |
| 6 | # the Free Software Foundation; version 2 of the License. |
| 7 | # |
| 8 | # This program is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | # GNU General Public License for more details. |
| 12 | # |
| 13 | |
| 14 | # Here are functions and macros defined for the Makefile |
| 15 | |
| 16 | define mark_unsupported |
| 17 | $(foreach p,$1, \ |
| 18 | $(if $(filter $($(p)),yes), \ |
| 19 | $(eval UNSUPPORTED_FEATURES += $(p)=yes), \ |
| 20 | $(eval override $(p) := no))) |
| 21 | endef |
| 22 | |
| 23 | define filter_deps |
| 24 | $(strip $(foreach p,$1, \ |
| 25 | $(if $(filter $($(p)),yes), \ |
| 26 | $(p)))) |
| 27 | endef |
| 28 | |
| 29 | define disable_all |
| 30 | $(foreach p,$1, \ |
| 31 | $(eval override $(p) := no)) |
| 32 | endef |
| 33 | |
Thomas Heijligen | 1e76dc8 | 2021-09-28 15:22:34 +0200 | [diff] [blame] | 34 | # Run the C Preprocessor with file $1 and return the last line, removing quotes. |
| 35 | define c_macro_test |
Thomas Heijligen | 121a5b8 | 2021-10-21 12:58:07 +0200 | [diff] [blame] | 36 | $(strip $(call debug_shell, $(CC) -E $1 | tail -n 1 | tr -d '"')) |
Thomas Heijligen | 1e76dc8 | 2021-09-28 15:22:34 +0200 | [diff] [blame] | 37 | endef |
Thomas Heijligen | 90fa815 | 2021-09-25 13:39:42 +0200 | [diff] [blame] | 38 | |
Thomas Heijligen | 121a5b8 | 2021-10-21 12:58:07 +0200 | [diff] [blame] | 39 | define c_compile_test # $1: files to compile, $2: cflags |
| 40 | $(call debug_shell, $(CC) -c -Wall -Werror $2 $1 -o /dev/null && echo yes || echo no) |
| 41 | endef |
| 42 | |
| 43 | define find_dependency |
| 44 | $(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --exists $1 && echo yes || echo no) |
| 45 | endef |
| 46 | |
| 47 | define dependency_cflags |
| 48 | $(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --cflags $1 2>/dev/null) |
| 49 | endef |
| 50 | |
| 51 | define dependency_ldflags |
| 52 | $(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --libs $1 2>/dev/null) |
Thomas Heijligen | 90fa815 | 2021-09-25 13:39:42 +0200 | [diff] [blame] | 53 | endef |