blob: 0939341a0d58d16c90fd7ddedce8678221eacfd2 [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 Taunerf4651f62015-03-01 22:05:16 +0000389RELEASE := 0.9.8
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 Taunerbfaf7b12016-01-07 09:50:26 +0000637FTDILIBS := $(shell [ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; pkg-config --libs libftdi1 || 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'")
Stefan Taunerbfaf7b12016-01-07 09:50:26 +0000639FTDI_INCLUDES := $(shell [ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; pkg-config --cflags-only-I libftdi1)
Alexandru Gagniuc3d06abe2015-12-25 22:42:45 +0000640FEATURE_CFLAGS += $(FTDI_INCLUDES)
Jörg Mayer8776db22009-11-16 14:05:13 +0000641FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000642# We can't set NEED_USB here because that would transform libftdi auto-enabling
643# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000644endif
645
646ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000647FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000648PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000649endif
650
651ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000652FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000653PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000654NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000655endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000656
Joerg Fischer5665ef32010-05-21 21:54:07 +0000657ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000658FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000659PROGRAMMER_OBJS += nicrealtek.o
660NEED_PCI := yes
661endif
662
Andrew Morganc29c2e72010-06-07 22:37:54 +0000663ifeq ($(CONFIG_NICNATSEMI), yes)
664FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
665PROGRAMMER_OBJS += nicnatsemi.o
666NEED_PCI := yes
667endif
668
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000669ifeq ($(CONFIG_NICINTEL), yes)
670FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
671PROGRAMMER_OBJS += nicintel.o
672NEED_PCI := yes
673endif
674
Idwer Vollering004f4b72010-09-03 18:21:21 +0000675ifeq ($(CONFIG_NICINTEL_SPI), yes)
676FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
677PROGRAMMER_OBJS += nicintel_spi.o
678NEED_PCI := yes
679endif
680
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000681ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
682FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
683PROGRAMMER_OBJS += nicintel_eeprom.o
684NEED_PCI := yes
685endif
686
Mark Marshall90021f22010-12-03 14:48:11 +0000687ifeq ($(CONFIG_OGP_SPI), yes)
688FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
689PROGRAMMER_OBJS += ogp_spi.o
690NEED_PCI := yes
691endif
692
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000693ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
694FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000695PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000696NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000697endif
698
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000699ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000700FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000701PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000702NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000703endif
704
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000705ifeq ($(CONFIG_SATAMV), yes)
706FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
707PROGRAMMER_OBJS += satamv.o
708NEED_PCI := yes
709endif
710
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000711ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000712# This is a totally ugly hack.
713FEATURE_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 +0000714PROGRAMMER_OBJS += linux_spi.o
715endif
716
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000717ifeq ($(CONFIG_MSTARDDC_SPI), yes)
718# This is a totally ugly hack.
719FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "LINUX_I2C_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_MSTARDDC_SPI=1'")
720NEED_LINUX_I2C := yes
721PROGRAMMER_OBJS += mstarddc_spi.o
722endif
723
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000724ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000725LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000726endif
727
728ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000729ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000730LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000731endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000732endif
733
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000734ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000735CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000736FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner56734502015-02-08 21:58:04 +0000737FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "OLD_PCI_GET_DEV := yes" .libdeps && printf "%s" "-D'OLD_PCI_GET_DEV=1'")
738
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000739PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000740ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000741# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000742PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000743# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000744PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000745else
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000746
Stefan Tauner449abe22013-09-11 23:34:57 +0000747PCILIBS += -lpci
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000748
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000749ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000750# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000751PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000752else
753ifeq ($(TARGET_OS), Darwin)
754# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000755PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000756endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000757endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000758endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000759endif
760
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000761ifeq ($(NEED_USB), yes)
762CHECK_LIBUSB0 = yes
763FEATURE_CFLAGS += -D'NEED_USB=1'
Stefan Taunerbfaf7b12016-01-07 09:50:26 +0000764USBLIBS := $(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 +0000765endif
766
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000767ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000768FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000769CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000770endif
771
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000772FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
773
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000774# We could use PULLED_IN_LIBS, but that would be ugly.
775FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
776
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000777LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000778OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000779
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000780all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000781ifeq ($(ARCH), x86)
782 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
783endif
784
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000785$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000786 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000787
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000788libflashrom.a: $(LIBFLASHROM_OBJS)
789 $(AR) rcs $@ $^
790 $(RANLIB) $@
791
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000792# TAROPTIONS reduces information leakage from the packager's system.
793# If other tar programs support command line arguments for setting uid/gid of
794# stored files, they can be handled here as well.
795TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000796
Paul Fox05dfbe62009-06-16 21:08:06 +0000797%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000798 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000799
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000800# Make sure to add all names of generated binaries here.
801# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000802# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000803clean:
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000804 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000805 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000806
Ollie Lho184a4042005-11-26 21:55:36 +0000807distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000808 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000809
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000810strip: $(PROGRAM)$(EXEC_SUFFIX)
811 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000812
Stefan Tauner56787082011-08-18 02:27:19 +0000813# to define test programs we use verbatim variables, which get exported
814# to environment variables and are referenced with $$<varname> later
815
816define COMPILER_TEST
817int main(int argc, char **argv)
818{
819 (void) argc;
820 (void) argv;
821 return 0;
822}
823endef
824export COMPILER_TEST
825
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000826compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000827 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000828 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000829 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000830 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000831 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
832 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000833 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000834 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000835 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000836 ( echo "unknown. Aborting."; exit 1)
837 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000838 @printf "Target OS is "
839 @# FreeBSD wc will output extraneous whitespace.
840 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
841 ( echo "unknown. Aborting."; exit 1)
842 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +0000843ifeq ($(TARGET_OS), libpayload)
844 @$(CC) --version 2>&1 | grep -q coreboot || \
845 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
846 echo "This might work but usually does not, please beware." )
847endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000848
Stefan Tauner56787082011-08-18 02:27:19 +0000849define LIBPCI_TEST
850/* Avoid a failing test due to libpci header symbol shadowing breakage */
851#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000852#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +0000853#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +0000854#else
855#include <pciutils/pci.h>
856#endif
Stefan Tauner56787082011-08-18 02:27:19 +0000857struct pci_access *pacc;
858int main(int argc, char **argv)
859{
860 (void) argc;
861 (void) argv;
862 pacc = pci_alloc();
863 return 0;
864}
865endef
866export LIBPCI_TEST
867
Stefan Tauner56734502015-02-08 21:58:04 +0000868define PCI_GET_DEV_TEST
869/* Avoid a failing test due to libpci header symbol shadowing breakage */
870#define index shadow_workaround_index
871#if !defined __NetBSD__
872#include <pci/pci.h>
873#else
874#include <pciutils/pci.h>
875#endif
876struct pci_access *pacc;
877struct pci_dev *dev = {0};
878int main(int argc, char **argv)
879{
880 (void) argc;
881 (void) argv;
882 pacc = pci_alloc();
883 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
884 return 0;
885}
886endef
887export PCI_GET_DEV_TEST
888
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000889define LIBUSB0_TEST
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000890#include "platform.h"
891#if IS_WINDOWS
892#include <lusb0_usb.h>
893#else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000894#include <usb.h>
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000895#endif
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000896int main(int argc, char **argv)
897{
898 (void) argc;
899 (void) argv;
900 usb_init();
901 return 0;
902}
903endef
904export LIBUSB0_TEST
905
906hwlibs: compiler
907 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000908ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000909 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000910 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000911 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000912 echo "found." || ( echo "not found."; echo; \
913 echo "Please install libpci headers (package pciutils-devel)."; \
914 echo "See README for more information."; echo; \
915 rm -f .test.c .test.o; exit 1)
Stefan Tauner56734502015-02-08 21:58:04 +0000916 @printf "Checking version of pci_get_dev... "
917 @echo "$$PCI_GET_DEV_TEST" > .test.c
918 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null 2>&1 && \
919 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
920 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps )
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000921 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000922 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000923 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000924 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000925 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000926 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000927 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000928 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000929 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
930 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000931endif
932ifeq ($(CHECK_LIBUSB0), yes)
933 @printf "Checking for libusb-0.1/libusb-compat headers... "
934 @echo "$$LIBUSB0_TEST" > .test.c
935 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
936 echo "found." || ( echo "not found."; echo; \
937 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
938 echo "See README for more information."; echo; \
939 rm -f .test.c .test.o; exit 1)
940 @printf "Checking if libusb-0.1 is usable... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000941 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000942 echo "yes." || ( echo "no."; \
943 echo "Please install libusb-0.1 or libusb-compat."; \
944 echo "See README for more information."; echo; \
945 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1)
946 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000947endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000948
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000949.features: features
950
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000951# If a user does not explicitly request a non-working feature, we should
952# silently disable it. However, if a non-working (does not compile) feature
953# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000954# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000955featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000956ifeq ($(PROGRAMMER_OBJS),)
957 @echo "You have to enable at least one programmer driver!"
958 @false
959endif
960ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000961 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
962 @false
963endif
964
Stefan Tauner56787082011-08-18 02:27:19 +0000965define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +0000966#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +0000967#include <ftdi.h>
968struct ftdi_context *ftdic = NULL;
969int main(int argc, char **argv)
970{
971 (void) argc;
972 (void) argv;
973 return ftdi_init(ftdic);
974}
975endef
976export FTDI_TEST
977
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000978define FTDI_232H_TEST
979#include <ftdi.h>
980enum ftdi_chip_type type = TYPE_232H;
981endef
982export FTDI_232H_TEST
983
Stefan Tauner56787082011-08-18 02:27:19 +0000984define UTSNAME_TEST
985#include <sys/utsname.h>
986struct utsname osinfo;
987int main(int argc, char **argv)
988{
989 (void) argc;
990 (void) argv;
991 uname (&osinfo);
992 return 0;
993}
994endef
995export UTSNAME_TEST
996
Stefan Tauner8868db32012-03-13 00:18:19 +0000997define LINUX_SPI_TEST
998#include <linux/types.h>
999#include <linux/spi/spidev.h>
1000
1001int main(int argc, char **argv)
1002{
1003 (void) argc;
1004 (void) argv;
1005 return 0;
1006}
1007endef
1008export LINUX_SPI_TEST
1009
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001010define LINUX_I2C_TEST
1011#include <linux/i2c-dev.h>
1012#include <linux/i2c.h>
1013
1014int main(int argc, char **argv)
1015{
1016 (void) argc;
1017 (void) argv;
1018 return 0;
1019}
1020endef
1021export LINUX_I2C_TEST
1022
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001023features: compiler
1024 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +00001025ifeq ($(NEED_FTDI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +00001026 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +00001027 @echo "$$FTDI_TEST" > .featuretest.c
Alexandru Gagniuc3d06abe2015-12-25 22:42:45 +00001028 @$(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001029 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
1030 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001031 @printf "Checking for FT232H support in libftdi... "
1032 @echo "$$FTDI_232H_TEST" >> .featuretest.c
Alexandru Gagniuc3d06abe2015-12-25 22:42:45 +00001033 @$(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001034 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1035 ( echo "not found."; echo "FT232H := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001036endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001037ifeq ($(CONFIG_LINUX_SPI), yes)
1038 @printf "Checking if Linux SPI headers are present... "
1039 @echo "$$LINUX_SPI_TEST" > .featuretest.c
1040 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1041 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
1042 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
1043endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001044ifeq ($(NEED_LINUX_I2C), yes)
1045 @printf "Checking if Linux I2C headers are present... "
1046 @echo "$$LINUX_I2C_TEST" > .featuretest.c
1047 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1048 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
1049 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp )
1050endif
Stefan Tauner56787082011-08-18 02:27:19 +00001051 @printf "Checking for utsname support... "
1052 @echo "$$UTSNAME_TEST" > .featuretest.c
1053 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
1054 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
1055 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
1056 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1057 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001058
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001059$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Taunerd5ff8452015-01-10 09:32:07 +00001060 @sed -e '1 s#".*".*#"$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001061
1062install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001063 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001064 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001065 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001066 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001067
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001068export: $(PROGRAM).8
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001069 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1070 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
1071 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001072 @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8"
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001073 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
1074 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001075
1076tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001077 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
1078 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1079 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001080
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001081djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001082 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
1083libpayload: clean
1084 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001085
Stefan Tauner74dc73f2015-03-01 22:04:38 +00001086.PHONY: all install clean distclean compiler hwlibs features export tarball djgpp-dos featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001087
Stefan Reinauere2f01582010-06-07 11:08:07 +00001088-include $(OBJS:.o=.d)