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