blob: 52a2f951c9800921d5e39a1477bdab0f50cb51dd [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#
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000016
Ollie Lho184a4042005-11-26 21:55:36 +000017PROGRAM = flashrom
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000018
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000019###############################################################################
20# Defaults for the toolchain.
21
22# If you want to cross-compile, just run e.g.
23# make CC=i586-pc-msdosdjgpp-gcc
24# You may have to specify STRIP/AR/RANLIB as well.
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000025#
26# Note for anyone editing this Makefile: gnumake will happily ignore any
27# changes in this Makefile to variables set on the command line.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000028STRIP ?= strip
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000029INSTALL = install
Paul Fox05dfbe62009-06-16 21:08:06 +000030DIFF = diff
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000031PREFIX ?= /usr/local
Uwe Hermann56b2cb02009-05-21 15:59:58 +000032MANDIR ?= $(PREFIX)/share/man
Nico Huber9e2dc2f2018-12-23 22:00:47 +010033CFLAGS ?= -Os -Wall -Wextra -Wno-unused-parameter -Wshadow -Wmissing-prototypes -Wwrite-strings
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000034EXPORTDIR ?= .
Patrick Georgi97bc95c2011-03-08 07:17:44 +000035RANLIB ?= ranlib
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000036PKG_CONFIG ?= pkg-config
37BUILD_DETAILS_FILE ?= build_details.txt
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000038
Stefan Taunerfd0d4132012-09-25 21:24:55 +000039# The following parameter changes the default programmer that will be used if there is no -p/--programmer
40# argument given when running flashrom. The predefined setting does not enable any default so that every
41# user has to declare the programmer he wants to use on every run. The rationale for this to be not set
42# (to e.g. the internal programmer) is that forgetting to specify this when working with another programmer
43# easily puts the system attached to the default programmer at risk (e.g. you want to flash coreboot to another
44# system attached to an external programmer while the default programmer is set to the internal programmer, and
45# you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer
46# running flashrom). Please do not enable this without thinking about the possible consequences. Possible
47# values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options
48# evaluated below, namely those that enable/disable the various programmers).
49# Compilation will fail for unspecified values.
50CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID
Stefan Tauner265fcac2014-06-02 00:12:23 +000051# The following adds a default parameter for the default programmer set above (only).
52CONFIG_DEFAULT_PROGRAMMER_ARGS ?= ''
53# Example: compiling with
54# make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000"
55# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000056
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000057# If your compiler spits out excessive warnings, run make WARNERROR=no
58# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000059WARNERROR ?= yes
60
61ifeq ($(WARNERROR), yes)
62CFLAGS += -Werror
63endif
64
Stefan Taunere37735a2015-01-26 22:03:35 +000065ifdef LIBS_BASE
Stefan Taunere37735a2015-01-26 22:03:35 +000066PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig
Stefan Tauner45207062016-02-19 08:17:24 +000067override CPPFLAGS += -I$(LIBS_BASE)/include
68override LDFLAGS += -L$(LIBS_BASE)/lib -Wl,-rpath -Wl,$(LIBS_BASE)/lib
Stefan Taunere37735a2015-01-26 22:03:35 +000069endif
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000070
Stefan Taunerbfb067b2016-01-07 18:13:07 +000071ifeq ($(CONFIG_STATIC),yes)
Stefan Tauner45207062016-02-19 08:17:24 +000072override PKG_CONFIG += --static
73override LDFLAGS += -static
Stefan Taunerbfb067b2016-01-07 18:13:07 +000074endif
75
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000076# Set LC_ALL=C to minimize influences of the locale.
77# However, this won't work for the majority of relevant commands because they use the $(shell) function and
78# GNU make does not relay variables exported within the makefile to their evironment.
79LC_ALL=C
80export LC_ALL
81
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000082dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUILD_DETAILS_FILE))
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000083
84# Provide an easy way to execute a command, print its output to stdout and capture any error message on stderr
85# in the build details file together with the original stdout output.
Pyry Kontio89cc73b2020-07-06 12:57:35 +090086debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(subst ','\'',$(1)) ; }' >&2; \
87 { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE))
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000088
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000089###############################################################################
Stefan Tauner037cd842013-08-25 00:10:56 +000090# General OS-specific settings.
91# 1. Prepare for later by gathering information about host and target OS
92# 2. Set compiler flags and parameters according to OSes
93# 3. Likewise verify user-supplied CONFIG_* variables.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000094
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000095# HOST_OS is only used to work around local toolchain issues.
Stefan Tauner037cd842013-08-25 00:10:56 +000096HOST_OS ?= $(shell uname)
Miklós Mártona75a2ed2018-01-30 20:25:00 +010097ifeq ($(findstring MINGW, $(HOST_OS)), MINGW)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000098# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
99CC = gcc
100endif
Miklós Mártona75a2ed2018-01-30 20:25:00 +0100101
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000102ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +0000103STRIP_ARGS = -s
104endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000105
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000106# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000107# IMPORTANT: The following line must be placed before TARGET_OS is ever used
108# (of course), but should come after any lines setting CC because the line
109# below uses CC itself.
Pyry Kontio89cc73b2020-07-06 12:57:35 +0900110override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null \
111 | tail -1 | cut -f 2 -d'"'))
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000112
113ifeq ($(TARGET_OS), Darwin)
Stefan Tauner45207062016-02-19 08:17:24 +0000114override CPPFLAGS += -I/opt/local/include -I/usr/local/include
115override LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +0000116endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000117
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000118ifeq ($(TARGET_OS), FreeBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000119override CPPFLAGS += -I/usr/local/include
120override LDFLAGS += -L/usr/local/lib
Andriy Gapon65c1b862008-05-22 13:22:45 +0000121endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000122
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000123ifeq ($(TARGET_OS), OpenBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000124override CPPFLAGS += -I/usr/local/include
125override LDFLAGS += -L/usr/local/lib
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000126endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000127
Stefan Taunerc65b8552013-09-12 15:48:39 +0000128ifeq ($(TARGET_OS), NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000129override CPPFLAGS += -I/usr/pkg/include
130override LDFLAGS += -L/usr/pkg/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000131endif
132
133ifeq ($(TARGET_OS), DragonFlyBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000134override CPPFLAGS += -I/usr/local/include
135override LDFLAGS += -L/usr/local/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000136endif
137
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000138ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000139EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000140# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Stefan Tauner45207062016-02-19 08:17:24 +0000141override CFLAGS += -Wno-format
Stefan Tauner449abe22013-09-11 23:34:57 +0000142LIBS += -lgetopt
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000143# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000144ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
145UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
146else
147override CONFIG_BUSPIRATE_SPI = no
148endif
149ifeq ($(CONFIG_SERPROG), yes)
150UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
151else
152override CONFIG_SERPROG = no
153endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000154ifeq ($(CONFIG_PONY_SPI), yes)
155UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
156else
157override CONFIG_PONY_SPI = no
158endif
Nico Huber84c6fb52019-06-07 17:35:56 +0200159# Digilent SPI, Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported under DOS (missing USB support).
160ifeq ($(CONFIG_DIGILENT_SPI), yes)
161UNSUPPORTED_FEATURES += CONFIG_DIGILENT_SPI=yes
162else
163override CONFIG_DIGILENT_SPI = no
164endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000165ifeq ($(CONFIG_DEDIPROG), yes)
166UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
167else
168override CONFIG_DEDIPROG = no
169endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100170ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
171UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
172else
173override CONFIG_DEVELOPERBOX_SPI = no
174endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000175ifeq ($(CONFIG_FT2232_SPI), yes)
176UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
177else
178override CONFIG_FT2232_SPI = no
179endif
James Lairdc60de0e2013-03-27 13:00:23 +0000180ifeq ($(CONFIG_USBBLASTER_SPI), yes)
181UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
182else
183override CONFIG_USBBLASTER_SPI = no
184endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000185ifeq ($(CONFIG_PICKIT2_SPI), yes)
186UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
187else
188override CONFIG_PICKIT2_SPI = no
189endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000190ifeq ($(CONFIG_CH341A_SPI), yes)
191UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
192else
193override CONFIG_CH341A_SPI = no
194endif
Miklós Márton324929c2019-08-01 19:14:10 +0200195ifeq ($(CONFIG_STLINKV3_SPI), yes)
196UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
197else
198override CONFIG_STLINKV3_SPI = no
199endif
Nico Hubera7246022019-06-07 17:39:18 +0200200# libjaylink is also not available for DOS
201ifeq ($(CONFIG_JLINK_SPI), yes)
202UNSUPPORTED_FEATURES += CONFIG_JLINK_SPI=yes
203else
204override CONFIG_JLINK_SPI = no
205endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000206endif
Ollie Lho184a4042005-11-26 21:55:36 +0000207
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000208# FIXME: Should we check for Cygwin/MSVC as well?
209ifeq ($(TARGET_OS), MinGW)
210EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000211# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000212FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000213# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
Stefan Tauner23e10b82016-01-23 16:16:49 +0000214# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000215FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100216
217# National Instruments USB-845x is Windows only for now
218CONFIG_NI845X_SPI ?= no
219
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000220# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
221ifeq ($(CONFIG_INTERNAL), yes)
222UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
223else
224override CONFIG_INTERNAL = no
225endif
226ifeq ($(CONFIG_RAYER_SPI), yes)
227UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
228else
229override CONFIG_RAYER_SPI = no
230endif
231ifeq ($(CONFIG_NIC3COM), yes)
232UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
233else
234override CONFIG_NIC3COM = no
235endif
236ifeq ($(CONFIG_GFXNVIDIA), yes)
237UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
238else
239override CONFIG_GFXNVIDIA = no
240endif
241ifeq ($(CONFIG_SATASII), yes)
242UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
243else
244override CONFIG_SATASII = no
245endif
246ifeq ($(CONFIG_ATAHPT), yes)
247UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
248else
249override CONFIG_ATAHPT = no
250endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000251ifeq ($(CONFIG_ATAVIA), yes)
252UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
253else
254override CONFIG_ATAVIA = no
255endif
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000256ifeq ($(CONFIG_ATAPROMISE), yes)
257UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
258else
259override CONFIG_ATAPROMISE = no
260endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000261ifeq ($(CONFIG_IT8212), yes)
262UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
263else
264override CONFIG_IT8212 = no
265endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000266ifeq ($(CONFIG_DRKAISER), yes)
267UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
268else
269override CONFIG_DRKAISER = no
270endif
271ifeq ($(CONFIG_NICREALTEK), yes)
272UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
273else
274override CONFIG_NICREALTEK = no
275endif
276ifeq ($(CONFIG_NICNATSEMI), yes)
277UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
278else
279override CONFIG_NICNATSEMI = no
280endif
281ifeq ($(CONFIG_NICINTEL), yes)
282UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
283else
284override CONFIG_NICINTEL = no
285endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000286ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
287UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
288else
289override CONFIG_NICINTEL_EEPROM = no
290endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000291ifeq ($(CONFIG_NICINTEL_SPI), yes)
292UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
293else
294override CONFIG_NICINTEL_SPI = no
295endif
296ifeq ($(CONFIG_OGP_SPI), yes)
297UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
298else
299override CONFIG_OGP_SPI = no
300endif
301ifeq ($(CONFIG_SATAMV), yes)
302UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
303else
304override CONFIG_SATAMV = no
305endif
306endif
307
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100308ifneq ($(TARGET_OS), MinGW)
309# NI USB-845x only supported on Windows at the moment
310ifeq ($(CONFIG_NI845X_SPI), yes)
311UNSUPPORTED_FEATURES += CONFIG_NI845X_SPI=yes
312else
313override CONFIG_NI845X_SPI = no
314endif
315endif
316
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000317ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000318ifeq ($(MAKECMDGOALS),)
319.DEFAULT_GOAL := libflashrom.a
320$(info Setting default goal to libflashrom.a)
321endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000322FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000323ifeq ($(CONFIG_DUMMY), yes)
324UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
325else
326override CONFIG_DUMMY = no
327endif
Stefan Taunere0168262016-02-21 11:18:24 +0000328# libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
329ifeq ($(CONFIG_ATAPROMISE), yes)
330UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
331else
332override CONFIG_ATAPROMISE = no
333endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000334# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000335ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
336UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
337else
338override CONFIG_BUSPIRATE_SPI = no
339endif
340ifeq ($(CONFIG_SERPROG), yes)
341UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
342else
343override CONFIG_SERPROG = no
344endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000345ifeq ($(CONFIG_PONY_SPI), yes)
346UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
347else
348override CONFIG_PONY_SPI = no
349endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100350# Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000351ifeq ($(CONFIG_DEDIPROG), yes)
352UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
353else
354override CONFIG_DEDIPROG = no
355endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100356ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
357UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
358else
359override CONFIG_DEVELOPERBOX_SPI = no
360endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000361ifeq ($(CONFIG_FT2232_SPI), yes)
362UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
363else
364override CONFIG_FT2232_SPI = no
365endif
James Lairdc60de0e2013-03-27 13:00:23 +0000366ifeq ($(CONFIG_USBBLASTER_SPI), yes)
367UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
368else
369override CONFIG_USBBLASTER_SPI = no
370endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000371ifeq ($(CONFIG_PICKIT2_SPI), yes)
372UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
373else
374override CONFIG_PICKIT2_SPI = no
375endif
Miklós Márton324929c2019-08-01 19:14:10 +0200376ifeq ($(CONFIG_STLINKV3_SPI), yes)
377UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
378else
379override CONFIG_STLINKV3_SPI = no
380endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000381ifeq ($(CONFIG_CH341A_SPI), yes)
382UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
383else
384override CONFIG_CH341A_SPI = no
385endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000386endif
387
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000388ifneq ($(TARGET_OS), Linux)
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000389# Android is handled internally as separate OS, but it supports CONFIG_LINUX_SPI and CONFIG_MSTARDDC_SPI
390ifneq ($(TARGET_OS), Android)
David Hendricksf9a30552015-05-23 20:30:30 -0700391ifeq ($(CONFIG_LINUX_MTD), yes)
392UNSUPPORTED_FEATURES += CONFIG_LINUX_MTD=yes
393else
394override CONFIG_LINUX_MTD = no
395endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000396ifeq ($(CONFIG_LINUX_SPI), yes)
397UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
398else
399override CONFIG_LINUX_SPI = no
400endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000401ifeq ($(CONFIG_MSTARDDC_SPI), yes)
402UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
403else
404override CONFIG_MSTARDDC_SPI = no
405endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000406endif
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000407endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000408
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000409ifeq ($(TARGET_OS), Android)
410# Android on x86 (currently) does not provide raw PCI port I/O operations
411ifeq ($(CONFIG_RAYER_SPI), yes)
412UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
413else
414override CONFIG_RAYER_SPI = no
415endif
416endif
417
Stefan Tauner037cd842013-08-25 00:10:56 +0000418###############################################################################
419# General architecture-specific settings.
420# Like above for the OS, below we verify user-supplied options depending on the target architecture.
421
Uwe Hermann44ffd582011-08-20 14:16:00 +0000422# Determine the destination processor architecture.
423# IMPORTANT: The following line must be placed before ARCH is ever used
424# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000425# below uses CC itself.
Pyry Kontio89cc73b2020-07-06 12:57:35 +0900426override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null \
427 | tail -1 | cut -f 2 -d'"'))
428override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \
429 | tail -1))
Uwe Hermann44ffd582011-08-20 14:16:00 +0000430
Nico Huberc8801732017-12-01 18:19:43 +0000431# Disable the internal programmer on unsupported architectures (everything but x86 and mipsel)
432ifneq ($(ARCH)-little, $(filter $(ARCH),x86 mips)-$(ENDIAN))
433ifeq ($(CONFIG_INTERNAL), yes)
434UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
435else
436override CONFIG_INTERNAL = no
437endif
438endif
439
Stefan Taunerfb2d77c2015-02-10 08:03:10 +0000440# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
David Hendricksb286da72012-02-13 00:35:35 +0000441# Right now this means the drivers below only work on x86.
442ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000443ifeq ($(CONFIG_NIC3COM), yes)
444UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
445else
446override CONFIG_NIC3COM = no
447endif
448ifeq ($(CONFIG_NICREALTEK), yes)
449UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
450else
451override CONFIG_NICREALTEK = no
452endif
453ifeq ($(CONFIG_NICNATSEMI), yes)
454UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
455else
456override CONFIG_NICNATSEMI = no
457endif
458ifeq ($(CONFIG_RAYER_SPI), yes)
459UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
460else
461override CONFIG_RAYER_SPI = no
462endif
463ifeq ($(CONFIG_ATAHPT), yes)
464UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
465else
466override CONFIG_ATAHPT = no
467endif
Carl-Daniel Hailfingerf636ffc2016-02-20 22:04:39 +0000468ifeq ($(CONFIG_ATAPROMISE), yes)
469UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
470else
471override CONFIG_ATAPROMISE = no
472endif
Uwe Hermann21b10c62011-07-29 12:13:01 +0000473ifeq ($(CONFIG_SATAMV), yes)
474UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
475else
476override CONFIG_SATAMV = no
477endif
478endif
479
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000480# Disable all drivers needing raw access (memory, PCI, port I/O) on
481# architectures with unknown raw access properties.
482# Right now those architectures are alpha hppa m68k sh s390
Rosen Penev34d07f02019-07-02 00:14:01 -0700483ifneq ($(ARCH),$(filter $(ARCH),x86 mips ppc arm sparc arc))
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000484ifeq ($(CONFIG_RAYER_SPI), yes)
485UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
486else
487override CONFIG_RAYER_SPI = no
488endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000489ifeq ($(CONFIG_NIC3COM), yes)
490UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
491else
492override CONFIG_NIC3COM = no
493endif
494ifeq ($(CONFIG_GFXNVIDIA), yes)
495UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
496else
497override CONFIG_GFXNVIDIA = no
498endif
499ifeq ($(CONFIG_SATASII), yes)
500UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
501else
502override CONFIG_SATASII = no
503endif
504ifeq ($(CONFIG_ATAHPT), yes)
505UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
506else
507override CONFIG_ATAHPT = no
508endif
509ifeq ($(CONFIG_ATAVIA), yes)
510UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
511else
512override CONFIG_ATAVIA = no
513endif
514ifeq ($(CONFIG_ATAPROMISE), yes)
515UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
516else
517override CONFIG_ATAPROMISE = no
518endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000519ifeq ($(CONFIG_DRKAISER), yes)
520UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
521else
522override CONFIG_DRKAISER = no
523endif
524ifeq ($(CONFIG_NICREALTEK), yes)
525UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
526else
527override CONFIG_NICREALTEK = no
528endif
529ifeq ($(CONFIG_NICNATSEMI), yes)
530UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
531else
532override CONFIG_NICNATSEMI = no
533endif
534ifeq ($(CONFIG_NICINTEL), yes)
535UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
536else
537override CONFIG_NICINTEL = no
538endif
539ifeq ($(CONFIG_NICINTEL_SPI), yes)
540UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
541else
542override CONFIG_NICINTEL_SPI = no
543endif
544ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
545UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
546else
547override CONFIG_NICINTEL_EEPROM = no
548endif
549ifeq ($(CONFIG_OGP_SPI), yes)
550UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
551else
552override CONFIG_OGP_SPI = no
553endif
554ifeq ($(CONFIG_SATAMV), yes)
555UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
556else
557override CONFIG_SATAMV = no
558endif
559ifeq ($(CONFIG_IT8212), yes)
560UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
561else
562override CONFIG_IT8212 = no
563endif
564endif
565
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000566###############################################################################
567# Flash chip drivers and bus support infrastructure.
568
Stefan Tauner4404f732013-09-12 08:28:56 +0000569CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000570 sst28sf040.o 82802ab.o \
Paul Kocialkowski80ae14e2018-01-15 01:07:46 +0300571 sst49lfxxxc.o sst_fwhub.o edi.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Konstantin Grudnev3d8868c2019-07-23 00:48:54 +0300572 spi95.o opaque.o sfdp.o en29lv640b.o at45db.o
Sean Nelson5d134642009-12-24 16:54:21 +0000573
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000574###############################################################################
575# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000576
Arthur Heymansc82900b2018-01-10 12:48:16 +0100577LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o helpers.o ich_descriptors.o fmap.o
Sean Nelson5d134642009-12-24 16:54:21 +0000578
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000579###############################################################################
580# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000581
Stefan Tauner9b32de92014-08-08 23:52:33 +0000582CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000583
Stefan Taunerfa25bc32017-10-04 03:47:26 +0200584# versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
585# imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
586# be obtained using util/getrevision.sh, which is the common case during development.
587-include versioninfo.inc
Stefan Tauner5bf6b852017-10-04 03:46:51 +0200588VERSION ?= $(shell ./util/getrevision.sh --revision)
Stefan Tauner96209122017-10-01 16:41:35 +0200589MAN_DATE ?= $(shell ./util/getrevision.sh --date $(PROGRAM).8.tmpl 2>/dev/null)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000590
Stefan Tauner76347082016-11-27 17:45:49 +0100591SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000592
Stefan Tauner76347082016-11-27 17:45:49 +0100593# No spaces in release names unless set explicitly
594RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/')
595
596# Inform user of the version string
597$(info Replacing all version templates with $(VERSION).)
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000598
Stefan Tauner96209122017-10-01 16:41:35 +0200599# If a VCS is found then try to install hooks.
600$(shell ./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh)
601
Stefan Tauner037cd842013-08-25 00:10:56 +0000602###############################################################################
603# Default settings of CONFIG_* variables.
604
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000605# Always enable internal/onboard support for now.
606CONFIG_INTERNAL ?= yes
607
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000608# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000609CONFIG_SERPROG ?= yes
610
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000611# RayeR SPIPGM hardware support
612CONFIG_RAYER_SPI ?= yes
613
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000614# PonyProg2000 SPI hardware support
615CONFIG_PONY_SPI ?= yes
616
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000617# Always enable 3Com NICs for now.
618CONFIG_NIC3COM ?= yes
619
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000620# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
621CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000622
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000623# Always enable SiI SATA controllers for now.
624CONFIG_SATASII ?= yes
625
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000626# Highpoint (HPT) ATA/RAID controller support.
627# IMPORTANT: This code is not yet working!
628CONFIG_ATAHPT ?= no
629
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000630# VIA VT6421A LPC memory support
631CONFIG_ATAVIA ?= yes
632
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000633# Promise ATA controller support.
634CONFIG_ATAPROMISE ?= no
635
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000636# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000637CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000638
James Lairdc60de0e2013-03-27 13:00:23 +0000639# Always enable Altera USB-Blaster dongles for now.
640CONFIG_USBBLASTER_SPI ?= yes
641
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000642# MSTAR DDC support needs more tests/reviews/cleanups.
643CONFIG_MSTARDDC_SPI ?= no
644
Justin Chevrier66e554b2015-02-08 21:58:10 +0000645# Always enable PICkit2 SPI dongles for now.
646CONFIG_PICKIT2_SPI ?= yes
647
Miklós Márton324929c2019-08-01 19:14:10 +0200648# Always enable STLink V3
649CONFIG_STLINKV3_SPI ?= yes
650
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000651# Always enable dummy tracing for now.
652CONFIG_DUMMY ?= yes
653
654# Always enable Dr. Kaiser for now.
655CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000656
Joerg Fischer5665ef32010-05-21 21:54:07 +0000657# Always enable Realtek NICs for now.
658CONFIG_NICREALTEK ?= yes
659
Andrew Morganc29c2e72010-06-07 22:37:54 +0000660# Disable National Semiconductor NICs until support is complete and tested.
661CONFIG_NICNATSEMI ?= no
662
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000663# Always enable Intel NICs for now.
664CONFIG_NICINTEL ?= yes
665
Idwer Vollering004f4b72010-09-03 18:21:21 +0000666# Always enable SPI on Intel NICs for now.
667CONFIG_NICINTEL_SPI ?= yes
668
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000669# Always enable EEPROM on Intel NICs for now.
670CONFIG_NICINTEL_EEPROM ?= yes
671
Mark Marshall90021f22010-12-03 14:48:11 +0000672# Always enable SPI on OGP cards for now.
673CONFIG_OGP_SPI ?= yes
674
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000675# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000676CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000677
Simon Glassae616512016-01-23 23:27:58 +0000678# Always enable Dediprog SF100 for now.
679CONFIG_DEDIPROG ?= yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000680
Daniel Thompson45e91a22018-06-04 13:46:29 +0100681# Always enable Developerbox emergency recovery for now.
682CONFIG_DEVELOPERBOX_SPI ?= yes
683
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000684# Always enable Marvell SATA controllers for now.
685CONFIG_SATAMV ?= yes
686
David Hendricksf9a30552015-05-23 20:30:30 -0700687# Enable Linux spidev and MTD interfaces by default. We disable them on non-Linux targets.
688CONFIG_LINUX_MTD ?= yes
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000689CONFIG_LINUX_SPI ?= yes
690
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000691# Always enable ITE IT8212F PATA controllers for now.
692CONFIG_IT8212 ?= yes
693
Urja Rannikko0870b022016-01-31 22:10:29 +0000694# Winchiphead CH341A
695CONFIG_CH341A_SPI ?= yes
696
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100697# Digilent Development board JTAG
698CONFIG_DIGILENT_SPI ?= yes
699
Marc Schink3578ec62016-03-17 16:23:03 +0100700# Disable J-Link for now.
701CONFIG_JLINK_SPI ?= no
702
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000703# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000704CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000705
Stefan Taunerf3503372016-02-26 23:51:21 +0000706# Disable all features if CONFIG_NOTHING=yes is given unless CONFIG_EVERYTHING was also set
707ifeq ($(CONFIG_NOTHING), yes)
708 ifeq ($(CONFIG_EVERYTHING), yes)
709 $(error Setting CONFIG_NOTHING=yes and CONFIG_EVERYTHING=yes does not make sense)
710 endif
711 $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
712 $(if $(filter yes, $($(var))),\
713 $(eval $(var)=no)))
714endif
715
Patrick Georgiced7ab62015-01-19 19:52:34 +0000716# Enable all features if CONFIG_EVERYTHING=yes is given
717ifeq ($(CONFIG_EVERYTHING), yes)
718$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
719 $(if $(filter no, $($(var))),\
720 $(eval $(var)=yes)))
721endif
722
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000723ifeq ($(CONFIG_ENABLE_LIBUSB1_PROGRAMMERS), no)
724override CONFIG_CH341A_SPI = no
725override CONFIG_DEDIPROG = no
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100726override CONFIG_DIGILENT_SPI = no
Daniel Thompson45e91a22018-06-04 13:46:29 +0100727override CONFIG_DEVELOPERBOX_SPI = no
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200728override CONFIG_PICKIT2_SPI = no
Miklós Márton324929c2019-08-01 19:14:10 +0200729override CONFIG_STLINKV3_SPI = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000730endif
731ifeq ($(CONFIG_ENABLE_LIBPCI_PROGRAMMERS), no)
Stefan Tauner0be072c2016-03-13 15:16:30 +0000732override CONFIG_INTERNAL = no
733override CONFIG_NIC3COM = no
734override CONFIG_GFXNVIDIA = no
735override CONFIG_SATASII = no
736override CONFIG_ATAHPT = no
737override CONFIG_ATAVIA = no
738override CONFIG_ATAPROMISE = no
739override CONFIG_IT8212 = no
740override CONFIG_DRKAISER = no
741override CONFIG_NICREALTEK = no
742override CONFIG_NICNATSEMI = no
743override CONFIG_NICINTEL = no
744override CONFIG_NICINTEL_SPI = no
745override CONFIG_NICINTEL_EEPROM = no
746override CONFIG_OGP_SPI = no
747override CONFIG_SATAMV = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000748endif
749
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000750# Bitbanging SPI infrastructure, default off unless needed.
751ifeq ($(CONFIG_RAYER_SPI), yes)
752override CONFIG_BITBANG_SPI = yes
753else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000754ifeq ($(CONFIG_PONY_SPI), yes)
755override CONFIG_BITBANG_SPI = yes
756else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000757ifeq ($(CONFIG_INTERNAL), yes)
758override CONFIG_BITBANG_SPI = yes
759else
760ifeq ($(CONFIG_NICINTEL_SPI), yes)
761override CONFIG_BITBANG_SPI = yes
762else
Mark Marshall90021f22010-12-03 14:48:11 +0000763ifeq ($(CONFIG_OGP_SPI), yes)
764override CONFIG_BITBANG_SPI = yes
765else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000766CONFIG_BITBANG_SPI ?= no
767endif
768endif
769endif
Mark Marshall90021f22010-12-03 14:48:11 +0000770endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000771endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000772
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000773###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000774# Handle CONFIG_* variables that depend on others set (and verified) above.
775
776# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
777ifeq ($(TARGET_OS), libpayload)
778ifeq ($(CONFIG_INTERNAL), yes)
779ifeq ($(CONFIG_INTERNAL_DMI), no)
780UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
781else
782override CONFIG_INTERNAL_DMI = yes
783endif
784endif
785endif
786
787# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
788CONFIG_INTERNAL_DMI ?= yes
789
790###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000791# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000792# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000793
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000794FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000795FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000796
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000797ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000798FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000799PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000800ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000801PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Nico Huber305f4172013-06-14 11:55:26 +0200802PROGRAMMER_OBJS += ichspi.o dmi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000803ifeq ($(CONFIG_INTERNAL_DMI), yes)
804FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
805endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000806else
807endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000808NEED_LIBPCI += CONFIG_INTERNAL
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000809endif
810
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000811ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000812FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000813PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000814NEED_SERIAL += CONFIG_SERPROG
815NEED_POSIX_SOCKETS += CONFIG_SERPROG
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000816endif
817
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000818ifeq ($(CONFIG_RAYER_SPI), yes)
819FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
820PROGRAMMER_OBJS += rayer_spi.o
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000821NEED_RAW_ACCESS += CONFIG_RAYER_SPI
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000822endif
823
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000824ifeq ($(CONFIG_PONY_SPI), yes)
825FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
826PROGRAMMER_OBJS += pony_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000827NEED_SERIAL += CONFIG_PONY_SPI
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000828endif
829
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000830ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000831FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000832PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000833endif
834
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000835ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000836FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000837PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000838NEED_LIBPCI += CONFIG_NIC3COM
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000839endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000840
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000841ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000842FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000843PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000844NEED_LIBPCI += CONFIG_GFXNVIDIA
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000845endif
846
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000847ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000848FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000849PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000850NEED_LIBPCI += CONFIG_SATASII
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000851endif
852
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000853ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000854FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000855PROGRAMMER_OBJS += atahpt.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000856NEED_LIBPCI += CONFIG_ATAHPT
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000857endif
858
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000859ifeq ($(CONFIG_ATAVIA), yes)
860FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
861PROGRAMMER_OBJS += atavia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000862NEED_LIBPCI += CONFIG_ATAVIA
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000863endif
864
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000865ifeq ($(CONFIG_ATAPROMISE), yes)
866FEATURE_CFLAGS += -D'CONFIG_ATAPROMISE=1'
867PROGRAMMER_OBJS += atapromise.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000868NEED_LIBPCI += CONFIG_ATAPROMISE
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000869endif
870
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000871ifeq ($(CONFIG_IT8212), yes)
872FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
873PROGRAMMER_OBJS += it8212.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000874NEED_LIBPCI += CONFIG_IT8212
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000875endif
876
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000877ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000878# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000879FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000880NEED_LIBFTDI += CONFIG_FT2232_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000881PROGRAMMER_OBJS += ft2232_spi.o
882endif
883
884ifeq ($(CONFIG_USBBLASTER_SPI), yes)
885# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000886FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000887NEED_LIBFTDI += CONFIG_USBBLASTER_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000888PROGRAMMER_OBJS += usbblaster_spi.o
889endif
890
Justin Chevrier66e554b2015-02-08 21:58:10 +0000891ifeq ($(CONFIG_PICKIT2_SPI), yes)
892FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
893PROGRAMMER_OBJS += pickit2_spi.o
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200894NEED_LIBUSB1 += CONFIG_PICKIT2_SPI
Justin Chevrier66e554b2015-02-08 21:58:10 +0000895endif
896
Miklós Márton324929c2019-08-01 19:14:10 +0200897ifeq ($(CONFIG_STLINKV3_SPI), yes)
898FEATURE_CFLAGS += -D'CONFIG_STLINKV3_SPI=1'
899PROGRAMMER_OBJS += stlinkv3_spi.o
900NEED_LIBUSB1 += CONFIG_STLINKV3_SPI
901endif
902
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000903ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000904FTDILIBS := $(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")
905FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
906FTDI_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 +0000907FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000908FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000909# We can't set NEED_LIBUSB0 here because that would transform libftdi auto-enabling
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000910# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000911endif
912
913ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000914FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000915PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000916endif
917
918ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000919FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000920PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000921NEED_LIBPCI += CONFIG_DRKAISER
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000922endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000923
Joerg Fischer5665ef32010-05-21 21:54:07 +0000924ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000925FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000926PROGRAMMER_OBJS += nicrealtek.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000927NEED_LIBPCI += CONFIG_NICREALTEK
Joerg Fischer5665ef32010-05-21 21:54:07 +0000928endif
929
Andrew Morganc29c2e72010-06-07 22:37:54 +0000930ifeq ($(CONFIG_NICNATSEMI), yes)
931FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
932PROGRAMMER_OBJS += nicnatsemi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000933NEED_LIBPCI += CONFIG_NICNATSEMI
Andrew Morganc29c2e72010-06-07 22:37:54 +0000934endif
935
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000936ifeq ($(CONFIG_NICINTEL), yes)
937FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
938PROGRAMMER_OBJS += nicintel.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000939NEED_LIBPCI += CONFIG_NICINTEL
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000940endif
941
Idwer Vollering004f4b72010-09-03 18:21:21 +0000942ifeq ($(CONFIG_NICINTEL_SPI), yes)
943FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
944PROGRAMMER_OBJS += nicintel_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000945NEED_LIBPCI += CONFIG_NICINTEL_SPI
Idwer Vollering004f4b72010-09-03 18:21:21 +0000946endif
947
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000948ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
949FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
950PROGRAMMER_OBJS += nicintel_eeprom.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000951NEED_LIBPCI += CONFIG_NICINTEL_EEPROM
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000952endif
953
Mark Marshall90021f22010-12-03 14:48:11 +0000954ifeq ($(CONFIG_OGP_SPI), yes)
955FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
956PROGRAMMER_OBJS += ogp_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000957NEED_LIBPCI += CONFIG_OGP_SPI
Mark Marshall90021f22010-12-03 14:48:11 +0000958endif
959
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000960ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
961FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000962PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000963NEED_SERIAL += CONFIG_BUSPIRATE_SPI
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000964endif
965
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000966ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000967FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000968PROGRAMMER_OBJS += dediprog.o
Nico Huberd99a2bd2016-02-18 21:42:49 +0000969NEED_LIBUSB1 += CONFIG_DEDIPROG
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000970endif
971
Daniel Thompson45e91a22018-06-04 13:46:29 +0100972ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
973FEATURE_CFLAGS += -D'CONFIG_DEVELOPERBOX_SPI=1'
974PROGRAMMER_OBJS += developerbox_spi.o
975NEED_LIBUSB1 += CONFIG_DEVELOPERBOX_SPI
976endif
977
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000978ifeq ($(CONFIG_SATAMV), yes)
979FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
980PROGRAMMER_OBJS += satamv.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000981NEED_LIBPCI += CONFIG_SATAMV
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000982endif
983
David Hendricksf9a30552015-05-23 20:30:30 -0700984ifeq ($(CONFIG_LINUX_MTD), yes)
985# This is a totally ugly hack.
986FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_MTD_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_MTD=1'")
987PROGRAMMER_OBJS += linux_mtd.o
988endif
989
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000990ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000991# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000992FEATURE_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 +0000993PROGRAMMER_OBJS += linux_spi.o
994endif
995
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000996ifeq ($(CONFIG_MSTARDDC_SPI), yes)
997# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000998FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_I2C_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_MSTARDDC_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000999NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001000PROGRAMMER_OBJS += mstarddc_spi.o
1001endif
1002
Urja Rannikko0870b022016-01-31 22:10:29 +00001003ifeq ($(CONFIG_CH341A_SPI), yes)
1004FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
1005PROGRAMMER_OBJS += ch341a_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001006NEED_LIBUSB1 += CONFIG_CH341A_SPI
Urja Rannikko0870b022016-01-31 22:10:29 +00001007endif
1008
Lubomir Rintelb2154e82018-01-14 17:35:33 +01001009ifeq ($(CONFIG_DIGILENT_SPI), yes)
1010FEATURE_CFLAGS += -D'CONFIG_DIGILENT_SPI=1'
1011PROGRAMMER_OBJS += digilent_spi.o
1012NEED_LIBUSB1 += CONFIG_DIGILENT_SPI
1013endif
1014
Marc Schink3578ec62016-03-17 16:23:03 +01001015ifeq ($(CONFIG_JLINK_SPI), yes)
1016NEED_LIBJAYLINK += CONFIG_JLINK_SPI
1017FEATURE_CFLAGS += -D'CONFIG_JLINK_SPI=1'
1018PROGRAMMER_OBJS += jlink_spi.o
1019endif
1020
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001021ifeq ($(CONFIG_NI845X_SPI), yes)
1022FEATURE_CFLAGS += -D'CONFIG_NI845X_SPI=1'
1023
1024ifeq ($(CONFIG_NI845X_LIBRARY_PATH),)
1025# if the user did not specified the NI-845x headers/lib path
1026# do a guess for both 32 and 64 bit Windows versions
1027NI845X_LIBS += -L'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1028NI845X_LIBS += -L'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1029NI845X_INCLUDES += -I'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1030NI845X_INCLUDES += -I'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1031else
1032NI845X_LIBS += -L'$(CONFIG_NI845X_LIBRARY_PATH)'
1033NI845X_INCLUDES += -I'$(CONFIG_NI845X_LIBRARY_PATH)'
1034endif
1035
1036FEATURE_CFLAGS += $(NI845X_INCLUDES)
1037LIBS += -lni845x
1038PROGRAMMER_OBJS += ni845x_spi.o
1039endif
1040
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001041ifneq ($(NEED_SERIAL), )
Urja Rannikko615ba182017-06-15 15:28:27 +03001042LIB_OBJS += serial.o custom_baud.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +00001043endif
1044
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001045ifneq ($(NEED_POSIX_SOCKETS), )
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001046ifeq ($(TARGET_OS), SunOS)
Stefan Taunerfc3ecc22016-03-13 12:57:03 +00001047LIBS += -lsocket -lnsl
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001048endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +00001049endif
1050
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001051ifneq ($(NEED_LIBPCI), )
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001052CHECK_LIBPCI = yes
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001053# This is a dirty hack, but it saves us from checking all PCI drivers and all platforms manually.
1054# libpci may need raw memory, MSR or PCI port I/O on some platforms.
1055# Individual drivers might have the same needs as well.
1056NEED_RAW_ACCESS += $(NEED_LIBPCI)
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001057FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001058FEATURE_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 +00001059
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001060PROGRAMMER_OBJS += pcidev.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001061ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001062# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001063PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001064else
1065PCILIBS += -lpci
1066endif
1067endif
1068
1069ifneq ($(NEED_RAW_ACCESS), )
1070# Raw memory, MSR or PCI port I/O access.
1071FEATURE_CFLAGS += -D'NEED_RAW_ACCESS=1'
1072PROGRAMMER_OBJS += physmap.o hwaccess.o
1073
1074ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001075# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001076PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001077else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001078ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001079# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001080PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001081else
1082ifeq ($(TARGET_OS), Darwin)
1083# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +00001084PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001085endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001086endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +00001087endif
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001088
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001089endif
1090
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001091
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001092ifneq ($(NEED_LIBUSB1), )
Stefan Taunere49edbb2016-01-31 22:10:14 +00001093CHECK_LIBUSB1 = yes
1094FEATURE_CFLAGS += -D'NEED_LIBUSB1=1'
Daniel Thompson1d507a02018-07-12 11:02:28 +01001095PROGRAMMER_OBJS += usbdev.o
Stefan Taunere49edbb2016-01-31 22:10:14 +00001096# FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
1097ifeq ($(TARGET_OS),$(filter $(TARGET_OS),FreeBSD DragonFlyBSD))
1098USB1LIBS += -lusb
1099else
1100ifeq ($(TARGET_OS),NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +00001101override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
Stefan Taunere49edbb2016-01-31 22:10:14 +00001102USB1LIBS += -lusb-1.0
1103else
Stefan Tauner45207062016-02-19 08:17:24 +00001104USB1LIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libusb-1.0 || printf "%s" "-lusb-1.0")
1105override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libusb-1.0 || printf "%s" "-I/usr/include/libusb-1.0")
Stefan Taunere49edbb2016-01-31 22:10:14 +00001106endif
1107endif
1108endif
1109
Marc Schink3578ec62016-03-17 16:23:03 +01001110ifneq ($(NEED_LIBJAYLINK), )
1111CHECK_LIBJAYLINK = yes
1112JAYLINKLIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libjaylink)
1113override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libjaylink)
1114endif
1115
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001116ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001117FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001118CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001119endif
1120
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001121FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +00001122
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001123# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001124FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001125
Nico Huber8624e8c2012-11-05 21:46:33 +01001126FEATURE_CFLAGS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-D'HAVE_CLOCK_GETTIME=1'")
1127FEATURE_LIBS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-lrt")
1128
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001129LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +00001130OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +00001131
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001132all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001133ifeq ($(ARCH), x86)
1134 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
1135endif
1136
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001137$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001138 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001139
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001140libflashrom.a: $(LIBFLASHROM_OBJS)
1141 $(AR) rcs $@ $^
1142 $(RANLIB) $@
1143
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +00001144# TAROPTIONS reduces information leakage from the packager's system.
1145# If other tar programs support command line arguments for setting uid/gid of
1146# stored files, they can be handled here as well.
1147TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001148
Paul Fox05dfbe62009-06-16 21:08:06 +00001149%.o: %.c .features
Stefan Tauner76347082016-11-27 17:45:49 +01001150 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +00001151
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +00001152# Make sure to add all names of generated binaries here.
1153# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001154# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001155clean:
Stefan Tauner4c723152016-01-14 22:47:55 +00001156 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001157 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001158
Ollie Lho184a4042005-11-26 21:55:36 +00001159distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +00001160 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +00001161
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001162strip: $(PROGRAM)$(EXEC_SUFFIX)
1163 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001164
Stefan Tauner56787082011-08-18 02:27:19 +00001165# to define test programs we use verbatim variables, which get exported
1166# to environment variables and are referenced with $$<varname> later
1167
1168define COMPILER_TEST
1169int main(int argc, char **argv)
1170{
1171 (void) argc;
1172 (void) argv;
1173 return 0;
1174}
1175endef
1176export COMPILER_TEST
1177
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001178compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001179 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001180 @echo "$$COMPILER_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001181 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001182 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
1183 echo "found." || { echo "not found."; \
1184 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 +00001185 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001186 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001187 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001188 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001189 ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001190 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001191 @printf "Target OS is "
1192 @# FreeBSD wc will output extraneous whitespace.
1193 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001194 ( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001195 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +00001196ifeq ($(TARGET_OS), libpayload)
1197 @$(CC) --version 2>&1 | grep -q coreboot || \
1198 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
1199 echo "This might work but usually does not, please beware." )
1200endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +00001201
Stefan Tauner56787082011-08-18 02:27:19 +00001202define LIBPCI_TEST
1203/* Avoid a failing test due to libpci header symbol shadowing breakage */
1204#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +00001205#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +00001206#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +00001207#else
1208#include <pciutils/pci.h>
1209#endif
Stefan Tauner56787082011-08-18 02:27:19 +00001210struct pci_access *pacc;
1211int main(int argc, char **argv)
1212{
1213 (void) argc;
1214 (void) argv;
1215 pacc = pci_alloc();
1216 return 0;
1217}
1218endef
1219export LIBPCI_TEST
1220
Stefan Tauner56734502015-02-08 21:58:04 +00001221define PCI_GET_DEV_TEST
1222/* Avoid a failing test due to libpci header symbol shadowing breakage */
1223#define index shadow_workaround_index
1224#if !defined __NetBSD__
1225#include <pci/pci.h>
1226#else
1227#include <pciutils/pci.h>
1228#endif
1229struct pci_access *pacc;
1230struct pci_dev *dev = {0};
1231int main(int argc, char **argv)
1232{
1233 (void) argc;
1234 (void) argv;
1235 pacc = pci_alloc();
1236 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
1237 return 0;
1238}
1239endef
1240export PCI_GET_DEV_TEST
1241
Stefan Taunere49edbb2016-01-31 22:10:14 +00001242define LIBUSB1_TEST
1243#include <stddef.h>
1244#include <libusb.h>
1245int main(int argc, char **argv)
1246{
1247 (void)argc;
1248 (void)argv;
1249 libusb_init(NULL);
1250 return 0;
1251}
1252endef
1253export LIBUSB1_TEST
1254
Marc Schink3578ec62016-03-17 16:23:03 +01001255define LIBJAYLINK_TEST
1256#include <stddef.h>
1257#include <libjaylink/libjaylink.h>
1258int main(int argc, char **argv)
1259{
1260 struct jaylink_context *ctx;
1261
1262 (void)argc;
1263 (void)argv;
1264
1265 jaylink_init(&ctx);
1266 jaylink_exit(ctx);
1267
1268 return 0;
1269}
1270endef
1271export LIBJAYLINK_TEST
1272
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001273hwlibs: compiler
1274 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001275ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001276 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001277 @echo "$$LIBPCI_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001278 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001279 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1280 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001281 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001282 echo "Please install libpci headers or disable all features"; \
1283 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001284 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001285 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
1286 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +00001287 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001288 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001289 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +00001290 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001291 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1292 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001293 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001294 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
1295 echo "yes." || { echo "no."; \
1296 printf "Checking if libz+libpci are present and sufficient..." ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001297 { printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz" >>$(BUILD_DETAILS_FILE) ; \
1298 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001299 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001300 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001301 echo "Please install libpci (package pciutils) and/or libz or disable all features"; \
1302 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001303 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001304 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 +00001305 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001306endif
Stefan Taunere49edbb2016-01-31 22:10:14 +00001307ifeq ($(CHECK_LIBUSB1), yes)
1308 @printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
1309 @echo "$$LIBUSB1_TEST" > .test.c
1310 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1311 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1312 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001313 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001314 echo "Please install libusb-1.0 headers or disable all features"; \
1315 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001316 echo "See README for more information."; echo; \
1317 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
1318 @printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
1319 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
1320 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
1321 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001322 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001323 echo "Please install libusb-1.0 or disable all features"; \
1324 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001325 echo "See README for more information."; echo; \
1326 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
1327 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1328endif
Marc Schink3578ec62016-03-17 16:23:03 +01001329ifeq ($(CHECK_LIBJAYLINK), yes)
1330 @printf "Checking for libjaylink headers... " | tee -a $(BUILD_DETAILS_FILE)
1331 @echo "$$LIBJAYLINK_TEST" > .test.c
1332 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1333 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1334 echo "found." || { echo "not found."; echo; \
1335 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1336 echo "Please install libjaylink headers or disable the feature"; \
1337 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1338 echo "See README for more information."; echo; \
1339 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
1340 @printf "Checking if libjaylink is usable... " | tee -a $(BUILD_DETAILS_FILE)
1341 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS)" >>$(BUILD_DETAILS_FILE)
1342 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS) >&2 && \
1343 echo "yes." || { echo "no."; \
1344 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1345 echo "Please install libjaylink or disable the feature"; \
1346 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1347 echo "See README for more information."; echo; \
1348 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
1349 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1350endif
Stefan Reinauer53e96252005-12-01 16:19:24 +00001351
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001352.features: features
1353
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001354# If a user does not explicitly request a non-working feature, we should
1355# silently disable it. However, if a non-working (does not compile) feature
1356# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001357# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001358featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001359ifeq ($(PROGRAMMER_OBJS),)
1360 @echo "You have to enable at least one programmer driver!"
1361 @false
1362endif
1363ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001364 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
1365 @false
1366endif
1367
Stefan Tauner56787082011-08-18 02:27:19 +00001368define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +00001369#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +00001370#include <ftdi.h>
1371struct ftdi_context *ftdic = NULL;
1372int main(int argc, char **argv)
1373{
1374 (void) argc;
1375 (void) argv;
1376 return ftdi_init(ftdic);
1377}
1378endef
1379export FTDI_TEST
1380
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001381define FTDI_232H_TEST
1382#include <ftdi.h>
1383enum ftdi_chip_type type = TYPE_232H;
1384endef
1385export FTDI_232H_TEST
1386
Stefan Tauner56787082011-08-18 02:27:19 +00001387define UTSNAME_TEST
1388#include <sys/utsname.h>
1389struct utsname osinfo;
1390int main(int argc, char **argv)
1391{
1392 (void) argc;
1393 (void) argv;
1394 uname (&osinfo);
1395 return 0;
1396}
1397endef
1398export UTSNAME_TEST
1399
David Hendricksf9a30552015-05-23 20:30:30 -07001400define LINUX_MTD_TEST
1401#include <mtd/mtd-user.h>
1402
1403int main(int argc, char **argv)
1404{
1405 (void) argc;
1406 (void) argv;
1407 return 0;
1408}
1409endef
1410export LINUX_MTD_TEST
1411
Stefan Tauner8868db32012-03-13 00:18:19 +00001412define LINUX_SPI_TEST
1413#include <linux/types.h>
1414#include <linux/spi/spidev.h>
1415
1416int main(int argc, char **argv)
1417{
1418 (void) argc;
1419 (void) argv;
1420 return 0;
1421}
1422endef
1423export LINUX_SPI_TEST
1424
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001425define LINUX_I2C_TEST
1426#include <linux/i2c-dev.h>
1427#include <linux/i2c.h>
1428
1429int main(int argc, char **argv)
1430{
1431 (void) argc;
1432 (void) argv;
1433 return 0;
1434}
1435endef
1436export LINUX_I2C_TEST
1437
Nico Huber8624e8c2012-11-05 21:46:33 +01001438define CLOCK_GETTIME_TEST
1439#include <time.h>
1440
1441int main(int argc, char **argv)
1442{
1443 struct timespec res;
1444 clock_gettime(CLOCK_REALTIME, &res);
1445 return 0;
1446}
1447endef
1448export CLOCK_GETTIME_TEST
1449
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001450define NI845X_TEST
1451#include <ni845x.h>
1452
1453int main(int argc, char **argv)
1454{
1455 (void) argc;
1456 (void) argv;
1457 char I2C_Device[256];
1458 NiHandle Dev_Handle;
1459 uInt32 NumberFound = 0;
1460 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
1461 ni845xCloseFindDeviceHandle(Dev_Handle);
1462 return 0;
1463}
1464endef
1465export NI845X_TEST
1466
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001467features: compiler
1468 @echo "FEATURES := yes" > .features.tmp
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001469ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001470 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001471 @echo "$$FTDI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001472 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001473 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1474 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
1475 printf "Checking for FT232H support in libftdi... " ; \
1476 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001477 printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE) ; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001478 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1479 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1480 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1481 ) || \
1482 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1483 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001484endif
David Hendricksf9a30552015-05-23 20:30:30 -07001485ifeq ($(CONFIG_LINUX_MTD), yes)
1486 @printf "Checking if Linux MTD headers are present... " | tee -a $(BUILD_DETAILS_FILE)
1487 @echo "$$LINUX_MTD_TEST" > .featuretest.c
1488 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1489 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1490 ( echo "yes."; echo "LINUX_MTD_SUPPORT := yes" >> .features.tmp ) || \
1491 ( echo "no."; echo "LINUX_MTD_SUPPORT := no" >> .features.tmp ) } \
1492 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1493endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001494ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001495 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001496 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001497 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001498 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001499 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001500 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1501 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001502endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001503ifneq ($(NEED_LINUX_I2C), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001504 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001505 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001506 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001507 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001508 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001509 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1510 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001511endif
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001512ifeq ($(CONFIG_NI845X_SPI), yes)
1513 @printf "Checking for NI USB-845x installation... " | tee -a $(BUILD_DETAILS_FILE)
1514 @echo "$$NI845X_TEST" > .featuretest.c
1515 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
1516
1517 @ { { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS) >&2 && \
1518 ( echo "yes."; echo "NI845X_SUPPORT := yes" >> .features.tmp ) || \
1519 { echo -e "\nUnable to find NI-845x headers or libraries."; \
1520 echo "Please pass the NI-845x library path to the make with the CONFIG_NI845X_LIBRARY_PATH parameter,"; \
1521 echo "or disable the NI-845x support by specifying make CONFIG_NI845X_SPI=no"; \
1522 echo "For the NI-845x 17.0 the library path is:"; \
1523 echo " On 32 bit systems: C:\Program Files)\National Instruments\NI-845x\MS Visual C"; \
1524 echo " On 64 bit systems: C:\Program Files (x86)\National Instruments\NI-845x\MS Visual C"; \
1525 exit 1; }; } \
1526 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1527endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001528 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001529 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001530 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001531 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001532 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001533 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Nico Huber8624e8c2012-11-05 21:46:33 +01001534 @printf "Checking for clock_gettime support... " | tee -a $(BUILD_DETAILS_FILE)
1535 @echo "$$CLOCK_GETTIME_TEST" >.featuretest.c
1536 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1537 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1538 ( echo "found."; echo "CLOCK_GETTIME := yes" >>.features.tmp ) || \
1539 ( echo "not found."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1540 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001541 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1542 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001543
Stefan Tauner4c723152016-01-14 22:47:55 +00001544$(PROGRAM).8.html: $(PROGRAM).8
1545 @groff -mandoc -Thtml $< >$@
1546
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001547$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Tauner4c723152016-01-14 22:47:55 +00001548 @# Add the man page change date and version to the man page
Stefan Taunerf0cbbb02017-10-01 00:49:05 +02001549 @sed -e 's#.TH FLASHROM 8 .*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)" "$(MAN_DATE)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001550
1551install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001552 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001553 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001554 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001555 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001556
Nico Huber454f6132012-12-10 13:34:10 +00001557libinstall: libflashrom.a libflashrom.h
1558 mkdir -p $(DESTDIR)$(PREFIX)/lib
1559 $(INSTALL) -m 0644 libflashrom.a $(DESTDIR)$(PREFIX)/lib
1560 mkdir -p $(DESTDIR)$(PREFIX)/include
1561 $(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include
1562
Stefan Tauner76347082016-11-27 17:45:49 +01001563_export: $(PROGRAM).8
1564 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1565 @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1566 @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
Stefan Tauner2dc5d292017-10-04 02:18:33 +02001567# Generate versioninfo.inc containing metadata that would not be available in exported sources otherwise.
1568 @echo "VERSION = $(VERSION)" > "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
1569 @echo "MAN_DATE = $(MAN_DATE)" >> "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
Stefan Taunere4136852017-10-01 15:57:25 +02001570# Restore modification date of all tracked files not marked 'export-ignore' in .gitattributes.
1571# sed is required to filter out file names having the attribute set.
1572# The sed program saves the file name in the hold buffer and then checks if the respective value is 'set'.
1573# If so it ignores the rest of the program, which otherwise restores the file name and prints it.
Stefan Tauner76347082016-11-27 17:45:49 +01001574 @git ls-tree -r -z -t --full-name --name-only HEAD | \
1575 git check-attr -z --stdin export-ignore | \
Stefan Taunere4136852017-10-01 15:57:25 +02001576 sed -zne 'x;n;n;{/^set$$/b;};x;p;' | \
Stefan Tauner76347082016-11-27 17:45:49 +01001577 xargs -0 sh -c 'for f; do \
1578 touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \
1579 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \
Stefan Taunere4136852017-10-01 15:57:25 +02001580 done' dummy_arg0
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001581
Stefan Tauner76347082016-11-27 17:45:49 +01001582export: _export
1583 @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/"
1584
1585tarball: _export
David Hendrickse1a960e2017-10-19 14:54:44 -07001586 @tar -cj --format=ustar -f "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2" -C $(EXPORTDIR)/ \
Stefan Tauner60f7a222017-10-01 15:45:06 +02001587 $(TAROPTIONS) "flashrom-$(RELEASENAME)/"
Stefan Tauner76347082016-11-27 17:45:49 +01001588# Delete the exported directory again because it is most likely what's expected by the user.
1589 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
David Hendrickse1a960e2017-10-19 14:54:44 -07001590 @echo Created "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2"
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001591
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001592libpayload: clean
1593 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001594
Stefan Tauner76347082016-11-27 17:45:49 +01001595.PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001596
Stefan Tauner23e10b82016-01-23 16:16:49 +00001597# Disable implicit suffixes and built-in rules (for performance and profit)
1598.SUFFIXES:
1599
Stefan Reinauere2f01582010-06-07 11:08:07 +00001600-include $(OBJS:.o=.d)