blob: 93759c3a34ed80bd89f5e0a95c8bc3882ed2ff4b [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
Stefan Tauner5c316f92015-02-08 21:57:52 +0000141# Dediprog, USB-Blaster 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
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000157endif
Ollie Lho184a4042005-11-26 21:55:36 +0000158
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000159# FIXME: Should we check for Cygwin/MSVC as well?
160ifeq ($(TARGET_OS), MinGW)
161EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000162# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000163FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000164# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
165# for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */
166FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000167# libusb-win32/libftdi stuff is usually installed in /usr/local.
168CPPFLAGS += -I/usr/local/include
169LDFLAGS += -L/usr/local/lib
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000170# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
171ifeq ($(CONFIG_INTERNAL), yes)
172UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
173else
174override CONFIG_INTERNAL = no
175endif
176ifeq ($(CONFIG_RAYER_SPI), yes)
177UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
178else
179override CONFIG_RAYER_SPI = no
180endif
181ifeq ($(CONFIG_NIC3COM), yes)
182UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
183else
184override CONFIG_NIC3COM = no
185endif
186ifeq ($(CONFIG_GFXNVIDIA), yes)
187UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
188else
189override CONFIG_GFXNVIDIA = no
190endif
191ifeq ($(CONFIG_SATASII), yes)
192UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
193else
194override CONFIG_SATASII = no
195endif
196ifeq ($(CONFIG_ATAHPT), yes)
197UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
198else
199override CONFIG_ATAHPT = no
200endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000201ifeq ($(CONFIG_ATAVIA), yes)
202UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
203else
204override CONFIG_ATAVIA = no
205endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000206ifeq ($(CONFIG_IT8212), yes)
207UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
208else
209override CONFIG_IT8212 = no
210endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000211ifeq ($(CONFIG_DRKAISER), yes)
212UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
213else
214override CONFIG_DRKAISER = no
215endif
216ifeq ($(CONFIG_NICREALTEK), yes)
217UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
218else
219override CONFIG_NICREALTEK = no
220endif
221ifeq ($(CONFIG_NICNATSEMI), yes)
222UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
223else
224override CONFIG_NICNATSEMI = no
225endif
226ifeq ($(CONFIG_NICINTEL), yes)
227UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
228else
229override CONFIG_NICINTEL = no
230endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000231ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
232UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
233else
234override CONFIG_NICINTEL_EEPROM = no
235endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000236ifeq ($(CONFIG_NICINTEL_SPI), yes)
237UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
238else
239override CONFIG_NICINTEL_SPI = no
240endif
241ifeq ($(CONFIG_OGP_SPI), yes)
242UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
243else
244override CONFIG_OGP_SPI = no
245endif
246ifeq ($(CONFIG_SATAMV), yes)
247UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
248else
249override CONFIG_SATAMV = no
250endif
251endif
252
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000253ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000254ifeq ($(MAKECMDGOALS),)
255.DEFAULT_GOAL := libflashrom.a
256$(info Setting default goal to libflashrom.a)
257endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000258FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000259ifeq ($(CONFIG_DUMMY), yes)
260UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
261else
262override CONFIG_DUMMY = no
263endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000264# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000265ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
266UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
267else
268override CONFIG_BUSPIRATE_SPI = no
269endif
270ifeq ($(CONFIG_SERPROG), yes)
271UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
272else
273override CONFIG_SERPROG = no
274endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000275ifeq ($(CONFIG_PONY_SPI), yes)
276UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
277else
278override CONFIG_PONY_SPI = no
279endif
Stefan Tauner5c316f92015-02-08 21:57:52 +0000280# Dediprog, USB-Blaster and FT2232 are not supported with libpayload (missing libusb support)
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000281ifeq ($(CONFIG_DEDIPROG), yes)
282UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
283else
284override CONFIG_DEDIPROG = no
285endif
286ifeq ($(CONFIG_FT2232_SPI), yes)
287UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
288else
289override CONFIG_FT2232_SPI = no
290endif
James Lairdc60de0e2013-03-27 13:00:23 +0000291ifeq ($(CONFIG_USBBLASTER_SPI), yes)
292UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
293else
294override CONFIG_USBBLASTER_SPI = no
295endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000296endif
297
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000298ifneq ($(TARGET_OS), Linux)
299ifeq ($(CONFIG_LINUX_SPI), yes)
300UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
301else
302override CONFIG_LINUX_SPI = no
303endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000304ifeq ($(CONFIG_MSTARDDC_SPI), yes)
305UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
306else
307override CONFIG_MSTARDDC_SPI = no
308endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000309endif
310
Stefan Tauner037cd842013-08-25 00:10:56 +0000311###############################################################################
312# General architecture-specific settings.
313# Like above for the OS, below we verify user-supplied options depending on the target architecture.
314
Uwe Hermann44ffd582011-08-20 14:16:00 +0000315# Determine the destination processor architecture.
316# IMPORTANT: The following line must be placed before ARCH is ever used
317# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000318# below uses CC itself.
Stefan Taunerb0eee9b2015-01-10 09:32:50 +0000319override 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 +0000320
David Hendricksb286da72012-02-13 00:35:35 +0000321# PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM.
322# Right now this means the drivers below only work on x86.
323ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000324ifeq ($(CONFIG_NIC3COM), yes)
325UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
326else
327override CONFIG_NIC3COM = no
328endif
329ifeq ($(CONFIG_NICREALTEK), yes)
330UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
331else
332override CONFIG_NICREALTEK = no
333endif
334ifeq ($(CONFIG_NICNATSEMI), yes)
335UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
336else
337override CONFIG_NICNATSEMI = no
338endif
339ifeq ($(CONFIG_RAYER_SPI), yes)
340UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
341else
342override CONFIG_RAYER_SPI = no
343endif
344ifeq ($(CONFIG_ATAHPT), yes)
345UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
346else
347override CONFIG_ATAHPT = no
348endif
349ifeq ($(CONFIG_SATAMV), yes)
350UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
351else
352override CONFIG_SATAMV = no
353endif
354endif
355
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000356###############################################################################
357# Flash chip drivers and bus support infrastructure.
358
Stefan Tauner4404f732013-09-12 08:28:56 +0000359CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000360 sst28sf040.o 82802ab.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000361 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Aidan Thorntondb4e87d2013-08-27 18:01:53 +0000362 opaque.o sfdp.o en29lv640b.o at45db.o
Sean Nelson5d134642009-12-24 16:54:21 +0000363
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000364###############################################################################
365# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000366
Stefan Tauner6ad6e012014-06-12 00:04:32 +0000367LIB_OBJS = layout.o flashrom.o udelay.o programmer.o helpers.o
Sean Nelson5d134642009-12-24 16:54:21 +0000368
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000369###############################################################################
370# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000371
Stefan Tauner9b32de92014-08-08 23:52:33 +0000372CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000373
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000374# Set the flashrom version string from the highest revision number of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000375# Note to packagers: Any tree exported with "make export" or "make tarball"
376# will not require subversion. The downloadable snapshots are already exported.
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000377SVNVERSION := $(shell ./util/getrevision.sh -u 2>/dev/null )
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000378
Stefan Tauner241e9d52013-08-13 22:13:01 +0000379RELEASE := 0.9.7
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000380VERSION := $(RELEASE)-$(SVNVERSION)
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000381RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000382
383SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000384
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000385# Inform user if there is no meaningful version string. If there is version information from a VCS print
386# something anyway because $(info...) will print a line break in any case which would look suspicious.
Stefan Tauner5d1ad352015-01-25 23:57:08 +0000387# The && between the echos is a workaround for old versions of GNU make that issue the error "unterminated
388# variable reference" if a semicolon is used instead.
389$(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 +0000390 echo "Replacing all version templates with $(VERSION)." ))
391
Stefan Tauner037cd842013-08-25 00:10:56 +0000392###############################################################################
393# Default settings of CONFIG_* variables.
394
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000395# Always enable internal/onboard support for now.
396CONFIG_INTERNAL ?= yes
397
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000398# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000399CONFIG_SERPROG ?= yes
400
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000401# RayeR SPIPGM hardware support
402CONFIG_RAYER_SPI ?= yes
403
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000404# PonyProg2000 SPI hardware support
405CONFIG_PONY_SPI ?= yes
406
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000407# Always enable 3Com NICs for now.
408CONFIG_NIC3COM ?= yes
409
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000410# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
411CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000412
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000413# Always enable SiI SATA controllers for now.
414CONFIG_SATASII ?= yes
415
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000416# Highpoint (HPT) ATA/RAID controller support.
417# IMPORTANT: This code is not yet working!
418CONFIG_ATAHPT ?= no
419
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000420# VIA VT6421A LPC memory support
421CONFIG_ATAVIA ?= yes
422
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000423# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000424CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000425
James Lairdc60de0e2013-03-27 13:00:23 +0000426# Always enable Altera USB-Blaster dongles for now.
427CONFIG_USBBLASTER_SPI ?= yes
428
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000429# MSTAR DDC support needs more tests/reviews/cleanups.
430CONFIG_MSTARDDC_SPI ?= no
431
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000432# Always enable dummy tracing for now.
433CONFIG_DUMMY ?= yes
434
435# Always enable Dr. Kaiser for now.
436CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000437
Joerg Fischer5665ef32010-05-21 21:54:07 +0000438# Always enable Realtek NICs for now.
439CONFIG_NICREALTEK ?= yes
440
Andrew Morganc29c2e72010-06-07 22:37:54 +0000441# Disable National Semiconductor NICs until support is complete and tested.
442CONFIG_NICNATSEMI ?= no
443
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000444# Always enable Intel NICs for now.
445CONFIG_NICINTEL ?= yes
446
Idwer Vollering004f4b72010-09-03 18:21:21 +0000447# Always enable SPI on Intel NICs for now.
448CONFIG_NICINTEL_SPI ?= yes
449
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000450# Always enable EEPROM on Intel NICs for now.
451CONFIG_NICINTEL_EEPROM ?= yes
452
Mark Marshall90021f22010-12-03 14:48:11 +0000453# Always enable SPI on OGP cards for now.
454CONFIG_OGP_SPI ?= yes
455
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000456# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000457CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000458
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000459# Disable Dediprog SF100 until support is complete and tested.
460CONFIG_DEDIPROG ?= no
461
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000462# Always enable Marvell SATA controllers for now.
463CONFIG_SATAMV ?= yes
464
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000465# Enable Linux spidev interface by default. We disable it on non-Linux targets.
466CONFIG_LINUX_SPI ?= yes
467
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000468# Always enable ITE IT8212F PATA controllers for now.
469CONFIG_IT8212 ?= yes
470
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000471# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000472CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000473
Patrick Georgiced7ab62015-01-19 19:52:34 +0000474# Enable all features if CONFIG_EVERYTHING=yes is given
475ifeq ($(CONFIG_EVERYTHING), yes)
476$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
477 $(if $(filter no, $($(var))),\
478 $(eval $(var)=yes)))
479endif
480
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000481# Bitbanging SPI infrastructure, default off unless needed.
482ifeq ($(CONFIG_RAYER_SPI), yes)
483override CONFIG_BITBANG_SPI = yes
484else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000485ifeq ($(CONFIG_PONY_SPI), yes)
486override CONFIG_BITBANG_SPI = yes
487else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000488ifeq ($(CONFIG_INTERNAL), yes)
489override CONFIG_BITBANG_SPI = yes
490else
491ifeq ($(CONFIG_NICINTEL_SPI), yes)
492override CONFIG_BITBANG_SPI = yes
493else
Mark Marshall90021f22010-12-03 14:48:11 +0000494ifeq ($(CONFIG_OGP_SPI), yes)
495override CONFIG_BITBANG_SPI = yes
496else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000497CONFIG_BITBANG_SPI ?= no
498endif
499endif
500endif
Mark Marshall90021f22010-12-03 14:48:11 +0000501endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000502endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000503
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000504###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000505# Handle CONFIG_* variables that depend on others set (and verified) above.
506
507# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
508ifeq ($(TARGET_OS), libpayload)
509ifeq ($(CONFIG_INTERNAL), yes)
510ifeq ($(CONFIG_INTERNAL_DMI), no)
511UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
512else
513override CONFIG_INTERNAL_DMI = yes
514endif
515endif
516endif
517
518# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
519CONFIG_INTERNAL_DMI ?= yes
520
521###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000522# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000523# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000524
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000525FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000526FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000527
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000528ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000529FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000530PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000531ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000532PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000533PROGRAMMER_OBJS += ichspi.o ich_descriptors.o dmi.o
534ifeq ($(CONFIG_INTERNAL_DMI), yes)
535FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
536endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000537else
538endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000539NEED_PCI := yes
540endif
541
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000542ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000543FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000544PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000545NEED_SERIAL := yes
546NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000547endif
548
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000549ifeq ($(CONFIG_RAYER_SPI), yes)
550FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
551PROGRAMMER_OBJS += rayer_spi.o
552# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
553NEED_PCI := yes
554endif
555
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000556ifeq ($(CONFIG_PONY_SPI), yes)
557FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
558PROGRAMMER_OBJS += pony_spi.o
559NEED_SERIAL := yes
560endif
561
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000562ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000563FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000564PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000565endif
566
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000567ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000568FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000569PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000570NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000571endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000572
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000573ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000574FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000575PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000576NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000577endif
578
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000579ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000580FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000581PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000582NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000583endif
584
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000585ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000586FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000587PROGRAMMER_OBJS += atahpt.o
588NEED_PCI := yes
589endif
590
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000591ifeq ($(CONFIG_ATAVIA), yes)
592FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
593PROGRAMMER_OBJS += atavia.o
594NEED_PCI := yes
595endif
596
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000597ifeq ($(CONFIG_IT8212), yes)
598FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
599PROGRAMMER_OBJS += it8212.o
600NEED_PCI := yes
601endif
602
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000603ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000604# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000605FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000606NEED_FTDI := yes
607PROGRAMMER_OBJS += ft2232_spi.o
608endif
609
610ifeq ($(CONFIG_USBBLASTER_SPI), yes)
611# This is a totally ugly hack.
612FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
613NEED_FTDI := yes
614PROGRAMMER_OBJS += usbblaster_spi.o
615endif
616
617ifeq ($(NEED_FTDI), yes)
Stefan Taunere37735a2015-01-26 22:03:35 +0000618FTDILIBS := $(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 +0000619FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
Jörg Mayer8776db22009-11-16 14:05:13 +0000620FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000621# We can't set NEED_USB here because that would transform libftdi auto-enabling
622# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000623endif
624
625ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000626FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000627PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000628endif
629
630ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000631FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000632PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000633NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000634endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000635
Joerg Fischer5665ef32010-05-21 21:54:07 +0000636ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000637FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000638PROGRAMMER_OBJS += nicrealtek.o
639NEED_PCI := yes
640endif
641
Andrew Morganc29c2e72010-06-07 22:37:54 +0000642ifeq ($(CONFIG_NICNATSEMI), yes)
643FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
644PROGRAMMER_OBJS += nicnatsemi.o
645NEED_PCI := yes
646endif
647
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000648ifeq ($(CONFIG_NICINTEL), yes)
649FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
650PROGRAMMER_OBJS += nicintel.o
651NEED_PCI := yes
652endif
653
Idwer Vollering004f4b72010-09-03 18:21:21 +0000654ifeq ($(CONFIG_NICINTEL_SPI), yes)
655FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
656PROGRAMMER_OBJS += nicintel_spi.o
657NEED_PCI := yes
658endif
659
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000660ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
661FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
662PROGRAMMER_OBJS += nicintel_eeprom.o
663NEED_PCI := yes
664endif
665
Mark Marshall90021f22010-12-03 14:48:11 +0000666ifeq ($(CONFIG_OGP_SPI), yes)
667FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
668PROGRAMMER_OBJS += ogp_spi.o
669NEED_PCI := yes
670endif
671
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000672ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
673FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000674PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000675NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000676endif
677
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000678ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000679FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000680PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000681NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000682endif
683
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000684ifeq ($(CONFIG_SATAMV), yes)
685FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
686PROGRAMMER_OBJS += satamv.o
687NEED_PCI := yes
688endif
689
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000690ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000691# This is a totally ugly hack.
692FEATURE_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 +0000693PROGRAMMER_OBJS += linux_spi.o
694endif
695
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000696ifeq ($(CONFIG_MSTARDDC_SPI), yes)
697# This is a totally ugly hack.
698FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "LINUX_I2C_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_MSTARDDC_SPI=1'")
699NEED_LINUX_I2C := yes
700PROGRAMMER_OBJS += mstarddc_spi.o
701endif
702
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000703ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000704LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000705endif
706
707ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000708ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000709LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000710endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000711endif
712
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000713ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000714CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000715FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner56734502015-02-08 21:58:04 +0000716FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "OLD_PCI_GET_DEV := yes" .libdeps && printf "%s" "-D'OLD_PCI_GET_DEV=1'")
717
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000718PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000719ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000720# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000721PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000722# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000723PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000724else
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000725
Stefan Tauner449abe22013-09-11 23:34:57 +0000726PCILIBS += -lpci
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000727
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000728ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000729# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000730PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000731else
732ifeq ($(TARGET_OS), Darwin)
733# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000734PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000735endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000736endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000737endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000738endif
739
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000740ifeq ($(NEED_USB), yes)
741CHECK_LIBUSB0 = yes
742FEATURE_CFLAGS += -D'NEED_USB=1'
Stefan Taunere37735a2015-01-26 22:03:35 +0000743USBLIBS := $(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 +0000744endif
745
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000746ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000747FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000748CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000749endif
750
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000751FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
752
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000753# We could use PULLED_IN_LIBS, but that would be ugly.
754FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
755
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000756LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000757OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000758
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000759all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000760ifeq ($(ARCH), x86)
761 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
762endif
763
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000764$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000765 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000766
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000767libflashrom.a: $(LIBFLASHROM_OBJS)
768 $(AR) rcs $@ $^
769 $(RANLIB) $@
770
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000771# TAROPTIONS reduces information leakage from the packager's system.
772# If other tar programs support command line arguments for setting uid/gid of
773# stored files, they can be handled here as well.
774TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000775
Paul Fox05dfbe62009-06-16 21:08:06 +0000776%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000777 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000778
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000779# Make sure to add all names of generated binaries here.
780# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000781# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000782clean:
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000783 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000784 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000785
Ollie Lho184a4042005-11-26 21:55:36 +0000786distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000787 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000788
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000789strip: $(PROGRAM)$(EXEC_SUFFIX)
790 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000791
Stefan Tauner56787082011-08-18 02:27:19 +0000792# to define test programs we use verbatim variables, which get exported
793# to environment variables and are referenced with $$<varname> later
794
795define COMPILER_TEST
796int main(int argc, char **argv)
797{
798 (void) argc;
799 (void) argv;
800 return 0;
801}
802endef
803export COMPILER_TEST
804
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000805compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000806 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000807 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000808 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000809 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000810 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
811 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000812 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000813 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000814 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000815 ( echo "unknown. Aborting."; exit 1)
816 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000817 @printf "Target OS is "
818 @# FreeBSD wc will output extraneous whitespace.
819 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
820 ( echo "unknown. Aborting."; exit 1)
821 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +0000822ifeq ($(TARGET_OS), libpayload)
823 @$(CC) --version 2>&1 | grep -q coreboot || \
824 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
825 echo "This might work but usually does not, please beware." )
826endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000827
Stefan Tauner56787082011-08-18 02:27:19 +0000828define LIBPCI_TEST
829/* Avoid a failing test due to libpci header symbol shadowing breakage */
830#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000831#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +0000832#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +0000833#else
834#include <pciutils/pci.h>
835#endif
Stefan Tauner56787082011-08-18 02:27:19 +0000836struct pci_access *pacc;
837int main(int argc, char **argv)
838{
839 (void) argc;
840 (void) argv;
841 pacc = pci_alloc();
842 return 0;
843}
844endef
845export LIBPCI_TEST
846
Stefan Tauner56734502015-02-08 21:58:04 +0000847define PCI_GET_DEV_TEST
848/* Avoid a failing test due to libpci header symbol shadowing breakage */
849#define index shadow_workaround_index
850#if !defined __NetBSD__
851#include <pci/pci.h>
852#else
853#include <pciutils/pci.h>
854#endif
855struct pci_access *pacc;
856struct pci_dev *dev = {0};
857int main(int argc, char **argv)
858{
859 (void) argc;
860 (void) argv;
861 pacc = pci_alloc();
862 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
863 return 0;
864}
865endef
866export PCI_GET_DEV_TEST
867
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000868define LIBUSB0_TEST
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000869#include "platform.h"
870#if IS_WINDOWS
871#include <lusb0_usb.h>
872#else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000873#include <usb.h>
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000874#endif
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000875int main(int argc, char **argv)
876{
877 (void) argc;
878 (void) argv;
879 usb_init();
880 return 0;
881}
882endef
883export LIBUSB0_TEST
884
885hwlibs: compiler
886 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000887ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000888 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000889 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000890 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000891 echo "found." || ( echo "not found."; echo; \
892 echo "Please install libpci headers (package pciutils-devel)."; \
893 echo "See README for more information."; echo; \
894 rm -f .test.c .test.o; exit 1)
Stefan Tauner56734502015-02-08 21:58:04 +0000895 @printf "Checking version of pci_get_dev... "
896 @echo "$$PCI_GET_DEV_TEST" > .test.c
897 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null 2>&1 && \
898 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
899 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps )
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000900 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000901 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000902 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000903 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000904 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000905 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000906 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000907 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000908 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
909 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000910endif
911ifeq ($(CHECK_LIBUSB0), yes)
912 @printf "Checking for libusb-0.1/libusb-compat headers... "
913 @echo "$$LIBUSB0_TEST" > .test.c
914 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
915 echo "found." || ( echo "not found."; echo; \
916 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
917 echo "See README for more information."; echo; \
918 rm -f .test.c .test.o; exit 1)
919 @printf "Checking if libusb-0.1 is usable... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000920 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000921 echo "yes." || ( echo "no."; \
922 echo "Please install libusb-0.1 or libusb-compat."; \
923 echo "See README for more information."; echo; \
924 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1)
925 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000926endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000927
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000928.features: features
929
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000930# If a user does not explicitly request a non-working feature, we should
931# silently disable it. However, if a non-working (does not compile) feature
932# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000933# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000934featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000935ifeq ($(PROGRAMMER_OBJS),)
936 @echo "You have to enable at least one programmer driver!"
937 @false
938endif
939ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000940 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
941 @false
942endif
943
Stefan Tauner56787082011-08-18 02:27:19 +0000944define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +0000945#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +0000946#include <ftdi.h>
947struct ftdi_context *ftdic = NULL;
948int main(int argc, char **argv)
949{
950 (void) argc;
951 (void) argv;
952 return ftdi_init(ftdic);
953}
954endef
955export FTDI_TEST
956
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000957define FTDI_232H_TEST
958#include <ftdi.h>
959enum ftdi_chip_type type = TYPE_232H;
960endef
961export FTDI_232H_TEST
962
Stefan Tauner56787082011-08-18 02:27:19 +0000963define UTSNAME_TEST
964#include <sys/utsname.h>
965struct utsname osinfo;
966int main(int argc, char **argv)
967{
968 (void) argc;
969 (void) argv;
970 uname (&osinfo);
971 return 0;
972}
973endef
974export UTSNAME_TEST
975
Stefan Tauner8868db32012-03-13 00:18:19 +0000976define LINUX_SPI_TEST
977#include <linux/types.h>
978#include <linux/spi/spidev.h>
979
980int main(int argc, char **argv)
981{
982 (void) argc;
983 (void) argv;
984 return 0;
985}
986endef
987export LINUX_SPI_TEST
988
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000989define LINUX_I2C_TEST
990#include <linux/i2c-dev.h>
991#include <linux/i2c.h>
992
993int main(int argc, char **argv)
994{
995 (void) argc;
996 (void) argv;
997 return 0;
998}
999endef
1000export LINUX_I2C_TEST
1001
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001002features: compiler
1003 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +00001004ifeq ($(NEED_FTDI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +00001005 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +00001006 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001007 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001008 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
1009 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001010 @printf "Checking for FT232H support in libftdi... "
1011 @echo "$$FTDI_232H_TEST" >> .featuretest.c
1012 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
1013 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1014 ( echo "not found."; echo "FT232H := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001015endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001016ifeq ($(CONFIG_LINUX_SPI), yes)
1017 @printf "Checking if Linux SPI headers are present... "
1018 @echo "$$LINUX_SPI_TEST" > .featuretest.c
1019 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1020 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
1021 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
1022endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001023ifeq ($(NEED_LINUX_I2C), yes)
1024 @printf "Checking if Linux I2C headers are present... "
1025 @echo "$$LINUX_I2C_TEST" > .featuretest.c
1026 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1027 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
1028 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp )
1029endif
Stefan Tauner56787082011-08-18 02:27:19 +00001030 @printf "Checking for utsname support... "
1031 @echo "$$UTSNAME_TEST" > .featuretest.c
1032 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1033 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
1034 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
1035 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1036 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001037
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001038$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Taunerd5ff8452015-01-10 09:32:07 +00001039 @sed -e '1 s#".*".*#"$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001040
1041install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001042 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001043 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001044 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001045 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001046
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001047export: $(PROGRAM).8
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001048 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1049 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
1050 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001051 @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8"
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001052 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
1053 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001054
1055tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001056 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
1057 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1058 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001059
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001060djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001061 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
1062libpayload: clean
1063 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001064
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001065.PHONY: all install clean distclean compiler hwlibs features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +00001066
Stefan Reinauere2f01582010-06-07 11:08:07 +00001067-include $(OBJS:.o=.d)