blob: 0cea6b7d4ddc4504f49a76d98744dab55303b7e5 [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
Felix Singer4cbc1cb2022-07-22 23:23:28 +0200766ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
767override CONFIG_BITBANG_SPI = yes
768else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000769CONFIG_BITBANG_SPI ?= no
770endif
771endif
772endif
Mark Marshall90021f22010-12-03 14:48:11 +0000773endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000774endif
Felix Singer4cbc1cb2022-07-22 23:23:28 +0200775endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000776
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000777###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000778# Handle CONFIG_* variables that depend on others set (and verified) above.
779
780# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
781ifeq ($(TARGET_OS), libpayload)
782ifeq ($(CONFIG_INTERNAL), yes)
783ifeq ($(CONFIG_INTERNAL_DMI), no)
784UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
785else
786override CONFIG_INTERNAL_DMI = yes
787endif
788endif
789endif
790
791# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
792CONFIG_INTERNAL_DMI ?= yes
793
794###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000795# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000796# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000797
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000798FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000799FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000800
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000801ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000802FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000803PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000804ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000805PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Nico Huber305f4172013-06-14 11:55:26 +0200806PROGRAMMER_OBJS += ichspi.o dmi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000807ifeq ($(CONFIG_INTERNAL_DMI), yes)
808FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
809endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000810else
811endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000812NEED_LIBPCI += CONFIG_INTERNAL
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000813endif
814
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000815ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000816FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000817PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000818NEED_SERIAL += CONFIG_SERPROG
819NEED_POSIX_SOCKETS += CONFIG_SERPROG
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000820endif
821
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000822ifeq ($(CONFIG_RAYER_SPI), yes)
823FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
824PROGRAMMER_OBJS += rayer_spi.o
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000825NEED_RAW_ACCESS += CONFIG_RAYER_SPI
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000826endif
827
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000828ifeq ($(CONFIG_PONY_SPI), yes)
829FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
830PROGRAMMER_OBJS += pony_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000831NEED_SERIAL += CONFIG_PONY_SPI
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000832endif
833
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000834ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000835FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000836PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000837endif
838
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000839ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000840FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000841PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000842NEED_LIBPCI += CONFIG_NIC3COM
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000843endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000844
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000845ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000846FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000847PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000848NEED_LIBPCI += CONFIG_GFXNVIDIA
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000849endif
850
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000851ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000852FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000853PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000854NEED_LIBPCI += CONFIG_SATASII
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000855endif
856
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000857ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000858FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000859PROGRAMMER_OBJS += atahpt.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000860NEED_LIBPCI += CONFIG_ATAHPT
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000861endif
862
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000863ifeq ($(CONFIG_ATAVIA), yes)
864FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
865PROGRAMMER_OBJS += atavia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000866NEED_LIBPCI += CONFIG_ATAVIA
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000867endif
868
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000869ifeq ($(CONFIG_ATAPROMISE), yes)
870FEATURE_CFLAGS += -D'CONFIG_ATAPROMISE=1'
871PROGRAMMER_OBJS += atapromise.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000872NEED_LIBPCI += CONFIG_ATAPROMISE
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000873endif
874
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000875ifeq ($(CONFIG_IT8212), yes)
876FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
877PROGRAMMER_OBJS += it8212.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000878NEED_LIBPCI += CONFIG_IT8212
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000879endif
880
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000881ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000882# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000883FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000884NEED_LIBFTDI += CONFIG_FT2232_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000885PROGRAMMER_OBJS += ft2232_spi.o
886endif
887
888ifeq ($(CONFIG_USBBLASTER_SPI), yes)
889# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000890FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000891NEED_LIBFTDI += CONFIG_USBBLASTER_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000892PROGRAMMER_OBJS += usbblaster_spi.o
893endif
894
Justin Chevrier66e554b2015-02-08 21:58:10 +0000895ifeq ($(CONFIG_PICKIT2_SPI), yes)
896FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
897PROGRAMMER_OBJS += pickit2_spi.o
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200898NEED_LIBUSB1 += CONFIG_PICKIT2_SPI
Justin Chevrier66e554b2015-02-08 21:58:10 +0000899endif
900
Miklós Márton324929c2019-08-01 19:14:10 +0200901ifeq ($(CONFIG_STLINKV3_SPI), yes)
902FEATURE_CFLAGS += -D'CONFIG_STLINKV3_SPI=1'
903PROGRAMMER_OBJS += stlinkv3_spi.o
904NEED_LIBUSB1 += CONFIG_STLINKV3_SPI
905endif
906
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000907ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000908FTDILIBS := $(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")
909FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
910FTDI_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 +0000911FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000912FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000913# We can't set NEED_LIBUSB0 here because that would transform libftdi auto-enabling
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000914# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000915endif
916
917ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000918FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000919PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000920endif
921
922ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000923FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000924PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000925NEED_LIBPCI += CONFIG_DRKAISER
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000926endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000927
Joerg Fischer5665ef32010-05-21 21:54:07 +0000928ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000929FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000930PROGRAMMER_OBJS += nicrealtek.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000931NEED_LIBPCI += CONFIG_NICREALTEK
Joerg Fischer5665ef32010-05-21 21:54:07 +0000932endif
933
Andrew Morganc29c2e72010-06-07 22:37:54 +0000934ifeq ($(CONFIG_NICNATSEMI), yes)
935FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
936PROGRAMMER_OBJS += nicnatsemi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000937NEED_LIBPCI += CONFIG_NICNATSEMI
Andrew Morganc29c2e72010-06-07 22:37:54 +0000938endif
939
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000940ifeq ($(CONFIG_NICINTEL), yes)
941FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
942PROGRAMMER_OBJS += nicintel.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000943NEED_LIBPCI += CONFIG_NICINTEL
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000944endif
945
Idwer Vollering004f4b72010-09-03 18:21:21 +0000946ifeq ($(CONFIG_NICINTEL_SPI), yes)
947FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
948PROGRAMMER_OBJS += nicintel_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000949NEED_LIBPCI += CONFIG_NICINTEL_SPI
Idwer Vollering004f4b72010-09-03 18:21:21 +0000950endif
951
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000952ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
953FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
954PROGRAMMER_OBJS += nicintel_eeprom.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000955NEED_LIBPCI += CONFIG_NICINTEL_EEPROM
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000956endif
957
Mark Marshall90021f22010-12-03 14:48:11 +0000958ifeq ($(CONFIG_OGP_SPI), yes)
959FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
960PROGRAMMER_OBJS += ogp_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000961NEED_LIBPCI += CONFIG_OGP_SPI
Mark Marshall90021f22010-12-03 14:48:11 +0000962endif
963
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000964ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
965FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000966PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000967NEED_SERIAL += CONFIG_BUSPIRATE_SPI
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000968endif
969
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000970ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000971FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000972PROGRAMMER_OBJS += dediprog.o
Nico Huberd99a2bd2016-02-18 21:42:49 +0000973NEED_LIBUSB1 += CONFIG_DEDIPROG
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000974endif
975
Daniel Thompson45e91a22018-06-04 13:46:29 +0100976ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
977FEATURE_CFLAGS += -D'CONFIG_DEVELOPERBOX_SPI=1'
978PROGRAMMER_OBJS += developerbox_spi.o
979NEED_LIBUSB1 += CONFIG_DEVELOPERBOX_SPI
980endif
981
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000982ifeq ($(CONFIG_SATAMV), yes)
983FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
984PROGRAMMER_OBJS += satamv.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000985NEED_LIBPCI += CONFIG_SATAMV
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000986endif
987
David Hendricksf9a30552015-05-23 20:30:30 -0700988ifeq ($(CONFIG_LINUX_MTD), yes)
989# This is a totally ugly hack.
990FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_MTD_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_MTD=1'")
991PROGRAMMER_OBJS += linux_mtd.o
992endif
993
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000994ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000995# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000996FEATURE_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 +0000997PROGRAMMER_OBJS += linux_spi.o
998endif
999
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001000ifeq ($(CONFIG_MSTARDDC_SPI), yes)
1001# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001002FEATURE_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 +00001003NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001004PROGRAMMER_OBJS += mstarddc_spi.o
1005endif
1006
Urja Rannikko0870b022016-01-31 22:10:29 +00001007ifeq ($(CONFIG_CH341A_SPI), yes)
1008FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
1009PROGRAMMER_OBJS += ch341a_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001010NEED_LIBUSB1 += CONFIG_CH341A_SPI
Urja Rannikko0870b022016-01-31 22:10:29 +00001011endif
1012
Lubomir Rintelb2154e82018-01-14 17:35:33 +01001013ifeq ($(CONFIG_DIGILENT_SPI), yes)
1014FEATURE_CFLAGS += -D'CONFIG_DIGILENT_SPI=1'
1015PROGRAMMER_OBJS += digilent_spi.o
1016NEED_LIBUSB1 += CONFIG_DIGILENT_SPI
1017endif
1018
Marc Schink3578ec62016-03-17 16:23:03 +01001019ifeq ($(CONFIG_JLINK_SPI), yes)
1020NEED_LIBJAYLINK += CONFIG_JLINK_SPI
1021FEATURE_CFLAGS += -D'CONFIG_JLINK_SPI=1'
1022PROGRAMMER_OBJS += jlink_spi.o
1023endif
1024
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001025ifeq ($(CONFIG_NI845X_SPI), yes)
1026FEATURE_CFLAGS += -D'CONFIG_NI845X_SPI=1'
1027
1028ifeq ($(CONFIG_NI845X_LIBRARY_PATH),)
1029# if the user did not specified the NI-845x headers/lib path
1030# do a guess for both 32 and 64 bit Windows versions
1031NI845X_LIBS += -L'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1032NI845X_LIBS += -L'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1033NI845X_INCLUDES += -I'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1034NI845X_INCLUDES += -I'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1035else
1036NI845X_LIBS += -L'$(CONFIG_NI845X_LIBRARY_PATH)'
1037NI845X_INCLUDES += -I'$(CONFIG_NI845X_LIBRARY_PATH)'
1038endif
1039
1040FEATURE_CFLAGS += $(NI845X_INCLUDES)
1041LIBS += -lni845x
1042PROGRAMMER_OBJS += ni845x_spi.o
1043endif
1044
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001045ifneq ($(NEED_SERIAL), )
Urja Rannikko615ba182017-06-15 15:28:27 +03001046LIB_OBJS += serial.o custom_baud.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +00001047endif
1048
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001049ifneq ($(NEED_POSIX_SOCKETS), )
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001050ifeq ($(TARGET_OS), SunOS)
Stefan Taunerfc3ecc22016-03-13 12:57:03 +00001051LIBS += -lsocket -lnsl
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001052endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +00001053endif
1054
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001055ifneq ($(NEED_LIBPCI), )
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001056CHECK_LIBPCI = yes
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001057# This is a dirty hack, but it saves us from checking all PCI drivers and all platforms manually.
1058# libpci may need raw memory, MSR or PCI port I/O on some platforms.
1059# Individual drivers might have the same needs as well.
1060NEED_RAW_ACCESS += $(NEED_LIBPCI)
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001061FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001062FEATURE_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 +00001063
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001064PROGRAMMER_OBJS += pcidev.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001065ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001066# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001067PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001068else
1069PCILIBS += -lpci
1070endif
1071endif
1072
1073ifneq ($(NEED_RAW_ACCESS), )
1074# Raw memory, MSR or PCI port I/O access.
1075FEATURE_CFLAGS += -D'NEED_RAW_ACCESS=1'
1076PROGRAMMER_OBJS += physmap.o hwaccess.o
1077
1078ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001079# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001080PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001081else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001082ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001083# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001084PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001085else
1086ifeq ($(TARGET_OS), Darwin)
1087# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +00001088PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001089endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001090endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +00001091endif
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001092
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001093endif
1094
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001095
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001096ifneq ($(NEED_LIBUSB1), )
Stefan Taunere49edbb2016-01-31 22:10:14 +00001097CHECK_LIBUSB1 = yes
1098FEATURE_CFLAGS += -D'NEED_LIBUSB1=1'
Daniel Thompson1d507a02018-07-12 11:02:28 +01001099PROGRAMMER_OBJS += usbdev.o
Stefan Taunere49edbb2016-01-31 22:10:14 +00001100# FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
1101ifeq ($(TARGET_OS),$(filter $(TARGET_OS),FreeBSD DragonFlyBSD))
1102USB1LIBS += -lusb
1103else
1104ifeq ($(TARGET_OS),NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +00001105override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
Stefan Taunere49edbb2016-01-31 22:10:14 +00001106USB1LIBS += -lusb-1.0
1107else
Stefan Tauner45207062016-02-19 08:17:24 +00001108USB1LIBS += $(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")
1109override 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 +00001110endif
1111endif
1112endif
1113
Marc Schink3578ec62016-03-17 16:23:03 +01001114ifneq ($(NEED_LIBJAYLINK), )
1115CHECK_LIBJAYLINK = yes
1116JAYLINKLIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libjaylink)
1117override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libjaylink)
1118endif
1119
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001120ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001121FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001122CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001123endif
1124
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001125FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +00001126
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001127# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001128FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001129
Nico Huber8624e8c2012-11-05 21:46:33 +01001130FEATURE_CFLAGS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-D'HAVE_CLOCK_GETTIME=1'")
1131FEATURE_LIBS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-lrt")
1132
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001133LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +00001134OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +00001135
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001136all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001137ifeq ($(ARCH), x86)
1138 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
1139endif
1140
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001141$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001142 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001143
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001144libflashrom.a: $(LIBFLASHROM_OBJS)
1145 $(AR) rcs $@ $^
1146 $(RANLIB) $@
1147
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +00001148# TAROPTIONS reduces information leakage from the packager's system.
1149# If other tar programs support command line arguments for setting uid/gid of
1150# stored files, they can be handled here as well.
1151TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001152
Paul Fox05dfbe62009-06-16 21:08:06 +00001153%.o: %.c .features
Stefan Tauner76347082016-11-27 17:45:49 +01001154 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +00001155
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +00001156# Make sure to add all names of generated binaries here.
1157# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001158# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001159clean:
Stefan Tauner4c723152016-01-14 22:47:55 +00001160 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 +00001161 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001162
Ollie Lho184a4042005-11-26 21:55:36 +00001163distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +00001164 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +00001165
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001166strip: $(PROGRAM)$(EXEC_SUFFIX)
1167 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001168
Stefan Tauner56787082011-08-18 02:27:19 +00001169# to define test programs we use verbatim variables, which get exported
1170# to environment variables and are referenced with $$<varname> later
1171
1172define COMPILER_TEST
1173int main(int argc, char **argv)
1174{
1175 (void) argc;
1176 (void) argv;
1177 return 0;
1178}
1179endef
1180export COMPILER_TEST
1181
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001182compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001183 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001184 @echo "$$COMPILER_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001185 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001186 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
1187 echo "found." || { echo "not found."; \
1188 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 +00001189 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001190 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001191 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001192 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001193 ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001194 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001195 @printf "Target OS is "
1196 @# FreeBSD wc will output extraneous whitespace.
1197 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001198 ( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001199 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +00001200ifeq ($(TARGET_OS), libpayload)
1201 @$(CC) --version 2>&1 | grep -q coreboot || \
1202 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
1203 echo "This might work but usually does not, please beware." )
1204endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +00001205
Stefan Tauner56787082011-08-18 02:27:19 +00001206define LIBPCI_TEST
1207/* Avoid a failing test due to libpci header symbol shadowing breakage */
1208#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +00001209#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +00001210#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +00001211#else
1212#include <pciutils/pci.h>
1213#endif
Stefan Tauner56787082011-08-18 02:27:19 +00001214struct pci_access *pacc;
1215int main(int argc, char **argv)
1216{
1217 (void) argc;
1218 (void) argv;
1219 pacc = pci_alloc();
1220 return 0;
1221}
1222endef
1223export LIBPCI_TEST
1224
Stefan Tauner56734502015-02-08 21:58:04 +00001225define PCI_GET_DEV_TEST
1226/* Avoid a failing test due to libpci header symbol shadowing breakage */
1227#define index shadow_workaround_index
1228#if !defined __NetBSD__
1229#include <pci/pci.h>
1230#else
1231#include <pciutils/pci.h>
1232#endif
1233struct pci_access *pacc;
1234struct pci_dev *dev = {0};
1235int main(int argc, char **argv)
1236{
1237 (void) argc;
1238 (void) argv;
1239 pacc = pci_alloc();
1240 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
1241 return 0;
1242}
1243endef
1244export PCI_GET_DEV_TEST
1245
Stefan Taunere49edbb2016-01-31 22:10:14 +00001246define LIBUSB1_TEST
1247#include <stddef.h>
1248#include <libusb.h>
1249int main(int argc, char **argv)
1250{
1251 (void)argc;
1252 (void)argv;
1253 libusb_init(NULL);
1254 return 0;
1255}
1256endef
1257export LIBUSB1_TEST
1258
Marc Schink3578ec62016-03-17 16:23:03 +01001259define LIBJAYLINK_TEST
1260#include <stddef.h>
1261#include <libjaylink/libjaylink.h>
1262int main(int argc, char **argv)
1263{
1264 struct jaylink_context *ctx;
1265
1266 (void)argc;
1267 (void)argv;
1268
1269 jaylink_init(&ctx);
1270 jaylink_exit(ctx);
1271
1272 return 0;
1273}
1274endef
1275export LIBJAYLINK_TEST
1276
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001277hwlibs: compiler
1278 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001279ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001280 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001281 @echo "$$LIBPCI_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001282 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001283 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1284 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001285 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001286 echo "Please install libpci headers or disable all features"; \
1287 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001288 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001289 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
1290 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +00001291 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001292 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001293 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +00001294 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001295 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1296 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001297 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001298 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
1299 echo "yes." || { echo "no."; \
1300 printf "Checking if libz+libpci are present and sufficient..." ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001301 { printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz" >>$(BUILD_DETAILS_FILE) ; \
1302 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001303 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001304 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001305 echo "Please install libpci (package pciutils) and/or libz or disable all features"; \
1306 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001307 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001308 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 +00001309 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001310endif
Stefan Taunere49edbb2016-01-31 22:10:14 +00001311ifeq ($(CHECK_LIBUSB1), yes)
1312 @printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
1313 @echo "$$LIBUSB1_TEST" > .test.c
1314 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1315 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1316 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001317 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001318 echo "Please install libusb-1.0 headers or disable all features"; \
1319 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001320 echo "See README for more information."; echo; \
1321 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
1322 @printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
1323 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
1324 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
1325 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001326 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001327 echo "Please install libusb-1.0 or disable all features"; \
1328 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001329 echo "See README for more information."; echo; \
1330 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
1331 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1332endif
Marc Schink3578ec62016-03-17 16:23:03 +01001333ifeq ($(CHECK_LIBJAYLINK), yes)
1334 @printf "Checking for libjaylink headers... " | tee -a $(BUILD_DETAILS_FILE)
1335 @echo "$$LIBJAYLINK_TEST" > .test.c
1336 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1337 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1338 echo "found." || { echo "not found."; echo; \
1339 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1340 echo "Please install libjaylink headers or disable the feature"; \
1341 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1342 echo "See README for more information."; echo; \
1343 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
1344 @printf "Checking if libjaylink is usable... " | tee -a $(BUILD_DETAILS_FILE)
1345 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS)" >>$(BUILD_DETAILS_FILE)
1346 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS) >&2 && \
1347 echo "yes." || { echo "no."; \
1348 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1349 echo "Please install libjaylink or disable the feature"; \
1350 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1351 echo "See README for more information."; echo; \
1352 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
1353 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1354endif
Stefan Reinauer53e96252005-12-01 16:19:24 +00001355
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001356.features: features
1357
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001358# If a user does not explicitly request a non-working feature, we should
1359# silently disable it. However, if a non-working (does not compile) feature
1360# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001361# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001362featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001363ifeq ($(PROGRAMMER_OBJS),)
1364 @echo "You have to enable at least one programmer driver!"
1365 @false
1366endif
1367ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001368 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
1369 @false
1370endif
1371
Stefan Tauner56787082011-08-18 02:27:19 +00001372define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +00001373#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +00001374#include <ftdi.h>
1375struct ftdi_context *ftdic = NULL;
1376int main(int argc, char **argv)
1377{
1378 (void) argc;
1379 (void) argv;
1380 return ftdi_init(ftdic);
1381}
1382endef
1383export FTDI_TEST
1384
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001385define FTDI_232H_TEST
1386#include <ftdi.h>
1387enum ftdi_chip_type type = TYPE_232H;
1388endef
1389export FTDI_232H_TEST
1390
Stefan Tauner56787082011-08-18 02:27:19 +00001391define UTSNAME_TEST
1392#include <sys/utsname.h>
1393struct utsname osinfo;
1394int main(int argc, char **argv)
1395{
1396 (void) argc;
1397 (void) argv;
1398 uname (&osinfo);
1399 return 0;
1400}
1401endef
1402export UTSNAME_TEST
1403
David Hendricksf9a30552015-05-23 20:30:30 -07001404define LINUX_MTD_TEST
1405#include <mtd/mtd-user.h>
1406
1407int main(int argc, char **argv)
1408{
1409 (void) argc;
1410 (void) argv;
1411 return 0;
1412}
1413endef
1414export LINUX_MTD_TEST
1415
Stefan Tauner8868db32012-03-13 00:18:19 +00001416define LINUX_SPI_TEST
1417#include <linux/types.h>
1418#include <linux/spi/spidev.h>
1419
1420int main(int argc, char **argv)
1421{
1422 (void) argc;
1423 (void) argv;
1424 return 0;
1425}
1426endef
1427export LINUX_SPI_TEST
1428
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001429define LINUX_I2C_TEST
1430#include <linux/i2c-dev.h>
1431#include <linux/i2c.h>
1432
1433int main(int argc, char **argv)
1434{
1435 (void) argc;
1436 (void) argv;
1437 return 0;
1438}
1439endef
1440export LINUX_I2C_TEST
1441
Nico Huber8624e8c2012-11-05 21:46:33 +01001442define CLOCK_GETTIME_TEST
1443#include <time.h>
1444
1445int main(int argc, char **argv)
1446{
1447 struct timespec res;
1448 clock_gettime(CLOCK_REALTIME, &res);
1449 return 0;
1450}
1451endef
1452export CLOCK_GETTIME_TEST
1453
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001454define NI845X_TEST
1455#include <ni845x.h>
1456
1457int main(int argc, char **argv)
1458{
1459 (void) argc;
1460 (void) argv;
1461 char I2C_Device[256];
1462 NiHandle Dev_Handle;
1463 uInt32 NumberFound = 0;
1464 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
1465 ni845xCloseFindDeviceHandle(Dev_Handle);
1466 return 0;
1467}
1468endef
1469export NI845X_TEST
1470
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001471features: compiler
1472 @echo "FEATURES := yes" > .features.tmp
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001473ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001474 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001475 @echo "$$FTDI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001476 @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 +00001477 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1478 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
1479 printf "Checking for FT232H support in libftdi... " ; \
1480 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001481 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 +00001482 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1483 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1484 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1485 ) || \
1486 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1487 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001488endif
David Hendricksf9a30552015-05-23 20:30:30 -07001489ifeq ($(CONFIG_LINUX_MTD), yes)
1490 @printf "Checking if Linux MTD headers are present... " | tee -a $(BUILD_DETAILS_FILE)
1491 @echo "$$LINUX_MTD_TEST" > .featuretest.c
1492 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1493 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1494 ( echo "yes."; echo "LINUX_MTD_SUPPORT := yes" >> .features.tmp ) || \
1495 ( echo "no."; echo "LINUX_MTD_SUPPORT := no" >> .features.tmp ) } \
1496 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1497endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001498ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001499 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001500 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001501 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001502 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001503 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001504 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1505 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001506endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001507ifneq ($(NEED_LINUX_I2C), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001508 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001509 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001510 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001511 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001512 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001513 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1514 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001515endif
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001516ifeq ($(CONFIG_NI845X_SPI), yes)
1517 @printf "Checking for NI USB-845x installation... " | tee -a $(BUILD_DETAILS_FILE)
1518 @echo "$$NI845X_TEST" > .featuretest.c
1519 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
1520
1521 @ { { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS) >&2 && \
1522 ( echo "yes."; echo "NI845X_SUPPORT := yes" >> .features.tmp ) || \
1523 { echo -e "\nUnable to find NI-845x headers or libraries."; \
1524 echo "Please pass the NI-845x library path to the make with the CONFIG_NI845X_LIBRARY_PATH parameter,"; \
1525 echo "or disable the NI-845x support by specifying make CONFIG_NI845X_SPI=no"; \
1526 echo "For the NI-845x 17.0 the library path is:"; \
1527 echo " On 32 bit systems: C:\Program Files)\National Instruments\NI-845x\MS Visual C"; \
1528 echo " On 64 bit systems: C:\Program Files (x86)\National Instruments\NI-845x\MS Visual C"; \
1529 exit 1; }; } \
1530 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1531endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001532 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001533 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001534 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001535 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001536 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001537 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Nico Huber8624e8c2012-11-05 21:46:33 +01001538 @printf "Checking for clock_gettime support... " | tee -a $(BUILD_DETAILS_FILE)
1539 @echo "$$CLOCK_GETTIME_TEST" >.featuretest.c
1540 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1541 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1542 ( echo "found."; echo "CLOCK_GETTIME := yes" >>.features.tmp ) || \
1543 ( echo "not found."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1544 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001545 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1546 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001547
Stefan Tauner4c723152016-01-14 22:47:55 +00001548$(PROGRAM).8.html: $(PROGRAM).8
1549 @groff -mandoc -Thtml $< >$@
1550
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001551$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Tauner4c723152016-01-14 22:47:55 +00001552 @# Add the man page change date and version to the man page
Stefan Taunerf0cbbb02017-10-01 00:49:05 +02001553 @sed -e 's#.TH FLASHROM 8 .*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)" "$(MAN_DATE)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001554
1555install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001556 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001557 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001558 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001559 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001560
Nico Huber454f6132012-12-10 13:34:10 +00001561libinstall: libflashrom.a libflashrom.h
1562 mkdir -p $(DESTDIR)$(PREFIX)/lib
1563 $(INSTALL) -m 0644 libflashrom.a $(DESTDIR)$(PREFIX)/lib
1564 mkdir -p $(DESTDIR)$(PREFIX)/include
1565 $(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include
1566
Stefan Tauner76347082016-11-27 17:45:49 +01001567_export: $(PROGRAM).8
1568 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1569 @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1570 @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
Stefan Tauner2dc5d292017-10-04 02:18:33 +02001571# Generate versioninfo.inc containing metadata that would not be available in exported sources otherwise.
1572 @echo "VERSION = $(VERSION)" > "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
1573 @echo "MAN_DATE = $(MAN_DATE)" >> "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
Stefan Taunere4136852017-10-01 15:57:25 +02001574# Restore modification date of all tracked files not marked 'export-ignore' in .gitattributes.
1575# sed is required to filter out file names having the attribute set.
1576# The sed program saves the file name in the hold buffer and then checks if the respective value is 'set'.
1577# 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 +01001578 @git ls-tree -r -z -t --full-name --name-only HEAD | \
1579 git check-attr -z --stdin export-ignore | \
Stefan Taunere4136852017-10-01 15:57:25 +02001580 sed -zne 'x;n;n;{/^set$$/b;};x;p;' | \
Stefan Tauner76347082016-11-27 17:45:49 +01001581 xargs -0 sh -c 'for f; do \
1582 touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \
1583 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \
Stefan Taunere4136852017-10-01 15:57:25 +02001584 done' dummy_arg0
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001585
Stefan Tauner76347082016-11-27 17:45:49 +01001586export: _export
1587 @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/"
1588
1589tarball: _export
David Hendrickse1a960e2017-10-19 14:54:44 -07001590 @tar -cj --format=ustar -f "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2" -C $(EXPORTDIR)/ \
Stefan Tauner60f7a222017-10-01 15:45:06 +02001591 $(TAROPTIONS) "flashrom-$(RELEASENAME)/"
Stefan Tauner76347082016-11-27 17:45:49 +01001592# Delete the exported directory again because it is most likely what's expected by the user.
1593 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
David Hendrickse1a960e2017-10-19 14:54:44 -07001594 @echo Created "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2"
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001595
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001596libpayload: clean
1597 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001598
Stefan Tauner76347082016-11-27 17:45:49 +01001599.PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001600
Stefan Tauner23e10b82016-01-23 16:16:49 +00001601# Disable implicit suffixes and built-in rules (for performance and profit)
1602.SUFFIXES:
1603
Stefan Reinauere2f01582010-06-07 11:08:07 +00001604-include $(OBJS:.o=.d)