blob: b723e8dbde90cc4e81cd042d3f359acdf1b42ce1 [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
Thomas Heijligen90fa8152021-09-25 13:39:42 +0200133define NI845X_TEST
134#include <ni845x.h>
135
136int main(int argc, char **argv)
137{
138 (void) argc;
139 (void) argv;
140 char I2C_Device[256];
141 NiHandle Dev_Handle;
142 uInt32 NumberFound = 0;
143 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
144 ni845xCloseFindDeviceHandle(Dev_Handle);
145 return 0;
146}
147endef
148export NI845X_TEST