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