blob: de8464d1bf70f42e9fc1ef9d3245d3caf5684a05 [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 Taunerbfb067b2016-01-07 18:13:07 +000075ifeq ($(CONFIG_STATIC),yes)
76PKG_CONFIG += --static
77LDFLAGS += -static
78endif
79
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000080dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUILD_DETAILS_FILE))
81debug_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 +000082###############################################################################
Stefan Tauner037cd842013-08-25 00:10:56 +000083# General OS-specific settings.
84# 1. Prepare for later by gathering information about host and target OS
85# 2. Set compiler flags and parameters according to OSes
86# 3. Likewise verify user-supplied CONFIG_* variables.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000087
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000088# HOST_OS is only used to work around local toolchain issues.
Stefan Tauner037cd842013-08-25 00:10:56 +000089HOST_OS ?= $(shell uname)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000090ifeq ($(HOST_OS), MINGW32_NT-5.1)
91# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
92CC = gcc
93endif
94ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +000095STRIP_ARGS = -s
96endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000097
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000098# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000099# IMPORTANT: The following line must be placed before TARGET_OS is ever used
100# (of course), but should come after any lines setting CC because the line
101# below uses CC itself.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000102override 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 +0000103
104ifeq ($(TARGET_OS), Darwin)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +0000105CPPFLAGS += -I/opt/local/include -I/usr/local/include
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000106LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +0000107endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000108
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000109ifeq ($(TARGET_OS), FreeBSD)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +0000110CPPFLAGS += -I/usr/local/include
Andriy Gapon65c1b862008-05-22 13:22:45 +0000111LDFLAGS += -L/usr/local/lib
112endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000113
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000114ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000115CPPFLAGS += -I/usr/local/include
116LDFLAGS += -L/usr/local/lib
117endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000118
Stefan Taunerc65b8552013-09-12 15:48:39 +0000119ifeq ($(TARGET_OS), NetBSD)
120CPPFLAGS += -I/usr/pkg/include
121LDFLAGS += -L/usr/pkg/lib
122endif
123
124ifeq ($(TARGET_OS), DragonFlyBSD)
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000125CPPFLAGS += -I/usr/local/include
126LDFLAGS += -L/usr/local/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000127endif
128
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000129ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000130EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000131# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +0000132CFLAGS += -Wno-format
Stefan Tauner449abe22013-09-11 23:34:57 +0000133LIBS += -lgetopt
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000134# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000135ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
136UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
137else
138override CONFIG_BUSPIRATE_SPI = no
139endif
140ifeq ($(CONFIG_SERPROG), yes)
141UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
142else
143override CONFIG_SERPROG = no
144endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000145ifeq ($(CONFIG_PONY_SPI), yes)
146UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
147else
148override CONFIG_PONY_SPI = no
149endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000150# Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported under DOS (missing USB support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000151ifeq ($(CONFIG_DEDIPROG), yes)
152UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
153else
154override CONFIG_DEDIPROG = no
155endif
156ifeq ($(CONFIG_FT2232_SPI), yes)
157UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
158else
159override CONFIG_FT2232_SPI = no
160endif
James Lairdc60de0e2013-03-27 13:00:23 +0000161ifeq ($(CONFIG_USBBLASTER_SPI), yes)
162UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
163else
164override CONFIG_USBBLASTER_SPI = no
165endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000166ifeq ($(CONFIG_PICKIT2_SPI), yes)
167UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
168else
169override CONFIG_PICKIT2_SPI = no
170endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000171endif
Ollie Lho184a4042005-11-26 21:55:36 +0000172
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000173# FIXME: Should we check for Cygwin/MSVC as well?
174ifeq ($(TARGET_OS), MinGW)
175EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000176# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000177FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000178# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
179# for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */
180FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000181# libusb-win32/libftdi stuff is usually installed in /usr/local.
182CPPFLAGS += -I/usr/local/include
183LDFLAGS += -L/usr/local/lib
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000184# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
185ifeq ($(CONFIG_INTERNAL), yes)
186UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
187else
188override CONFIG_INTERNAL = no
189endif
190ifeq ($(CONFIG_RAYER_SPI), yes)
191UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
192else
193override CONFIG_RAYER_SPI = no
194endif
195ifeq ($(CONFIG_NIC3COM), yes)
196UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
197else
198override CONFIG_NIC3COM = no
199endif
200ifeq ($(CONFIG_GFXNVIDIA), yes)
201UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
202else
203override CONFIG_GFXNVIDIA = no
204endif
205ifeq ($(CONFIG_SATASII), yes)
206UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
207else
208override CONFIG_SATASII = no
209endif
210ifeq ($(CONFIG_ATAHPT), yes)
211UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
212else
213override CONFIG_ATAHPT = no
214endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000215ifeq ($(CONFIG_ATAVIA), yes)
216UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
217else
218override CONFIG_ATAVIA = no
219endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000220ifeq ($(CONFIG_IT8212), yes)
221UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
222else
223override CONFIG_IT8212 = no
224endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000225ifeq ($(CONFIG_DRKAISER), yes)
226UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
227else
228override CONFIG_DRKAISER = no
229endif
230ifeq ($(CONFIG_NICREALTEK), yes)
231UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
232else
233override CONFIG_NICREALTEK = no
234endif
235ifeq ($(CONFIG_NICNATSEMI), yes)
236UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
237else
238override CONFIG_NICNATSEMI = no
239endif
240ifeq ($(CONFIG_NICINTEL), yes)
241UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
242else
243override CONFIG_NICINTEL = no
244endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000245ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
246UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
247else
248override CONFIG_NICINTEL_EEPROM = no
249endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000250ifeq ($(CONFIG_NICINTEL_SPI), yes)
251UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
252else
253override CONFIG_NICINTEL_SPI = no
254endif
255ifeq ($(CONFIG_OGP_SPI), yes)
256UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
257else
258override CONFIG_OGP_SPI = no
259endif
260ifeq ($(CONFIG_SATAMV), yes)
261UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
262else
263override CONFIG_SATAMV = no
264endif
265endif
266
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000267ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000268ifeq ($(MAKECMDGOALS),)
269.DEFAULT_GOAL := libflashrom.a
270$(info Setting default goal to libflashrom.a)
271endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000272FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000273ifeq ($(CONFIG_DUMMY), yes)
274UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
275else
276override CONFIG_DUMMY = no
277endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000278# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000279ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
280UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
281else
282override CONFIG_BUSPIRATE_SPI = no
283endif
284ifeq ($(CONFIG_SERPROG), yes)
285UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
286else
287override CONFIG_SERPROG = no
288endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000289ifeq ($(CONFIG_PONY_SPI), yes)
290UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
291else
292override CONFIG_PONY_SPI = no
293endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000294# Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported with libpayload (missing libusb support)
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000295ifeq ($(CONFIG_DEDIPROG), yes)
296UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
297else
298override CONFIG_DEDIPROG = no
299endif
300ifeq ($(CONFIG_FT2232_SPI), yes)
301UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
302else
303override CONFIG_FT2232_SPI = no
304endif
James Lairdc60de0e2013-03-27 13:00:23 +0000305ifeq ($(CONFIG_USBBLASTER_SPI), yes)
306UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
307else
308override CONFIG_USBBLASTER_SPI = no
309endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000310ifeq ($(CONFIG_PICKIT2_SPI), yes)
311UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
312else
313override CONFIG_PICKIT2_SPI = no
314endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000315endif
316
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000317ifneq ($(TARGET_OS), Linux)
318ifeq ($(CONFIG_LINUX_SPI), yes)
319UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
320else
321override CONFIG_LINUX_SPI = no
322endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000323ifeq ($(CONFIG_MSTARDDC_SPI), yes)
324UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
325else
326override CONFIG_MSTARDDC_SPI = no
327endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000328endif
329
Stefan Tauner037cd842013-08-25 00:10:56 +0000330###############################################################################
331# General architecture-specific settings.
332# Like above for the OS, below we verify user-supplied options depending on the target architecture.
333
Uwe Hermann44ffd582011-08-20 14:16:00 +0000334# Determine the destination processor architecture.
335# IMPORTANT: The following line must be placed before ARCH is ever used
336# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000337# below uses CC itself.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000338override 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 +0000339
Stefan Taunerfb2d77c2015-02-10 08:03:10 +0000340# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
David Hendricksb286da72012-02-13 00:35:35 +0000341# Right now this means the drivers below only work on x86.
342ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000343ifeq ($(CONFIG_NIC3COM), yes)
344UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
345else
346override CONFIG_NIC3COM = no
347endif
348ifeq ($(CONFIG_NICREALTEK), yes)
349UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
350else
351override CONFIG_NICREALTEK = no
352endif
353ifeq ($(CONFIG_NICNATSEMI), yes)
354UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
355else
356override CONFIG_NICNATSEMI = no
357endif
358ifeq ($(CONFIG_RAYER_SPI), yes)
359UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
360else
361override CONFIG_RAYER_SPI = no
362endif
363ifeq ($(CONFIG_ATAHPT), yes)
364UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
365else
366override CONFIG_ATAHPT = no
367endif
368ifeq ($(CONFIG_SATAMV), yes)
369UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
370else
371override CONFIG_SATAMV = no
372endif
373endif
374
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000375###############################################################################
376# Flash chip drivers and bus support infrastructure.
377
Stefan Tauner4404f732013-09-12 08:28:56 +0000378CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000379 sst28sf040.o 82802ab.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000380 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Aidan Thorntondb4e87d2013-08-27 18:01:53 +0000381 opaque.o sfdp.o en29lv640b.o at45db.o
Sean Nelson5d134642009-12-24 16:54:21 +0000382
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000383###############################################################################
384# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000385
Stefan Tauner6ad6e012014-06-12 00:04:32 +0000386LIB_OBJS = layout.o flashrom.o udelay.o programmer.o helpers.o
Sean Nelson5d134642009-12-24 16:54:21 +0000387
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000388###############################################################################
389# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000390
Stefan Tauner9b32de92014-08-08 23:52:33 +0000391CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000392
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000393# Set the flashrom version string from the highest revision number of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000394# Note to packagers: Any tree exported with "make export" or "make tarball"
395# will not require subversion. The downloadable snapshots are already exported.
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000396SVNVERSION := $(shell ./util/getrevision.sh -u 2>/dev/null )
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000397
Stefan Taunerf4651f62015-03-01 22:05:16 +0000398RELEASE := 0.9.8
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000399VERSION := $(RELEASE)-$(SVNVERSION)
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000400RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000401
402SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000403
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000404# Inform user if there is no meaningful version string. If there is version information from a VCS print
405# something anyway because $(info...) will print a line break in any case which would look suspicious.
Stefan Tauner5d1ad352015-01-25 23:57:08 +0000406# The && between the echos is a workaround for old versions of GNU make that issue the error "unterminated
407# variable reference" if a semicolon is used instead.
408$(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 +0000409 echo "Replacing all version templates with $(VERSION)." ))
410
Stefan Tauner037cd842013-08-25 00:10:56 +0000411###############################################################################
412# Default settings of CONFIG_* variables.
413
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000414# Always enable internal/onboard support for now.
415CONFIG_INTERNAL ?= yes
416
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000417# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000418CONFIG_SERPROG ?= yes
419
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000420# RayeR SPIPGM hardware support
421CONFIG_RAYER_SPI ?= yes
422
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000423# PonyProg2000 SPI hardware support
424CONFIG_PONY_SPI ?= yes
425
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000426# Always enable 3Com NICs for now.
427CONFIG_NIC3COM ?= yes
428
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000429# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
430CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000431
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000432# Always enable SiI SATA controllers for now.
433CONFIG_SATASII ?= yes
434
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000435# Highpoint (HPT) ATA/RAID controller support.
436# IMPORTANT: This code is not yet working!
437CONFIG_ATAHPT ?= no
438
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000439# VIA VT6421A LPC memory support
440CONFIG_ATAVIA ?= yes
441
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000442# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000443CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000444
James Lairdc60de0e2013-03-27 13:00:23 +0000445# Always enable Altera USB-Blaster dongles for now.
446CONFIG_USBBLASTER_SPI ?= yes
447
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000448# MSTAR DDC support needs more tests/reviews/cleanups.
449CONFIG_MSTARDDC_SPI ?= no
450
Justin Chevrier66e554b2015-02-08 21:58:10 +0000451# Always enable PICkit2 SPI dongles for now.
452CONFIG_PICKIT2_SPI ?= yes
453
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000454# Always enable dummy tracing for now.
455CONFIG_DUMMY ?= yes
456
457# Always enable Dr. Kaiser for now.
458CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000459
Joerg Fischer5665ef32010-05-21 21:54:07 +0000460# Always enable Realtek NICs for now.
461CONFIG_NICREALTEK ?= yes
462
Andrew Morganc29c2e72010-06-07 22:37:54 +0000463# Disable National Semiconductor NICs until support is complete and tested.
464CONFIG_NICNATSEMI ?= no
465
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000466# Always enable Intel NICs for now.
467CONFIG_NICINTEL ?= yes
468
Idwer Vollering004f4b72010-09-03 18:21:21 +0000469# Always enable SPI on Intel NICs for now.
470CONFIG_NICINTEL_SPI ?= yes
471
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000472# Always enable EEPROM on Intel NICs for now.
473CONFIG_NICINTEL_EEPROM ?= yes
474
Mark Marshall90021f22010-12-03 14:48:11 +0000475# Always enable SPI on OGP cards for now.
476CONFIG_OGP_SPI ?= yes
477
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000478# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000479CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000480
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000481# Disable Dediprog SF100 until support is complete and tested.
482CONFIG_DEDIPROG ?= no
483
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000484# Always enable Marvell SATA controllers for now.
485CONFIG_SATAMV ?= yes
486
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000487# Enable Linux spidev interface by default. We disable it on non-Linux targets.
488CONFIG_LINUX_SPI ?= yes
489
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000490# Always enable ITE IT8212F PATA controllers for now.
491CONFIG_IT8212 ?= yes
492
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000493# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000494CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000495
Patrick Georgiced7ab62015-01-19 19:52:34 +0000496# Enable all features if CONFIG_EVERYTHING=yes is given
497ifeq ($(CONFIG_EVERYTHING), yes)
498$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
499 $(if $(filter no, $($(var))),\
500 $(eval $(var)=yes)))
501endif
502
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000503# Bitbanging SPI infrastructure, default off unless needed.
504ifeq ($(CONFIG_RAYER_SPI), yes)
505override CONFIG_BITBANG_SPI = yes
506else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000507ifeq ($(CONFIG_PONY_SPI), yes)
508override CONFIG_BITBANG_SPI = yes
509else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000510ifeq ($(CONFIG_INTERNAL), yes)
511override CONFIG_BITBANG_SPI = yes
512else
513ifeq ($(CONFIG_NICINTEL_SPI), yes)
514override CONFIG_BITBANG_SPI = yes
515else
Mark Marshall90021f22010-12-03 14:48:11 +0000516ifeq ($(CONFIG_OGP_SPI), yes)
517override CONFIG_BITBANG_SPI = yes
518else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000519CONFIG_BITBANG_SPI ?= no
520endif
521endif
522endif
Mark Marshall90021f22010-12-03 14:48:11 +0000523endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000524endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000525
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000526###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000527# Handle CONFIG_* variables that depend on others set (and verified) above.
528
529# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
530ifeq ($(TARGET_OS), libpayload)
531ifeq ($(CONFIG_INTERNAL), yes)
532ifeq ($(CONFIG_INTERNAL_DMI), no)
533UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
534else
535override CONFIG_INTERNAL_DMI = yes
536endif
537endif
538endif
539
540# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
541CONFIG_INTERNAL_DMI ?= yes
542
543###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000544# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000545# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000546
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000547FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000548FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000549
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000550ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000551FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000552PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000553ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000554PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000555PROGRAMMER_OBJS += ichspi.o ich_descriptors.o dmi.o
556ifeq ($(CONFIG_INTERNAL_DMI), yes)
557FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
558endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000559else
560endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000561NEED_PCI := yes
562endif
563
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000564ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000565FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000566PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000567NEED_SERIAL := yes
568NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000569endif
570
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000571ifeq ($(CONFIG_RAYER_SPI), yes)
572FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
573PROGRAMMER_OBJS += rayer_spi.o
574# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
575NEED_PCI := yes
576endif
577
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000578ifeq ($(CONFIG_PONY_SPI), yes)
579FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
580PROGRAMMER_OBJS += pony_spi.o
581NEED_SERIAL := yes
582endif
583
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000584ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000585FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000586PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000587endif
588
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000589ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000590FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000591PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000592NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000593endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000594
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000595ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000596FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000597PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000598NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000599endif
600
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000601ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000602FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000603PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000604NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000605endif
606
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000607ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000608FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000609PROGRAMMER_OBJS += atahpt.o
610NEED_PCI := yes
611endif
612
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000613ifeq ($(CONFIG_ATAVIA), yes)
614FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
615PROGRAMMER_OBJS += atavia.o
616NEED_PCI := yes
617endif
618
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000619ifeq ($(CONFIG_IT8212), yes)
620FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
621PROGRAMMER_OBJS += it8212.o
622NEED_PCI := yes
623endif
624
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000625ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000626# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000627FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000628NEED_FTDI := yes
629PROGRAMMER_OBJS += ft2232_spi.o
630endif
631
632ifeq ($(CONFIG_USBBLASTER_SPI), yes)
633# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000634FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000635NEED_FTDI := yes
636PROGRAMMER_OBJS += usbblaster_spi.o
637endif
638
Justin Chevrier66e554b2015-02-08 21:58:10 +0000639ifeq ($(CONFIG_PICKIT2_SPI), yes)
640FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
641PROGRAMMER_OBJS += pickit2_spi.o
642NEED_USB := yes
643endif
644
James Lairdc60de0e2013-03-27 13:00:23 +0000645ifeq ($(NEED_FTDI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000646FTDILIBS := $(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")
647FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
648FTDI_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 +0000649FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000650FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000651# We can't set NEED_USB here because that would transform libftdi auto-enabling
652# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000653endif
654
655ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000656FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000657PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000658endif
659
660ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000661FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000662PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000663NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000664endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000665
Joerg Fischer5665ef32010-05-21 21:54:07 +0000666ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000667FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000668PROGRAMMER_OBJS += nicrealtek.o
669NEED_PCI := yes
670endif
671
Andrew Morganc29c2e72010-06-07 22:37:54 +0000672ifeq ($(CONFIG_NICNATSEMI), yes)
673FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
674PROGRAMMER_OBJS += nicnatsemi.o
675NEED_PCI := yes
676endif
677
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000678ifeq ($(CONFIG_NICINTEL), yes)
679FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
680PROGRAMMER_OBJS += nicintel.o
681NEED_PCI := yes
682endif
683
Idwer Vollering004f4b72010-09-03 18:21:21 +0000684ifeq ($(CONFIG_NICINTEL_SPI), yes)
685FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
686PROGRAMMER_OBJS += nicintel_spi.o
687NEED_PCI := yes
688endif
689
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000690ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
691FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
692PROGRAMMER_OBJS += nicintel_eeprom.o
693NEED_PCI := yes
694endif
695
Mark Marshall90021f22010-12-03 14:48:11 +0000696ifeq ($(CONFIG_OGP_SPI), yes)
697FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
698PROGRAMMER_OBJS += ogp_spi.o
699NEED_PCI := yes
700endif
701
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000702ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
703FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000704PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000705NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000706endif
707
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000708ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000709FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000710PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000711NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000712endif
713
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000714ifeq ($(CONFIG_SATAMV), yes)
715FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
716PROGRAMMER_OBJS += satamv.o
717NEED_PCI := yes
718endif
719
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000720ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000721# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000722FEATURE_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 +0000723PROGRAMMER_OBJS += linux_spi.o
724endif
725
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000726ifeq ($(CONFIG_MSTARDDC_SPI), yes)
727# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000728FEATURE_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 +0000729NEED_LINUX_I2C := yes
730PROGRAMMER_OBJS += mstarddc_spi.o
731endif
732
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000733ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000734LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000735endif
736
737ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000738ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000739LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000740endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000741endif
742
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000743ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000744CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000745FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000746FEATURE_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 +0000747
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000748PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000749ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000750# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000751PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000752# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000753PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000754else
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000755
Stefan Tauner449abe22013-09-11 23:34:57 +0000756PCILIBS += -lpci
Stefan Taunerbe62d3f2015-01-10 09:32:44 +0000757
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000758ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000759# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000760PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000761else
762ifeq ($(TARGET_OS), Darwin)
763# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000764PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000765endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000766endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000767endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000768endif
769
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000770ifeq ($(NEED_USB), yes)
771CHECK_LIBUSB0 = yes
772FEATURE_CFLAGS += -D'NEED_USB=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000773USBLIBS := $(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 +0000774endif
775
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000776ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000777FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000778CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000779endif
780
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000781FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000782
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000783# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000784FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000785
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000786LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000787OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000788
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000789all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000790ifeq ($(ARCH), x86)
791 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
792endif
793
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000794$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000795 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000796
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000797libflashrom.a: $(LIBFLASHROM_OBJS)
798 $(AR) rcs $@ $^
799 $(RANLIB) $@
800
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000801# TAROPTIONS reduces information leakage from the packager's system.
802# If other tar programs support command line arguments for setting uid/gid of
803# stored files, they can be handled here as well.
804TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000805
Paul Fox05dfbe62009-06-16 21:08:06 +0000806%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000807 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000808
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000809# Make sure to add all names of generated binaries here.
810# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000811# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000812clean:
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000813 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000814 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000815
Ollie Lho184a4042005-11-26 21:55:36 +0000816distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000817 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000818
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000819strip: $(PROGRAM)$(EXEC_SUFFIX)
820 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000821
Stefan Tauner56787082011-08-18 02:27:19 +0000822# to define test programs we use verbatim variables, which get exported
823# to environment variables and are referenced with $$<varname> later
824
825define COMPILER_TEST
826int main(int argc, char **argv)
827{
828 (void) argc;
829 (void) argv;
830 return 0;
831}
832endef
833export COMPILER_TEST
834
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000835compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000836 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +0000837 @echo "$$COMPILER_TEST" > .test.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000838 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
839 echo "found." || { echo "not found."; \
840 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 +0000841 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000842 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000843 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000844 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000845 ( echo "unknown. Aborting."; exit 1)
846 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000847 @printf "Target OS is "
848 @# FreeBSD wc will output extraneous whitespace.
849 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
850 ( echo "unknown. Aborting."; exit 1)
851 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +0000852ifeq ($(TARGET_OS), libpayload)
853 @$(CC) --version 2>&1 | grep -q coreboot || \
854 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
855 echo "This might work but usually does not, please beware." )
856endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000857
Stefan Tauner56787082011-08-18 02:27:19 +0000858define LIBPCI_TEST
859/* Avoid a failing test due to libpci header symbol shadowing breakage */
860#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000861#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +0000862#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +0000863#else
864#include <pciutils/pci.h>
865#endif
Stefan Tauner56787082011-08-18 02:27:19 +0000866struct pci_access *pacc;
867int main(int argc, char **argv)
868{
869 (void) argc;
870 (void) argv;
871 pacc = pci_alloc();
872 return 0;
873}
874endef
875export LIBPCI_TEST
876
Stefan Tauner56734502015-02-08 21:58:04 +0000877define PCI_GET_DEV_TEST
878/* Avoid a failing test due to libpci header symbol shadowing breakage */
879#define index shadow_workaround_index
880#if !defined __NetBSD__
881#include <pci/pci.h>
882#else
883#include <pciutils/pci.h>
884#endif
885struct pci_access *pacc;
886struct pci_dev *dev = {0};
887int main(int argc, char **argv)
888{
889 (void) argc;
890 (void) argv;
891 pacc = pci_alloc();
892 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
893 return 0;
894}
895endef
896export PCI_GET_DEV_TEST
897
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000898define LIBUSB0_TEST
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000899#include "platform.h"
900#if IS_WINDOWS
901#include <lusb0_usb.h>
902#else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000903#include <usb.h>
Stefan Tauner0cbd8c22015-01-26 22:06:04 +0000904#endif
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000905int main(int argc, char **argv)
906{
907 (void) argc;
908 (void) argv;
909 usb_init();
910 return 0;
911}
912endef
913export LIBUSB0_TEST
914
915hwlibs: compiler
916 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000917ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000918 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +0000919 @echo "$$LIBPCI_TEST" > .test.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000920 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
921 echo "found." || { echo "not found."; echo; \
922 echo "Please install libpci headers."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000923 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000924 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
925 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +0000926 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000927 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +0000928 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000929 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
930 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
931 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
932 echo "yes." || { echo "no."; \
933 printf "Checking if libz+libpci are present and sufficient..." ; \
934 { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
935 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000936 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000937 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000938 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 +0000939 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000940endif
941ifeq ($(CHECK_LIBUSB0), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000942 @printf "Checking for libusb-0.1/libusb-compat headers... " | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000943 @echo "$$LIBUSB0_TEST" > .test.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000944 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
945 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000946 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
947 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000948 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
949 @printf "Checking if libusb-0.1 is usable... " | tee -a $(BUILD_DETAILS_FILE)
950 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >&2 && \
951 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000952 echo "Please install libusb-0.1 or libusb-compat."; \
953 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000954 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 +0000955 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000956endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000957
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000958.features: features
959
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000960# If a user does not explicitly request a non-working feature, we should
961# silently disable it. However, if a non-working (does not compile) feature
962# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000963# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000964featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000965ifeq ($(PROGRAMMER_OBJS),)
966 @echo "You have to enable at least one programmer driver!"
967 @false
968endif
969ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000970 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
971 @false
972endif
973
Stefan Tauner56787082011-08-18 02:27:19 +0000974define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +0000975#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +0000976#include <ftdi.h>
977struct ftdi_context *ftdic = NULL;
978int main(int argc, char **argv)
979{
980 (void) argc;
981 (void) argv;
982 return ftdi_init(ftdic);
983}
984endef
985export FTDI_TEST
986
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000987define FTDI_232H_TEST
988#include <ftdi.h>
989enum ftdi_chip_type type = TYPE_232H;
990endef
991export FTDI_232H_TEST
992
Stefan Tauner56787082011-08-18 02:27:19 +0000993define UTSNAME_TEST
994#include <sys/utsname.h>
995struct utsname osinfo;
996int main(int argc, char **argv)
997{
998 (void) argc;
999 (void) argv;
1000 uname (&osinfo);
1001 return 0;
1002}
1003endef
1004export UTSNAME_TEST
1005
Stefan Tauner8868db32012-03-13 00:18:19 +00001006define LINUX_SPI_TEST
1007#include <linux/types.h>
1008#include <linux/spi/spidev.h>
1009
1010int main(int argc, char **argv)
1011{
1012 (void) argc;
1013 (void) argv;
1014 return 0;
1015}
1016endef
1017export LINUX_SPI_TEST
1018
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001019define LINUX_I2C_TEST
1020#include <linux/i2c-dev.h>
1021#include <linux/i2c.h>
1022
1023int main(int argc, char **argv)
1024{
1025 (void) argc;
1026 (void) argv;
1027 return 0;
1028}
1029endef
1030export LINUX_I2C_TEST
1031
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001032features: compiler
1033 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +00001034ifeq ($(NEED_FTDI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001035 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001036 @echo "$$FTDI_TEST" > .featuretest.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001037 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1038 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
1039 printf "Checking for FT232H support in libftdi... " ; \
1040 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
1041 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1042 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1043 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1044 ) || \
1045 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1046 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001047endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001048ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001049 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001050 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001051 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001052 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001053 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1054 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001055endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001056ifeq ($(NEED_LINUX_I2C), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001057 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001058 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001059 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001060 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001061 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1062 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001063endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001064 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001065 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001066 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001067 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001068 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001069 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1070 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001071
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001072$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Taunerd5ff8452015-01-10 09:32:07 +00001073 @sed -e '1 s#".*".*#"$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001074
1075install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001076 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001077 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001078 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001079 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001080
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001081export: $(PROGRAM).8
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001082 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1083 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
1084 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001085 @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8"
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001086 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
1087 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001088
1089tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +00001090 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
1091 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
1092 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001093
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001094djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001095 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
1096libpayload: clean
1097 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001098
Stefan Tauner74dc73f2015-03-01 22:04:38 +00001099.PHONY: all install clean distclean compiler hwlibs features export tarball djgpp-dos featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001100
Stefan Reinauere2f01582010-06-07 11:08:07 +00001101-include $(OBJS:.o=.d)