Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 1 | # |
Uwe Hermann | f78cff1 | 2009-06-12 14:05:25 +0000 | [diff] [blame] | 2 | # This file is part of the flashrom project. |
| 3 | # |
| 4 | # Copyright (C) 2005 coresystems GmbH <stepan@coresystems.de> |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 5 | # Copyright (C) 2009,2010,2012 Carl-Daniel Hailfinger |
Uwe Hermann | f78cff1 | 2009-06-12 14:05:25 +0000 | [diff] [blame] | 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; version 2 of the License. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program; if not, write to the Free Software |
| 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 19 | # |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 20 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 21 | PROGRAM = flashrom |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 22 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 23 | ############################################################################### |
| 24 | # Defaults for the toolchain. |
| 25 | |
| 26 | # If you want to cross-compile, just run e.g. |
| 27 | # make CC=i586-pc-msdosdjgpp-gcc |
| 28 | # You may have to specify STRIP/AR/RANLIB as well. |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 29 | # |
| 30 | # Note for anyone editing this Makefile: gnumake will happily ignore any |
| 31 | # changes in this Makefile to variables set on the command line. |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 32 | STRIP ?= strip |
Christian Ruppert | db9d9f4 | 2009-05-14 14:17:07 +0000 | [diff] [blame] | 33 | INSTALL = install |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 34 | DIFF = diff |
Christian Ruppert | db9d9f4 | 2009-05-14 14:17:07 +0000 | [diff] [blame] | 35 | PREFIX ?= /usr/local |
Uwe Hermann | 56b2cb0 | 2009-05-21 15:59:58 +0000 | [diff] [blame] | 36 | MANDIR ?= $(PREFIX)/share/man |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 37 | CFLAGS ?= -Os -Wall -Wshadow |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 38 | EXPORTDIR ?= . |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 39 | RANLIB ?= ranlib |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 40 | PKG_CONFIG ?= pkg-config |
| 41 | BUILD_DETAILS_FILE ?= build_details.txt |
Stefan Tauner | be62d3f | 2015-01-10 09:32:44 +0000 | [diff] [blame] | 42 | |
Stefan Tauner | fd0d413 | 2012-09-25 21:24:55 +0000 | [diff] [blame] | 43 | # The following parameter changes the default programmer that will be used if there is no -p/--programmer |
| 44 | # argument given when running flashrom. The predefined setting does not enable any default so that every |
| 45 | # user has to declare the programmer he wants to use on every run. The rationale for this to be not set |
| 46 | # (to e.g. the internal programmer) is that forgetting to specify this when working with another programmer |
| 47 | # easily puts the system attached to the default programmer at risk (e.g. you want to flash coreboot to another |
| 48 | # system attached to an external programmer while the default programmer is set to the internal programmer, and |
| 49 | # you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer |
| 50 | # running flashrom). Please do not enable this without thinking about the possible consequences. Possible |
| 51 | # values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options |
| 52 | # evaluated below, namely those that enable/disable the various programmers). |
| 53 | # Compilation will fail for unspecified values. |
| 54 | CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID |
Stefan Tauner | 265fcac | 2014-06-02 00:12:23 +0000 | [diff] [blame] | 55 | # The following adds a default parameter for the default programmer set above (only). |
| 56 | CONFIG_DEFAULT_PROGRAMMER_ARGS ?= '' |
| 57 | # Example: compiling with |
| 58 | # make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000" |
| 59 | # would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'. |
Christian Ruppert | db9d9f4 | 2009-05-14 14:17:07 +0000 | [diff] [blame] | 60 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 61 | # If your compiler spits out excessive warnings, run make WARNERROR=no |
| 62 | # You shouldn't have to change this flag. |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 63 | WARNERROR ?= yes |
| 64 | |
| 65 | ifeq ($(WARNERROR), yes) |
| 66 | CFLAGS += -Werror |
| 67 | endif |
| 68 | |
Stefan Tauner | e37735a | 2015-01-26 22:03:35 +0000 | [diff] [blame] | 69 | ifdef LIBS_BASE |
Stefan Tauner | be62d3f | 2015-01-10 09:32:44 +0000 | [diff] [blame] | 70 | CPPFLAGS += -I$(LIBS_BASE)/include |
Stefan Tauner | e37735a | 2015-01-26 22:03:35 +0000 | [diff] [blame] | 71 | LDFLAGS += -L$(LIBS_BASE)/lib -Wl,-rpath -Wl,$(LIBS_BASE)/lib |
| 72 | PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig |
| 73 | endif |
Stefan Tauner | be62d3f | 2015-01-10 09:32:44 +0000 | [diff] [blame] | 74 | |
Stefan Tauner | bfb067b | 2016-01-07 18:13:07 +0000 | [diff] [blame] | 75 | ifeq ($(CONFIG_STATIC),yes) |
| 76 | PKG_CONFIG += --static |
| 77 | LDFLAGS += -static |
| 78 | endif |
| 79 | |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 80 | dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUILD_DETAILS_FILE)) |
| 81 | debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(1) ; }' >&2; { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE)) |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 82 | ############################################################################### |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 83 | # General OS-specific settings. |
| 84 | # 1. Prepare for later by gathering information about host and target OS |
| 85 | # 2. Set compiler flags and parameters according to OSes |
| 86 | # 3. Likewise verify user-supplied CONFIG_* variables. |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 87 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 88 | # HOST_OS is only used to work around local toolchain issues. |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 89 | HOST_OS ?= $(shell uname) |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 90 | ifeq ($(HOST_OS), MINGW32_NT-5.1) |
| 91 | # Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found". |
| 92 | CC = gcc |
| 93 | endif |
| 94 | ifneq ($(HOST_OS), SunOS) |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 95 | STRIP_ARGS = -s |
| 96 | endif |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 97 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 98 | # Determine the destination OS. |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 99 | # IMPORTANT: The following line must be placed before TARGET_OS is ever used |
| 100 | # (of course), but should come after any lines setting CC because the line |
| 101 | # below uses CC itself. |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 102 | override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"')) |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 103 | |
| 104 | ifeq ($(TARGET_OS), Darwin) |
Stefan Reinauer | 2fea3f3 | 2010-01-21 20:26:30 +0000 | [diff] [blame] | 105 | CPPFLAGS += -I/opt/local/include -I/usr/local/include |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 106 | LDFLAGS += -L/opt/local/lib -L/usr/local/lib |
Stefan Reinauer | f79edb9 | 2009-01-26 01:23:31 +0000 | [diff] [blame] | 107 | endif |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 108 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 109 | ifeq ($(TARGET_OS), FreeBSD) |
Stefan Reinauer | 2fea3f3 | 2010-01-21 20:26:30 +0000 | [diff] [blame] | 110 | CPPFLAGS += -I/usr/local/include |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 111 | LDFLAGS += -L/usr/local/lib |
| 112 | endif |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 113 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 114 | ifeq ($(TARGET_OS), OpenBSD) |
Carl-Daniel Hailfinger | b63b067 | 2010-07-02 17:12:50 +0000 | [diff] [blame] | 115 | CPPFLAGS += -I/usr/local/include |
| 116 | LDFLAGS += -L/usr/local/lib |
| 117 | endif |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 118 | |
Stefan Tauner | c65b855 | 2013-09-12 15:48:39 +0000 | [diff] [blame] | 119 | ifeq ($(TARGET_OS), NetBSD) |
| 120 | CPPFLAGS += -I/usr/pkg/include |
| 121 | LDFLAGS += -L/usr/pkg/lib |
| 122 | endif |
| 123 | |
| 124 | ifeq ($(TARGET_OS), DragonFlyBSD) |
Stefan Tauner | 8d21ff1 | 2015-01-10 09:33:06 +0000 | [diff] [blame] | 125 | CPPFLAGS += -I/usr/local/include |
| 126 | LDFLAGS += -L/usr/local/lib |
Stefan Tauner | c65b855 | 2013-09-12 15:48:39 +0000 | [diff] [blame] | 127 | endif |
| 128 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 129 | ifeq ($(TARGET_OS), DOS) |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 130 | EXEC_SUFFIX := .exe |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 131 | # DJGPP has odd uint*_t definitions which cause lots of format string warnings. |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 132 | CFLAGS += -Wno-format |
Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 133 | LIBS += -lgetopt |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 134 | # Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support). |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 135 | ifeq ($(CONFIG_BUSPIRATE_SPI), yes) |
| 136 | UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes |
| 137 | else |
| 138 | override CONFIG_BUSPIRATE_SPI = no |
| 139 | endif |
| 140 | ifeq ($(CONFIG_SERPROG), yes) |
| 141 | UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes |
| 142 | else |
| 143 | override CONFIG_SERPROG = no |
| 144 | endif |
Stefan Tauner | d94d25d | 2012-07-28 03:17:15 +0000 | [diff] [blame] | 145 | ifeq ($(CONFIG_PONY_SPI), yes) |
| 146 | UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes |
| 147 | else |
| 148 | override CONFIG_PONY_SPI = no |
| 149 | endif |
Justin Chevrier | 66e554b | 2015-02-08 21:58:10 +0000 | [diff] [blame] | 150 | # Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported under DOS (missing USB support). |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 151 | ifeq ($(CONFIG_DEDIPROG), yes) |
| 152 | UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes |
| 153 | else |
| 154 | override CONFIG_DEDIPROG = no |
| 155 | endif |
| 156 | ifeq ($(CONFIG_FT2232_SPI), yes) |
| 157 | UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes |
| 158 | else |
| 159 | override CONFIG_FT2232_SPI = no |
| 160 | endif |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 161 | ifeq ($(CONFIG_USBBLASTER_SPI), yes) |
| 162 | UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes |
| 163 | else |
| 164 | override CONFIG_USBBLASTER_SPI = no |
| 165 | endif |
Justin Chevrier | 66e554b | 2015-02-08 21:58:10 +0000 | [diff] [blame] | 166 | ifeq ($(CONFIG_PICKIT2_SPI), yes) |
| 167 | UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes |
| 168 | else |
| 169 | override CONFIG_PICKIT2_SPI = no |
| 170 | endif |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 171 | endif |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 172 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 173 | # FIXME: Should we check for Cygwin/MSVC as well? |
| 174 | ifeq ($(TARGET_OS), MinGW) |
| 175 | EXEC_SUFFIX := .exe |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 176 | # MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs(). |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 177 | FLASHROM_CFLAGS += -Dffs=__builtin_ffs |
Carl-Daniel Hailfinger | 11990da | 2013-07-13 23:21:05 +0000 | [diff] [blame] | 178 | # Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that |
| 179 | # for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */ |
| 180 | FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 181 | # libusb-win32/libftdi stuff is usually installed in /usr/local. |
| 182 | CPPFLAGS += -I/usr/local/include |
| 183 | LDFLAGS += -L/usr/local/lib |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 184 | # For now we disable all PCI-based programmers on Windows/MinGW (no libpci). |
| 185 | ifeq ($(CONFIG_INTERNAL), yes) |
| 186 | UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes |
| 187 | else |
| 188 | override CONFIG_INTERNAL = no |
| 189 | endif |
| 190 | ifeq ($(CONFIG_RAYER_SPI), yes) |
| 191 | UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes |
| 192 | else |
| 193 | override CONFIG_RAYER_SPI = no |
| 194 | endif |
| 195 | ifeq ($(CONFIG_NIC3COM), yes) |
| 196 | UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes |
| 197 | else |
| 198 | override CONFIG_NIC3COM = no |
| 199 | endif |
| 200 | ifeq ($(CONFIG_GFXNVIDIA), yes) |
| 201 | UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes |
| 202 | else |
| 203 | override CONFIG_GFXNVIDIA = no |
| 204 | endif |
| 205 | ifeq ($(CONFIG_SATASII), yes) |
| 206 | UNSUPPORTED_FEATURES += CONFIG_SATASII=yes |
| 207 | else |
| 208 | override CONFIG_SATASII = no |
| 209 | endif |
| 210 | ifeq ($(CONFIG_ATAHPT), yes) |
| 211 | UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes |
| 212 | else |
| 213 | override CONFIG_ATAHPT = no |
| 214 | endif |
Jonathan Kollasch | 7f0f3fa | 2014-06-01 10:26:23 +0000 | [diff] [blame] | 215 | ifeq ($(CONFIG_ATAVIA), yes) |
| 216 | UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes |
| 217 | else |
| 218 | override CONFIG_ATAVIA = no |
| 219 | endif |
Kyösti Mälkki | 72d42f8 | 2014-06-01 23:48:31 +0000 | [diff] [blame] | 220 | ifeq ($(CONFIG_IT8212), yes) |
| 221 | UNSUPPORTED_FEATURES += CONFIG_IT8212=yes |
| 222 | else |
| 223 | override CONFIG_IT8212 = no |
| 224 | endif |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 225 | ifeq ($(CONFIG_DRKAISER), yes) |
| 226 | UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes |
| 227 | else |
| 228 | override CONFIG_DRKAISER = no |
| 229 | endif |
| 230 | ifeq ($(CONFIG_NICREALTEK), yes) |
| 231 | UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes |
| 232 | else |
| 233 | override CONFIG_NICREALTEK = no |
| 234 | endif |
| 235 | ifeq ($(CONFIG_NICNATSEMI), yes) |
| 236 | UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes |
| 237 | else |
| 238 | override CONFIG_NICNATSEMI = no |
| 239 | endif |
| 240 | ifeq ($(CONFIG_NICINTEL), yes) |
| 241 | UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes |
| 242 | else |
| 243 | override CONFIG_NICINTEL = no |
| 244 | endif |
Ricardo Ribalda Delgado | 2a41f0a | 2014-07-28 20:35:21 +0000 | [diff] [blame] | 245 | ifeq ($(CONFIG_NICINTEL_EEPROM), yes) |
| 246 | UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes |
| 247 | else |
| 248 | override CONFIG_NICINTEL_EEPROM = no |
| 249 | endif |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 250 | ifeq ($(CONFIG_NICINTEL_SPI), yes) |
| 251 | UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes |
| 252 | else |
| 253 | override CONFIG_NICINTEL_SPI = no |
| 254 | endif |
| 255 | ifeq ($(CONFIG_OGP_SPI), yes) |
| 256 | UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes |
| 257 | else |
| 258 | override CONFIG_OGP_SPI = no |
| 259 | endif |
| 260 | ifeq ($(CONFIG_SATAMV), yes) |
| 261 | UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes |
| 262 | else |
| 263 | override CONFIG_SATAMV = no |
| 264 | endif |
| 265 | endif |
| 266 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 267 | ifeq ($(TARGET_OS), libpayload) |
Stefan Tauner | 8e19b04 | 2013-08-28 09:55:04 +0000 | [diff] [blame] | 268 | ifeq ($(MAKECMDGOALS),) |
| 269 | .DEFAULT_GOAL := libflashrom.a |
| 270 | $(info Setting default goal to libflashrom.a) |
| 271 | endif |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 272 | FLASHROM_CFLAGS += -DSTANDALONE |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 273 | ifeq ($(CONFIG_DUMMY), yes) |
| 274 | UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes |
| 275 | else |
| 276 | override CONFIG_DUMMY = no |
| 277 | endif |
Carl-Daniel Hailfinger | 11990da | 2013-07-13 23:21:05 +0000 | [diff] [blame] | 278 | # Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support). |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 279 | ifeq ($(CONFIG_BUSPIRATE_SPI), yes) |
| 280 | UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes |
| 281 | else |
| 282 | override CONFIG_BUSPIRATE_SPI = no |
| 283 | endif |
| 284 | ifeq ($(CONFIG_SERPROG), yes) |
| 285 | UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes |
| 286 | else |
| 287 | override CONFIG_SERPROG = no |
| 288 | endif |
Carl-Daniel Hailfinger | 11990da | 2013-07-13 23:21:05 +0000 | [diff] [blame] | 289 | ifeq ($(CONFIG_PONY_SPI), yes) |
| 290 | UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes |
| 291 | else |
| 292 | override CONFIG_PONY_SPI = no |
| 293 | endif |
Justin Chevrier | 66e554b | 2015-02-08 21:58:10 +0000 | [diff] [blame] | 294 | # Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported with libpayload (missing libusb support) |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 295 | ifeq ($(CONFIG_DEDIPROG), yes) |
| 296 | UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes |
| 297 | else |
| 298 | override CONFIG_DEDIPROG = no |
| 299 | endif |
| 300 | ifeq ($(CONFIG_FT2232_SPI), yes) |
| 301 | UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes |
| 302 | else |
| 303 | override CONFIG_FT2232_SPI = no |
| 304 | endif |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 305 | ifeq ($(CONFIG_USBBLASTER_SPI), yes) |
| 306 | UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes |
| 307 | else |
| 308 | override CONFIG_USBBLASTER_SPI = no |
| 309 | endif |
Justin Chevrier | 66e554b | 2015-02-08 21:58:10 +0000 | [diff] [blame] | 310 | ifeq ($(CONFIG_PICKIT2_SPI), yes) |
| 311 | UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes |
| 312 | else |
| 313 | override CONFIG_PICKIT2_SPI = no |
| 314 | endif |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 315 | endif |
| 316 | |
Carl-Daniel Hailfinger | 8541d23 | 2012-02-16 21:00:27 +0000 | [diff] [blame] | 317 | ifneq ($(TARGET_OS), Linux) |
| 318 | ifeq ($(CONFIG_LINUX_SPI), yes) |
| 319 | UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes |
| 320 | else |
| 321 | override CONFIG_LINUX_SPI = no |
| 322 | endif |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 323 | ifeq ($(CONFIG_MSTARDDC_SPI), yes) |
| 324 | UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes |
| 325 | else |
| 326 | override CONFIG_MSTARDDC_SPI = no |
| 327 | endif |
Carl-Daniel Hailfinger | 8541d23 | 2012-02-16 21:00:27 +0000 | [diff] [blame] | 328 | endif |
| 329 | |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 330 | ############################################################################### |
| 331 | # General architecture-specific settings. |
| 332 | # Like above for the OS, below we verify user-supplied options depending on the target architecture. |
| 333 | |
Uwe Hermann | 44ffd58 | 2011-08-20 14:16:00 +0000 | [diff] [blame] | 334 | # Determine the destination processor architecture. |
| 335 | # IMPORTANT: The following line must be placed before ARCH is ever used |
| 336 | # (of course), but should come after any lines setting CC because the line |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 337 | # below uses CC itself. |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 338 | override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"')) |
Uwe Hermann | 44ffd58 | 2011-08-20 14:16:00 +0000 | [diff] [blame] | 339 | |
Stefan Tauner | fb2d77c | 2015-02-10 08:03:10 +0000 | [diff] [blame] | 340 | # PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM. |
David Hendricks | b286da7 | 2012-02-13 00:35:35 +0000 | [diff] [blame] | 341 | # Right now this means the drivers below only work on x86. |
| 342 | ifneq ($(ARCH), x86) |
Uwe Hermann | 21b10c6 | 2011-07-29 12:13:01 +0000 | [diff] [blame] | 343 | ifeq ($(CONFIG_NIC3COM), yes) |
| 344 | UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes |
| 345 | else |
| 346 | override CONFIG_NIC3COM = no |
| 347 | endif |
| 348 | ifeq ($(CONFIG_NICREALTEK), yes) |
| 349 | UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes |
| 350 | else |
| 351 | override CONFIG_NICREALTEK = no |
| 352 | endif |
| 353 | ifeq ($(CONFIG_NICNATSEMI), yes) |
| 354 | UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes |
| 355 | else |
| 356 | override CONFIG_NICNATSEMI = no |
| 357 | endif |
| 358 | ifeq ($(CONFIG_RAYER_SPI), yes) |
| 359 | UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes |
| 360 | else |
| 361 | override CONFIG_RAYER_SPI = no |
| 362 | endif |
| 363 | ifeq ($(CONFIG_ATAHPT), yes) |
| 364 | UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes |
| 365 | else |
| 366 | override CONFIG_ATAHPT = no |
| 367 | endif |
| 368 | ifeq ($(CONFIG_SATAMV), yes) |
| 369 | UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes |
| 370 | else |
| 371 | override CONFIG_SATAMV = no |
| 372 | endif |
| 373 | endif |
| 374 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 375 | ############################################################################### |
| 376 | # Flash chip drivers and bus support infrastructure. |
| 377 | |
Stefan Tauner | 4404f73 | 2013-09-12 08:28:56 +0000 | [diff] [blame] | 378 | CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \ |
Carl-Daniel Hailfinger | a8cf362 | 2014-08-08 08:33:01 +0000 | [diff] [blame] | 379 | sst28sf040.o 82802ab.o \ |
Stefan Tauner | 6ee37e2 | 2012-12-29 15:03:51 +0000 | [diff] [blame] | 380 | sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \ |
Aidan Thornton | db4e87d | 2013-08-27 18:01:53 +0000 | [diff] [blame] | 381 | opaque.o sfdp.o en29lv640b.o at45db.o |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 382 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 383 | ############################################################################### |
| 384 | # Library code. |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 385 | |
Stefan Tauner | 6ad6e01 | 2014-06-12 00:04:32 +0000 | [diff] [blame] | 386 | LIB_OBJS = layout.o flashrom.o udelay.o programmer.o helpers.o |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 387 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 388 | ############################################################################### |
| 389 | # Frontend related stuff. |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 390 | |
Stefan Tauner | 9b32de9 | 2014-08-08 23:52:33 +0000 | [diff] [blame] | 391 | CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 392 | |
Stefan Tauner | ec7a35f | 2013-08-29 00:38:14 +0000 | [diff] [blame] | 393 | # Set the flashrom version string from the highest revision number of the checked out flashrom files. |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 394 | # Note to packagers: Any tree exported with "make export" or "make tarball" |
| 395 | # will not require subversion. The downloadable snapshots are already exported. |
Stefan Tauner | d5ff845 | 2015-01-10 09:32:07 +0000 | [diff] [blame] | 396 | SVNVERSION := $(shell ./util/getrevision.sh -u 2>/dev/null ) |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 397 | |
Stefan Tauner | f4651f6 | 2015-03-01 22:05:16 +0000 | [diff] [blame] | 398 | RELEASE := 0.9.8 |
Stefan Tauner | ec7a35f | 2013-08-29 00:38:14 +0000 | [diff] [blame] | 399 | VERSION := $(RELEASE)-$(SVNVERSION) |
Carl-Daniel Hailfinger | 48e5e09 | 2009-08-31 16:25:08 +0000 | [diff] [blame] | 400 | RELEASENAME ?= $(VERSION) |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 401 | |
| 402 | SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"' |
Bernhard Walle | 201bde3 | 2008-01-21 15:24:22 +0000 | [diff] [blame] | 403 | |
Stefan Tauner | d5ff845 | 2015-01-10 09:32:07 +0000 | [diff] [blame] | 404 | # Inform user if there is no meaningful version string. If there is version information from a VCS print |
| 405 | # something anyway because $(info...) will print a line break in any case which would look suspicious. |
Stefan Tauner | 5d1ad35 | 2015-01-25 23:57:08 +0000 | [diff] [blame] | 406 | # The && between the echos is a workaround for old versions of GNU make that issue the error "unterminated |
| 407 | # variable reference" if a semicolon is used instead. |
| 408 | $(info $(shell ./util/getrevision.sh -c 2>/dev/null || echo "Files don't seem to be under version control." && \ |
Stefan Tauner | d5ff845 | 2015-01-10 09:32:07 +0000 | [diff] [blame] | 409 | echo "Replacing all version templates with $(VERSION)." )) |
| 410 | |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 411 | ############################################################################### |
| 412 | # Default settings of CONFIG_* variables. |
| 413 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 414 | # Always enable internal/onboard support for now. |
| 415 | CONFIG_INTERNAL ?= yes |
| 416 | |
Stefan Tauner | 52b6e9d | 2013-04-01 00:46:05 +0000 | [diff] [blame] | 417 | # Always enable serprog for now. |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 418 | CONFIG_SERPROG ?= yes |
| 419 | |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 420 | # RayeR SPIPGM hardware support |
| 421 | CONFIG_RAYER_SPI ?= yes |
| 422 | |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 423 | # PonyProg2000 SPI hardware support |
| 424 | CONFIG_PONY_SPI ?= yes |
| 425 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 426 | # Always enable 3Com NICs for now. |
| 427 | CONFIG_NIC3COM ?= yes |
| 428 | |
Carl-Daniel Hailfinger | bf3af29 | 2010-07-29 14:41:46 +0000 | [diff] [blame] | 429 | # Enable NVIDIA graphics cards. Note: write and erase do not work properly. |
| 430 | CONFIG_GFXNVIDIA ?= yes |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 431 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 432 | # Always enable SiI SATA controllers for now. |
| 433 | CONFIG_SATASII ?= yes |
| 434 | |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 435 | # Highpoint (HPT) ATA/RAID controller support. |
| 436 | # IMPORTANT: This code is not yet working! |
| 437 | CONFIG_ATAHPT ?= no |
| 438 | |
Jonathan Kollasch | 7f0f3fa | 2014-06-01 10:26:23 +0000 | [diff] [blame] | 439 | # VIA VT6421A LPC memory support |
| 440 | CONFIG_ATAVIA ?= yes |
| 441 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 442 | # Always enable FT2232 SPI dongles for now. |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 443 | CONFIG_FT2232_SPI ?= yes |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 444 | |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 445 | # Always enable Altera USB-Blaster dongles for now. |
| 446 | CONFIG_USBBLASTER_SPI ?= yes |
| 447 | |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 448 | # MSTAR DDC support needs more tests/reviews/cleanups. |
| 449 | CONFIG_MSTARDDC_SPI ?= no |
| 450 | |
Justin Chevrier | 66e554b | 2015-02-08 21:58:10 +0000 | [diff] [blame] | 451 | # Always enable PICkit2 SPI dongles for now. |
| 452 | CONFIG_PICKIT2_SPI ?= yes |
| 453 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 454 | # Always enable dummy tracing for now. |
| 455 | CONFIG_DUMMY ?= yes |
| 456 | |
| 457 | # Always enable Dr. Kaiser for now. |
| 458 | CONFIG_DRKAISER ?= yes |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 459 | |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 460 | # Always enable Realtek NICs for now. |
| 461 | CONFIG_NICREALTEK ?= yes |
| 462 | |
Andrew Morgan | c29c2e7 | 2010-06-07 22:37:54 +0000 | [diff] [blame] | 463 | # Disable National Semiconductor NICs until support is complete and tested. |
| 464 | CONFIG_NICNATSEMI ?= no |
| 465 | |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 466 | # Always enable Intel NICs for now. |
| 467 | CONFIG_NICINTEL ?= yes |
| 468 | |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 469 | # Always enable SPI on Intel NICs for now. |
| 470 | CONFIG_NICINTEL_SPI ?= yes |
| 471 | |
Ricardo Ribalda Delgado | 2a41f0a | 2014-07-28 20:35:21 +0000 | [diff] [blame] | 472 | # Always enable EEPROM on Intel NICs for now. |
| 473 | CONFIG_NICINTEL_EEPROM ?= yes |
| 474 | |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 475 | # Always enable SPI on OGP cards for now. |
| 476 | CONFIG_OGP_SPI ?= yes |
| 477 | |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 478 | # Always enable Bus Pirate SPI for now. |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 479 | CONFIG_BUSPIRATE_SPI ?= yes |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 480 | |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 481 | # Disable Dediprog SF100 until support is complete and tested. |
| 482 | CONFIG_DEDIPROG ?= no |
| 483 | |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 484 | # Always enable Marvell SATA controllers for now. |
| 485 | CONFIG_SATAMV ?= yes |
| 486 | |
Carl-Daniel Hailfinger | 8541d23 | 2012-02-16 21:00:27 +0000 | [diff] [blame] | 487 | # Enable Linux spidev interface by default. We disable it on non-Linux targets. |
| 488 | CONFIG_LINUX_SPI ?= yes |
| 489 | |
Kyösti Mälkki | 72d42f8 | 2014-06-01 23:48:31 +0000 | [diff] [blame] | 490 | # Always enable ITE IT8212F PATA controllers for now. |
| 491 | CONFIG_IT8212 ?= yes |
| 492 | |
Carl-Daniel Hailfinger | 6161ff1 | 2009-11-16 21:22:24 +0000 | [diff] [blame] | 493 | # Disable wiki printing by default. It is only useful if you have wiki access. |
Uwe Hermann | 2db77a0 | 2010-06-04 17:07:39 +0000 | [diff] [blame] | 494 | CONFIG_PRINT_WIKI ?= no |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 495 | |
Patrick Georgi | ced7ab6 | 2015-01-19 19:52:34 +0000 | [diff] [blame] | 496 | # Enable all features if CONFIG_EVERYTHING=yes is given |
| 497 | ifeq ($(CONFIG_EVERYTHING), yes) |
| 498 | $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\ |
| 499 | $(if $(filter no, $($(var))),\ |
| 500 | $(eval $(var)=yes))) |
| 501 | endif |
| 502 | |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 503 | # Bitbanging SPI infrastructure, default off unless needed. |
| 504 | ifeq ($(CONFIG_RAYER_SPI), yes) |
| 505 | override CONFIG_BITBANG_SPI = yes |
| 506 | else |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 507 | ifeq ($(CONFIG_PONY_SPI), yes) |
| 508 | override CONFIG_BITBANG_SPI = yes |
| 509 | else |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 510 | ifeq ($(CONFIG_INTERNAL), yes) |
| 511 | override CONFIG_BITBANG_SPI = yes |
| 512 | else |
| 513 | ifeq ($(CONFIG_NICINTEL_SPI), yes) |
| 514 | override CONFIG_BITBANG_SPI = yes |
| 515 | else |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 516 | ifeq ($(CONFIG_OGP_SPI), yes) |
| 517 | override CONFIG_BITBANG_SPI = yes |
| 518 | else |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 519 | CONFIG_BITBANG_SPI ?= no |
| 520 | endif |
| 521 | endif |
| 522 | endif |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 523 | endif |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 524 | endif |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 525 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 526 | ############################################################################### |
Sean Nelson | 4c6d3a4 | 2013-09-11 23:35:03 +0000 | [diff] [blame] | 527 | # Handle CONFIG_* variables that depend on others set (and verified) above. |
| 528 | |
| 529 | # The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled. |
| 530 | ifeq ($(TARGET_OS), libpayload) |
| 531 | ifeq ($(CONFIG_INTERNAL), yes) |
| 532 | ifeq ($(CONFIG_INTERNAL_DMI), no) |
| 533 | UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no |
| 534 | else |
| 535 | override CONFIG_INTERNAL_DMI = yes |
| 536 | endif |
| 537 | endif |
| 538 | endif |
| 539 | |
| 540 | # Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode. |
| 541 | CONFIG_INTERNAL_DMI ?= yes |
| 542 | |
| 543 | ############################################################################### |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 544 | # Programmer drivers and programmer support infrastructure. |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 545 | # Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below. |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 546 | |
Stefan Tauner | fd0d413 | 2012-09-25 21:24:55 +0000 | [diff] [blame] | 547 | FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)' |
Stefan Tauner | 265fcac | 2014-06-02 00:12:23 +0000 | [diff] [blame] | 548 | FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"' |
Stefan Tauner | fd0d413 | 2012-09-25 21:24:55 +0000 | [diff] [blame] | 549 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 550 | ifeq ($(CONFIG_INTERNAL), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 551 | FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1' |
Sean Nelson | 4c6d3a4 | 2013-09-11 23:35:03 +0000 | [diff] [blame] | 552 | PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 553 | ifeq ($(ARCH), x86) |
Rudolf Marek | 70e1459 | 2013-07-25 22:58:56 +0000 | [diff] [blame] | 554 | PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o |
Sean Nelson | 4c6d3a4 | 2013-09-11 23:35:03 +0000 | [diff] [blame] | 555 | PROGRAMMER_OBJS += ichspi.o ich_descriptors.o dmi.o |
| 556 | ifeq ($(CONFIG_INTERNAL_DMI), yes) |
| 557 | FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1' |
| 558 | endif |
Carl-Daniel Hailfinger | 91199a1 | 2011-07-07 06:59:18 +0000 | [diff] [blame] | 559 | else |
| 560 | endif |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 561 | NEED_PCI := yes |
| 562 | endif |
| 563 | |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 564 | ifeq ($(CONFIG_SERPROG), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 565 | FEATURE_CFLAGS += -D'CONFIG_SERPROG=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 566 | PROGRAMMER_OBJS += serprog.o |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 567 | NEED_SERIAL := yes |
| 568 | NEED_NET := yes |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 569 | endif |
| 570 | |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 571 | ifeq ($(CONFIG_RAYER_SPI), yes) |
| 572 | FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1' |
| 573 | PROGRAMMER_OBJS += rayer_spi.o |
| 574 | # Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct. |
| 575 | NEED_PCI := yes |
| 576 | endif |
| 577 | |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 578 | ifeq ($(CONFIG_PONY_SPI), yes) |
| 579 | FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1' |
| 580 | PROGRAMMER_OBJS += pony_spi.o |
| 581 | NEED_SERIAL := yes |
| 582 | endif |
| 583 | |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 584 | ifeq ($(CONFIG_BITBANG_SPI), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 585 | FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 586 | PROGRAMMER_OBJS += bitbang_spi.o |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 587 | endif |
| 588 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 589 | ifeq ($(CONFIG_NIC3COM), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 590 | FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 591 | PROGRAMMER_OBJS += nic3com.o |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 592 | NEED_PCI := yes |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 593 | endif |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 594 | |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 595 | ifeq ($(CONFIG_GFXNVIDIA), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 596 | FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 597 | PROGRAMMER_OBJS += gfxnvidia.o |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 598 | NEED_PCI := yes |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 599 | endif |
| 600 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 601 | ifeq ($(CONFIG_SATASII), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 602 | FEATURE_CFLAGS += -D'CONFIG_SATASII=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 603 | PROGRAMMER_OBJS += satasii.o |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 604 | NEED_PCI := yes |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 605 | endif |
| 606 | |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 607 | ifeq ($(CONFIG_ATAHPT), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 608 | FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1' |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 609 | PROGRAMMER_OBJS += atahpt.o |
| 610 | NEED_PCI := yes |
| 611 | endif |
| 612 | |
Jonathan Kollasch | 7f0f3fa | 2014-06-01 10:26:23 +0000 | [diff] [blame] | 613 | ifeq ($(CONFIG_ATAVIA), yes) |
| 614 | FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1' |
| 615 | PROGRAMMER_OBJS += atavia.o |
| 616 | NEED_PCI := yes |
| 617 | endif |
| 618 | |
Kyösti Mälkki | 72d42f8 | 2014-06-01 23:48:31 +0000 | [diff] [blame] | 619 | ifeq ($(CONFIG_IT8212), yes) |
| 620 | FEATURE_CFLAGS += -D'CONFIG_IT8212=1' |
| 621 | PROGRAMMER_OBJS += it8212.o |
| 622 | NEED_PCI := yes |
| 623 | endif |
| 624 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 625 | ifeq ($(CONFIG_FT2232_SPI), yes) |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 626 | # This is a totally ugly hack. |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 627 | FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'") |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 628 | NEED_FTDI := yes |
| 629 | PROGRAMMER_OBJS += ft2232_spi.o |
| 630 | endif |
| 631 | |
| 632 | ifeq ($(CONFIG_USBBLASTER_SPI), yes) |
| 633 | # This is a totally ugly hack. |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 634 | FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'") |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 635 | NEED_FTDI := yes |
| 636 | PROGRAMMER_OBJS += usbblaster_spi.o |
| 637 | endif |
| 638 | |
Justin Chevrier | 66e554b | 2015-02-08 21:58:10 +0000 | [diff] [blame] | 639 | ifeq ($(CONFIG_PICKIT2_SPI), yes) |
| 640 | FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1' |
| 641 | PROGRAMMER_OBJS += pickit2_spi.o |
| 642 | NEED_USB := yes |
| 643 | endif |
| 644 | |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 645 | ifeq ($(NEED_FTDI), yes) |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 646 | FTDILIBS := $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; $(PKG_CONFIG) --libs libftdi1 || $(PKG_CONFIG) --libs libftdi || printf "%s" "-lftdi -lusb") |
| 647 | FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'") |
| 648 | FTDI_INCLUDES := $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; $(PKG_CONFIG) --cflags-only-I libftdi1) |
Alexandru Gagniuc | 3d06abe | 2015-12-25 22:42:45 +0000 | [diff] [blame] | 649 | FEATURE_CFLAGS += $(FTDI_INCLUDES) |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 650 | FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)") |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 651 | # We can't set NEED_USB here because that would transform libftdi auto-enabling |
| 652 | # into a hard requirement for libusb, defeating the purpose of auto-enabling. |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 653 | endif |
| 654 | |
| 655 | ifeq ($(CONFIG_DUMMY), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 656 | FEATURE_CFLAGS += -D'CONFIG_DUMMY=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 657 | PROGRAMMER_OBJS += dummyflasher.o |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 658 | endif |
| 659 | |
| 660 | ifeq ($(CONFIG_DRKAISER), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 661 | FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 662 | PROGRAMMER_OBJS += drkaiser.o |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 663 | NEED_PCI := yes |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 664 | endif |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 665 | |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 666 | ifeq ($(CONFIG_NICREALTEK), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 667 | FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1' |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 668 | PROGRAMMER_OBJS += nicrealtek.o |
| 669 | NEED_PCI := yes |
| 670 | endif |
| 671 | |
Andrew Morgan | c29c2e7 | 2010-06-07 22:37:54 +0000 | [diff] [blame] | 672 | ifeq ($(CONFIG_NICNATSEMI), yes) |
| 673 | FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1' |
| 674 | PROGRAMMER_OBJS += nicnatsemi.o |
| 675 | NEED_PCI := yes |
| 676 | endif |
| 677 | |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 678 | ifeq ($(CONFIG_NICINTEL), yes) |
| 679 | FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1' |
| 680 | PROGRAMMER_OBJS += nicintel.o |
| 681 | NEED_PCI := yes |
| 682 | endif |
| 683 | |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 684 | ifeq ($(CONFIG_NICINTEL_SPI), yes) |
| 685 | FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1' |
| 686 | PROGRAMMER_OBJS += nicintel_spi.o |
| 687 | NEED_PCI := yes |
| 688 | endif |
| 689 | |
Ricardo Ribalda Delgado | 2a41f0a | 2014-07-28 20:35:21 +0000 | [diff] [blame] | 690 | ifeq ($(CONFIG_NICINTEL_EEPROM), yes) |
| 691 | FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1' |
| 692 | PROGRAMMER_OBJS += nicintel_eeprom.o |
| 693 | NEED_PCI := yes |
| 694 | endif |
| 695 | |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 696 | ifeq ($(CONFIG_OGP_SPI), yes) |
| 697 | FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1' |
| 698 | PROGRAMMER_OBJS += ogp_spi.o |
| 699 | NEED_PCI := yes |
| 700 | endif |
| 701 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 702 | ifeq ($(CONFIG_BUSPIRATE_SPI), yes) |
| 703 | FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 704 | PROGRAMMER_OBJS += buspirate_spi.o |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 705 | NEED_SERIAL := yes |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 706 | endif |
| 707 | |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 708 | ifeq ($(CONFIG_DEDIPROG), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 709 | FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1' |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 710 | PROGRAMMER_OBJS += dediprog.o |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 711 | NEED_USB := yes |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 712 | endif |
| 713 | |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 714 | ifeq ($(CONFIG_SATAMV), yes) |
| 715 | FEATURE_CFLAGS += -D'CONFIG_SATAMV=1' |
| 716 | PROGRAMMER_OBJS += satamv.o |
| 717 | NEED_PCI := yes |
| 718 | endif |
| 719 | |
Carl-Daniel Hailfinger | 8541d23 | 2012-02-16 21:00:27 +0000 | [diff] [blame] | 720 | ifeq ($(CONFIG_LINUX_SPI), yes) |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 721 | # This is a totally ugly hack. |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 722 | FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_SPI_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_SPI=1'") |
Carl-Daniel Hailfinger | 8541d23 | 2012-02-16 21:00:27 +0000 | [diff] [blame] | 723 | PROGRAMMER_OBJS += linux_spi.o |
| 724 | endif |
| 725 | |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 726 | ifeq ($(CONFIG_MSTARDDC_SPI), yes) |
| 727 | # This is a totally ugly hack. |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 728 | FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_I2C_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_MSTARDDC_SPI=1'") |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 729 | NEED_LINUX_I2C := yes |
| 730 | PROGRAMMER_OBJS += mstarddc_spi.o |
| 731 | endif |
| 732 | |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 733 | ifeq ($(NEED_SERIAL), yes) |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 734 | LIB_OBJS += serial.o |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 735 | endif |
| 736 | |
| 737 | ifeq ($(NEED_NET), yes) |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 738 | ifeq ($(TARGET_OS), SunOS) |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 739 | LIBS += -lsocket |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 740 | endif |
Carl-Daniel Hailfinger | e51ea10 | 2009-11-23 19:20:11 +0000 | [diff] [blame] | 741 | endif |
| 742 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 743 | ifeq ($(NEED_PCI), yes) |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 744 | CHECK_LIBPCI = yes |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 745 | FEATURE_CFLAGS += -D'NEED_PCI=1' |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 746 | FEATURE_CFLAGS += $(call debug_shell,grep -q "OLD_PCI_GET_DEV := yes" .libdeps && printf "%s" "-D'OLD_PCI_GET_DEV=1'") |
Stefan Tauner | 5673450 | 2015-02-08 21:58:04 +0000 | [diff] [blame] | 747 | |
Carl-Daniel Hailfinger | fb0828f | 2010-02-12 19:35:25 +0000 | [diff] [blame] | 748 | PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 749 | ifeq ($(TARGET_OS), NetBSD) |
Carl-Daniel Hailfinger | 460b282 | 2010-06-04 23:24:57 +0000 | [diff] [blame] | 750 | # The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci. |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 751 | PCILIBS += -lpciutils -lpci |
Carl-Daniel Hailfinger | 460b282 | 2010-06-04 23:24:57 +0000 | [diff] [blame] | 752 | # For (i386|x86_64)_iopl(2). |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 753 | PCILIBS += -l$(shell uname -p) |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 754 | else |
Stefan Tauner | be62d3f | 2015-01-10 09:32:44 +0000 | [diff] [blame] | 755 | |
Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 756 | PCILIBS += -lpci |
Stefan Tauner | be62d3f | 2015-01-10 09:32:44 +0000 | [diff] [blame] | 757 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 758 | ifeq ($(TARGET_OS), OpenBSD) |
Carl-Daniel Hailfinger | b63b067 | 2010-07-02 17:12:50 +0000 | [diff] [blame] | 759 | # For (i386|amd64)_iopl(2). |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 760 | PCILIBS += -l$(shell uname -m) |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 761 | else |
| 762 | ifeq ($(TARGET_OS), Darwin) |
| 763 | # DirectHW framework can be found in the DirectHW library. |
Stefan Tauner | e34e3e8 | 2013-01-01 00:06:51 +0000 | [diff] [blame] | 764 | PCILIBS += -framework IOKit -framework DirectHW |
Carl-Daniel Hailfinger | b63b067 | 2010-07-02 17:12:50 +0000 | [diff] [blame] | 765 | endif |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 766 | endif |
Jonathan A. Kollasch | 3646c8f | 2010-01-08 21:18:08 +0000 | [diff] [blame] | 767 | endif |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 768 | endif |
| 769 | |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 770 | ifeq ($(NEED_USB), yes) |
| 771 | CHECK_LIBUSB0 = yes |
| 772 | FEATURE_CFLAGS += -D'NEED_USB=1' |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 773 | USBLIBS := $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; $(PKG_CONFIG) --libs libusb || printf "%s" "-lusb") |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 774 | endif |
| 775 | |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 776 | ifeq ($(CONFIG_PRINT_WIKI), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 777 | FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 778 | CLI_OBJS += print_wiki.o |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 779 | endif |
| 780 | |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 781 | FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'") |
Carl-Daniel Hailfinger | 132e2ec | 2010-03-27 16:36:40 +0000 | [diff] [blame] | 782 | |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 783 | # We could use PULLED_IN_LIBS, but that would be ugly. |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 784 | FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz") |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 785 | |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 786 | LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS) |
Stefan Tauner | d94d25d | 2012-07-28 03:17:15 +0000 | [diff] [blame] | 787 | OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS) |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 788 | |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 789 | all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8 |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 790 | ifeq ($(ARCH), x86) |
| 791 | @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX) |
| 792 | endif |
| 793 | |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 794 | $(PROGRAM)$(EXEC_SUFFIX): $(OBJS) |
Carl-Daniel Hailfinger | 11990da | 2013-07-13 23:21:05 +0000 | [diff] [blame] | 795 | $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 796 | |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 797 | libflashrom.a: $(LIBFLASHROM_OBJS) |
| 798 | $(AR) rcs $@ $^ |
| 799 | $(RANLIB) $@ |
| 800 | |
Carl-Daniel Hailfinger | 8ef7dce | 2009-07-10 20:19:48 +0000 | [diff] [blame] | 801 | # TAROPTIONS reduces information leakage from the packager's system. |
| 802 | # If other tar programs support command line arguments for setting uid/gid of |
| 803 | # stored files, they can be handled here as well. |
| 804 | TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root") |
Carl-Daniel Hailfinger | b18ecbc | 2009-06-19 14:20:34 +0000 | [diff] [blame] | 805 | |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 806 | %.o: %.c .features |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 807 | $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $< |
Clark Rawlins | 02016f7 | 2008-02-14 23:22:20 +0000 | [diff] [blame] | 808 | |
Carl-Daniel Hailfinger | a0020df | 2010-05-30 22:35:14 +0000 | [diff] [blame] | 809 | # Make sure to add all names of generated binaries here. |
| 810 | # This includes all frontends and libflashrom. |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 811 | # We don't use EXEC_SUFFIX here because we want to clean everything. |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 812 | clean: |
Stefan Tauner | 4c72315 | 2016-01-14 22:47:55 +0000 | [diff] [blame^] | 813 | rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE) |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 814 | @+$(MAKE) -C util/ich_descriptors_tool/ clean |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 815 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 816 | distclean: clean |
Stefan Reinauer | e2f0158 | 2010-06-07 11:08:07 +0000 | [diff] [blame] | 817 | rm -f .features .libdeps |
Christian Ruppert | db9d9f4 | 2009-05-14 14:17:07 +0000 | [diff] [blame] | 818 | |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 819 | strip: $(PROGRAM)$(EXEC_SUFFIX) |
| 820 | $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 821 | |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 822 | # to define test programs we use verbatim variables, which get exported |
| 823 | # to environment variables and are referenced with $$<varname> later |
| 824 | |
| 825 | define COMPILER_TEST |
| 826 | int main(int argc, char **argv) |
| 827 | { |
| 828 | (void) argc; |
| 829 | (void) argv; |
| 830 | return 0; |
| 831 | } |
| 832 | endef |
| 833 | export COMPILER_TEST |
| 834 | |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 835 | compiler: featuresavailable |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 836 | @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE) |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 837 | @echo "$$COMPILER_TEST" > .test.c |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 838 | @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \ |
| 839 | echo "found." || { echo "not found."; \ |
| 840 | rm -f .test.c .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1 |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 841 | @rm -f .test.c .test$(EXEC_SUFFIX) |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 842 | @printf "Target arch is " |
Carl-Daniel Hailfinger | 91199a1 | 2011-07-07 06:59:18 +0000 | [diff] [blame] | 843 | @# FreeBSD wc will output extraneous whitespace. |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 844 | @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \ |
Carl-Daniel Hailfinger | 91199a1 | 2011-07-07 06:59:18 +0000 | [diff] [blame] | 845 | ( echo "unknown. Aborting."; exit 1) |
| 846 | @printf "%s\n" '$(ARCH)' |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 847 | @printf "Target OS is " |
| 848 | @# FreeBSD wc will output extraneous whitespace. |
| 849 | @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \ |
| 850 | ( echo "unknown. Aborting."; exit 1) |
| 851 | @printf "%s\n" '$(TARGET_OS)' |
Stefan Tauner | d6c17f6 | 2013-09-12 14:04:31 +0000 | [diff] [blame] | 852 | ifeq ($(TARGET_OS), libpayload) |
| 853 | @$(CC) --version 2>&1 | grep -q coreboot || \ |
| 854 | ( echo "Warning: It seems you are not using coreboot's reference compiler."; \ |
| 855 | echo "This might work but usually does not, please beware." ) |
| 856 | endif |
Carl-Daniel Hailfinger | 4cb7a96 | 2009-06-16 09:31:51 +0000 | [diff] [blame] | 857 | |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 858 | define LIBPCI_TEST |
| 859 | /* Avoid a failing test due to libpci header symbol shadowing breakage */ |
| 860 | #define index shadow_workaround_index |
Stefan Tauner | 8d21ff1 | 2015-01-10 09:33:06 +0000 | [diff] [blame] | 861 | #if !defined __NetBSD__ |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 862 | #include <pci/pci.h> |
Stefan Tauner | c65b855 | 2013-09-12 15:48:39 +0000 | [diff] [blame] | 863 | #else |
| 864 | #include <pciutils/pci.h> |
| 865 | #endif |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 866 | struct pci_access *pacc; |
| 867 | int main(int argc, char **argv) |
| 868 | { |
| 869 | (void) argc; |
| 870 | (void) argv; |
| 871 | pacc = pci_alloc(); |
| 872 | return 0; |
| 873 | } |
| 874 | endef |
| 875 | export LIBPCI_TEST |
| 876 | |
Stefan Tauner | 5673450 | 2015-02-08 21:58:04 +0000 | [diff] [blame] | 877 | define PCI_GET_DEV_TEST |
| 878 | /* Avoid a failing test due to libpci header symbol shadowing breakage */ |
| 879 | #define index shadow_workaround_index |
| 880 | #if !defined __NetBSD__ |
| 881 | #include <pci/pci.h> |
| 882 | #else |
| 883 | #include <pciutils/pci.h> |
| 884 | #endif |
| 885 | struct pci_access *pacc; |
| 886 | struct pci_dev *dev = {0}; |
| 887 | int main(int argc, char **argv) |
| 888 | { |
| 889 | (void) argc; |
| 890 | (void) argv; |
| 891 | pacc = pci_alloc(); |
| 892 | dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1); |
| 893 | return 0; |
| 894 | } |
| 895 | endef |
| 896 | export PCI_GET_DEV_TEST |
| 897 | |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 898 | define LIBUSB0_TEST |
Stefan Tauner | 0cbd8c2 | 2015-01-26 22:06:04 +0000 | [diff] [blame] | 899 | #include "platform.h" |
| 900 | #if IS_WINDOWS |
| 901 | #include <lusb0_usb.h> |
| 902 | #else |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 903 | #include <usb.h> |
Stefan Tauner | 0cbd8c2 | 2015-01-26 22:06:04 +0000 | [diff] [blame] | 904 | #endif |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 905 | int main(int argc, char **argv) |
| 906 | { |
| 907 | (void) argc; |
| 908 | (void) argv; |
| 909 | usb_init(); |
| 910 | return 0; |
| 911 | } |
| 912 | endef |
| 913 | export LIBUSB0_TEST |
| 914 | |
| 915 | hwlibs: compiler |
| 916 | @printf "" > .libdeps |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 917 | ifeq ($(CHECK_LIBPCI), yes) |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 918 | @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE) |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 919 | @echo "$$LIBPCI_TEST" > .test.c |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 920 | @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \ |
| 921 | echo "found." || { echo "not found."; echo; \ |
| 922 | echo "Please install libpci headers."; \ |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 923 | echo "See README for more information."; echo; \ |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 924 | rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1 |
| 925 | @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE) |
Stefan Tauner | 5673450 | 2015-02-08 21:58:04 +0000 | [diff] [blame] | 926 | @echo "$$PCI_GET_DEV_TEST" > .test.c |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 927 | @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \ |
Stefan Tauner | 5673450 | 2015-02-08 21:58:04 +0000 | [diff] [blame] | 928 | ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \ |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 929 | ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) |
| 930 | @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE) |
| 931 | @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \ |
| 932 | echo "yes." || { echo "no."; \ |
| 933 | printf "Checking if libz+libpci are present and sufficient..." ; \ |
| 934 | { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \ |
| 935 | echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \ |
Carl-Daniel Hailfinger | 9979eac | 2010-03-22 12:29:45 +0000 | [diff] [blame] | 936 | echo "Please install libpci (package pciutils) and/or libz."; \ |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 937 | echo "See README for more information."; echo; \ |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 938 | rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1 |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 939 | @rm -f .test.c .test.o .test$(EXEC_SUFFIX) |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 940 | endif |
| 941 | ifeq ($(CHECK_LIBUSB0), yes) |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 942 | @printf "Checking for libusb-0.1/libusb-compat headers... " | tee -a $(BUILD_DETAILS_FILE) |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 943 | @echo "$$LIBUSB0_TEST" > .test.c |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 944 | @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \ |
| 945 | echo "found." || { echo "not found."; echo; \ |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 946 | echo "Please install libusb-0.1 headers or libusb-compat headers."; \ |
| 947 | echo "See README for more information."; echo; \ |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 948 | rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1 |
| 949 | @printf "Checking if libusb-0.1 is usable... " | tee -a $(BUILD_DETAILS_FILE) |
| 950 | @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >&2 && \ |
| 951 | echo "yes." || { echo "no."; \ |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 952 | echo "Please install libusb-0.1 or libusb-compat."; \ |
| 953 | echo "See README for more information."; echo; \ |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 954 | rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1 |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 955 | @rm -f .test.c .test.o .test$(EXEC_SUFFIX) |
Carl-Daniel Hailfinger | 8a59ff0 | 2009-12-24 03:33:11 +0000 | [diff] [blame] | 956 | endif |
Stefan Reinauer | 53e9625 | 2005-12-01 16:19:24 +0000 | [diff] [blame] | 957 | |
Carl-Daniel Hailfinger | b18ecbc | 2009-06-19 14:20:34 +0000 | [diff] [blame] | 958 | .features: features |
| 959 | |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 960 | # If a user does not explicitly request a non-working feature, we should |
| 961 | # silently disable it. However, if a non-working (does not compile) feature |
| 962 | # is explicitly requested, we should bail out with a descriptive error message. |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 963 | # We also have to check that at least one programmer driver is enabled. |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 964 | featuresavailable: |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 965 | ifeq ($(PROGRAMMER_OBJS),) |
| 966 | @echo "You have to enable at least one programmer driver!" |
| 967 | @false |
| 968 | endif |
| 969 | ifneq ($(UNSUPPORTED_FEATURES), ) |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 970 | @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)" |
| 971 | @false |
| 972 | endif |
| 973 | |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 974 | define FTDI_TEST |
Stefan Tauner | 5c316f9 | 2015-02-08 21:57:52 +0000 | [diff] [blame] | 975 | #include <stdlib.h> |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 976 | #include <ftdi.h> |
| 977 | struct ftdi_context *ftdic = NULL; |
| 978 | int main(int argc, char **argv) |
| 979 | { |
| 980 | (void) argc; |
| 981 | (void) argv; |
| 982 | return ftdi_init(ftdic); |
| 983 | } |
| 984 | endef |
| 985 | export FTDI_TEST |
| 986 | |
Ilya A. Volynets-Evenbakh | 2c714ab | 2012-09-26 00:47:09 +0000 | [diff] [blame] | 987 | define FTDI_232H_TEST |
| 988 | #include <ftdi.h> |
| 989 | enum ftdi_chip_type type = TYPE_232H; |
| 990 | endef |
| 991 | export FTDI_232H_TEST |
| 992 | |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 993 | define UTSNAME_TEST |
| 994 | #include <sys/utsname.h> |
| 995 | struct utsname osinfo; |
| 996 | int main(int argc, char **argv) |
| 997 | { |
| 998 | (void) argc; |
| 999 | (void) argv; |
| 1000 | uname (&osinfo); |
| 1001 | return 0; |
| 1002 | } |
| 1003 | endef |
| 1004 | export UTSNAME_TEST |
| 1005 | |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 1006 | define LINUX_SPI_TEST |
| 1007 | #include <linux/types.h> |
| 1008 | #include <linux/spi/spidev.h> |
| 1009 | |
| 1010 | int main(int argc, char **argv) |
| 1011 | { |
| 1012 | (void) argc; |
| 1013 | (void) argv; |
| 1014 | return 0; |
| 1015 | } |
| 1016 | endef |
| 1017 | export LINUX_SPI_TEST |
| 1018 | |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 1019 | define LINUX_I2C_TEST |
| 1020 | #include <linux/i2c-dev.h> |
| 1021 | #include <linux/i2c.h> |
| 1022 | |
| 1023 | int main(int argc, char **argv) |
| 1024 | { |
| 1025 | (void) argc; |
| 1026 | (void) argv; |
| 1027 | return 0; |
| 1028 | } |
| 1029 | endef |
| 1030 | export LINUX_I2C_TEST |
| 1031 | |
Carl-Daniel Hailfinger | b18ecbc | 2009-06-19 14:20:34 +0000 | [diff] [blame] | 1032 | features: compiler |
| 1033 | @echo "FEATURES := yes" > .features.tmp |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 1034 | ifeq ($(NEED_FTDI), yes) |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1035 | @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE) |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 1036 | @echo "$$FTDI_TEST" > .featuretest.c |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1037 | @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \ |
| 1038 | ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \ |
| 1039 | printf "Checking for FT232H support in libftdi... " ; \ |
| 1040 | echo "$$FTDI_232H_TEST" >> .featuretest.c ; \ |
| 1041 | { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \ |
| 1042 | ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \ |
| 1043 | ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \ |
| 1044 | ) || \ |
| 1045 | ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \ |
| 1046 | 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) |
Carl-Daniel Hailfinger | 8a59ff0 | 2009-12-24 03:33:11 +0000 | [diff] [blame] | 1047 | endif |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 1048 | ifeq ($(CONFIG_LINUX_SPI), yes) |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1049 | @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE) |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 1050 | @echo "$$LINUX_SPI_TEST" > .featuretest.c |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1051 | @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \ |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 1052 | ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \ |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1053 | ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \ |
| 1054 | 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 1055 | endif |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 1056 | ifeq ($(NEED_LINUX_I2C), yes) |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1057 | @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE) |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 1058 | @echo "$$LINUX_I2C_TEST" > .featuretest.c |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1059 | @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \ |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 1060 | ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \ |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1061 | ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \ |
| 1062 | 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) |
Alexandre Boeglin | 80e6471 | 2014-12-20 20:25:19 +0000 | [diff] [blame] | 1063 | endif |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1064 | @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE) |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 1065 | @echo "$$UTSNAME_TEST" > .featuretest.c |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1066 | @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \ |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 1067 | ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \ |
Stefan Tauner | 3f73ffe | 2016-01-07 17:45:59 +0000 | [diff] [blame] | 1068 | ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 1069 | @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features |
| 1070 | @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX) |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 1071 | |
Stefan Tauner | 4c72315 | 2016-01-14 22:47:55 +0000 | [diff] [blame^] | 1072 | $(PROGRAM).8.html: $(PROGRAM).8 |
| 1073 | @groff -mandoc -Thtml $< >$@ |
| 1074 | |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 1075 | $(PROGRAM).8: $(PROGRAM).8.tmpl |
Stefan Tauner | 4c72315 | 2016-01-14 22:47:55 +0000 | [diff] [blame^] | 1076 | @# Add the man page change date and version to the man page |
| 1077 | @sed -e 's#.TH FLASHROM 8 ".*".*#.TH FLASHROM 8 "$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@ |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 1078 | |
| 1079 | install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8 |
Uwe Hermann | c2a9c9c | 2009-05-14 14:51:14 +0000 | [diff] [blame] | 1080 | mkdir -p $(DESTDIR)$(PREFIX)/sbin |
Uwe Hermann | 56b2cb0 | 2009-05-21 15:59:58 +0000 | [diff] [blame] | 1081 | mkdir -p $(DESTDIR)$(MANDIR)/man8 |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 1082 | $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin |
Uwe Hermann | 56b2cb0 | 2009-05-21 15:59:58 +0000 | [diff] [blame] | 1083 | $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8 |
Uwe Hermann | c113b57 | 2006-12-14 00:59:41 +0000 | [diff] [blame] | 1084 | |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 1085 | export: $(PROGRAM).8 |
Carl-Daniel Hailfinger | 48e5e09 | 2009-08-31 16:25:08 +0000 | [diff] [blame] | 1086 | @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME) |
| 1087 | @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME) |
| 1088 | @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 1089 | @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8" |
Carl-Daniel Hailfinger | 48e5e09 | 2009-08-31 16:25:08 +0000 | [diff] [blame] | 1090 | @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog |
| 1091 | @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/ |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 1092 | |
| 1093 | tarball: export |
Carl-Daniel Hailfinger | 48e5e09 | 2009-08-31 16:25:08 +0000 | [diff] [blame] | 1094 | @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/ |
| 1095 | @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME) |
| 1096 | @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 1097 | |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 1098 | djgpp-dos: clean |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 1099 | make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip |
| 1100 | libpayload: clean |
| 1101 | make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 1102 | |
Stefan Tauner | 74dc73f | 2015-03-01 22:04:38 +0000 | [diff] [blame] | 1103 | .PHONY: all install clean distclean compiler hwlibs features export tarball djgpp-dos featuresavailable libpayload |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 1104 | |
Stefan Reinauer | e2f0158 | 2010-06-07 11:08:07 +0000 | [diff] [blame] | 1105 | -include $(OBJS:.o=.d) |