blob: 12fdd8159c598f6a95ab1fcf7a8ae1122b5d8816 [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
36$(strip $(shell $(CC) -E $1 2>/dev/null | tail -n 1 | tr -d '"'))
37endef
Thomas Heijligen90fa8152021-09-25 13:39:42 +020038
39define COMPILER_TEST
40int main(int argc, char **argv)
41{
42 (void) argc;
43 (void) argv;
44 return 0;
45}
46endef
47export COMPILER_TEST
48
49define LIBPCI_TEST
50/* Avoid a failing test due to libpci header symbol shadowing breakage */
51#define index shadow_workaround_index
52#if !defined PCIUTILS_PCI_H
53#include <pci/pci.h>
54#else
55#include <pciutils/pci.h>
56#endif
57struct pci_access *pacc;
58int main(int argc, char **argv)
59{
60 (void) argc;
61 (void) argv;
62 pacc = pci_alloc();
63 return 0;
64}
65endef
66export LIBPCI_TEST
67
68define PCI_GET_DEV_TEST
69/* Avoid a failing test due to libpci header symbol shadowing breakage */
70#define index shadow_workaround_index
71#if !defined PCIUTILS_PCI_H
72#include <pci/pci.h>
73#else
74#include <pciutils/pci.h>
75#endif
76struct pci_access *pacc;
77struct pci_dev *dev = {0};
78int main(int argc, char **argv)
79{
80 (void) argc;
81 (void) argv;
82 pacc = pci_alloc();
83 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
84 return 0;
85}
86endef
87export PCI_GET_DEV_TEST
88
89define LIBUSB1_TEST
90#include <stddef.h>
91#include <libusb.h>
92int main(int argc, char **argv)
93{
94 (void)argc;
95 (void)argv;
96 libusb_init(NULL);
97 return 0;
98}
99endef
100export LIBUSB1_TEST
101
102define LIBJAYLINK_TEST
103#include <stddef.h>
104#include <libjaylink/libjaylink.h>
105int main(int argc, char **argv)
106{
107 struct jaylink_context *ctx;
108
109 (void)argc;
110 (void)argv;
111
112 jaylink_init(&ctx);
113 jaylink_exit(ctx);
114
115 return 0;
116}
117endef
118export LIBJAYLINK_TEST
119
120define FTDI_TEST
121#include <stdlib.h>
122#include <ftdi.h>
123struct ftdi_context *ftdic = NULL;
124int main(int argc, char **argv)
125{
126 (void) argc;
127 (void) argv;
128 return ftdi_init(ftdic);
129}
130endef
131export FTDI_TEST
132
133define FTDI_232H_TEST
134#include <ftdi.h>
135enum ftdi_chip_type type = TYPE_232H;
136endef
137export FTDI_232H_TEST
138
139define UTSNAME_TEST
140#include <sys/utsname.h>
141struct utsname osinfo;
142int main(int argc, char **argv)
143{
144 (void) argc;
145 (void) argv;
146 uname (&osinfo);
147 return 0;
148}
149endef
150export UTSNAME_TEST
151
152define LINUX_MTD_TEST
153#include <mtd/mtd-user.h>
154
155int main(int argc, char **argv)
156{
157 (void) argc;
158 (void) argv;
159 return 0;
160}
161endef
162export LINUX_MTD_TEST
163
164define LINUX_SPI_TEST
165#include <linux/types.h>
166#include <linux/spi/spidev.h>
167
168int main(int argc, char **argv)
169{
170 (void) argc;
171 (void) argv;
172 return 0;
173}
174endef
175export LINUX_SPI_TEST
176
177define LINUX_I2C_TEST
178#include <linux/i2c-dev.h>
179#include <linux/i2c.h>
180
181int main(int argc, char **argv)
182{
183 (void) argc;
184 (void) argv;
185 return 0;
186}
187endef
188export LINUX_I2C_TEST
189
190define CLOCK_GETTIME_TEST
191#include <time.h>
192
193int main(int argc, char **argv)
194{
195 struct timespec res;
196 clock_gettime(CLOCK_REALTIME, &res);
197 return 0;
198}
199endef
200export CLOCK_GETTIME_TEST
201
202define NI845X_TEST
203#include <ni845x.h>
204
205int main(int argc, char **argv)
206{
207 (void) argc;
208 (void) argv;
209 char I2C_Device[256];
210 NiHandle Dev_Handle;
211 uInt32 NumberFound = 0;
212 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
213 ni845xCloseFindDeviceHandle(Dev_Handle);
214 return 0;
215}
216endef
217export NI845X_TEST