blob: d38552d023267dc29905e411b0bf150ce75ab882 [file] [log] [blame]
Thomas Heijligen90fa8152021-09-25 13:39:42 +02001#
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
16define mark_unsupported
17$(foreach p,$1, \
18 $(if $(filter $($(p)),yes), \
19 $(eval UNSUPPORTED_FEATURES += $(p)=yes), \
20 $(eval override $(p) := no)))
21endef
22
23define filter_deps
24$(strip $(foreach p,$1, \
25 $(if $(filter $($(p)),yes), \
26 $(p))))
27endef
28
29define disable_all
30$(foreach p,$1, \
31 $(eval override $(p) := no))
32endef
33
Thomas Heijligen1e76dc82021-09-28 15:22:34 +020034# Run the C Preprocessor with file $1 and return the last line, removing quotes.
35define c_macro_test
Thomas Heijligen121a5b82021-10-21 12:58:07 +020036$(strip $(call debug_shell, $(CC) -E $1 | tail -n 1 | tr -d '"'))
Thomas Heijligen1e76dc82021-09-28 15:22:34 +020037endef
Thomas Heijligen90fa8152021-09-25 13:39:42 +020038
Thomas Heijligen121a5b82021-10-21 12:58:07 +020039define 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)
41endef
42
43define find_dependency
44$(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --exists $1 && echo yes || echo no)
45endef
46
47define dependency_cflags
48$(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --cflags $1 2>/dev/null)
49endef
50
51define dependency_ldflags
52$(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --libs $1 2>/dev/null)
Thomas Heijligen90fa8152021-09-25 13:39:42 +020053endef
Thomas Heijligen90fa8152021-09-25 13:39:42 +020054
55define LIBPCI_TEST
56/* Avoid a failing test due to libpci header symbol shadowing breakage */
57#define index shadow_workaround_index
58#if !defined PCIUTILS_PCI_H
59#include <pci/pci.h>
60#else
61#include <pciutils/pci.h>
62#endif
63struct pci_access *pacc;
64int main(int argc, char **argv)
65{
66 (void) argc;
67 (void) argv;
68 pacc = pci_alloc();
69 return 0;
70}
71endef
72export LIBPCI_TEST
73
74define PCI_GET_DEV_TEST
75/* Avoid a failing test due to libpci header symbol shadowing breakage */
76#define index shadow_workaround_index
77#if !defined PCIUTILS_PCI_H
78#include <pci/pci.h>
79#else
80#include <pciutils/pci.h>
81#endif
82struct pci_access *pacc;
83struct pci_dev *dev = {0};
84int main(int argc, char **argv)
85{
86 (void) argc;
87 (void) argv;
88 pacc = pci_alloc();
89 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
90 return 0;
91}
92endef
93export PCI_GET_DEV_TEST
94
95define LIBUSB1_TEST
96#include <stddef.h>
97#include <libusb.h>
98int main(int argc, char **argv)
99{
100 (void)argc;
101 (void)argv;
102 libusb_init(NULL);
103 return 0;
104}
105endef
106export LIBUSB1_TEST
107
108define LIBJAYLINK_TEST
109#include <stddef.h>
110#include <libjaylink/libjaylink.h>
111int main(int argc, char **argv)
112{
113 struct jaylink_context *ctx;
114
115 (void)argc;
116 (void)argv;
117
118 jaylink_init(&ctx);
119 jaylink_exit(ctx);
120
121 return 0;
122}
123endef
124export LIBJAYLINK_TEST
125
Thomas Heijligen90fa8152021-09-25 13:39:42 +0200126define NI845X_TEST
127#include <ni845x.h>
128
129int main(int argc, char **argv)
130{
131 (void) argc;
132 (void) argv;
133 char I2C_Device[256];
134 NiHandle Dev_Handle;
135 uInt32 NumberFound = 0;
136 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
137 ni845xCloseFindDeviceHandle(Dev_Handle);
138 return 0;
139}
140endef
141export NI845X_TEST