summaryrefslogtreecommitdiffstats
path: root/Makefile.include
blob: 2b5a3447d04e14eb0b07b2c0e5b028a95fd2737b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#
# This file is part of the flashrom project.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#

# Here are functions and macros defined for the Makefile

define mark_unsupported
$(foreach p,$1, \
	$(if $(filter $($(p)),yes), \
		$(eval UNSUPPORTED_FEATURES += $(p)=yes), \
		$(eval override $(p) := no)))
endef

define filter_deps
$(strip $(foreach p,$1, \
	$(if $(filter $($(p)),yes), \
		$(p))))
endef

define disable_all
$(foreach p,$1, \
	$(eval override $(p) := no))
endef

# Run the C Preprocessor with file $1 and return the last line, removing quotes.
define c_macro_test
$(strip $(shell $(CC) -E $1 2>/dev/null | tail -1 | tr -d '"'))
endef

define c_compile_test
$(shell $(CC) -c -Wall -Werror -o /dev/null $1 2>/dev/null && echo yes || echo no)
endef

define LIBPCI_TEST
/* Avoid a failing test due to libpci header symbol shadowing breakage */
#define index shadow_workaround_index
#if !defined __NetBSD__
#include <pci/pci.h>
#else
#include <pciutils/pci.h>
#endif
struct pci_access *pacc;
int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	pacc = pci_alloc();
	return 0;
}
endef
export LIBPCI_TEST

define PCI_GET_DEV_TEST
/* Avoid a failing test due to libpci header symbol shadowing breakage */
#define index shadow_workaround_index
#if !defined __NetBSD__
#include <pci/pci.h>
#else
#include <pciutils/pci.h>
#endif
struct pci_access *pacc;
struct pci_dev *dev = {0};
int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	pacc = pci_alloc();
	dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
	return 0;
}
endef
export PCI_GET_DEV_TEST

define LIBUSB1_TEST
#include <stddef.h>
#include <libusb.h>
int main(int argc, char **argv)
{
	(void)argc;
	(void)argv;
	libusb_init(NULL);
	return 0;
}
endef
export LIBUSB1_TEST

define LIBJAYLINK_TEST
#include <stddef.h>
#include <libjaylink/libjaylink.h>
int main(int argc, char **argv)
{
	struct jaylink_context *ctx;

	(void)argc;
	(void)argv;

	jaylink_init(&ctx);
	jaylink_exit(ctx);

	return 0;
}
endef
export LIBJAYLINK_TEST

define FTDI_TEST
#include <stdlib.h>
#include <ftdi.h>
struct ftdi_context *ftdic = NULL;
int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	return ftdi_init(ftdic);
}
endef
export FTDI_TEST

define FTDI_232H_TEST
#include <ftdi.h>
enum ftdi_chip_type type = TYPE_232H;
endef
export FTDI_232H_TEST

define UTSNAME_TEST
#include <sys/utsname.h>
struct utsname osinfo;
int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	uname (&osinfo);
	return 0;
}
endef
export UTSNAME_TEST

define LINUX_MTD_TEST
#include <mtd/mtd-user.h>

int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	return 0;
}
endef
export LINUX_MTD_TEST

define LINUX_SPI_TEST
#include <linux/types.h>
#include <linux/spi/spidev.h>

int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	return 0;
}
endef
export LINUX_SPI_TEST

define LINUX_I2C_TEST
#include <linux/i2c-dev.h>
#include <linux/i2c.h>

int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	return 0;
}
endef
export LINUX_I2C_TEST

define CLOCK_GETTIME_TEST
#include <time.h>

int main(int argc, char **argv)
{
	struct timespec res;
	clock_gettime(CLOCK_REALTIME, &res);
	return 0;
}
endef
export CLOCK_GETTIME_TEST

define NI845X_TEST
#include <ni845x.h>

int main(int argc, char **argv)
{
    (void) argc;
    (void) argv;
    char I2C_Device[256];
    NiHandle Dev_Handle;
    uInt32 NumberFound = 0;
    ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
    ni845xCloseFindDeviceHandle(Dev_Handle);
    return 0;
}
endef
export NI845X_TEST