blob: e100b161544ede458f3baab69ea36635063a9b4f [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 Tauner3f73ffe2016-01-07 17:45:59 +000040PKG_CONFIG ?= pkg-config
41BUILD_DETAILS_FILE ?= build_details.txt
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000042
Stefan Taunerfd0d4132012-09-25 21:24:55 +000043# The following parameter changes the default programmer that will be used if there is no -p/--programmer
44# argument given when running flashrom. The predefined setting does not enable any default so that every
45# user has to declare the programmer he wants to use on every run. The rationale for this to be not set
46# (to e.g. the internal programmer) is that forgetting to specify this when working with another programmer
47# easily puts the system attached to the default programmer at risk (e.g. you want to flash coreboot to another
48# system attached to an external programmer while the default programmer is set to the internal programmer, and
49# you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer
50# running flashrom). Please do not enable this without thinking about the possible consequences. Possible
51# values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options
52# evaluated below, namely those that enable/disable the various programmers).
53# Compilation will fail for unspecified values.
54CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID
Stefan Tauner265fcac2014-06-02 00:12:23 +000055# The following adds a default parameter for the default programmer set above (only).
56CONFIG_DEFAULT_PROGRAMMER_ARGS ?= ''
57# Example: compiling with
58# make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000"
59# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000060
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000061# If your compiler spits out excessive warnings, run make WARNERROR=no
62# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000063WARNERROR ?= yes
64
65ifeq ($(WARNERROR), yes)
66CFLAGS += -Werror
67endif
68
Stefan Taunere37735a2015-01-26 22:03:35 +000069ifdef LIBS_BASE
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000070CPPFLAGS += -I$(LIBS_BASE)/include
Stefan Taunere37735a2015-01-26 22:03:35 +000071LDFLAGS += -L$(LIBS_BASE)/lib -Wl,-rpath -Wl,$(LIBS_BASE)/lib
72PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig
73endif
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000074
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000075dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUILD_DETAILS_FILE))
76debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(1) ; }' >&2; { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE))
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000077###############################################################################
Stefan Tauner037cd842013-08-25 00:10:56 +000078# General OS-specific settings.
79# 1. Prepare for later by gathering information about host and target OS
80# 2. Set compiler flags and parameters according to OSes
81# 3. Likewise verify user-supplied CONFIG_* variables.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000082
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000083# HOST_OS is only used to work around local toolchain issues.
Stefan Tauner037cd842013-08-25 00:10:56 +000084HOST_OS ?= $(shell uname)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000085ifeq ($(HOST_OS), MINGW32_NT-5.1)
86# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
87CC = gcc
88endif
89ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +000090STRIP_ARGS = -s
91endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000092
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000093# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000094# IMPORTANT: The following line must be placed before TARGET_OS is ever used
95# (of course), but should come after any lines setting CC because the line
96# below uses CC itself.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000097override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000098
99ifeq ($(TARGET_OS), Darwin)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +0000100CPPFLAGS += -I/opt/local/include -I/usr/local/include
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000101LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +0000102endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000103
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000104ifeq ($(TARGET_OS), FreeBSD)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +0000105CPPFLAGS += -I/usr/local/include
Andriy Gapon65c1b862008-05-22 13:22:45 +0000106LDFLAGS += -L/usr/local/lib
107endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000108
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000109ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000110CPPFLAGS += -I/usr/local/include
111LDFLAGS += -L/usr/local/lib
112endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000113
Stefan Taunerc65b8552013-09-12 15:48:39 +0000114ifeq ($(TARGET_OS), NetBSD)
115CPPFLAGS += -I/usr/pkg/include
116LDFLAGS += -L/usr/pkg/lib
117endif
118
119ifeq ($(TARGET_OS), DragonFlyBSD)
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000120CPPFLAGS += -I/usr/local/include
121LDFLAGS += -L/usr/local/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000122endif
123
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000124ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000125EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000126# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +0000127CFLAGS += -Wno-format
Stefan Tauner449abe22013-09-11 23:34:57 +0000128LIBS += -lgetopt
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000129# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000130ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
131UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
132else
133override CONFIG_BUSPIRATE_SPI = no
134endif
135ifeq ($(CONFIG_SERPROG), yes)
136UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
137else
138override CONFIG_SERPROG = no
139endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000140ifeq ($(CONFIG_PONY_SPI), yes)
141UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
142else
143override CONFIG_PONY_SPI = no
144endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000145# Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported under DOS (missing USB support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000146ifeq ($(CONFIG_DEDIPROG), yes)
147UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
148else
149override CONFIG_DEDIPROG = no
150endif
151ifeq ($(CONFIG_FT2232_SPI), yes)
152UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
153else
154override CONFIG_FT2232_SPI = no
155endif
James Lairdc60de0e2013-03-27 13:00:23 +0000156ifeq ($(CONFIG_USBBLASTER_SPI), yes)
157UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
158else
159override CONFIG_USBBLASTER_SPI = no
160endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000161ifeq ($(CONFIG_PICKIT2_SPI), yes)
162UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
163else
164override CONFIG_PICKIT2_SPI = no
165endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000166endif
Ollie Lho184a4042005-11-26 21:55:36 +0000167
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000168# FIXME: Should we check for Cygwin/MSVC as well?
169ifeq ($(TARGET_OS), MinGW)
170EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000171# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000172FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000173# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
174# for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */
175FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000176# libusb-win32/libftdi stuff is usually installed in /usr/local.
177CPPFLAGS += -I/usr/local/include
178LDFLAGS += -L/usr/local/lib
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000179# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
180ifeq ($(CONFIG_INTERNAL), yes)
181UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
182else
183override CONFIG_INTERNAL = no
184endif
185ifeq ($(CONFIG_RAYER_SPI), yes)
186UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
187else
188override CONFIG_RAYER_SPI = no
189endif
190ifeq ($(CONFIG_NIC3COM), yes)
191UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
192else
193override CONFIG_NIC3COM = no
194endif
195ifeq ($(CONFIG_GFXNVIDIA), yes)
196UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
197else
198override CONFIG_GFXNVIDIA = no
199endif
200ifeq ($(CONFIG_SATASII), yes)
201UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
202else
203override CONFIG_SATASII = no
204endif
205ifeq ($(CONFIG_ATAHPT), yes)
206UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
207else
208override CONFIG_ATAHPT = no
209endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000210ifeq ($(CONFIG_ATAVIA), yes)
211UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
212else
213override CONFIG_ATAVIA = no
214endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000215ifeq ($(CONFIG_IT8212), yes)
216UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
217else
218override CONFIG_IT8212 = no
219endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000220ifeq ($(CONFIG_DRKAISER), yes)
221UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
222else
223override CONFIG_DRKAISER = no
224endif
225ifeq ($(CONFIG_NICREALTEK), yes)
226UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
227else
228override CONFIG_NICREALTEK = no
229endif
230ifeq ($(CONFIG_NICNATSEMI), yes)
231UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
232else
233override CONFIG_NICNATSEMI = no
234endif
235ifeq ($(CONFIG_NICINTEL), yes)
236UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
237else
238override CONFIG_NICINTEL = no
239endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000240ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
241UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
242else
243override CONFIG_NICINTEL_EEPROM = no
244endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000245ifeq ($(CONFIG_NICINTEL_SPI), yes)
246UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
247else
248override CONFIG_NICINTEL_SPI = no
249endif
250ifeq ($(CONFIG_OGP_SPI), yes)
251UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
252else
253override CONFIG_OGP_SPI = no
254endif
255ifeq ($(CONFIG_SATAMV), yes)
256UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
257else
258override CONFIG_SATAMV = no
259endif
260endif
261
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000262ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000263ifeq ($(MAKECMDGOALS),)
264.DEFAULT_GOAL := libflashrom.a
265$(info Setting default goal to libflashrom.a)
266endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000267FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000268ifeq ($(CONFIG_DUMMY), yes)
269UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
270else
271override CONFIG_DUMMY = no
272endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000273# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000274ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
275UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
276else
277override CONFIG_BUSPIRATE_SPI = no
278endif
279ifeq ($(CONFIG_SERPROG), yes)
280UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
281else
282override CONFIG_SERPROG = no
283endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000284ifeq ($(CONFIG_PONY_SPI), yes)
285UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
286else
287override CONFIG_PONY_SPI = no
288endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000289# Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported with libpayload (missing libusb support)
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000290ifeq ($(CONFIG_DEDIPROG), yes)
291UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
292else
293override CONFIG_DEDIPROG = no
294endif
295ifeq ($(CONFIG_FT2232_SPI), yes)
296UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
297else
298override CONFIG_FT2232_SPI = no
299endif
James Lairdc60de0e2013-03-27 13:00:23 +0000300ifeq ($(CONFIG_USBBLASTER_SPI), yes)
301UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
302else
303override CONFIG_USBBLASTER_SPI = no
304endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000305ifeq ($(CONFIG_PICKIT2_SPI), yes)
306UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
307else
308override CONFIG_PICKIT2_SPI = no
309endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000310endif
311
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000312ifneq ($(TARGET_OS), Linux)
313ifeq ($(CONFIG_LINUX_SPI), yes)
314UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
315else
316override CONFIG_LINUX_SPI = no
317endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000318ifeq ($(CONFIG_MSTARDDC_SPI), yes)
319UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
320else
321override CONFIG_MSTARDDC_SPI = no
322endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000323endif
324
Stefan Tauner037cd842013-08-25 00:10:56 +0000325###############################################################################
326# General architecture-specific settings.
327# Like above for the OS, below we verify user-supplied options depending on the target architecture.
328
Uwe Hermann44ffd582011-08-20 14:16:00 +0000329# Determine the destination processor architecture.
330# IMPORTANT: The following line must be placed before ARCH is ever used
331# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000332# below uses CC itself.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000333override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
Uwe Hermann44ffd582011-08-20 14:16:00 +0000334
Stefan Taunerfb2d77c2015-02-10 08:03:10 +0000335# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
David Hendricksb286da72012-02-13 00:35:35 +0000336# Right now this means the drivers below only work on x86.
337ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000338ifeq ($(CONFIG_NIC3COM), yes)
339UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
340else
341override CONFIG_NIC3COM = no
342endif
343ifeq ($(CONFIG_NICREALTEK), yes)
344UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
345else
346override CONFIG_NICREALTEK = no
347endif
348ifeq ($(CONFIG_NICNATSEMI), yes)
349UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
350else
351override CONFIG_NICNATSEMI = no
352endif
353ifeq ($(CONFIG_RAYER_SPI), yes)
354UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
355else
356override CONFIG_RAYER_SPI = no
357endif
358ifeq ($(CONFIG_ATAHPT), yes)
359UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
360else
361override CONFIG_ATAHPT = no
362endif
363ifeq ($(CONFIG_SATAMV), yes)
364UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
365else
366override CONFIG_SATAMV = no
367endif
368endif
369
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000370###############################################################################
371# Flash chip drivers and bus support infrastructure.
372
Stefan Tauner4404f732013-09-12 08:28:56 +0000373CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000374 sst28sf040.o 82802ab.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000375 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Aidan Thorntondb4e87d2013-08-27 18:01:53 +0000376 opaque.o sfdp.o en29lv640b.o at45db.o
Sean Nelson5d134642009-12-24 16:54:21 +0000377
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000378###############################################################################
379# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000380
Stefan Tauner6ad6e012014-06-12 00:04:32 +0000381LIB_OBJS = layout.o flashrom.o udelay.o programmer.o helpers.o
Sean Nelson5d134642009-12-24 16:54:21 +0000382
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000383###############################################################################
384# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000385
Stefan Tauner9b32de92014-08-08 23:52:33 +0000386CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000387
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000388# Set the flashrom version string from the highest revision number of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000389# Note to packagers: Any tree exported with "make export" or "make tarball"
390# will not require subversion. The downloadable snapshots are already exported.
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000391SVNVERSION := $(shell ./util/getrevision.sh -u 2>/dev/null )
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000392
Stefan Taunerf4651f62015-03-01 22:05:16 +0000393RELEASE := 0.9.8
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000394VERSION := $(RELEASE)-$(SVNVERSION)
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000395RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000396
397SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000398
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000399# Inform user if there is no meaningful version string. If there is version information from a VCS print
400# something anyway because $(info...) will print a line break in any case which would look suspicious.
Stefan Tauner5d1ad352015-01-25 23:57:08 +0000401# The && between the echos is a workaround for old versions of GNU make that issue the error "unterminated
402# variable reference" if a semicolon is used instead.
403$(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 +0000404 echo "Replacing all version templates with $(VERSION)." ))
405
Stefan Tauner037cd842013-08-25 00:10:56 +0000406###############################################################################
407# Default settings of CONFIG_* variables.
408
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000409# Always enable internal/onboard support for now.
410CONFIG_INTERNAL ?= yes
411
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000412# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000413CONFIG_SERPROG ?= yes
414
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000415# RayeR SPIPGM hardware support
416CONFIG_RAYER_SPI ?= yes
417
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000418# PonyProg2000 SPI hardware support
419CONFIG_PONY_SPI ?= yes
420
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000421# Always enable 3Com NICs for now.
422CONFIG_NIC3COM ?= yes
423
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000424# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
425CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000426
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000427# Always enable SiI SATA controllers for now.
428CONFIG_SATASII ?= yes
429
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000430# Highpoint (HPT) ATA/RAID controller support.
431# IMPORTANT: This code is not yet working!
432CONFIG_ATAHPT ?= no
433
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000434# VIA VT6421A LPC memory support
435CONFIG_ATAVIA ?= yes
436
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000437# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000438CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000439
James Lairdc60de0e2013-03-27 13:00:23 +0000440# Always enable Altera USB-Blaster dongles for now.
441CONFIG_USBBLASTER_SPI ?= yes
442
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000443# MSTAR DDC support needs more tests/reviews/cleanups.
444CONFIG_MSTARDDC_SPI ?= no
445
Justin Chevrier66e554b2015-02-08 21:58:10 +0000446# Always enable PICkit2 SPI dongles for now.
447CONFIG_PICKIT2_SPI ?= yes
448
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000449# Always enable dummy tracing for now.
450CONFIG_DUMMY ?= yes
451
452# Always enable Dr. Kaiser for now.
453CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000454
Joerg Fischer5665ef32010-05-21 21:54:07 +0000455# Always enable Realtek NICs for now.
456CONFIG_NICREALTEK ?= yes
457
Andrew Morganc29c2e72010-06-07 22:37:54 +0000458# Disable National Semiconductor NICs until support is complete and tested.
459CONFIG_NICNATSEMI ?= no
460
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000461# Always enable Intel NICs for now.
462CONFIG_NICINTEL ?= yes
463
Idwer Vollering004f4b72010-09-03 18:21:21 +0000464# Always enable SPI on Intel NICs for now.
465CONFIG_NICINTEL_SPI ?= yes
466
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000467# Always enable EEPROM on Intel NICs for now.
468CONFIG_NICINTEL_EEPROM ?= yes
469
Mark Marshall90021f22010-12-03 14:48:11 +0000470# Always enable SPI on OGP cards for now.
471CONFIG_OGP_SPI ?= yes
472
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000473# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000474CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000475
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000476# Disable Dediprog SF100 until support is complete and tested.
477CONFIG_DEDIPROG ?= no
478
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000479# Always enable Marvell SATA controllers for now.
480CONFIG_SATAMV ?= yes
481
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000482# Enable Linux spidev interface by default. We disable it on non-Linux targets.
483CONFIG_LINUX_SPI ?= yes
484
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000485# Always enable ITE IT8212F PATA controllers for now.
486CONFIG_IT8212 ?= yes
487
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000488# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000489CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000490
Patrick Georgiced7ab62015-01-19 19:52:34 +0000491# Enable all features if CONFIG_EVERYTHING=yes is given
492ifeq ($(CONFIG_EVERYTHING), yes)
493$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
494 $(if $(filter no, $($(var))),\
495 $(eval $(var)=yes)))
496endif
497
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000498# Bitbanging SPI infrastructure, default off unless needed.
499ifeq ($(CONFIG_RAYER_SPI), yes)
500override CONFIG_BITBANG_SPI = yes
501else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000502ifeq ($(CONFIG_PONY_SPI), yes)
503override CONFIG_BITBANG_SPI = yes
504else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000505ifeq ($(CONFIG_INTERNAL), yes)
506override CONFIG_BITBANG_SPI = yes
507else
508ifeq ($(CONFIG_NICINTEL_SPI), yes)
509override CONFIG_BITBANG_SPI = yes
510else
Mark Marshall90021f22010-12-03 14:48:11 +0000511ifeq ($(CONFIG_OGP_SPI), yes)
512override CONFIG_BITBANG_SPI = yes
513else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000514CONFIG_BITBANG_SPI ?= no
515endif
516endif
517endif
Mark Marshall90021f22010-12-03 14:48:11 +0000518endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000519endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000520
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000521###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000522# Handle CONFIG_* variables that depend on others set (and verified) above.
523
524# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
525ifeq ($(TARGET_OS), libpayload)
526ifeq ($(CONFIG_INTERNAL), yes)
527ifeq ($(CONFIG_INTERNAL_DMI), no)
528UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
529else
530override CONFIG_INTERNAL_DMI = yes
531endif
532endif
533endif
534
535# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
536CONFIG_INTERNAL_DMI ?= yes
537
538###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000539# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000540# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000541
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000542FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000543FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000544
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000545ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000546FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000547PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000548ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000549PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000550PROGRAMMER_OBJS += ichspi.o ich_descriptors.o dmi.o
551ifeq ($(CONFIG_INTERNAL_DMI), yes)
552FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
553endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000554else
555endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000556NEED_PCI := yes
557endif
558
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000559ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000560FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000561PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000562NEED_SERIAL := yes
563NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000564endif
565
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000566ifeq ($(CONFIG_RAYER_SPI), yes)
567FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
568PROGRAMMER_OBJS += rayer_spi.o
569# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
570NEED_PCI := yes
571endif
572
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000573ifeq ($(CONFIG_PONY_SPI), yes)
574FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
575PROGRAMMER_OBJS += pony_spi.o
576NEED_SERIAL := yes
577endif
578
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000579ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000580FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000581PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000582endif
583
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000584ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000585FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000586PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000587NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000588endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000589
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000590ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000591FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000592PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000593NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000594endif
595
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000596ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000597FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000598PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000599NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000600endif
601
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000602ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000603FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000604PROGRAMMER_OBJS += atahpt.o
605NEED_PCI := yes
606endif
607
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000608ifeq ($(CONFIG_ATAVIA), yes)
609FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
610PROGRAMMER_OBJS += atavia.o
611NEED_PCI := yes
612endif
613
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000614ifeq ($(CONFIG_IT8212), yes)
615FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
616PROGRAMMER_OBJS += it8212.o
617NEED_PCI := yes
618endif
619
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000620ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000621# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000622FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000623NEED_FTDI := yes
624PROGRAMMER_OBJS += ft2232_spi.o
625endif
626
627ifeq ($(CONFIG_USBBLASTER_SPI), yes)
628# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000629FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000630NEED_FTDI := yes
631PROGRAMMER_OBJS += usbblaster_spi.o
632endif
633
Justin Chevrier66e554b2015-02-08 21:58:10 +0000634ifeq ($(CONFIG_PICKIT2_SPI), yes)
635FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
636PROGRAMMER_OBJS += pickit2_spi.o
637NEED_USB := yes
638endif
639
James Lairdc60de0e2013-03-27 13:00:23 +0000640ifeq ($(NEED_FTDI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000641FTDILIBS := $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; $(PKG_CONFIG) --libs libftdi1 || $(PKG_CONFIG) --libs libftdi || printf "%s" "-lftdi -lusb")
642FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
643FTDI_INCLUDES := $(call debug_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 +0000644FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000645FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000646# We can't set NEED_USB here because that would transform libftdi auto-enabling
647# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000648endif
649
650ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000651FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000652PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000653endif
654
655ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000656FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000657PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000658NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000659endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000660
Joerg Fischer5665ef32010-05-21 21:54:07 +0000661ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000662FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000663PROGRAMMER_OBJS += nicrealtek.o
664NEED_PCI := yes
665endif
666
Andrew Morganc29c2e72010-06-07 22:37:54 +0000667ifeq ($(CONFIG_NICNATSEMI), yes)
668FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
669PROGRAMMER_OBJS += nicnatsemi.o
670NEED_PCI := yes
671endif
672
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000673ifeq ($(CONFIG_NICINTEL), yes)
674FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
675PROGRAMMER_OBJS += nicintel.o
676NEED_PCI := yes
677endif
678
Idwer Vollering004f4b72010-09-03 18:21:21 +0000679ifeq ($(CONFIG_NICINTEL_SPI), yes)
680FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
681PROGRAMMER_OBJS += nicintel_spi.o
682NEED_PCI := yes
683endif
684
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000685ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
686FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
687PROGRAMMER_OBJS += nicintel_eeprom.o
688NEED_PCI := yes
689endif
690
Mark Marshall90021f22010-12-03 14:48:11 +0000691ifeq ($(CONFIG_OGP_SPI), yes)
692FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
693PROGRAMMER_OBJS += ogp_spi.o
694NEED_PCI := yes
695endif
696
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000697ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
698FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000699PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000700NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000701endif
702
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000703ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000704FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000705PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000706NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000707endif
708
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000709ifeq ($(CONFIG_SATAMV), yes)
710FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
711PROGRAMMER_OBJS += satamv.o
712NEED_PCI := yes
713endif
714
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000715ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000716# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000717FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_SPI_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_SPI=1'")
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000718PROGRAMMER_OBJS += linux_spi.o
719endif
720
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000721ifeq ($(CONFIG_MSTARDDC_SPI), yes)
722# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000723FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_I2C_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_MSTARDDC_SPI=1'")
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000724NEED_LINUX_I2C := yes
725PROGRAMMER_OBJS += mstarddc_spi.o
726endif
727
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000728ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000729LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000730endif
731
732ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000733ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000734LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000735endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000736endif
737
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000738ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000739CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000740FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000741FEATURE_CFLAGS += $(call debug_shell,grep -q "OLD_PCI_GET_DEV := yes" .libdeps && printf "%s" "-D'OLD_PCI_GET_DEV=1'")
Stefan Tauner56734502015-02-08 21:58:04 +0000742
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000743PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000744ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000745# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000746PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000747# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000748PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000749else
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000750
Stefan Tauner449abe22013-09-11 23:34:57 +0000751PCILIBS += -lpci
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000752
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000753ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000754# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000755PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000756else
757ifeq ($(TARGET_OS), Darwin)
758# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000759PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000760endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000761endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000762endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000763endif
764
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000765ifeq ($(NEED_USB), yes)
766CHECK_LIBUSB0 = yes
767FEATURE_CFLAGS += -D'NEED_USB=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000768USBLIBS := $(call debug_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 +0000769endif
770
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000771ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000772FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000773CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000774endif
775
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000776FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000777
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000778# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000779FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000780
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000781LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000782OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000783
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000784all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000785ifeq ($(ARCH), x86)
786 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
787endif
788
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000789$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000790 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000791
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000792libflashrom.a: $(LIBFLASHROM_OBJS)
793 $(AR) rcs $@ $^
794 $(RANLIB) $@
795
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000796# TAROPTIONS reduces information leakage from the packager's system.
797# If other tar programs support command line arguments for setting uid/gid of
798# stored files, they can be handled here as well.
799TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000800
Paul Fox05dfbe62009-06-16 21:08:06 +0000801%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000802 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000803
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000804# Make sure to add all names of generated binaries here.
805# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000806# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000807clean:
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000808 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000809 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000810
Ollie Lho184a4042005-11-26 21:55:36 +0000811distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000812 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000813
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000814strip: $(PROGRAM)$(EXEC_SUFFIX)
815 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000816
Stefan Tauner56787082011-08-18 02:27:19 +0000817# to define test programs we use verbatim variables, which get exported
818# to environment variables and are referenced with $$<varname> later
819
820define COMPILER_TEST
821int main(int argc, char **argv)
822{
823 (void) argc;
824 (void) argv;
825 return 0;
826}
827endef
828export COMPILER_TEST
829
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000830compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000831 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +0000832 @echo "$$COMPILER_TEST" > .test.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000833 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
834 echo "found." || { echo "not found."; \
835 rm -f .test.c .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000836 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000837 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000838 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000839 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000840 ( echo "unknown. Aborting."; exit 1)
841 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000842 @printf "Target OS is "
843 @# FreeBSD wc will output extraneous whitespace.
844 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
845 ( echo "unknown. Aborting."; exit 1)
846 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +0000847ifeq ($(TARGET_OS), libpayload)
848 @$(CC) --version 2>&1 | grep -q coreboot || \
849 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
850 echo "This might work but usually does not, please beware." )
851endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000852
Stefan Tauner56787082011-08-18 02:27:19 +0000853define LIBPCI_TEST
854/* Avoid a failing test due to libpci header symbol shadowing breakage */
855#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000856#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +0000857#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +0000858#else
859#include <pciutils/pci.h>
860#endif
Stefan Tauner56787082011-08-18 02:27:19 +0000861struct pci_access *pacc;
862int main(int argc, char **argv)
863{
864 (void) argc;
865 (void) argv;
866 pacc = pci_alloc();
867 return 0;
868}
869endef
870export LIBPCI_TEST
871
Stefan Tauner56734502015-02-08 21:58:04 +0000872define PCI_GET_DEV_TEST
873/* Avoid a failing test due to libpci header symbol shadowing breakage */
874#define index shadow_workaround_index
875#if !defined __NetBSD__
876#include <pci/pci.h>
877#else
878#include <pciutils/pci.h>
879#endif
880struct pci_access *pacc;
881struct pci_dev *dev = {0};
882int main(int argc, char **argv)
883{
884 (void) argc;
885 (void) argv;
886 pacc = pci_alloc();
887 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
888 return 0;
889}
890endef
891export PCI_GET_DEV_TEST
892
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000893define LIBUSB0_TEST
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000894#include "platform.h"
895#if IS_WINDOWS
896#include <lusb0_usb.h>
897#else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000898#include <usb.h>
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000899#endif
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000900int main(int argc, char **argv)
901{
902 (void) argc;
903 (void) argv;
904 usb_init();
905 return 0;
906}
907endef
908export LIBUSB0_TEST
909
910hwlibs: compiler
911 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000912ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000913 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +0000914 @echo "$$LIBPCI_TEST" > .test.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000915 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
916 echo "found." || { echo "not found."; echo; \
917 echo "Please install libpci headers."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000918 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000919 rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
920 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +0000921 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000922 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +0000923 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000924 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
925 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
926 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
927 echo "yes." || { echo "no."; \
928 printf "Checking if libz+libpci are present and sufficient..." ; \
929 { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
930 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000931 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000932 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000933 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000934 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000935endif
936ifeq ($(CHECK_LIBUSB0), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000937 @printf "Checking for libusb-0.1/libusb-compat headers... " | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000938 @echo "$$LIBUSB0_TEST" > .test.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000939 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
940 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000941 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
942 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000943 rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
944 @printf "Checking if libusb-0.1 is usable... " | tee -a $(BUILD_DETAILS_FILE)
945 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >&2 && \
946 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000947 echo "Please install libusb-0.1 or libusb-compat."; \
948 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000949 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000950 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000951endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000952
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000953.features: features
954
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000955# If a user does not explicitly request a non-working feature, we should
956# silently disable it. However, if a non-working (does not compile) feature
957# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000958# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000959featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000960ifeq ($(PROGRAMMER_OBJS),)
961 @echo "You have to enable at least one programmer driver!"
962 @false
963endif
964ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000965 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
966 @false
967endif
968
Stefan Tauner56787082011-08-18 02:27:19 +0000969define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +0000970#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +0000971#include <ftdi.h>
972struct ftdi_context *ftdic = NULL;
973int main(int argc, char **argv)
974{
975 (void) argc;
976 (void) argv;
977 return ftdi_init(ftdic);
978}
979endef
980export FTDI_TEST
981
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000982define FTDI_232H_TEST
983#include <ftdi.h>
984enum ftdi_chip_type type = TYPE_232H;
985endef
986export FTDI_232H_TEST
987
Stefan Tauner56787082011-08-18 02:27:19 +0000988define UTSNAME_TEST
989#include <sys/utsname.h>
990struct utsname osinfo;
991int main(int argc, char **argv)
992{
993 (void) argc;
994 (void) argv;
995 uname (&osinfo);
996 return 0;
997}
998endef
999export UTSNAME_TEST
1000
Stefan Tauner8868db32012-03-13 00:18:19 +00001001define LINUX_SPI_TEST
1002#include <linux/types.h>
1003#include <linux/spi/spidev.h>
1004
1005int main(int argc, char **argv)
1006{
1007 (void) argc;
1008 (void) argv;
1009 return 0;
1010}
1011endef
1012export LINUX_SPI_TEST
1013
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001014define LINUX_I2C_TEST
1015#include <linux/i2c-dev.h>
1016#include <linux/i2c.h>
1017
1018int main(int argc, char **argv)
1019{
1020 (void) argc;
1021 (void) argv;
1022 return 0;
1023}
1024endef
1025export LINUX_I2C_TEST
1026
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001027features: compiler
1028 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +00001029ifeq ($(NEED_FTDI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001030 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001031 @echo "$$FTDI_TEST" > .featuretest.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001032 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1033 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
1034 printf "Checking for FT232H support in libftdi... " ; \
1035 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
1036 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1037 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1038 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1039 ) || \
1040 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1041 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001042endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001043ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001044 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001045 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001046 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001047 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001048 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1049 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001050endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001051ifeq ($(NEED_LINUX_I2C), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001052 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001053 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001054 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001055 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001056 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1057 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001058endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001059 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001060 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001061 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001062 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001063 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001064 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1065 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001066
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001067$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Taunerd5ff8452015-01-10 09:32:07 +00001068 @sed -e '1 s#".*".*#"$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001069
1070install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001071 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001072 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001073 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001074 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001075
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001076export: $(PROGRAM).8
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001077 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1078 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
1079 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001080 @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8"
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001081 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
1082 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001083
1084tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001085 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
1086 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1087 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001088
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001089djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001090 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
1091libpayload: clean
1092 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001093
Stefan Tauner74dc73f2015-03-01 22:04:38 +00001094.PHONY: all install clean distclean compiler hwlibs features export tarball djgpp-dos featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001095
Stefan Reinauere2f01582010-06-07 11:08:07 +00001096-include $(OBJS:.o=.d)