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. |
Uwe Hermann | c2a9c9c | 2009-05-14 14:51:14 +0000 | [diff] [blame] | 32 | CC ?= gcc |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 33 | STRIP ?= strip |
Christian Ruppert | db9d9f4 | 2009-05-14 14:17:07 +0000 | [diff] [blame] | 34 | INSTALL = install |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 35 | DIFF = diff |
Christian Ruppert | db9d9f4 | 2009-05-14 14:17:07 +0000 | [diff] [blame] | 36 | PREFIX ?= /usr/local |
Uwe Hermann | 56b2cb0 | 2009-05-21 15:59:58 +0000 | [diff] [blame] | 37 | MANDIR ?= $(PREFIX)/share/man |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 38 | CFLAGS ?= -Os -Wall -Wshadow |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 39 | EXPORTDIR ?= . |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 40 | AR ?= ar |
| 41 | RANLIB ?= ranlib |
Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 42 | DOSLIBS_BASE ?= .. |
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 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 69 | ############################################################################### |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 70 | # General OS-specific settings. |
| 71 | # 1. Prepare for later by gathering information about host and target OS |
| 72 | # 2. Set compiler flags and parameters according to OSes |
| 73 | # 3. Likewise verify user-supplied CONFIG_* variables. |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 74 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 75 | # HOST_OS is only used to work around local toolchain issues. |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 76 | HOST_OS ?= $(shell uname) |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 77 | ifeq ($(HOST_OS), MINGW32_NT-5.1) |
| 78 | # Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found". |
| 79 | CC = gcc |
| 80 | endif |
| 81 | ifneq ($(HOST_OS), SunOS) |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 82 | STRIP_ARGS = -s |
| 83 | endif |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 84 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 85 | # Determine the destination OS. |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 86 | # IMPORTANT: The following line must be placed before TARGET_OS is ever used |
| 87 | # (of course), but should come after any lines setting CC because the line |
| 88 | # below uses CC itself. |
| 89 | override TARGET_OS := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"')) |
| 90 | |
| 91 | ifeq ($(TARGET_OS), Darwin) |
Stefan Reinauer | 2fea3f3 | 2010-01-21 20:26:30 +0000 | [diff] [blame] | 92 | CPPFLAGS += -I/opt/local/include -I/usr/local/include |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 93 | LDFLAGS += -L/opt/local/lib -L/usr/local/lib |
Stefan Reinauer | f79edb9 | 2009-01-26 01:23:31 +0000 | [diff] [blame] | 94 | endif |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 95 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 96 | ifeq ($(TARGET_OS), FreeBSD) |
Stefan Reinauer | 2fea3f3 | 2010-01-21 20:26:30 +0000 | [diff] [blame] | 97 | CPPFLAGS += -I/usr/local/include |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 98 | LDFLAGS += -L/usr/local/lib |
| 99 | endif |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 100 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 101 | ifeq ($(TARGET_OS), OpenBSD) |
Carl-Daniel Hailfinger | b63b067 | 2010-07-02 17:12:50 +0000 | [diff] [blame] | 102 | CPPFLAGS += -I/usr/local/include |
| 103 | LDFLAGS += -L/usr/local/lib |
| 104 | endif |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 105 | |
Stefan Tauner | c65b855 | 2013-09-12 15:48:39 +0000 | [diff] [blame] | 106 | ifeq ($(TARGET_OS), NetBSD) |
| 107 | CPPFLAGS += -I/usr/pkg/include |
| 108 | LDFLAGS += -L/usr/pkg/lib |
| 109 | endif |
| 110 | |
| 111 | ifeq ($(TARGET_OS), DragonFlyBSD) |
| 112 | CPPFLAGS += -I/usr/pkg/include |
| 113 | LDFLAGS += -L/usr/pkg/lib |
| 114 | endif |
| 115 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 116 | ifeq ($(TARGET_OS), DOS) |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 117 | EXEC_SUFFIX := .exe |
Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 118 | CPPFLAGS += -I$(DOSLIBS_BASE)/libgetopt |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 119 | # 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] | 120 | CFLAGS += -Wno-format |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 121 | # FIXME Check if we can achieve the same effect with -L../libgetopt -lgetopt |
Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 122 | LIBS += -lgetopt |
| 123 | LDFLAGS += -L$(DOSLIBS_BASE)/libgetopt/ |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 124 | # 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] | 125 | ifeq ($(CONFIG_BUSPIRATE_SPI), yes) |
| 126 | UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes |
| 127 | else |
| 128 | override CONFIG_BUSPIRATE_SPI = no |
| 129 | endif |
| 130 | ifeq ($(CONFIG_SERPROG), yes) |
| 131 | UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes |
| 132 | else |
| 133 | override CONFIG_SERPROG = no |
| 134 | endif |
Stefan Tauner | d94d25d | 2012-07-28 03:17:15 +0000 | [diff] [blame] | 135 | ifeq ($(CONFIG_PONY_SPI), yes) |
| 136 | UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes |
| 137 | else |
| 138 | override CONFIG_PONY_SPI = no |
| 139 | endif |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 140 | # Dediprog and FT2232 are not supported under DOS (missing USB support). |
| 141 | ifeq ($(CONFIG_DEDIPROG), yes) |
| 142 | UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes |
| 143 | else |
| 144 | override CONFIG_DEDIPROG = no |
| 145 | endif |
| 146 | ifeq ($(CONFIG_FT2232_SPI), yes) |
| 147 | UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes |
| 148 | else |
| 149 | override CONFIG_FT2232_SPI = no |
| 150 | endif |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 151 | ifeq ($(CONFIG_USBBLASTER_SPI), yes) |
| 152 | UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes |
| 153 | else |
| 154 | override CONFIG_USBBLASTER_SPI = no |
| 155 | endif |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 156 | endif |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 157 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 158 | # FIXME: Should we check for Cygwin/MSVC as well? |
| 159 | ifeq ($(TARGET_OS), MinGW) |
| 160 | EXEC_SUFFIX := .exe |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 161 | # 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] | 162 | FLASHROM_CFLAGS += -Dffs=__builtin_ffs |
Carl-Daniel Hailfinger | 11990da | 2013-07-13 23:21:05 +0000 | [diff] [blame] | 163 | # Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that |
| 164 | # for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */ |
| 165 | FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 166 | # libusb-win32/libftdi stuff is usually installed in /usr/local. |
| 167 | CPPFLAGS += -I/usr/local/include |
| 168 | LDFLAGS += -L/usr/local/lib |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 169 | # For now we disable all PCI-based programmers on Windows/MinGW (no libpci). |
| 170 | ifeq ($(CONFIG_INTERNAL), yes) |
| 171 | UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes |
| 172 | else |
| 173 | override CONFIG_INTERNAL = no |
| 174 | endif |
| 175 | ifeq ($(CONFIG_RAYER_SPI), yes) |
| 176 | UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes |
| 177 | else |
| 178 | override CONFIG_RAYER_SPI = no |
| 179 | endif |
| 180 | ifeq ($(CONFIG_NIC3COM), yes) |
| 181 | UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes |
| 182 | else |
| 183 | override CONFIG_NIC3COM = no |
| 184 | endif |
| 185 | ifeq ($(CONFIG_GFXNVIDIA), yes) |
| 186 | UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes |
| 187 | else |
| 188 | override CONFIG_GFXNVIDIA = no |
| 189 | endif |
| 190 | ifeq ($(CONFIG_SATASII), yes) |
| 191 | UNSUPPORTED_FEATURES += CONFIG_SATASII=yes |
| 192 | else |
| 193 | override CONFIG_SATASII = no |
| 194 | endif |
| 195 | ifeq ($(CONFIG_ATAHPT), yes) |
| 196 | UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes |
| 197 | else |
| 198 | override CONFIG_ATAHPT = no |
| 199 | endif |
Jonathan Kollasch | 7f0f3fa | 2014-06-01 10:26:23 +0000 | [diff] [blame] | 200 | ifeq ($(CONFIG_ATAVIA), yes) |
| 201 | UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes |
| 202 | else |
| 203 | override CONFIG_ATAVIA = no |
| 204 | endif |
Kyösti Mälkki | 72d42f8 | 2014-06-01 23:48:31 +0000 | [diff] [blame] | 205 | ifeq ($(CONFIG_IT8212), yes) |
| 206 | UNSUPPORTED_FEATURES += CONFIG_IT8212=yes |
| 207 | else |
| 208 | override CONFIG_IT8212 = no |
| 209 | endif |
Uwe Hermann | d5e85d6 | 2011-07-03 19:44:12 +0000 | [diff] [blame] | 210 | ifeq ($(CONFIG_DRKAISER), yes) |
| 211 | UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes |
| 212 | else |
| 213 | override CONFIG_DRKAISER = no |
| 214 | endif |
| 215 | ifeq ($(CONFIG_NICREALTEK), yes) |
| 216 | UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes |
| 217 | else |
| 218 | override CONFIG_NICREALTEK = no |
| 219 | endif |
| 220 | ifeq ($(CONFIG_NICNATSEMI), yes) |
| 221 | UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes |
| 222 | else |
| 223 | override CONFIG_NICNATSEMI = no |
| 224 | endif |
| 225 | ifeq ($(CONFIG_NICINTEL), yes) |
| 226 | UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes |
| 227 | else |
| 228 | override CONFIG_NICINTEL = no |
| 229 | endif |
| 230 | ifeq ($(CONFIG_NICINTEL_SPI), yes) |
| 231 | UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes |
| 232 | else |
| 233 | override CONFIG_NICINTEL_SPI = no |
| 234 | endif |
| 235 | ifeq ($(CONFIG_OGP_SPI), yes) |
| 236 | UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes |
| 237 | else |
| 238 | override CONFIG_OGP_SPI = no |
| 239 | endif |
| 240 | ifeq ($(CONFIG_SATAMV), yes) |
| 241 | UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes |
| 242 | else |
| 243 | override CONFIG_SATAMV = no |
| 244 | endif |
| 245 | endif |
| 246 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 247 | ifeq ($(TARGET_OS), libpayload) |
Stefan Tauner | 8e19b04 | 2013-08-28 09:55:04 +0000 | [diff] [blame] | 248 | ifeq ($(MAKECMDGOALS),) |
| 249 | .DEFAULT_GOAL := libflashrom.a |
| 250 | $(info Setting default goal to libflashrom.a) |
| 251 | endif |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 252 | FLASHROM_CFLAGS += -DSTANDALONE |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 253 | ifeq ($(CONFIG_DUMMY), yes) |
| 254 | UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes |
| 255 | else |
| 256 | override CONFIG_DUMMY = no |
| 257 | endif |
Carl-Daniel Hailfinger | 11990da | 2013-07-13 23:21:05 +0000 | [diff] [blame] | 258 | # 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] | 259 | ifeq ($(CONFIG_BUSPIRATE_SPI), yes) |
| 260 | UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes |
| 261 | else |
| 262 | override CONFIG_BUSPIRATE_SPI = no |
| 263 | endif |
| 264 | ifeq ($(CONFIG_SERPROG), yes) |
| 265 | UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes |
| 266 | else |
| 267 | override CONFIG_SERPROG = no |
| 268 | endif |
Carl-Daniel Hailfinger | 11990da | 2013-07-13 23:21:05 +0000 | [diff] [blame] | 269 | ifeq ($(CONFIG_PONY_SPI), yes) |
| 270 | UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes |
| 271 | else |
| 272 | override CONFIG_PONY_SPI = no |
| 273 | endif |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 274 | # Dediprog and FT2232 are not supported with libpayload (missing libusb support) |
| 275 | ifeq ($(CONFIG_DEDIPROG), yes) |
| 276 | UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes |
| 277 | else |
| 278 | override CONFIG_DEDIPROG = no |
| 279 | endif |
| 280 | ifeq ($(CONFIG_FT2232_SPI), yes) |
| 281 | UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes |
| 282 | else |
| 283 | override CONFIG_FT2232_SPI = no |
| 284 | endif |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 285 | ifeq ($(CONFIG_USBBLASTER_SPI), yes) |
| 286 | UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes |
| 287 | else |
| 288 | override CONFIG_USBBLASTER_SPI = no |
| 289 | endif |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 290 | endif |
| 291 | |
Carl-Daniel Hailfinger | 8541d23 | 2012-02-16 21:00:27 +0000 | [diff] [blame] | 292 | ifneq ($(TARGET_OS), Linux) |
| 293 | ifeq ($(CONFIG_LINUX_SPI), yes) |
| 294 | UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes |
| 295 | else |
| 296 | override CONFIG_LINUX_SPI = no |
| 297 | endif |
| 298 | endif |
| 299 | |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 300 | ############################################################################### |
| 301 | # General architecture-specific settings. |
| 302 | # Like above for the OS, below we verify user-supplied options depending on the target architecture. |
| 303 | |
Uwe Hermann | 44ffd58 | 2011-08-20 14:16:00 +0000 | [diff] [blame] | 304 | # Determine the destination processor architecture. |
| 305 | # IMPORTANT: The following line must be placed before ARCH is ever used |
| 306 | # (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] | 307 | # below uses CC itself. |
| 308 | override ARCH := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E arch.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"')) |
Uwe Hermann | 44ffd58 | 2011-08-20 14:16:00 +0000 | [diff] [blame] | 309 | |
David Hendricks | b286da7 | 2012-02-13 00:35:35 +0000 | [diff] [blame] | 310 | # PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM. |
| 311 | # Right now this means the drivers below only work on x86. |
| 312 | ifneq ($(ARCH), x86) |
Uwe Hermann | 21b10c6 | 2011-07-29 12:13:01 +0000 | [diff] [blame] | 313 | ifeq ($(CONFIG_NIC3COM), yes) |
| 314 | UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes |
| 315 | else |
| 316 | override CONFIG_NIC3COM = no |
| 317 | endif |
| 318 | ifeq ($(CONFIG_NICREALTEK), yes) |
| 319 | UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes |
| 320 | else |
| 321 | override CONFIG_NICREALTEK = no |
| 322 | endif |
| 323 | ifeq ($(CONFIG_NICNATSEMI), yes) |
| 324 | UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes |
| 325 | else |
| 326 | override CONFIG_NICNATSEMI = no |
| 327 | endif |
| 328 | ifeq ($(CONFIG_RAYER_SPI), yes) |
| 329 | UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes |
| 330 | else |
| 331 | override CONFIG_RAYER_SPI = no |
| 332 | endif |
| 333 | ifeq ($(CONFIG_ATAHPT), yes) |
| 334 | UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes |
| 335 | else |
| 336 | override CONFIG_ATAHPT = no |
| 337 | endif |
| 338 | ifeq ($(CONFIG_SATAMV), yes) |
| 339 | UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes |
| 340 | else |
| 341 | override CONFIG_SATAMV = no |
| 342 | endif |
| 343 | endif |
| 344 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 345 | ############################################################################### |
| 346 | # Flash chip drivers and bus support infrastructure. |
| 347 | |
Stefan Tauner | 4404f73 | 2013-09-12 08:28:56 +0000 | [diff] [blame] | 348 | CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \ |
Sean Nelson | 35727f7 | 2010-01-28 23:55:12 +0000 | [diff] [blame] | 349 | sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \ |
Stefan Tauner | 6ee37e2 | 2012-12-29 15:03:51 +0000 | [diff] [blame] | 350 | 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] | 351 | opaque.o sfdp.o en29lv640b.o at45db.o |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 352 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 353 | ############################################################################### |
| 354 | # Library code. |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 355 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 356 | LIB_OBJS = layout.o flashrom.o udelay.o programmer.o |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 357 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 358 | ############################################################################### |
| 359 | # Frontend related stuff. |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 360 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 361 | CLI_OBJS = cli_classic.o cli_output.o print.o |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 362 | |
Stefan Tauner | ec7a35f | 2013-08-29 00:38:14 +0000 | [diff] [blame] | 363 | # 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] | 364 | # Note to packagers: Any tree exported with "make export" or "make tarball" |
| 365 | # will not require subversion. The downloadable snapshots are already exported. |
David Hendricks | 36e9f4b | 2013-08-14 14:47:26 +0000 | [diff] [blame] | 366 | SVNVERSION := $(shell ./util/getrevision.sh -u) |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 367 | |
Stefan Tauner | 241e9d5 | 2013-08-13 22:13:01 +0000 | [diff] [blame] | 368 | RELEASE := 0.9.7 |
Stefan Tauner | ec7a35f | 2013-08-29 00:38:14 +0000 | [diff] [blame] | 369 | VERSION := $(RELEASE)-$(SVNVERSION) |
Carl-Daniel Hailfinger | 48e5e09 | 2009-08-31 16:25:08 +0000 | [diff] [blame] | 370 | RELEASENAME ?= $(VERSION) |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 371 | |
| 372 | SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"' |
Bernhard Walle | 201bde3 | 2008-01-21 15:24:22 +0000 | [diff] [blame] | 373 | |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 374 | ############################################################################### |
| 375 | # Default settings of CONFIG_* variables. |
| 376 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 377 | # Always enable internal/onboard support for now. |
| 378 | CONFIG_INTERNAL ?= yes |
| 379 | |
Stefan Tauner | 52b6e9d | 2013-04-01 00:46:05 +0000 | [diff] [blame] | 380 | # Always enable serprog for now. |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 381 | CONFIG_SERPROG ?= yes |
| 382 | |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 383 | # RayeR SPIPGM hardware support |
| 384 | CONFIG_RAYER_SPI ?= yes |
| 385 | |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 386 | # PonyProg2000 SPI hardware support |
| 387 | CONFIG_PONY_SPI ?= yes |
| 388 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 389 | # Always enable 3Com NICs for now. |
| 390 | CONFIG_NIC3COM ?= yes |
| 391 | |
Carl-Daniel Hailfinger | bf3af29 | 2010-07-29 14:41:46 +0000 | [diff] [blame] | 392 | # Enable NVIDIA graphics cards. Note: write and erase do not work properly. |
| 393 | CONFIG_GFXNVIDIA ?= yes |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 394 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 395 | # Always enable SiI SATA controllers for now. |
| 396 | CONFIG_SATASII ?= yes |
| 397 | |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 398 | # Highpoint (HPT) ATA/RAID controller support. |
| 399 | # IMPORTANT: This code is not yet working! |
| 400 | CONFIG_ATAHPT ?= no |
| 401 | |
Jonathan Kollasch | 7f0f3fa | 2014-06-01 10:26:23 +0000 | [diff] [blame] | 402 | # VIA VT6421A LPC memory support |
| 403 | CONFIG_ATAVIA ?= yes |
| 404 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 405 | # Always enable FT2232 SPI dongles for now. |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 406 | CONFIG_FT2232_SPI ?= yes |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 407 | |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 408 | # Always enable Altera USB-Blaster dongles for now. |
| 409 | CONFIG_USBBLASTER_SPI ?= yes |
| 410 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 411 | # Always enable dummy tracing for now. |
| 412 | CONFIG_DUMMY ?= yes |
| 413 | |
| 414 | # Always enable Dr. Kaiser for now. |
| 415 | CONFIG_DRKAISER ?= yes |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 416 | |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 417 | # Always enable Realtek NICs for now. |
| 418 | CONFIG_NICREALTEK ?= yes |
| 419 | |
Andrew Morgan | c29c2e7 | 2010-06-07 22:37:54 +0000 | [diff] [blame] | 420 | # Disable National Semiconductor NICs until support is complete and tested. |
| 421 | CONFIG_NICNATSEMI ?= no |
| 422 | |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 423 | # Always enable Intel NICs for now. |
| 424 | CONFIG_NICINTEL ?= yes |
| 425 | |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 426 | # Always enable SPI on Intel NICs for now. |
| 427 | CONFIG_NICINTEL_SPI ?= yes |
| 428 | |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 429 | # Always enable SPI on OGP cards for now. |
| 430 | CONFIG_OGP_SPI ?= yes |
| 431 | |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 432 | # Always enable Bus Pirate SPI for now. |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 433 | CONFIG_BUSPIRATE_SPI ?= yes |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 434 | |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 435 | # Disable Dediprog SF100 until support is complete and tested. |
| 436 | CONFIG_DEDIPROG ?= no |
| 437 | |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 438 | # Always enable Marvell SATA controllers for now. |
| 439 | CONFIG_SATAMV ?= yes |
| 440 | |
Carl-Daniel Hailfinger | 8541d23 | 2012-02-16 21:00:27 +0000 | [diff] [blame] | 441 | # Enable Linux spidev interface by default. We disable it on non-Linux targets. |
| 442 | CONFIG_LINUX_SPI ?= yes |
| 443 | |
Kyösti Mälkki | 72d42f8 | 2014-06-01 23:48:31 +0000 | [diff] [blame] | 444 | # Always enable ITE IT8212F PATA controllers for now. |
| 445 | CONFIG_IT8212 ?= yes |
| 446 | |
Carl-Daniel Hailfinger | 6161ff1 | 2009-11-16 21:22:24 +0000 | [diff] [blame] | 447 | # 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] | 448 | CONFIG_PRINT_WIKI ?= no |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 449 | |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 450 | # Bitbanging SPI infrastructure, default off unless needed. |
| 451 | ifeq ($(CONFIG_RAYER_SPI), yes) |
| 452 | override CONFIG_BITBANG_SPI = yes |
| 453 | else |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 454 | ifeq ($(CONFIG_PONY_SPI), yes) |
| 455 | override CONFIG_BITBANG_SPI = yes |
| 456 | else |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 457 | ifeq ($(CONFIG_INTERNAL), yes) |
| 458 | override CONFIG_BITBANG_SPI = yes |
| 459 | else |
| 460 | ifeq ($(CONFIG_NICINTEL_SPI), yes) |
| 461 | override CONFIG_BITBANG_SPI = yes |
| 462 | else |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 463 | ifeq ($(CONFIG_OGP_SPI), yes) |
| 464 | override CONFIG_BITBANG_SPI = yes |
| 465 | else |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 466 | CONFIG_BITBANG_SPI ?= no |
| 467 | endif |
| 468 | endif |
| 469 | endif |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 470 | endif |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 471 | endif |
Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 472 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 473 | ############################################################################### |
Sean Nelson | 4c6d3a4 | 2013-09-11 23:35:03 +0000 | [diff] [blame] | 474 | # Handle CONFIG_* variables that depend on others set (and verified) above. |
| 475 | |
| 476 | # The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled. |
| 477 | ifeq ($(TARGET_OS), libpayload) |
| 478 | ifeq ($(CONFIG_INTERNAL), yes) |
| 479 | ifeq ($(CONFIG_INTERNAL_DMI), no) |
| 480 | UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no |
| 481 | else |
| 482 | override CONFIG_INTERNAL_DMI = yes |
| 483 | endif |
| 484 | endif |
| 485 | endif |
| 486 | |
| 487 | # Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode. |
| 488 | CONFIG_INTERNAL_DMI ?= yes |
| 489 | |
| 490 | ############################################################################### |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 491 | # Programmer drivers and programmer support infrastructure. |
Stefan Tauner | 037cd84 | 2013-08-25 00:10:56 +0000 | [diff] [blame] | 492 | # 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] | 493 | |
Stefan Tauner | fd0d413 | 2012-09-25 21:24:55 +0000 | [diff] [blame] | 494 | FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)' |
Stefan Tauner | 265fcac | 2014-06-02 00:12:23 +0000 | [diff] [blame^] | 495 | FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"' |
Stefan Tauner | fd0d413 | 2012-09-25 21:24:55 +0000 | [diff] [blame] | 496 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 497 | ifeq ($(CONFIG_INTERNAL), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 498 | FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1' |
Sean Nelson | 4c6d3a4 | 2013-09-11 23:35:03 +0000 | [diff] [blame] | 499 | 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] | 500 | ifeq ($(ARCH), x86) |
Rudolf Marek | 70e1459 | 2013-07-25 22:58:56 +0000 | [diff] [blame] | 501 | 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] | 502 | PROGRAMMER_OBJS += ichspi.o ich_descriptors.o dmi.o |
| 503 | ifeq ($(CONFIG_INTERNAL_DMI), yes) |
| 504 | FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1' |
| 505 | endif |
Carl-Daniel Hailfinger | 91199a1 | 2011-07-07 06:59:18 +0000 | [diff] [blame] | 506 | else |
| 507 | endif |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 508 | NEED_PCI := yes |
| 509 | endif |
| 510 | |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 511 | ifeq ($(CONFIG_SERPROG), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 512 | FEATURE_CFLAGS += -D'CONFIG_SERPROG=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 513 | PROGRAMMER_OBJS += serprog.o |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 514 | NEED_SERIAL := yes |
| 515 | NEED_NET := yes |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 516 | endif |
| 517 | |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 518 | ifeq ($(CONFIG_RAYER_SPI), yes) |
| 519 | FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1' |
| 520 | PROGRAMMER_OBJS += rayer_spi.o |
| 521 | # Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct. |
| 522 | NEED_PCI := yes |
| 523 | endif |
| 524 | |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 525 | ifeq ($(CONFIG_PONY_SPI), yes) |
| 526 | FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1' |
| 527 | PROGRAMMER_OBJS += pony_spi.o |
| 528 | NEED_SERIAL := yes |
| 529 | endif |
| 530 | |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 531 | ifeq ($(CONFIG_BITBANG_SPI), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 532 | FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 533 | PROGRAMMER_OBJS += bitbang_spi.o |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 534 | endif |
| 535 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 536 | ifeq ($(CONFIG_NIC3COM), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 537 | FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 538 | PROGRAMMER_OBJS += nic3com.o |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 539 | NEED_PCI := yes |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 540 | endif |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 541 | |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 542 | ifeq ($(CONFIG_GFXNVIDIA), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 543 | FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 544 | PROGRAMMER_OBJS += gfxnvidia.o |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 545 | NEED_PCI := yes |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 546 | endif |
| 547 | |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 548 | ifeq ($(CONFIG_SATASII), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 549 | FEATURE_CFLAGS += -D'CONFIG_SATASII=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 550 | PROGRAMMER_OBJS += satasii.o |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 551 | NEED_PCI := yes |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 552 | endif |
| 553 | |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 554 | ifeq ($(CONFIG_ATAHPT), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 555 | FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1' |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 556 | PROGRAMMER_OBJS += atahpt.o |
| 557 | NEED_PCI := yes |
| 558 | endif |
| 559 | |
Jonathan Kollasch | 7f0f3fa | 2014-06-01 10:26:23 +0000 | [diff] [blame] | 560 | ifeq ($(CONFIG_ATAVIA), yes) |
| 561 | FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1' |
| 562 | PROGRAMMER_OBJS += atavia.o |
| 563 | NEED_PCI := yes |
| 564 | endif |
| 565 | |
Kyösti Mälkki | 72d42f8 | 2014-06-01 23:48:31 +0000 | [diff] [blame] | 566 | ifeq ($(CONFIG_IT8212), yes) |
| 567 | FEATURE_CFLAGS += -D'CONFIG_IT8212=1' |
| 568 | PROGRAMMER_OBJS += it8212.o |
| 569 | NEED_PCI := yes |
| 570 | endif |
| 571 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 572 | ifeq ($(CONFIG_FT2232_SPI), yes) |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 573 | # This is a totally ugly hack. |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 574 | FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'") |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 575 | NEED_FTDI := yes |
| 576 | PROGRAMMER_OBJS += ft2232_spi.o |
| 577 | endif |
| 578 | |
| 579 | ifeq ($(CONFIG_USBBLASTER_SPI), yes) |
| 580 | # This is a totally ugly hack. |
| 581 | FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'") |
| 582 | NEED_FTDI := yes |
| 583 | PROGRAMMER_OBJS += usbblaster_spi.o |
| 584 | endif |
| 585 | |
| 586 | ifeq ($(NEED_FTDI), yes) |
| 587 | FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb") |
Ilya A. Volynets-Evenbakh | 2c714ab | 2012-09-26 00:47:09 +0000 | [diff] [blame] | 588 | FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'") |
Jörg Mayer | 8776db2 | 2009-11-16 14:05:13 +0000 | [diff] [blame] | 589 | FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)") |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 590 | # We can't set NEED_USB here because that would transform libftdi auto-enabling |
| 591 | # 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] | 592 | endif |
| 593 | |
| 594 | ifeq ($(CONFIG_DUMMY), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 595 | FEATURE_CFLAGS += -D'CONFIG_DUMMY=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 596 | PROGRAMMER_OBJS += dummyflasher.o |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 597 | endif |
| 598 | |
| 599 | ifeq ($(CONFIG_DRKAISER), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 600 | FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 601 | PROGRAMMER_OBJS += drkaiser.o |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 602 | NEED_PCI := yes |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 603 | endif |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 604 | |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 605 | ifeq ($(CONFIG_NICREALTEK), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 606 | FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1' |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 607 | PROGRAMMER_OBJS += nicrealtek.o |
| 608 | NEED_PCI := yes |
| 609 | endif |
| 610 | |
Andrew Morgan | c29c2e7 | 2010-06-07 22:37:54 +0000 | [diff] [blame] | 611 | ifeq ($(CONFIG_NICNATSEMI), yes) |
| 612 | FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1' |
| 613 | PROGRAMMER_OBJS += nicnatsemi.o |
| 614 | NEED_PCI := yes |
| 615 | endif |
| 616 | |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 617 | ifeq ($(CONFIG_NICINTEL), yes) |
| 618 | FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1' |
| 619 | PROGRAMMER_OBJS += nicintel.o |
| 620 | NEED_PCI := yes |
| 621 | endif |
| 622 | |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 623 | ifeq ($(CONFIG_NICINTEL_SPI), yes) |
| 624 | FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1' |
| 625 | PROGRAMMER_OBJS += nicintel_spi.o |
| 626 | NEED_PCI := yes |
| 627 | endif |
| 628 | |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 629 | ifeq ($(CONFIG_OGP_SPI), yes) |
| 630 | FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1' |
| 631 | PROGRAMMER_OBJS += ogp_spi.o |
| 632 | NEED_PCI := yes |
| 633 | endif |
| 634 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 635 | ifeq ($(CONFIG_BUSPIRATE_SPI), yes) |
| 636 | FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 637 | PROGRAMMER_OBJS += buspirate_spi.o |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 638 | NEED_SERIAL := yes |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 639 | endif |
| 640 | |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 641 | ifeq ($(CONFIG_DEDIPROG), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 642 | FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1' |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 643 | PROGRAMMER_OBJS += dediprog.o |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 644 | NEED_USB := yes |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 645 | endif |
| 646 | |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 647 | ifeq ($(CONFIG_SATAMV), yes) |
| 648 | FEATURE_CFLAGS += -D'CONFIG_SATAMV=1' |
| 649 | PROGRAMMER_OBJS += satamv.o |
| 650 | NEED_PCI := yes |
| 651 | endif |
| 652 | |
Carl-Daniel Hailfinger | 8541d23 | 2012-02-16 21:00:27 +0000 | [diff] [blame] | 653 | ifeq ($(CONFIG_LINUX_SPI), yes) |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 654 | # This is a totally ugly hack. |
| 655 | FEATURE_CFLAGS += $(shell LC_ALL=C 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] | 656 | PROGRAMMER_OBJS += linux_spi.o |
| 657 | endif |
| 658 | |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 659 | ifeq ($(NEED_SERIAL), yes) |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 660 | LIB_OBJS += serial.o |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 661 | endif |
| 662 | |
| 663 | ifeq ($(NEED_NET), yes) |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 664 | ifeq ($(TARGET_OS), SunOS) |
Carl-Daniel Hailfinger | 5bdf298 | 2010-06-14 12:42:05 +0000 | [diff] [blame] | 665 | LIBS += -lsocket |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 666 | endif |
Carl-Daniel Hailfinger | e51ea10 | 2009-11-23 19:20:11 +0000 | [diff] [blame] | 667 | endif |
| 668 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 669 | ifeq ($(NEED_PCI), yes) |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 670 | CHECK_LIBPCI = yes |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 671 | FEATURE_CFLAGS += -D'NEED_PCI=1' |
Carl-Daniel Hailfinger | fb0828f | 2010-02-12 19:35:25 +0000 | [diff] [blame] | 672 | PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 673 | ifeq ($(TARGET_OS), NetBSD) |
Carl-Daniel Hailfinger | 460b282 | 2010-06-04 23:24:57 +0000 | [diff] [blame] | 674 | # 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] | 675 | PCILIBS += -lpciutils -lpci |
Carl-Daniel Hailfinger | 460b282 | 2010-06-04 23:24:57 +0000 | [diff] [blame] | 676 | # For (i386|x86_64)_iopl(2). |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 677 | PCILIBS += -l$(shell uname -p) |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 678 | else |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 679 | ifeq ($(TARGET_OS), DOS) |
Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 680 | CPPFLAGS += -I$(DOSLIBS_BASE)/libpci/include |
| 681 | LDFLAGS += -L$(DOSLIBS_BASE)/libpci/lib/ |
| 682 | PCILIBS += -lpci |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 683 | else |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 684 | PCILIBS += -lpci |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 685 | ifeq ($(TARGET_OS), OpenBSD) |
Carl-Daniel Hailfinger | b63b067 | 2010-07-02 17:12:50 +0000 | [diff] [blame] | 686 | # For (i386|amd64)_iopl(2). |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 687 | PCILIBS += -l$(shell uname -m) |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 688 | else |
| 689 | ifeq ($(TARGET_OS), Darwin) |
| 690 | # DirectHW framework can be found in the DirectHW library. |
Stefan Tauner | e34e3e8 | 2013-01-01 00:06:51 +0000 | [diff] [blame] | 691 | PCILIBS += -framework IOKit -framework DirectHW |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 692 | else |
| 693 | endif |
Carl-Daniel Hailfinger | b63b067 | 2010-07-02 17:12:50 +0000 | [diff] [blame] | 694 | endif |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 695 | endif |
Jonathan A. Kollasch | 3646c8f | 2010-01-08 21:18:08 +0000 | [diff] [blame] | 696 | endif |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 697 | endif |
| 698 | |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 699 | ifeq ($(NEED_USB), yes) |
| 700 | CHECK_LIBUSB0 = yes |
| 701 | FEATURE_CFLAGS += -D'NEED_USB=1' |
| 702 | USBLIBS := $(shell pkg-config --libs libusb 2>/dev/null || printf "%s" "-lusb") |
| 703 | endif |
| 704 | |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 705 | ifeq ($(CONFIG_PRINT_WIKI), yes) |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 706 | FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1' |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 707 | CLI_OBJS += print_wiki.o |
Carl-Daniel Hailfinger | 9c8476b | 2009-09-16 12:19:03 +0000 | [diff] [blame] | 708 | endif |
| 709 | |
Carl-Daniel Hailfinger | 132e2ec | 2010-03-27 16:36:40 +0000 | [diff] [blame] | 710 | FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'") |
| 711 | |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 712 | # We could use PULLED_IN_LIBS, but that would be ugly. |
| 713 | FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz") |
| 714 | |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 715 | LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS) |
Stefan Tauner | d94d25d | 2012-07-28 03:17:15 +0000 | [diff] [blame] | 716 | OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS) |
Sean Nelson | 5d13464 | 2009-12-24 16:54:21 +0000 | [diff] [blame] | 717 | |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 718 | all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8 |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 719 | ifeq ($(ARCH), x86) |
| 720 | @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX) |
| 721 | endif |
| 722 | |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 723 | $(PROGRAM)$(EXEC_SUFFIX): $(OBJS) |
Carl-Daniel Hailfinger | 11990da | 2013-07-13 23:21:05 +0000 | [diff] [blame] | 724 | $(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] | 725 | |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 726 | libflashrom.a: $(LIBFLASHROM_OBJS) |
| 727 | $(AR) rcs $@ $^ |
| 728 | $(RANLIB) $@ |
| 729 | |
Carl-Daniel Hailfinger | 8ef7dce | 2009-07-10 20:19:48 +0000 | [diff] [blame] | 730 | # TAROPTIONS reduces information leakage from the packager's system. |
| 731 | # If other tar programs support command line arguments for setting uid/gid of |
| 732 | # stored files, they can be handled here as well. |
| 733 | 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] | 734 | |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 735 | %.o: %.c .features |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 736 | $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $< |
Clark Rawlins | 02016f7 | 2008-02-14 23:22:20 +0000 | [diff] [blame] | 737 | |
Carl-Daniel Hailfinger | a0020df | 2010-05-30 22:35:14 +0000 | [diff] [blame] | 738 | # Make sure to add all names of generated binaries here. |
| 739 | # This includes all frontends and libflashrom. |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 740 | # 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] | 741 | clean: |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 742 | rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 743 | @+$(MAKE) -C util/ich_descriptors_tool/ clean |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 744 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 745 | distclean: clean |
Stefan Reinauer | e2f0158 | 2010-06-07 11:08:07 +0000 | [diff] [blame] | 746 | rm -f .features .libdeps |
Christian Ruppert | db9d9f4 | 2009-05-14 14:17:07 +0000 | [diff] [blame] | 747 | |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 748 | strip: $(PROGRAM)$(EXEC_SUFFIX) |
| 749 | $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 750 | |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 751 | # to define test programs we use verbatim variables, which get exported |
| 752 | # to environment variables and are referenced with $$<varname> later |
| 753 | |
| 754 | define COMPILER_TEST |
| 755 | int main(int argc, char **argv) |
| 756 | { |
| 757 | (void) argc; |
| 758 | (void) argv; |
| 759 | return 0; |
| 760 | } |
| 761 | endef |
| 762 | export COMPILER_TEST |
| 763 | |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 764 | compiler: featuresavailable |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 765 | @printf "Checking for a C compiler... " |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 766 | @echo "$$COMPILER_TEST" > .test.c |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 767 | @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \ |
Carl-Daniel Hailfinger | 4cb7a96 | 2009-06-16 09:31:51 +0000 | [diff] [blame] | 768 | echo "found." || ( echo "not found."; \ |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 769 | rm -f .test.c .test$(EXEC_SUFFIX); exit 1) |
| 770 | @rm -f .test.c .test$(EXEC_SUFFIX) |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 771 | @printf "Target arch is " |
Carl-Daniel Hailfinger | 91199a1 | 2011-07-07 06:59:18 +0000 | [diff] [blame] | 772 | @# FreeBSD wc will output extraneous whitespace. |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 773 | @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \ |
Carl-Daniel Hailfinger | 91199a1 | 2011-07-07 06:59:18 +0000 | [diff] [blame] | 774 | ( echo "unknown. Aborting."; exit 1) |
| 775 | @printf "%s\n" '$(ARCH)' |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 776 | @printf "Target OS is " |
| 777 | @# FreeBSD wc will output extraneous whitespace. |
| 778 | @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \ |
| 779 | ( echo "unknown. Aborting."; exit 1) |
| 780 | @printf "%s\n" '$(TARGET_OS)' |
Stefan Tauner | d6c17f6 | 2013-09-12 14:04:31 +0000 | [diff] [blame] | 781 | ifeq ($(TARGET_OS), libpayload) |
| 782 | @$(CC) --version 2>&1 | grep -q coreboot || \ |
| 783 | ( echo "Warning: It seems you are not using coreboot's reference compiler."; \ |
| 784 | echo "This might work but usually does not, please beware." ) |
| 785 | endif |
Carl-Daniel Hailfinger | 4cb7a96 | 2009-06-16 09:31:51 +0000 | [diff] [blame] | 786 | |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 787 | define LIBPCI_TEST |
| 788 | /* Avoid a failing test due to libpci header symbol shadowing breakage */ |
| 789 | #define index shadow_workaround_index |
Stefan Tauner | c65b855 | 2013-09-12 15:48:39 +0000 | [diff] [blame] | 790 | #if !defined __NetBSD__ && !defined __DragonFly__ |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 791 | #include <pci/pci.h> |
Stefan Tauner | c65b855 | 2013-09-12 15:48:39 +0000 | [diff] [blame] | 792 | #else |
| 793 | #include <pciutils/pci.h> |
| 794 | #endif |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 795 | struct pci_access *pacc; |
| 796 | int main(int argc, char **argv) |
| 797 | { |
| 798 | (void) argc; |
| 799 | (void) argv; |
| 800 | pacc = pci_alloc(); |
| 801 | return 0; |
| 802 | } |
| 803 | endef |
| 804 | export LIBPCI_TEST |
| 805 | |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 806 | define LIBUSB0_TEST |
| 807 | #include <usb.h> |
| 808 | int main(int argc, char **argv) |
| 809 | { |
| 810 | (void) argc; |
| 811 | (void) argv; |
| 812 | usb_init(); |
| 813 | return 0; |
| 814 | } |
| 815 | endef |
| 816 | export LIBUSB0_TEST |
| 817 | |
| 818 | hwlibs: compiler |
| 819 | @printf "" > .libdeps |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 820 | ifeq ($(CHECK_LIBPCI), yes) |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 821 | @printf "Checking for libpci headers... " |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 822 | @echo "$$LIBPCI_TEST" > .test.c |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 823 | @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \ |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 824 | echo "found." || ( echo "not found."; echo; \ |
| 825 | echo "Please install libpci headers (package pciutils-devel)."; \ |
| 826 | echo "See README for more information."; echo; \ |
| 827 | rm -f .test.c .test.o; exit 1) |
Carl-Daniel Hailfinger | 9979eac | 2010-03-22 12:29:45 +0000 | [diff] [blame] | 828 | @printf "Checking if libpci is present and sufficient... " |
Carl-Daniel Hailfinger | 26148ae | 2012-11-29 22:22:04 +0000 | [diff] [blame] | 829 | @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \ |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 830 | echo "yes." || ( echo "no."; \ |
Carl-Daniel Hailfinger | 9979eac | 2010-03-22 12:29:45 +0000 | [diff] [blame] | 831 | printf "Checking if libz+libpci are present and sufficient..."; \ |
Carl-Daniel Hailfinger | 26148ae | 2012-11-29 22:22:04 +0000 | [diff] [blame] | 832 | $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \ |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 833 | ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \ |
Carl-Daniel Hailfinger | 9979eac | 2010-03-22 12:29:45 +0000 | [diff] [blame] | 834 | echo "Please install libpci (package pciutils) and/or libz."; \ |
Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 835 | echo "See README for more information."; echo; \ |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 836 | rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) ) |
| 837 | @rm -f .test.c .test.o .test$(EXEC_SUFFIX) |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 838 | endif |
| 839 | ifeq ($(CHECK_LIBUSB0), yes) |
| 840 | @printf "Checking for libusb-0.1/libusb-compat headers... " |
| 841 | @echo "$$LIBUSB0_TEST" > .test.c |
| 842 | @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \ |
| 843 | echo "found." || ( echo "not found."; echo; \ |
| 844 | echo "Please install libusb-0.1 headers or libusb-compat headers."; \ |
| 845 | echo "See README for more information."; echo; \ |
| 846 | rm -f .test.c .test.o; exit 1) |
| 847 | @printf "Checking if libusb-0.1 is usable... " |
Carl-Daniel Hailfinger | 26148ae | 2012-11-29 22:22:04 +0000 | [diff] [blame] | 848 | @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \ |
Carl-Daniel Hailfinger | e7a39bf | 2012-11-20 21:06:16 +0000 | [diff] [blame] | 849 | echo "yes." || ( echo "no."; \ |
| 850 | echo "Please install libusb-0.1 or libusb-compat."; \ |
| 851 | echo "See README for more information."; echo; \ |
| 852 | rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) |
| 853 | @rm -f .test.c .test.o .test$(EXEC_SUFFIX) |
Carl-Daniel Hailfinger | 8a59ff0 | 2009-12-24 03:33:11 +0000 | [diff] [blame] | 854 | endif |
Stefan Reinauer | 53e9625 | 2005-12-01 16:19:24 +0000 | [diff] [blame] | 855 | |
Carl-Daniel Hailfinger | b18ecbc | 2009-06-19 14:20:34 +0000 | [diff] [blame] | 856 | .features: features |
| 857 | |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 858 | # If a user does not explicitly request a non-working feature, we should |
| 859 | # silently disable it. However, if a non-working (does not compile) feature |
| 860 | # 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] | 861 | # 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] | 862 | featuresavailable: |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 863 | ifeq ($(PROGRAMMER_OBJS),) |
| 864 | @echo "You have to enable at least one programmer driver!" |
| 865 | @false |
| 866 | endif |
| 867 | ifneq ($(UNSUPPORTED_FEATURES), ) |
Carl-Daniel Hailfinger | 5d3fcb9 | 2010-06-14 18:40:59 +0000 | [diff] [blame] | 868 | @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)" |
| 869 | @false |
| 870 | endif |
| 871 | |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 872 | define FTDI_TEST |
| 873 | #include <ftdi.h> |
| 874 | struct ftdi_context *ftdic = NULL; |
| 875 | int main(int argc, char **argv) |
| 876 | { |
| 877 | (void) argc; |
| 878 | (void) argv; |
| 879 | return ftdi_init(ftdic); |
| 880 | } |
| 881 | endef |
| 882 | export FTDI_TEST |
| 883 | |
Ilya A. Volynets-Evenbakh | 2c714ab | 2012-09-26 00:47:09 +0000 | [diff] [blame] | 884 | define FTDI_232H_TEST |
| 885 | #include <ftdi.h> |
| 886 | enum ftdi_chip_type type = TYPE_232H; |
| 887 | endef |
| 888 | export FTDI_232H_TEST |
| 889 | |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 890 | define UTSNAME_TEST |
| 891 | #include <sys/utsname.h> |
| 892 | struct utsname osinfo; |
| 893 | int main(int argc, char **argv) |
| 894 | { |
| 895 | (void) argc; |
| 896 | (void) argv; |
| 897 | uname (&osinfo); |
| 898 | return 0; |
| 899 | } |
| 900 | endef |
| 901 | export UTSNAME_TEST |
| 902 | |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 903 | define LINUX_SPI_TEST |
| 904 | #include <linux/types.h> |
| 905 | #include <linux/spi/spidev.h> |
| 906 | |
| 907 | int main(int argc, char **argv) |
| 908 | { |
| 909 | (void) argc; |
| 910 | (void) argv; |
| 911 | return 0; |
| 912 | } |
| 913 | endef |
| 914 | export LINUX_SPI_TEST |
| 915 | |
Carl-Daniel Hailfinger | b18ecbc | 2009-06-19 14:20:34 +0000 | [diff] [blame] | 916 | features: compiler |
| 917 | @echo "FEATURES := yes" > .features.tmp |
James Laird | c60de0e | 2013-03-27 13:00:23 +0000 | [diff] [blame] | 918 | ifeq ($(NEED_FTDI), yes) |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 919 | @printf "Checking for FTDI support... " |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 920 | @echo "$$FTDI_TEST" > .featuretest.c |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 921 | @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \ |
Carl-Daniel Hailfinger | b18ecbc | 2009-06-19 14:20:34 +0000 | [diff] [blame] | 922 | ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \ |
| 923 | ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) |
Ilya A. Volynets-Evenbakh | 2c714ab | 2012-09-26 00:47:09 +0000 | [diff] [blame] | 924 | @printf "Checking for FT232H support in libftdi... " |
| 925 | @echo "$$FTDI_232H_TEST" >> .featuretest.c |
| 926 | @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \ |
| 927 | ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \ |
| 928 | ( echo "not found."; echo "FT232H := no" >> .features.tmp ) |
Carl-Daniel Hailfinger | 8a59ff0 | 2009-12-24 03:33:11 +0000 | [diff] [blame] | 929 | endif |
Stefan Tauner | 8868db3 | 2012-03-13 00:18:19 +0000 | [diff] [blame] | 930 | ifeq ($(CONFIG_LINUX_SPI), yes) |
| 931 | @printf "Checking if Linux SPI headers are present... " |
| 932 | @echo "$$LINUX_SPI_TEST" > .featuretest.c |
| 933 | @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \ |
| 934 | ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \ |
| 935 | ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) |
| 936 | endif |
Stefan Tauner | 5678708 | 2011-08-18 02:27:19 +0000 | [diff] [blame] | 937 | @printf "Checking for utsname support... " |
| 938 | @echo "$$UTSNAME_TEST" > .featuretest.c |
| 939 | @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \ |
| 940 | ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \ |
| 941 | ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) |
| 942 | @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features |
| 943 | @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX) |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 944 | |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 945 | $(PROGRAM).8: $(PROGRAM).8.tmpl |
| 946 | @sed -e '1 s#".*".*#"$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl)" "$(VERSION)"#' <$< >$@ |
| 947 | |
| 948 | install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8 |
Uwe Hermann | c2a9c9c | 2009-05-14 14:51:14 +0000 | [diff] [blame] | 949 | mkdir -p $(DESTDIR)$(PREFIX)/sbin |
Uwe Hermann | 56b2cb0 | 2009-05-21 15:59:58 +0000 | [diff] [blame] | 950 | mkdir -p $(DESTDIR)$(MANDIR)/man8 |
Carl-Daniel Hailfinger | ddbab71 | 2010-06-14 14:44:08 +0000 | [diff] [blame] | 951 | $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin |
Uwe Hermann | 56b2cb0 | 2009-05-21 15:59:58 +0000 | [diff] [blame] | 952 | $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8 |
Uwe Hermann | c113b57 | 2006-12-14 00:59:41 +0000 | [diff] [blame] | 953 | |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 954 | export: $(PROGRAM).8 |
Carl-Daniel Hailfinger | 48e5e09 | 2009-08-31 16:25:08 +0000 | [diff] [blame] | 955 | @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME) |
| 956 | @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME) |
| 957 | @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 958 | @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8" |
Carl-Daniel Hailfinger | 48e5e09 | 2009-08-31 16:25:08 +0000 | [diff] [blame] | 959 | @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog |
| 960 | @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/ |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 961 | |
| 962 | tarball: export |
Carl-Daniel Hailfinger | 48e5e09 | 2009-08-31 16:25:08 +0000 | [diff] [blame] | 963 | @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/ |
| 964 | @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME) |
| 965 | @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 |
Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 966 | |
Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 967 | djgpp-dos: clean |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 968 | make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip |
| 969 | libpayload: clean |
| 970 | 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] | 971 | |
Joerg Mayer | a93d9dc | 2013-08-29 00:38:19 +0000 | [diff] [blame] | 972 | .PHONY: all install clean distclean compiler hwlibs features export tarball dos featuresavailable |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 973 | |
Stefan Reinauer | e2f0158 | 2010-06-07 11:08:07 +0000 | [diff] [blame] | 974 | -include $(OBJS:.o=.d) |