blob: b4fdd27810e5fa5eaf3c734e222c3faf2bc44465 [file] [log] [blame]
Ollie Lho184a4042005-11-26 21:55:36 +00001#
Uwe Hermannf78cff12009-06-12 14:05:25 +00002# This file is part of the flashrom project.
3#
4# Copyright (C) 2005 coresystems GmbH <stepan@coresystems.de>
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00005# Copyright (C) 2009,2010,2012 Carl-Daniel Hailfinger
Uwe Hermannf78cff12009-06-12 14:05:25 +00006#
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 Lho184a4042005-11-26 21:55:36 +000019#
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000020
Ollie Lho184a4042005-11-26 21:55:36 +000021PROGRAM = flashrom
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000022
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000023###############################################################################
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 Hailfingerb7bce8a2012-08-14 21:36:11 +000029#
30# Note for anyone editing this Makefile: gnumake will happily ignore any
31# changes in this Makefile to variables set on the command line.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000032STRIP ?= strip
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000033INSTALL = install
Paul Fox05dfbe62009-06-16 21:08:06 +000034DIFF = diff
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000035PREFIX ?= /usr/local
Uwe Hermann56b2cb02009-05-21 15:59:58 +000036MANDIR ?= $(PREFIX)/share/man
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000037CFLAGS ?= -Os -Wall -Wshadow
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000038EXPORTDIR ?= .
Patrick Georgi97bc95c2011-03-08 07:17:44 +000039RANLIB ?= ranlib
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000040
Stefan Taunerfd0d4132012-09-25 21:24:55 +000041# The following parameter changes the default programmer that will be used if there is no -p/--programmer
42# argument given when running flashrom. The predefined setting does not enable any default so that every
43# user has to declare the programmer he wants to use on every run. The rationale for this to be not set
44# (to e.g. the internal programmer) is that forgetting to specify this when working with another programmer
45# easily puts the system attached to the default programmer at risk (e.g. you want to flash coreboot to another
46# system attached to an external programmer while the default programmer is set to the internal programmer, and
47# you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer
48# running flashrom). Please do not enable this without thinking about the possible consequences. Possible
49# values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options
50# evaluated below, namely those that enable/disable the various programmers).
51# Compilation will fail for unspecified values.
52CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID
Stefan Tauner265fcac2014-06-02 00:12:23 +000053# The following adds a default parameter for the default programmer set above (only).
54CONFIG_DEFAULT_PROGRAMMER_ARGS ?= ''
55# Example: compiling with
56# make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000"
57# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000058
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000059# If your compiler spits out excessive warnings, run make WARNERROR=no
60# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000061WARNERROR ?= yes
62
63ifeq ($(WARNERROR), yes)
64CFLAGS += -Werror
65endif
66
Stefan Taunere37735a2015-01-26 22:03:35 +000067ifdef LIBS_BASE
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000068CPPFLAGS += -I$(LIBS_BASE)/include
Stefan Taunere37735a2015-01-26 22:03:35 +000069LDFLAGS += -L$(LIBS_BASE)/lib -Wl,-rpath -Wl,$(LIBS_BASE)/lib
70PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig
71endif
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000072
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000073###############################################################################
Stefan Tauner037cd842013-08-25 00:10:56 +000074# General OS-specific settings.
75# 1. Prepare for later by gathering information about host and target OS
76# 2. Set compiler flags and parameters according to OSes
77# 3. Likewise verify user-supplied CONFIG_* variables.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000078
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000079# HOST_OS is only used to work around local toolchain issues.
Stefan Tauner037cd842013-08-25 00:10:56 +000080HOST_OS ?= $(shell uname)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000081ifeq ($(HOST_OS), MINGW32_NT-5.1)
82# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
83CC = gcc
84endif
85ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +000086STRIP_ARGS = -s
87endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000088
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000089# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000090# IMPORTANT: The following line must be placed before TARGET_OS is ever used
91# (of course), but should come after any lines setting CC because the line
92# below uses CC itself.
93override TARGET_OS := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
94
95ifeq ($(TARGET_OS), Darwin)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000096CPPFLAGS += -I/opt/local/include -I/usr/local/include
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000097LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +000098endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000099
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000100ifeq ($(TARGET_OS), FreeBSD)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +0000101CPPFLAGS += -I/usr/local/include
Andriy Gapon65c1b862008-05-22 13:22:45 +0000102LDFLAGS += -L/usr/local/lib
103endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000104
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000105ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000106CPPFLAGS += -I/usr/local/include
107LDFLAGS += -L/usr/local/lib
108endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000109
Stefan Taunerc65b8552013-09-12 15:48:39 +0000110ifeq ($(TARGET_OS), NetBSD)
111CPPFLAGS += -I/usr/pkg/include
112LDFLAGS += -L/usr/pkg/lib
113endif
114
115ifeq ($(TARGET_OS), DragonFlyBSD)
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000116CPPFLAGS += -I/usr/local/include
117LDFLAGS += -L/usr/local/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000118endif
119
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000120ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000121EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000122# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +0000123CFLAGS += -Wno-format
Stefan Tauner449abe22013-09-11 23:34:57 +0000124LIBS += -lgetopt
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000125# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000126ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
127UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
128else
129override CONFIG_BUSPIRATE_SPI = no
130endif
131ifeq ($(CONFIG_SERPROG), yes)
132UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
133else
134override CONFIG_SERPROG = no
135endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000136ifeq ($(CONFIG_PONY_SPI), yes)
137UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
138else
139override CONFIG_PONY_SPI = no
140endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000141# Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported under DOS (missing USB support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000142ifeq ($(CONFIG_DEDIPROG), yes)
143UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
144else
145override CONFIG_DEDIPROG = no
146endif
147ifeq ($(CONFIG_FT2232_SPI), yes)
148UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
149else
150override CONFIG_FT2232_SPI = no
151endif
James Lairdc60de0e2013-03-27 13:00:23 +0000152ifeq ($(CONFIG_USBBLASTER_SPI), yes)
153UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
154else
155override CONFIG_USBBLASTER_SPI = no
156endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000157ifeq ($(CONFIG_PICKIT2_SPI), yes)
158UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
159else
160override CONFIG_PICKIT2_SPI = no
161endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000162endif
Ollie Lho184a4042005-11-26 21:55:36 +0000163
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000164# FIXME: Should we check for Cygwin/MSVC as well?
165ifeq ($(TARGET_OS), MinGW)
166EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000167# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000168FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000169# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
170# for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */
171FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000172# libusb-win32/libftdi stuff is usually installed in /usr/local.
173CPPFLAGS += -I/usr/local/include
174LDFLAGS += -L/usr/local/lib
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000175# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
176ifeq ($(CONFIG_INTERNAL), yes)
177UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
178else
179override CONFIG_INTERNAL = no
180endif
181ifeq ($(CONFIG_RAYER_SPI), yes)
182UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
183else
184override CONFIG_RAYER_SPI = no
185endif
186ifeq ($(CONFIG_NIC3COM), yes)
187UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
188else
189override CONFIG_NIC3COM = no
190endif
191ifeq ($(CONFIG_GFXNVIDIA), yes)
192UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
193else
194override CONFIG_GFXNVIDIA = no
195endif
196ifeq ($(CONFIG_SATASII), yes)
197UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
198else
199override CONFIG_SATASII = no
200endif
201ifeq ($(CONFIG_ATAHPT), yes)
202UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
203else
204override CONFIG_ATAHPT = no
205endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000206ifeq ($(CONFIG_ATAVIA), yes)
207UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
208else
209override CONFIG_ATAVIA = no
210endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000211ifeq ($(CONFIG_IT8212), yes)
212UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
213else
214override CONFIG_IT8212 = no
215endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000216ifeq ($(CONFIG_DRKAISER), yes)
217UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
218else
219override CONFIG_DRKAISER = no
220endif
221ifeq ($(CONFIG_NICREALTEK), yes)
222UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
223else
224override CONFIG_NICREALTEK = no
225endif
226ifeq ($(CONFIG_NICNATSEMI), yes)
227UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
228else
229override CONFIG_NICNATSEMI = no
230endif
231ifeq ($(CONFIG_NICINTEL), yes)
232UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
233else
234override CONFIG_NICINTEL = no
235endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000236ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
237UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
238else
239override CONFIG_NICINTEL_EEPROM = no
240endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000241ifeq ($(CONFIG_NICINTEL_SPI), yes)
242UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
243else
244override CONFIG_NICINTEL_SPI = no
245endif
246ifeq ($(CONFIG_OGP_SPI), yes)
247UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
248else
249override CONFIG_OGP_SPI = no
250endif
251ifeq ($(CONFIG_SATAMV), yes)
252UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
253else
254override CONFIG_SATAMV = no
255endif
256endif
257
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000258ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000259ifeq ($(MAKECMDGOALS),)
260.DEFAULT_GOAL := libflashrom.a
261$(info Setting default goal to libflashrom.a)
262endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000263FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000264ifeq ($(CONFIG_DUMMY), yes)
265UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
266else
267override CONFIG_DUMMY = no
268endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000269# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000270ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
271UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
272else
273override CONFIG_BUSPIRATE_SPI = no
274endif
275ifeq ($(CONFIG_SERPROG), yes)
276UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
277else
278override CONFIG_SERPROG = no
279endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000280ifeq ($(CONFIG_PONY_SPI), yes)
281UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
282else
283override CONFIG_PONY_SPI = no
284endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000285# Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported with libpayload (missing libusb support)
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000286ifeq ($(CONFIG_DEDIPROG), yes)
287UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
288else
289override CONFIG_DEDIPROG = no
290endif
291ifeq ($(CONFIG_FT2232_SPI), yes)
292UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
293else
294override CONFIG_FT2232_SPI = no
295endif
James Lairdc60de0e2013-03-27 13:00:23 +0000296ifeq ($(CONFIG_USBBLASTER_SPI), yes)
297UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
298else
299override CONFIG_USBBLASTER_SPI = no
300endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000301ifeq ($(CONFIG_PICKIT2_SPI), yes)
302UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
303else
304override CONFIG_PICKIT2_SPI = no
305endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000306endif
307
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000308ifneq ($(TARGET_OS), Linux)
309ifeq ($(CONFIG_LINUX_SPI), yes)
310UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
311else
312override CONFIG_LINUX_SPI = no
313endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000314ifeq ($(CONFIG_MSTARDDC_SPI), yes)
315UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
316else
317override CONFIG_MSTARDDC_SPI = no
318endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000319endif
320
Stefan Tauner037cd842013-08-25 00:10:56 +0000321###############################################################################
322# General architecture-specific settings.
323# Like above for the OS, below we verify user-supplied options depending on the target architecture.
324
Uwe Hermann44ffd582011-08-20 14:16:00 +0000325# Determine the destination processor architecture.
326# IMPORTANT: The following line must be placed before ARCH is ever used
327# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000328# below uses CC itself.
Stefan Taunerb0eee9b2015-01-10 09:32:50 +0000329override ARCH := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
Uwe Hermann44ffd582011-08-20 14:16:00 +0000330
Stefan Taunerfb2d77c2015-02-10 08:03:10 +0000331# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
David Hendricksb286da72012-02-13 00:35:35 +0000332# Right now this means the drivers below only work on x86.
333ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000334ifeq ($(CONFIG_NIC3COM), yes)
335UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
336else
337override CONFIG_NIC3COM = no
338endif
339ifeq ($(CONFIG_NICREALTEK), yes)
340UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
341else
342override CONFIG_NICREALTEK = no
343endif
344ifeq ($(CONFIG_NICNATSEMI), yes)
345UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
346else
347override CONFIG_NICNATSEMI = no
348endif
349ifeq ($(CONFIG_RAYER_SPI), yes)
350UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
351else
352override CONFIG_RAYER_SPI = no
353endif
354ifeq ($(CONFIG_ATAHPT), yes)
355UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
356else
357override CONFIG_ATAHPT = no
358endif
359ifeq ($(CONFIG_SATAMV), yes)
360UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
361else
362override CONFIG_SATAMV = no
363endif
364endif
365
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000366###############################################################################
367# Flash chip drivers and bus support infrastructure.
368
Stefan Tauner4404f732013-09-12 08:28:56 +0000369CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000370 sst28sf040.o 82802ab.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000371 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Aidan Thorntondb4e87d2013-08-27 18:01:53 +0000372 opaque.o sfdp.o en29lv640b.o at45db.o
Sean Nelson5d134642009-12-24 16:54:21 +0000373
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000374###############################################################################
375# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000376
Stefan Tauner6ad6e012014-06-12 00:04:32 +0000377LIB_OBJS = layout.o flashrom.o udelay.o programmer.o helpers.o
Sean Nelson5d134642009-12-24 16:54:21 +0000378
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000379###############################################################################
380# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000381
Stefan Tauner9b32de92014-08-08 23:52:33 +0000382CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000383
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000384# Set the flashrom version string from the highest revision number of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000385# Note to packagers: Any tree exported with "make export" or "make tarball"
386# will not require subversion. The downloadable snapshots are already exported.
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000387SVNVERSION := $(shell ./util/getrevision.sh -u 2>/dev/null )
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000388
Stefan Tauner241e9d52013-08-13 22:13:01 +0000389RELEASE := 0.9.7
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000390VERSION := $(RELEASE)-$(SVNVERSION)
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000391RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000392
393SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000394
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000395# Inform user if there is no meaningful version string. If there is version information from a VCS print
396# something anyway because $(info...) will print a line break in any case which would look suspicious.
Stefan Tauner5d1ad352015-01-25 23:57:08 +0000397# The && between the echos is a workaround for old versions of GNU make that issue the error "unterminated
398# variable reference" if a semicolon is used instead.
399$(info $(shell ./util/getrevision.sh -c 2>/dev/null || echo "Files don't seem to be under version control." && \
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000400 echo "Replacing all version templates with $(VERSION)." ))
401
Stefan Tauner037cd842013-08-25 00:10:56 +0000402###############################################################################
403# Default settings of CONFIG_* variables.
404
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000405# Always enable internal/onboard support for now.
406CONFIG_INTERNAL ?= yes
407
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000408# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000409CONFIG_SERPROG ?= yes
410
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000411# RayeR SPIPGM hardware support
412CONFIG_RAYER_SPI ?= yes
413
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000414# PonyProg2000 SPI hardware support
415CONFIG_PONY_SPI ?= yes
416
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000417# Always enable 3Com NICs for now.
418CONFIG_NIC3COM ?= yes
419
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000420# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
421CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000422
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000423# Always enable SiI SATA controllers for now.
424CONFIG_SATASII ?= yes
425
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000426# Highpoint (HPT) ATA/RAID controller support.
427# IMPORTANT: This code is not yet working!
428CONFIG_ATAHPT ?= no
429
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000430# VIA VT6421A LPC memory support
431CONFIG_ATAVIA ?= yes
432
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000433# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000434CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000435
James Lairdc60de0e2013-03-27 13:00:23 +0000436# Always enable Altera USB-Blaster dongles for now.
437CONFIG_USBBLASTER_SPI ?= yes
438
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000439# MSTAR DDC support needs more tests/reviews/cleanups.
440CONFIG_MSTARDDC_SPI ?= no
441
Justin Chevrier66e554b2015-02-08 21:58:10 +0000442# Always enable PICkit2 SPI dongles for now.
443CONFIG_PICKIT2_SPI ?= yes
444
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000445# Always enable dummy tracing for now.
446CONFIG_DUMMY ?= yes
447
448# Always enable Dr. Kaiser for now.
449CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000450
Joerg Fischer5665ef32010-05-21 21:54:07 +0000451# Always enable Realtek NICs for now.
452CONFIG_NICREALTEK ?= yes
453
Andrew Morganc29c2e72010-06-07 22:37:54 +0000454# Disable National Semiconductor NICs until support is complete and tested.
455CONFIG_NICNATSEMI ?= no
456
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000457# Always enable Intel NICs for now.
458CONFIG_NICINTEL ?= yes
459
Idwer Vollering004f4b72010-09-03 18:21:21 +0000460# Always enable SPI on Intel NICs for now.
461CONFIG_NICINTEL_SPI ?= yes
462
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000463# Always enable EEPROM on Intel NICs for now.
464CONFIG_NICINTEL_EEPROM ?= yes
465
Mark Marshall90021f22010-12-03 14:48:11 +0000466# Always enable SPI on OGP cards for now.
467CONFIG_OGP_SPI ?= yes
468
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000469# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000470CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000471
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000472# Disable Dediprog SF100 until support is complete and tested.
473CONFIG_DEDIPROG ?= no
474
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000475# Always enable Marvell SATA controllers for now.
476CONFIG_SATAMV ?= yes
477
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000478# Enable Linux spidev interface by default. We disable it on non-Linux targets.
479CONFIG_LINUX_SPI ?= yes
480
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000481# Always enable ITE IT8212F PATA controllers for now.
482CONFIG_IT8212 ?= yes
483
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000484# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000485CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000486
Patrick Georgiced7ab62015-01-19 19:52:34 +0000487# Enable all features if CONFIG_EVERYTHING=yes is given
488ifeq ($(CONFIG_EVERYTHING), yes)
489$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
490 $(if $(filter no, $($(var))),\
491 $(eval $(var)=yes)))
492endif
493
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000494# Bitbanging SPI infrastructure, default off unless needed.
495ifeq ($(CONFIG_RAYER_SPI), yes)
496override CONFIG_BITBANG_SPI = yes
497else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000498ifeq ($(CONFIG_PONY_SPI), yes)
499override CONFIG_BITBANG_SPI = yes
500else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000501ifeq ($(CONFIG_INTERNAL), yes)
502override CONFIG_BITBANG_SPI = yes
503else
504ifeq ($(CONFIG_NICINTEL_SPI), yes)
505override CONFIG_BITBANG_SPI = yes
506else
Mark Marshall90021f22010-12-03 14:48:11 +0000507ifeq ($(CONFIG_OGP_SPI), yes)
508override CONFIG_BITBANG_SPI = yes
509else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000510CONFIG_BITBANG_SPI ?= no
511endif
512endif
513endif
Mark Marshall90021f22010-12-03 14:48:11 +0000514endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000515endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000516
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000517###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000518# Handle CONFIG_* variables that depend on others set (and verified) above.
519
520# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
521ifeq ($(TARGET_OS), libpayload)
522ifeq ($(CONFIG_INTERNAL), yes)
523ifeq ($(CONFIG_INTERNAL_DMI), no)
524UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
525else
526override CONFIG_INTERNAL_DMI = yes
527endif
528endif
529endif
530
531# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
532CONFIG_INTERNAL_DMI ?= yes
533
534###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000535# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000536# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000537
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000538FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000539FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000540
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000541ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000542FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000543PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000544ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000545PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000546PROGRAMMER_OBJS += ichspi.o ich_descriptors.o dmi.o
547ifeq ($(CONFIG_INTERNAL_DMI), yes)
548FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
549endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000550else
551endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000552NEED_PCI := yes
553endif
554
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000555ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000556FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000557PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000558NEED_SERIAL := yes
559NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000560endif
561
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000562ifeq ($(CONFIG_RAYER_SPI), yes)
563FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
564PROGRAMMER_OBJS += rayer_spi.o
565# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
566NEED_PCI := yes
567endif
568
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000569ifeq ($(CONFIG_PONY_SPI), yes)
570FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
571PROGRAMMER_OBJS += pony_spi.o
572NEED_SERIAL := yes
573endif
574
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000575ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000576FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000577PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000578endif
579
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000580ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000581FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000582PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000583NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000584endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000585
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000586ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000587FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000588PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000589NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000590endif
591
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000592ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000593FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000594PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000595NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000596endif
597
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000598ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000599FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000600PROGRAMMER_OBJS += atahpt.o
601NEED_PCI := yes
602endif
603
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000604ifeq ($(CONFIG_ATAVIA), yes)
605FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
606PROGRAMMER_OBJS += atavia.o
607NEED_PCI := yes
608endif
609
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000610ifeq ($(CONFIG_IT8212), yes)
611FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
612PROGRAMMER_OBJS += it8212.o
613NEED_PCI := yes
614endif
615
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000616ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000617# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000618FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000619NEED_FTDI := yes
620PROGRAMMER_OBJS += ft2232_spi.o
621endif
622
623ifeq ($(CONFIG_USBBLASTER_SPI), yes)
624# This is a totally ugly hack.
625FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
626NEED_FTDI := yes
627PROGRAMMER_OBJS += usbblaster_spi.o
628endif
629
Justin Chevrier66e554b2015-02-08 21:58:10 +0000630ifeq ($(CONFIG_PICKIT2_SPI), yes)
631FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
632PROGRAMMER_OBJS += pickit2_spi.o
633NEED_USB := yes
634endif
635
James Lairdc60de0e2013-03-27 13:00:23 +0000636ifeq ($(NEED_FTDI), yes)
Stefan Taunere37735a2015-01-26 22:03:35 +0000637FTDILIBS := $(shell ([ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ); pkg-config --libs libftdi || printf "%s" "-lftdi -lusb")
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000638FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
Jörg Mayer8776db22009-11-16 14:05:13 +0000639FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000640# We can't set NEED_USB here because that would transform libftdi auto-enabling
641# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000642endif
643
644ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000645FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000646PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000647endif
648
649ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000650FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000651PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000652NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000653endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000654
Joerg Fischer5665ef32010-05-21 21:54:07 +0000655ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000656FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000657PROGRAMMER_OBJS += nicrealtek.o
658NEED_PCI := yes
659endif
660
Andrew Morganc29c2e72010-06-07 22:37:54 +0000661ifeq ($(CONFIG_NICNATSEMI), yes)
662FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
663PROGRAMMER_OBJS += nicnatsemi.o
664NEED_PCI := yes
665endif
666
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000667ifeq ($(CONFIG_NICINTEL), yes)
668FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
669PROGRAMMER_OBJS += nicintel.o
670NEED_PCI := yes
671endif
672
Idwer Vollering004f4b72010-09-03 18:21:21 +0000673ifeq ($(CONFIG_NICINTEL_SPI), yes)
674FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
675PROGRAMMER_OBJS += nicintel_spi.o
676NEED_PCI := yes
677endif
678
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000679ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
680FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
681PROGRAMMER_OBJS += nicintel_eeprom.o
682NEED_PCI := yes
683endif
684
Mark Marshall90021f22010-12-03 14:48:11 +0000685ifeq ($(CONFIG_OGP_SPI), yes)
686FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
687PROGRAMMER_OBJS += ogp_spi.o
688NEED_PCI := yes
689endif
690
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000691ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
692FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000693PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000694NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000695endif
696
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000697ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000698FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000699PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000700NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000701endif
702
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000703ifeq ($(CONFIG_SATAMV), yes)
704FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
705PROGRAMMER_OBJS += satamv.o
706NEED_PCI := yes
707endif
708
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000709ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000710# This is a totally ugly hack.
711FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "LINUX_SPI_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_SPI=1'")
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000712PROGRAMMER_OBJS += linux_spi.o
713endif
714
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000715ifeq ($(CONFIG_MSTARDDC_SPI), yes)
716# This is a totally ugly hack.
717FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "LINUX_I2C_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_MSTARDDC_SPI=1'")
718NEED_LINUX_I2C := yes
719PROGRAMMER_OBJS += mstarddc_spi.o
720endif
721
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000722ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000723LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000724endif
725
726ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000727ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000728LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000729endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000730endif
731
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000732ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000733CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000734FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner56734502015-02-08 21:58:04 +0000735FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "OLD_PCI_GET_DEV := yes" .libdeps && printf "%s" "-D'OLD_PCI_GET_DEV=1'")
736
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000737PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000738ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000739# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000740PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000741# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000742PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000743else
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000744
Stefan Tauner449abe22013-09-11 23:34:57 +0000745PCILIBS += -lpci
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000746
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000747ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000748# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000749PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000750else
751ifeq ($(TARGET_OS), Darwin)
752# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000753PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000754endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000755endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000756endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000757endif
758
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000759ifeq ($(NEED_USB), yes)
760CHECK_LIBUSB0 = yes
761FEATURE_CFLAGS += -D'NEED_USB=1'
Stefan Taunere37735a2015-01-26 22:03:35 +0000762USBLIBS := $(shell ([ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ); pkg-config --libs libusb || printf "%s" "-lusb")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000763endif
764
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000765ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000766FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000767CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000768endif
769
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000770FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
771
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000772# We could use PULLED_IN_LIBS, but that would be ugly.
773FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
774
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000775LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000776OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000777
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000778all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000779ifeq ($(ARCH), x86)
780 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
781endif
782
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000783$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000784 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000785
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000786libflashrom.a: $(LIBFLASHROM_OBJS)
787 $(AR) rcs $@ $^
788 $(RANLIB) $@
789
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000790# TAROPTIONS reduces information leakage from the packager's system.
791# If other tar programs support command line arguments for setting uid/gid of
792# stored files, they can be handled here as well.
793TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000794
Paul Fox05dfbe62009-06-16 21:08:06 +0000795%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000796 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000797
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000798# Make sure to add all names of generated binaries here.
799# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000800# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000801clean:
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000802 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000803 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000804
Ollie Lho184a4042005-11-26 21:55:36 +0000805distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000806 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000807
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000808strip: $(PROGRAM)$(EXEC_SUFFIX)
809 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000810
Stefan Tauner56787082011-08-18 02:27:19 +0000811# to define test programs we use verbatim variables, which get exported
812# to environment variables and are referenced with $$<varname> later
813
814define COMPILER_TEST
815int main(int argc, char **argv)
816{
817 (void) argc;
818 (void) argv;
819 return 0;
820}
821endef
822export COMPILER_TEST
823
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000824compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000825 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000826 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000827 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000828 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000829 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
830 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000831 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000832 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000833 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000834 ( echo "unknown. Aborting."; exit 1)
835 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000836 @printf "Target OS is "
837 @# FreeBSD wc will output extraneous whitespace.
838 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
839 ( echo "unknown. Aborting."; exit 1)
840 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +0000841ifeq ($(TARGET_OS), libpayload)
842 @$(CC) --version 2>&1 | grep -q coreboot || \
843 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
844 echo "This might work but usually does not, please beware." )
845endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000846
Stefan Tauner56787082011-08-18 02:27:19 +0000847define LIBPCI_TEST
848/* Avoid a failing test due to libpci header symbol shadowing breakage */
849#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000850#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +0000851#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +0000852#else
853#include <pciutils/pci.h>
854#endif
Stefan Tauner56787082011-08-18 02:27:19 +0000855struct pci_access *pacc;
856int main(int argc, char **argv)
857{
858 (void) argc;
859 (void) argv;
860 pacc = pci_alloc();
861 return 0;
862}
863endef
864export LIBPCI_TEST
865
Stefan Tauner56734502015-02-08 21:58:04 +0000866define PCI_GET_DEV_TEST
867/* Avoid a failing test due to libpci header symbol shadowing breakage */
868#define index shadow_workaround_index
869#if !defined __NetBSD__
870#include <pci/pci.h>
871#else
872#include <pciutils/pci.h>
873#endif
874struct pci_access *pacc;
875struct pci_dev *dev = {0};
876int main(int argc, char **argv)
877{
878 (void) argc;
879 (void) argv;
880 pacc = pci_alloc();
881 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
882 return 0;
883}
884endef
885export PCI_GET_DEV_TEST
886
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000887define LIBUSB0_TEST
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000888#include "platform.h"
889#if IS_WINDOWS
890#include <lusb0_usb.h>
891#else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000892#include <usb.h>
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000893#endif
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000894int main(int argc, char **argv)
895{
896 (void) argc;
897 (void) argv;
898 usb_init();
899 return 0;
900}
901endef
902export LIBUSB0_TEST
903
904hwlibs: compiler
905 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000906ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000907 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000908 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000909 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000910 echo "found." || ( echo "not found."; echo; \
911 echo "Please install libpci headers (package pciutils-devel)."; \
912 echo "See README for more information."; echo; \
913 rm -f .test.c .test.o; exit 1)
Stefan Tauner56734502015-02-08 21:58:04 +0000914 @printf "Checking version of pci_get_dev... "
915 @echo "$$PCI_GET_DEV_TEST" > .test.c
916 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null 2>&1 && \
917 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
918 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps )
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000919 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000920 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000921 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000922 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000923 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000924 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000925 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000926 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000927 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
928 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000929endif
930ifeq ($(CHECK_LIBUSB0), yes)
931 @printf "Checking for libusb-0.1/libusb-compat headers... "
932 @echo "$$LIBUSB0_TEST" > .test.c
933 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
934 echo "found." || ( echo "not found."; echo; \
935 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
936 echo "See README for more information."; echo; \
937 rm -f .test.c .test.o; exit 1)
938 @printf "Checking if libusb-0.1 is usable... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000939 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000940 echo "yes." || ( echo "no."; \
941 echo "Please install libusb-0.1 or libusb-compat."; \
942 echo "See README for more information."; echo; \
943 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1)
944 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000945endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000946
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000947.features: features
948
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000949# If a user does not explicitly request a non-working feature, we should
950# silently disable it. However, if a non-working (does not compile) feature
951# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000952# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000953featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000954ifeq ($(PROGRAMMER_OBJS),)
955 @echo "You have to enable at least one programmer driver!"
956 @false
957endif
958ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000959 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
960 @false
961endif
962
Stefan Tauner56787082011-08-18 02:27:19 +0000963define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +0000964#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +0000965#include <ftdi.h>
966struct ftdi_context *ftdic = NULL;
967int main(int argc, char **argv)
968{
969 (void) argc;
970 (void) argv;
971 return ftdi_init(ftdic);
972}
973endef
974export FTDI_TEST
975
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000976define FTDI_232H_TEST
977#include <ftdi.h>
978enum ftdi_chip_type type = TYPE_232H;
979endef
980export FTDI_232H_TEST
981
Stefan Tauner56787082011-08-18 02:27:19 +0000982define UTSNAME_TEST
983#include <sys/utsname.h>
984struct utsname osinfo;
985int main(int argc, char **argv)
986{
987 (void) argc;
988 (void) argv;
989 uname (&osinfo);
990 return 0;
991}
992endef
993export UTSNAME_TEST
994
Stefan Tauner8868db32012-03-13 00:18:19 +0000995define LINUX_SPI_TEST
996#include <linux/types.h>
997#include <linux/spi/spidev.h>
998
999int main(int argc, char **argv)
1000{
1001 (void) argc;
1002 (void) argv;
1003 return 0;
1004}
1005endef
1006export LINUX_SPI_TEST
1007
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001008define LINUX_I2C_TEST
1009#include <linux/i2c-dev.h>
1010#include <linux/i2c.h>
1011
1012int main(int argc, char **argv)
1013{
1014 (void) argc;
1015 (void) argv;
1016 return 0;
1017}
1018endef
1019export LINUX_I2C_TEST
1020
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001021features: compiler
1022 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +00001023ifeq ($(NEED_FTDI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +00001024 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +00001025 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001026 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001027 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
1028 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001029 @printf "Checking for FT232H support in libftdi... "
1030 @echo "$$FTDI_232H_TEST" >> .featuretest.c
1031 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
1032 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1033 ( echo "not found."; echo "FT232H := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001034endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001035ifeq ($(CONFIG_LINUX_SPI), yes)
1036 @printf "Checking if Linux SPI headers are present... "
1037 @echo "$$LINUX_SPI_TEST" > .featuretest.c
1038 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1039 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
1040 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
1041endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001042ifeq ($(NEED_LINUX_I2C), yes)
1043 @printf "Checking if Linux I2C headers are present... "
1044 @echo "$$LINUX_I2C_TEST" > .featuretest.c
1045 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1046 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
1047 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp )
1048endif
Stefan Tauner56787082011-08-18 02:27:19 +00001049 @printf "Checking for utsname support... "
1050 @echo "$$UTSNAME_TEST" > .featuretest.c
1051 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1052 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
1053 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
1054 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1055 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001056
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001057$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Taunerd5ff8452015-01-10 09:32:07 +00001058 @sed -e '1 s#".*".*#"$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001059
1060install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001061 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001062 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001063 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001064 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001065
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001066export: $(PROGRAM).8
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001067 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1068 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
1069 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001070 @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8"
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001071 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
1072 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001073
1074tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001075 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
1076 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1077 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001078
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001079djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001080 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
1081libpayload: clean
1082 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001083
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001084.PHONY: all install clean distclean compiler hwlibs features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +00001085
Stefan Reinauere2f01582010-06-07 11:08:07 +00001086-include $(OBJS:.o=.d)