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