blob: d47c5a8d792e2d2324faec548d999e25c766fad1 [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
Thomas Heijligen84e9c912021-06-01 16:22:14 +020047# values can be found when running 'flashrom --list-supported' under the 'Supported programmers' section.
48CONFIG_DEFAULT_PROGRAMMER_NAME ?=
Stefan Tauner265fcac2014-06-02 00:12:23 +000049# The following adds a default parameter for the default programmer set above (only).
Thomas Heijligen84e9c912021-06-01 16:22:14 +020050CONFIG_DEFAULT_PROGRAMMER_ARGS ?=
Stefan Tauner265fcac2014-06-02 00:12:23 +000051# Example: compiling with
Thomas Heijligen84e9c912021-06-01 16:22:14 +020052# make CONFIG_DEFAULT_PROGRAMMER_NAME=serprog CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000"
Stefan Tauner265fcac2014-06-02 00:12:23 +000053# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000054
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000055# If your compiler spits out excessive warnings, run make WARNERROR=no
56# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000057WARNERROR ?= yes
58
59ifeq ($(WARNERROR), yes)
60CFLAGS += -Werror
61endif
62
Stefan Taunere37735a2015-01-26 22:03:35 +000063ifdef LIBS_BASE
Stefan Taunere37735a2015-01-26 22:03:35 +000064PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig
Stefan Tauner45207062016-02-19 08:17:24 +000065override CPPFLAGS += -I$(LIBS_BASE)/include
66override LDFLAGS += -L$(LIBS_BASE)/lib -Wl,-rpath -Wl,$(LIBS_BASE)/lib
Stefan Taunere37735a2015-01-26 22:03:35 +000067endif
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000068
Stefan Taunerbfb067b2016-01-07 18:13:07 +000069ifeq ($(CONFIG_STATIC),yes)
Stefan Tauner45207062016-02-19 08:17:24 +000070override PKG_CONFIG += --static
71override LDFLAGS += -static
Stefan Taunerbfb067b2016-01-07 18:13:07 +000072endif
73
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000074# Set LC_ALL=C to minimize influences of the locale.
75# However, this won't work for the majority of relevant commands because they use the $(shell) function and
76# GNU make does not relay variables exported within the makefile to their evironment.
77LC_ALL=C
78export LC_ALL
79
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000080dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUILD_DETAILS_FILE))
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000081
82# Provide an easy way to execute a command, print its output to stdout and capture any error message on stderr
83# in the build details file together with the original stdout output.
Pyry Kontio89cc73b2020-07-06 12:57:35 +090084debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(subst ','\'',$(1)) ; }' >&2; \
85 { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE))
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000086
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000087###############################################################################
Stefan Tauner037cd842013-08-25 00:10:56 +000088# General OS-specific settings.
89# 1. Prepare for later by gathering information about host and target OS
90# 2. Set compiler flags and parameters according to OSes
91# 3. Likewise verify user-supplied CONFIG_* variables.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000092
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000093# HOST_OS is only used to work around local toolchain issues.
Stefan Tauner037cd842013-08-25 00:10:56 +000094HOST_OS ?= $(shell uname)
Miklós Mártona75a2ed2018-01-30 20:25:00 +010095ifeq ($(findstring MINGW, $(HOST_OS)), MINGW)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000096# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
97CC = gcc
98endif
Miklós Mártona75a2ed2018-01-30 20:25:00 +010099
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000100ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +0000101STRIP_ARGS = -s
102endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000103
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000104# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000105# IMPORTANT: The following line must be placed before TARGET_OS is ever used
106# (of course), but should come after any lines setting CC because the line
107# below uses CC itself.
Pyry Kontio89cc73b2020-07-06 12:57:35 +0900108override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null \
109 | tail -1 | cut -f 2 -d'"'))
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000110
111ifeq ($(TARGET_OS), Darwin)
Stefan Tauner45207062016-02-19 08:17:24 +0000112override CPPFLAGS += -I/opt/local/include -I/usr/local/include
113override LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +0000114endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000115
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000116ifeq ($(TARGET_OS), FreeBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000117override CPPFLAGS += -I/usr/local/include
118override LDFLAGS += -L/usr/local/lib
Andriy Gapon65c1b862008-05-22 13:22:45 +0000119endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000120
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000121ifeq ($(TARGET_OS), OpenBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000122override CPPFLAGS += -I/usr/local/include
123override LDFLAGS += -L/usr/local/lib
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000124endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000125
Stefan Taunerc65b8552013-09-12 15:48:39 +0000126ifeq ($(TARGET_OS), NetBSD)
Nico Huberc0e1c4b2022-12-13 21:55:22 +0000127# Needs special `pciutils/pci.h` for older NetBSD packages
128PCIUTILS_PCI_H := $(shell [ -f /usr/pkg/include/pciutils/pci.h ] && echo -DPCIUTILS_PCI_H)
129override CPPFLAGS += -I/usr/pkg/include $(PCIUTILS_PCI_H)
Stefan Tauner45207062016-02-19 08:17:24 +0000130override 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
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000217# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
218ifeq ($(CONFIG_INTERNAL), yes)
219UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
220else
221override CONFIG_INTERNAL = no
222endif
223ifeq ($(CONFIG_RAYER_SPI), yes)
224UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
225else
226override CONFIG_RAYER_SPI = no
227endif
228ifeq ($(CONFIG_NIC3COM), yes)
229UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
230else
231override CONFIG_NIC3COM = no
232endif
233ifeq ($(CONFIG_GFXNVIDIA), yes)
234UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
235else
236override CONFIG_GFXNVIDIA = no
237endif
238ifeq ($(CONFIG_SATASII), yes)
239UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
240else
241override CONFIG_SATASII = no
242endif
243ifeq ($(CONFIG_ATAHPT), yes)
244UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
245else
246override CONFIG_ATAHPT = no
247endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000248ifeq ($(CONFIG_ATAVIA), yes)
249UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
250else
251override CONFIG_ATAVIA = no
252endif
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000253ifeq ($(CONFIG_ATAPROMISE), yes)
254UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
255else
256override CONFIG_ATAPROMISE = no
257endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000258ifeq ($(CONFIG_IT8212), yes)
259UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
260else
261override CONFIG_IT8212 = no
262endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000263ifeq ($(CONFIG_DRKAISER), yes)
264UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
265else
266override CONFIG_DRKAISER = no
267endif
268ifeq ($(CONFIG_NICREALTEK), yes)
269UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
270else
271override CONFIG_NICREALTEK = no
272endif
273ifeq ($(CONFIG_NICNATSEMI), yes)
274UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
275else
276override CONFIG_NICNATSEMI = no
277endif
278ifeq ($(CONFIG_NICINTEL), yes)
279UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
280else
281override CONFIG_NICINTEL = no
282endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000283ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
284UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
285else
286override CONFIG_NICINTEL_EEPROM = no
287endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000288ifeq ($(CONFIG_NICINTEL_SPI), yes)
289UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
290else
291override CONFIG_NICINTEL_SPI = no
292endif
293ifeq ($(CONFIG_OGP_SPI), yes)
294UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
295else
296override CONFIG_OGP_SPI = no
297endif
298ifeq ($(CONFIG_SATAMV), yes)
299UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
300else
301override CONFIG_SATAMV = no
302endif
303endif
304
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100305ifneq ($(TARGET_OS), MinGW)
306# NI USB-845x only supported on Windows at the moment
307ifeq ($(CONFIG_NI845X_SPI), yes)
308UNSUPPORTED_FEATURES += CONFIG_NI845X_SPI=yes
309else
310override CONFIG_NI845X_SPI = no
311endif
312endif
313
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000314ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000315ifeq ($(MAKECMDGOALS),)
316.DEFAULT_GOAL := libflashrom.a
317$(info Setting default goal to libflashrom.a)
318endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000319FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000320ifeq ($(CONFIG_DUMMY), yes)
321UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
322else
323override CONFIG_DUMMY = no
324endif
Stefan Taunere0168262016-02-21 11:18:24 +0000325# libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
326ifeq ($(CONFIG_ATAPROMISE), yes)
327UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
328else
329override CONFIG_ATAPROMISE = no
330endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000331# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000332ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
333UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
334else
335override CONFIG_BUSPIRATE_SPI = no
336endif
337ifeq ($(CONFIG_SERPROG), yes)
338UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
339else
340override CONFIG_SERPROG = no
341endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000342ifeq ($(CONFIG_PONY_SPI), yes)
343UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
344else
345override CONFIG_PONY_SPI = no
346endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100347# Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000348ifeq ($(CONFIG_DEDIPROG), yes)
349UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
350else
351override CONFIG_DEDIPROG = no
352endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100353ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
354UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
355else
356override CONFIG_DEVELOPERBOX_SPI = no
357endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000358ifeq ($(CONFIG_FT2232_SPI), yes)
359UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
360else
361override CONFIG_FT2232_SPI = no
362endif
James Lairdc60de0e2013-03-27 13:00:23 +0000363ifeq ($(CONFIG_USBBLASTER_SPI), yes)
364UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
365else
366override CONFIG_USBBLASTER_SPI = no
367endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000368ifeq ($(CONFIG_PICKIT2_SPI), yes)
369UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
370else
371override CONFIG_PICKIT2_SPI = no
372endif
Miklós Márton324929c2019-08-01 19:14:10 +0200373ifeq ($(CONFIG_STLINKV3_SPI), yes)
374UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
375else
376override CONFIG_STLINKV3_SPI = no
377endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000378ifeq ($(CONFIG_CH341A_SPI), yes)
379UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
380else
381override CONFIG_CH341A_SPI = no
382endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000383endif
384
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000385ifneq ($(TARGET_OS), Linux)
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000386# Android is handled internally as separate OS, but it supports CONFIG_LINUX_SPI and CONFIG_MSTARDDC_SPI
387ifneq ($(TARGET_OS), Android)
David Hendricksf9a30552015-05-23 20:30:30 -0700388ifeq ($(CONFIG_LINUX_MTD), yes)
389UNSUPPORTED_FEATURES += CONFIG_LINUX_MTD=yes
390else
391override CONFIG_LINUX_MTD = no
392endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000393ifeq ($(CONFIG_LINUX_SPI), yes)
394UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
395else
396override CONFIG_LINUX_SPI = no
397endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000398ifeq ($(CONFIG_MSTARDDC_SPI), yes)
399UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
400else
401override CONFIG_MSTARDDC_SPI = no
402endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000403endif
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000404endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000405
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000406ifeq ($(TARGET_OS), Android)
407# Android on x86 (currently) does not provide raw PCI port I/O operations
408ifeq ($(CONFIG_RAYER_SPI), yes)
409UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
410else
411override CONFIG_RAYER_SPI = no
412endif
413endif
414
Stefan Tauner037cd842013-08-25 00:10:56 +0000415###############################################################################
416# General architecture-specific settings.
417# Like above for the OS, below we verify user-supplied options depending on the target architecture.
418
Uwe Hermann44ffd582011-08-20 14:16:00 +0000419# Determine the destination processor architecture.
420# IMPORTANT: The following line must be placed before ARCH is ever used
421# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000422# below uses CC itself.
Pyry Kontio89cc73b2020-07-06 12:57:35 +0900423override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null \
424 | tail -1 | cut -f 2 -d'"'))
425override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \
426 | tail -1))
Uwe Hermann44ffd582011-08-20 14:16:00 +0000427
Nico Huberc8801732017-12-01 18:19:43 +0000428# Disable the internal programmer on unsupported architectures (everything but x86 and mipsel)
429ifneq ($(ARCH)-little, $(filter $(ARCH),x86 mips)-$(ENDIAN))
430ifeq ($(CONFIG_INTERNAL), yes)
431UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
432else
433override CONFIG_INTERNAL = no
434endif
435endif
436
Stefan Taunerfb2d77c2015-02-10 08:03:10 +0000437# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
David Hendricksb286da72012-02-13 00:35:35 +0000438# Right now this means the drivers below only work on x86.
439ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000440ifeq ($(CONFIG_NIC3COM), yes)
441UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
442else
443override CONFIG_NIC3COM = no
444endif
445ifeq ($(CONFIG_NICREALTEK), yes)
446UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
447else
448override CONFIG_NICREALTEK = no
449endif
450ifeq ($(CONFIG_NICNATSEMI), yes)
451UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
452else
453override CONFIG_NICNATSEMI = no
454endif
455ifeq ($(CONFIG_RAYER_SPI), yes)
456UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
457else
458override CONFIG_RAYER_SPI = no
459endif
460ifeq ($(CONFIG_ATAHPT), yes)
461UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
462else
463override CONFIG_ATAHPT = no
464endif
Carl-Daniel Hailfingerf636ffc2016-02-20 22:04:39 +0000465ifeq ($(CONFIG_ATAPROMISE), yes)
466UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
467else
468override CONFIG_ATAPROMISE = no
469endif
Uwe Hermann21b10c62011-07-29 12:13:01 +0000470ifeq ($(CONFIG_SATAMV), yes)
471UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
472else
473override CONFIG_SATAMV = no
474endif
475endif
476
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000477# Disable all drivers needing raw access (memory, PCI, port I/O) on
478# architectures with unknown raw access properties.
479# Right now those architectures are alpha hppa m68k sh s390
Rosen Penev34d07f02019-07-02 00:14:01 -0700480ifneq ($(ARCH),$(filter $(ARCH),x86 mips ppc arm sparc arc))
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000481ifeq ($(CONFIG_RAYER_SPI), yes)
482UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
483else
484override CONFIG_RAYER_SPI = no
485endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000486ifeq ($(CONFIG_NIC3COM), yes)
487UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
488else
489override CONFIG_NIC3COM = no
490endif
491ifeq ($(CONFIG_GFXNVIDIA), yes)
492UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
493else
494override CONFIG_GFXNVIDIA = no
495endif
496ifeq ($(CONFIG_SATASII), yes)
497UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
498else
499override CONFIG_SATASII = no
500endif
501ifeq ($(CONFIG_ATAHPT), yes)
502UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
503else
504override CONFIG_ATAHPT = no
505endif
506ifeq ($(CONFIG_ATAVIA), yes)
507UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
508else
509override CONFIG_ATAVIA = no
510endif
511ifeq ($(CONFIG_ATAPROMISE), yes)
512UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
513else
514override CONFIG_ATAPROMISE = no
515endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000516ifeq ($(CONFIG_DRKAISER), yes)
517UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
518else
519override CONFIG_DRKAISER = no
520endif
521ifeq ($(CONFIG_NICREALTEK), yes)
522UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
523else
524override CONFIG_NICREALTEK = no
525endif
526ifeq ($(CONFIG_NICNATSEMI), yes)
527UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
528else
529override CONFIG_NICNATSEMI = no
530endif
531ifeq ($(CONFIG_NICINTEL), yes)
532UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
533else
534override CONFIG_NICINTEL = no
535endif
536ifeq ($(CONFIG_NICINTEL_SPI), yes)
537UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
538else
539override CONFIG_NICINTEL_SPI = no
540endif
541ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
542UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
543else
544override CONFIG_NICINTEL_EEPROM = no
545endif
546ifeq ($(CONFIG_OGP_SPI), yes)
547UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
548else
549override CONFIG_OGP_SPI = no
550endif
551ifeq ($(CONFIG_SATAMV), yes)
552UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
553else
554override CONFIG_SATAMV = no
555endif
556ifeq ($(CONFIG_IT8212), yes)
557UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
558else
559override CONFIG_IT8212 = no
560endif
561endif
562
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000563###############################################################################
564# Flash chip drivers and bus support infrastructure.
565
Stefan Tauner4404f732013-09-12 08:28:56 +0000566CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000567 sst28sf040.o 82802ab.o \
Paul Kocialkowski80ae14e2018-01-15 01:07:46 +0300568 sst49lfxxxc.o sst_fwhub.o edi.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Nikolai Artemievc9feb1b2021-10-21 01:35:13 +1100569 spi95.o opaque.o sfdp.o en29lv640b.o at45db.o \
570 writeprotect.o writeprotect_ranges.o
Sean Nelson5d134642009-12-24 16:54:21 +0000571
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000572###############################################################################
573# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000574
Thomas Heijligenbbfacff2021-03-31 20:40:01 +0200575LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o programmer_table.o helpers.o ich_descriptors.o fmap.o
Sean Nelson5d134642009-12-24 16:54:21 +0000576
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000577###############################################################################
578# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000579
Stefan Tauner9b32de92014-08-08 23:52:33 +0000580CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000581
Stefan Taunerfa25bc32017-10-04 03:47:26 +0200582# versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
583# imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
584# be obtained using util/getrevision.sh, which is the common case during development.
585-include versioninfo.inc
Stefan Tauner5bf6b852017-10-04 03:46:51 +0200586VERSION ?= $(shell ./util/getrevision.sh --revision)
Stefan Tauner96209122017-10-01 16:41:35 +0200587MAN_DATE ?= $(shell ./util/getrevision.sh --date $(PROGRAM).8.tmpl 2>/dev/null)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000588
Stefan Tauner76347082016-11-27 17:45:49 +0100589SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000590
Stefan Tauner76347082016-11-27 17:45:49 +0100591# No spaces in release names unless set explicitly
592RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/')
593
594# Inform user of the version string
595$(info Replacing all version templates with $(VERSION).)
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000596
Stefan Tauner96209122017-10-01 16:41:35 +0200597# If a VCS is found then try to install hooks.
598$(shell ./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh)
599
Stefan Tauner037cd842013-08-25 00:10:56 +0000600###############################################################################
601# Default settings of CONFIG_* variables.
602
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000603# Always enable internal/onboard support for now.
604CONFIG_INTERNAL ?= yes
605
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000606# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000607CONFIG_SERPROG ?= yes
608
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000609# RayeR SPIPGM hardware support
610CONFIG_RAYER_SPI ?= yes
611
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000612# PonyProg2000 SPI hardware support
613CONFIG_PONY_SPI ?= yes
614
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000615# Always enable 3Com NICs for now.
616CONFIG_NIC3COM ?= yes
617
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000618# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
619CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000620
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000621# Always enable SiI SATA controllers for now.
622CONFIG_SATASII ?= yes
623
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000624# Highpoint (HPT) ATA/RAID controller support.
625# IMPORTANT: This code is not yet working!
626CONFIG_ATAHPT ?= no
627
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000628# VIA VT6421A LPC memory support
629CONFIG_ATAVIA ?= yes
630
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000631# Promise ATA controller support.
632CONFIG_ATAPROMISE ?= no
633
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000634# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000635CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000636
James Lairdc60de0e2013-03-27 13:00:23 +0000637# Always enable Altera USB-Blaster dongles for now.
638CONFIG_USBBLASTER_SPI ?= yes
639
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000640# MSTAR DDC support needs more tests/reviews/cleanups.
641CONFIG_MSTARDDC_SPI ?= no
642
Justin Chevrier66e554b2015-02-08 21:58:10 +0000643# Always enable PICkit2 SPI dongles for now.
644CONFIG_PICKIT2_SPI ?= yes
645
Miklós Márton324929c2019-08-01 19:14:10 +0200646# Always enable STLink V3
647CONFIG_STLINKV3_SPI ?= yes
648
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000649# Always enable dummy tracing for now.
650CONFIG_DUMMY ?= yes
651
652# Always enable Dr. Kaiser for now.
653CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000654
Joerg Fischer5665ef32010-05-21 21:54:07 +0000655# Always enable Realtek NICs for now.
656CONFIG_NICREALTEK ?= yes
657
Andrew Morganc29c2e72010-06-07 22:37:54 +0000658# Disable National Semiconductor NICs until support is complete and tested.
659CONFIG_NICNATSEMI ?= no
660
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000661# Always enable Intel NICs for now.
662CONFIG_NICINTEL ?= yes
663
Idwer Vollering004f4b72010-09-03 18:21:21 +0000664# Always enable SPI on Intel NICs for now.
665CONFIG_NICINTEL_SPI ?= yes
666
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000667# Always enable EEPROM on Intel NICs for now.
668CONFIG_NICINTEL_EEPROM ?= yes
669
Mark Marshall90021f22010-12-03 14:48:11 +0000670# Always enable SPI on OGP cards for now.
671CONFIG_OGP_SPI ?= yes
672
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000673# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000674CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000675
Simon Glassae616512016-01-23 23:27:58 +0000676# Always enable Dediprog SF100 for now.
677CONFIG_DEDIPROG ?= yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000678
Daniel Thompson45e91a22018-06-04 13:46:29 +0100679# Always enable Developerbox emergency recovery for now.
680CONFIG_DEVELOPERBOX_SPI ?= yes
681
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000682# Always enable Marvell SATA controllers for now.
683CONFIG_SATAMV ?= yes
684
David Hendricksf9a30552015-05-23 20:30:30 -0700685# Enable Linux spidev and MTD interfaces by default. We disable them on non-Linux targets.
686CONFIG_LINUX_MTD ?= yes
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000687CONFIG_LINUX_SPI ?= yes
688
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000689# Always enable ITE IT8212F PATA controllers for now.
690CONFIG_IT8212 ?= yes
691
Urja Rannikko0870b022016-01-31 22:10:29 +0000692# Winchiphead CH341A
693CONFIG_CH341A_SPI ?= yes
694
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100695# Digilent Development board JTAG
696CONFIG_DIGILENT_SPI ?= yes
697
Marc Schink3578ec62016-03-17 16:23:03 +0100698# Disable J-Link for now.
699CONFIG_JLINK_SPI ?= no
700
Nico Huber83d52072021-06-27 00:07:13 +0200701# National Instruments USB-845x is Windows only and needs a proprietary library.
702CONFIG_NI845X_SPI ?= no
703
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000704# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000705CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000706
Stefan Taunerf3503372016-02-26 23:51:21 +0000707# Disable all features if CONFIG_NOTHING=yes is given unless CONFIG_EVERYTHING was also set
708ifeq ($(CONFIG_NOTHING), yes)
709 ifeq ($(CONFIG_EVERYTHING), yes)
710 $(error Setting CONFIG_NOTHING=yes and CONFIG_EVERYTHING=yes does not make sense)
711 endif
712 $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
713 $(if $(filter yes, $($(var))),\
714 $(eval $(var)=no)))
715endif
716
Patrick Georgiced7ab62015-01-19 19:52:34 +0000717# Enable all features if CONFIG_EVERYTHING=yes is given
718ifeq ($(CONFIG_EVERYTHING), yes)
719$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
720 $(if $(filter no, $($(var))),\
721 $(eval $(var)=yes)))
722endif
723
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000724ifeq ($(CONFIG_ENABLE_LIBUSB1_PROGRAMMERS), no)
725override CONFIG_CH341A_SPI = no
726override CONFIG_DEDIPROG = no
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100727override CONFIG_DIGILENT_SPI = no
Daniel Thompson45e91a22018-06-04 13:46:29 +0100728override CONFIG_DEVELOPERBOX_SPI = no
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200729override CONFIG_PICKIT2_SPI = no
Miklós Márton324929c2019-08-01 19:14:10 +0200730override CONFIG_STLINKV3_SPI = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000731endif
732ifeq ($(CONFIG_ENABLE_LIBPCI_PROGRAMMERS), no)
Stefan Tauner0be072c2016-03-13 15:16:30 +0000733override CONFIG_INTERNAL = no
734override CONFIG_NIC3COM = no
735override CONFIG_GFXNVIDIA = no
736override CONFIG_SATASII = no
737override CONFIG_ATAHPT = no
738override CONFIG_ATAVIA = no
739override CONFIG_ATAPROMISE = no
740override CONFIG_IT8212 = no
741override CONFIG_DRKAISER = no
742override CONFIG_NICREALTEK = no
743override CONFIG_NICNATSEMI = no
744override CONFIG_NICINTEL = no
745override CONFIG_NICINTEL_SPI = no
746override CONFIG_NICINTEL_EEPROM = no
747override CONFIG_OGP_SPI = no
748override CONFIG_SATAMV = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000749endif
750
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000751# Bitbanging SPI infrastructure, default off unless needed.
752ifeq ($(CONFIG_RAYER_SPI), yes)
753override CONFIG_BITBANG_SPI = yes
754else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000755ifeq ($(CONFIG_PONY_SPI), yes)
756override CONFIG_BITBANG_SPI = yes
757else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000758ifeq ($(CONFIG_INTERNAL), yes)
759override CONFIG_BITBANG_SPI = yes
760else
761ifeq ($(CONFIG_NICINTEL_SPI), yes)
762override CONFIG_BITBANG_SPI = yes
763else
Mark Marshall90021f22010-12-03 14:48:11 +0000764ifeq ($(CONFIG_OGP_SPI), yes)
765override CONFIG_BITBANG_SPI = yes
766else
Felix Singer4cbc1cb2022-07-22 23:23:28 +0200767ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
768override CONFIG_BITBANG_SPI = yes
769else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000770CONFIG_BITBANG_SPI ?= no
771endif
772endif
773endif
Mark Marshall90021f22010-12-03 14:48:11 +0000774endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000775endif
Felix Singer4cbc1cb2022-07-22 23:23:28 +0200776endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000777
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000778###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000779# Handle CONFIG_* variables that depend on others set (and verified) above.
780
781# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
782ifeq ($(TARGET_OS), libpayload)
783ifeq ($(CONFIG_INTERNAL), yes)
784ifeq ($(CONFIG_INTERNAL_DMI), no)
785UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
786else
787override CONFIG_INTERNAL_DMI = yes
788endif
789endif
790endif
791
792# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
793CONFIG_INTERNAL_DMI ?= yes
794
795###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000796# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000797# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000798
Thomas Heijligen84e9c912021-06-01 16:22:14 +0200799ifdef CONFIG_DEFAULT_PROGRAMMER_NAME
800FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_$(CONFIG_DEFAULT_PROGRAMMER_NAME)'
801else
802FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_NAME=NULL'
803endif
804
Stefan Tauner265fcac2014-06-02 00:12:23 +0000805FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000806
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000807ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000808FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000809PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000810ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000811PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Nico Huber305f4172013-06-14 11:55:26 +0200812PROGRAMMER_OBJS += ichspi.o dmi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000813ifeq ($(CONFIG_INTERNAL_DMI), yes)
814FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
815endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000816else
817endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000818NEED_LIBPCI += CONFIG_INTERNAL
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000819endif
820
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000821ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000822FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000823PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000824NEED_SERIAL += CONFIG_SERPROG
825NEED_POSIX_SOCKETS += CONFIG_SERPROG
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000826endif
827
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000828ifeq ($(CONFIG_RAYER_SPI), yes)
829FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
830PROGRAMMER_OBJS += rayer_spi.o
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000831NEED_RAW_ACCESS += CONFIG_RAYER_SPI
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000832endif
833
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000834ifeq ($(CONFIG_PONY_SPI), yes)
835FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
836PROGRAMMER_OBJS += pony_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000837NEED_SERIAL += CONFIG_PONY_SPI
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000838endif
839
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000840ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000841FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000842PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000843endif
844
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000845ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000846FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000847PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000848NEED_LIBPCI += CONFIG_NIC3COM
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000849endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000850
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000851ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000852FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000853PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000854NEED_LIBPCI += CONFIG_GFXNVIDIA
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000855endif
856
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000857ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000858FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000859PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000860NEED_LIBPCI += CONFIG_SATASII
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000861endif
862
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000863ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000864FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000865PROGRAMMER_OBJS += atahpt.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000866NEED_LIBPCI += CONFIG_ATAHPT
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000867endif
868
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000869ifeq ($(CONFIG_ATAVIA), yes)
870FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
871PROGRAMMER_OBJS += atavia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000872NEED_LIBPCI += CONFIG_ATAVIA
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000873endif
874
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000875ifeq ($(CONFIG_ATAPROMISE), yes)
876FEATURE_CFLAGS += -D'CONFIG_ATAPROMISE=1'
877PROGRAMMER_OBJS += atapromise.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000878NEED_LIBPCI += CONFIG_ATAPROMISE
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000879endif
880
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000881ifeq ($(CONFIG_IT8212), yes)
882FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
883PROGRAMMER_OBJS += it8212.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000884NEED_LIBPCI += CONFIG_IT8212
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000885endif
886
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000887ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000888# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000889FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000890NEED_LIBFTDI += CONFIG_FT2232_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000891PROGRAMMER_OBJS += ft2232_spi.o
892endif
893
894ifeq ($(CONFIG_USBBLASTER_SPI), yes)
895# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000896FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000897NEED_LIBFTDI += CONFIG_USBBLASTER_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000898PROGRAMMER_OBJS += usbblaster_spi.o
899endif
900
Justin Chevrier66e554b2015-02-08 21:58:10 +0000901ifeq ($(CONFIG_PICKIT2_SPI), yes)
902FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
903PROGRAMMER_OBJS += pickit2_spi.o
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200904NEED_LIBUSB1 += CONFIG_PICKIT2_SPI
Justin Chevrier66e554b2015-02-08 21:58:10 +0000905endif
906
Miklós Márton324929c2019-08-01 19:14:10 +0200907ifeq ($(CONFIG_STLINKV3_SPI), yes)
908FEATURE_CFLAGS += -D'CONFIG_STLINKV3_SPI=1'
909PROGRAMMER_OBJS += stlinkv3_spi.o
910NEED_LIBUSB1 += CONFIG_STLINKV3_SPI
911endif
912
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000913ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000914FTDILIBS := $(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")
915FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
916FTDI_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 +0000917FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000918FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Edward O'Callaghan0ad11992020-10-28 16:05:18 +1100919# We can't set NEED_LIBUSB1 here because that would transform libftdi auto-enabling
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000920# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000921endif
922
923ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000924FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000925PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000926endif
927
928ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000929FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000930PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000931NEED_LIBPCI += CONFIG_DRKAISER
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000932endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000933
Joerg Fischer5665ef32010-05-21 21:54:07 +0000934ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000935FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000936PROGRAMMER_OBJS += nicrealtek.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000937NEED_LIBPCI += CONFIG_NICREALTEK
Joerg Fischer5665ef32010-05-21 21:54:07 +0000938endif
939
Andrew Morganc29c2e72010-06-07 22:37:54 +0000940ifeq ($(CONFIG_NICNATSEMI), yes)
941FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
942PROGRAMMER_OBJS += nicnatsemi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000943NEED_LIBPCI += CONFIG_NICNATSEMI
Andrew Morganc29c2e72010-06-07 22:37:54 +0000944endif
945
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000946ifeq ($(CONFIG_NICINTEL), yes)
947FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
948PROGRAMMER_OBJS += nicintel.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000949NEED_LIBPCI += CONFIG_NICINTEL
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000950endif
951
Idwer Vollering004f4b72010-09-03 18:21:21 +0000952ifeq ($(CONFIG_NICINTEL_SPI), yes)
953FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
954PROGRAMMER_OBJS += nicintel_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000955NEED_LIBPCI += CONFIG_NICINTEL_SPI
Idwer Vollering004f4b72010-09-03 18:21:21 +0000956endif
957
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000958ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
959FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
960PROGRAMMER_OBJS += nicintel_eeprom.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000961NEED_LIBPCI += CONFIG_NICINTEL_EEPROM
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000962endif
963
Mark Marshall90021f22010-12-03 14:48:11 +0000964ifeq ($(CONFIG_OGP_SPI), yes)
965FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
966PROGRAMMER_OBJS += ogp_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000967NEED_LIBPCI += CONFIG_OGP_SPI
Mark Marshall90021f22010-12-03 14:48:11 +0000968endif
969
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000970ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
971FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000972PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000973NEED_SERIAL += CONFIG_BUSPIRATE_SPI
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000974endif
975
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000976ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000977FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000978PROGRAMMER_OBJS += dediprog.o
Nico Huberd99a2bd2016-02-18 21:42:49 +0000979NEED_LIBUSB1 += CONFIG_DEDIPROG
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000980endif
981
Daniel Thompson45e91a22018-06-04 13:46:29 +0100982ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
983FEATURE_CFLAGS += -D'CONFIG_DEVELOPERBOX_SPI=1'
984PROGRAMMER_OBJS += developerbox_spi.o
985NEED_LIBUSB1 += CONFIG_DEVELOPERBOX_SPI
986endif
987
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000988ifeq ($(CONFIG_SATAMV), yes)
989FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
990PROGRAMMER_OBJS += satamv.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000991NEED_LIBPCI += CONFIG_SATAMV
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000992endif
993
David Hendricksf9a30552015-05-23 20:30:30 -0700994ifeq ($(CONFIG_LINUX_MTD), yes)
995# This is a totally ugly hack.
996FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_MTD_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_MTD=1'")
997PROGRAMMER_OBJS += linux_mtd.o
998endif
999
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +00001000ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +00001001# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001002FEATURE_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 +00001003PROGRAMMER_OBJS += linux_spi.o
1004endif
1005
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001006ifeq ($(CONFIG_MSTARDDC_SPI), yes)
1007# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001008FEATURE_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 +00001009NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001010PROGRAMMER_OBJS += mstarddc_spi.o
1011endif
1012
Urja Rannikko0870b022016-01-31 22:10:29 +00001013ifeq ($(CONFIG_CH341A_SPI), yes)
1014FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
1015PROGRAMMER_OBJS += ch341a_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001016NEED_LIBUSB1 += CONFIG_CH341A_SPI
Urja Rannikko0870b022016-01-31 22:10:29 +00001017endif
1018
Lubomir Rintelb2154e82018-01-14 17:35:33 +01001019ifeq ($(CONFIG_DIGILENT_SPI), yes)
1020FEATURE_CFLAGS += -D'CONFIG_DIGILENT_SPI=1'
1021PROGRAMMER_OBJS += digilent_spi.o
1022NEED_LIBUSB1 += CONFIG_DIGILENT_SPI
1023endif
1024
Marc Schink3578ec62016-03-17 16:23:03 +01001025ifeq ($(CONFIG_JLINK_SPI), yes)
1026NEED_LIBJAYLINK += CONFIG_JLINK_SPI
1027FEATURE_CFLAGS += -D'CONFIG_JLINK_SPI=1'
1028PROGRAMMER_OBJS += jlink_spi.o
1029endif
1030
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001031ifeq ($(CONFIG_NI845X_SPI), yes)
1032FEATURE_CFLAGS += -D'CONFIG_NI845X_SPI=1'
1033
1034ifeq ($(CONFIG_NI845X_LIBRARY_PATH),)
1035# if the user did not specified the NI-845x headers/lib path
1036# do a guess for both 32 and 64 bit Windows versions
1037NI845X_LIBS += -L'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1038NI845X_LIBS += -L'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1039NI845X_INCLUDES += -I'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1040NI845X_INCLUDES += -I'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1041else
1042NI845X_LIBS += -L'$(CONFIG_NI845X_LIBRARY_PATH)'
1043NI845X_INCLUDES += -I'$(CONFIG_NI845X_LIBRARY_PATH)'
1044endif
1045
1046FEATURE_CFLAGS += $(NI845X_INCLUDES)
1047LIBS += -lni845x
1048PROGRAMMER_OBJS += ni845x_spi.o
1049endif
1050
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001051ifneq ($(NEED_SERIAL), )
Urja Rannikko615ba182017-06-15 15:28:27 +03001052LIB_OBJS += serial.o custom_baud.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +00001053endif
1054
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001055ifneq ($(NEED_POSIX_SOCKETS), )
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001056ifeq ($(TARGET_OS), SunOS)
Stefan Taunerfc3ecc22016-03-13 12:57:03 +00001057LIBS += -lsocket -lnsl
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001058endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +00001059endif
1060
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001061ifneq ($(NEED_LIBPCI), )
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001062CHECK_LIBPCI = yes
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001063# This is a dirty hack, but it saves us from checking all PCI drivers and all platforms manually.
1064# libpci may need raw memory, MSR or PCI port I/O on some platforms.
1065# Individual drivers might have the same needs as well.
1066NEED_RAW_ACCESS += $(NEED_LIBPCI)
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001067FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001068FEATURE_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 +00001069
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001070PROGRAMMER_OBJS += pcidev.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001071ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001072# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001073PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001074else
1075PCILIBS += -lpci
1076endif
1077endif
1078
1079ifneq ($(NEED_RAW_ACCESS), )
1080# Raw memory, MSR or PCI port I/O access.
1081FEATURE_CFLAGS += -D'NEED_RAW_ACCESS=1'
1082PROGRAMMER_OBJS += physmap.o hwaccess.o
1083
1084ifeq ($(TARGET_OS), NetBSD)
Nico Huber9245b882021-04-18 20:50:32 +02001085ifeq ($(ARCH), x86)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001086PCILIBS += -l$(shell uname -p)
Nico Huber9245b882021-04-18 20:50:32 +02001087endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001088else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001089ifeq ($(TARGET_OS), OpenBSD)
Nico Huber9245b882021-04-18 20:50:32 +02001090ifeq ($(ARCH), x86)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001091PCILIBS += -l$(shell uname -m)
Nico Huber9245b882021-04-18 20:50:32 +02001092endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001093else
1094ifeq ($(TARGET_OS), Darwin)
1095# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +00001096PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001097endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001098endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +00001099endif
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001100
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001101endif
1102
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001103
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001104ifneq ($(NEED_LIBUSB1), )
Stefan Taunere49edbb2016-01-31 22:10:14 +00001105CHECK_LIBUSB1 = yes
1106FEATURE_CFLAGS += -D'NEED_LIBUSB1=1'
Daniel Thompson1d507a02018-07-12 11:02:28 +01001107PROGRAMMER_OBJS += usbdev.o
Stefan Taunere49edbb2016-01-31 22:10:14 +00001108# FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
1109ifeq ($(TARGET_OS),$(filter $(TARGET_OS),FreeBSD DragonFlyBSD))
1110USB1LIBS += -lusb
1111else
1112ifeq ($(TARGET_OS),NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +00001113override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
Stefan Taunere49edbb2016-01-31 22:10:14 +00001114USB1LIBS += -lusb-1.0
1115else
Stefan Tauner45207062016-02-19 08:17:24 +00001116USB1LIBS += $(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")
1117override 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 +00001118endif
1119endif
1120endif
1121
Marc Schink3578ec62016-03-17 16:23:03 +01001122ifneq ($(NEED_LIBJAYLINK), )
1123CHECK_LIBJAYLINK = yes
1124JAYLINKLIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libjaylink)
1125override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libjaylink)
1126endif
1127
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001128ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001129FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001130CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001131endif
1132
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001133FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +00001134
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001135# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001136FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001137
Nico Huber8624e8c2012-11-05 21:46:33 +01001138FEATURE_CFLAGS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-D'HAVE_CLOCK_GETTIME=1'")
1139FEATURE_LIBS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-lrt")
1140
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001141LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +00001142OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +00001143
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001144all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001145ifeq ($(ARCH), x86)
1146 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
1147endif
1148
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001149$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001150 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001151
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001152libflashrom.a: $(LIBFLASHROM_OBJS)
1153 $(AR) rcs $@ $^
1154 $(RANLIB) $@
1155
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +00001156# TAROPTIONS reduces information leakage from the packager's system.
1157# If other tar programs support command line arguments for setting uid/gid of
1158# stored files, they can be handled here as well.
1159TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001160
Paul Fox05dfbe62009-06-16 21:08:06 +00001161%.o: %.c .features
Stefan Tauner76347082016-11-27 17:45:49 +01001162 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +00001163
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +00001164# Make sure to add all names of generated binaries here.
1165# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001166# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001167clean:
Stefan Tauner4c723152016-01-14 22:47:55 +00001168 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 +00001169 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001170
Ollie Lho184a4042005-11-26 21:55:36 +00001171distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +00001172 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +00001173
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001174strip: $(PROGRAM)$(EXEC_SUFFIX)
1175 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001176
Stefan Tauner56787082011-08-18 02:27:19 +00001177# to define test programs we use verbatim variables, which get exported
1178# to environment variables and are referenced with $$<varname> later
1179
1180define COMPILER_TEST
1181int main(int argc, char **argv)
1182{
1183 (void) argc;
1184 (void) argv;
1185 return 0;
1186}
1187endef
1188export COMPILER_TEST
1189
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001190compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001191 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001192 @echo "$$COMPILER_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001193 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001194 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
1195 echo "found." || { echo "not found."; \
1196 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 +00001197 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001198 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001199 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001200 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001201 ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001202 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001203 @printf "Target OS is "
1204 @# FreeBSD wc will output extraneous whitespace.
1205 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001206 ( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001207 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +00001208ifeq ($(TARGET_OS), libpayload)
1209 @$(CC) --version 2>&1 | grep -q coreboot || \
1210 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
1211 echo "This might work but usually does not, please beware." )
1212endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +00001213
Stefan Tauner56787082011-08-18 02:27:19 +00001214define LIBPCI_TEST
1215/* Avoid a failing test due to libpci header symbol shadowing breakage */
1216#define index shadow_workaround_index
Nico Huberc0e1c4b2022-12-13 21:55:22 +00001217#if !defined PCIUTILS_PCI_H
Stefan Tauner56787082011-08-18 02:27:19 +00001218#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +00001219#else
1220#include <pciutils/pci.h>
1221#endif
Stefan Tauner56787082011-08-18 02:27:19 +00001222struct pci_access *pacc;
1223int main(int argc, char **argv)
1224{
1225 (void) argc;
1226 (void) argv;
1227 pacc = pci_alloc();
1228 return 0;
1229}
1230endef
1231export LIBPCI_TEST
1232
Stefan Tauner56734502015-02-08 21:58:04 +00001233define PCI_GET_DEV_TEST
1234/* Avoid a failing test due to libpci header symbol shadowing breakage */
1235#define index shadow_workaround_index
Nico Huberc0e1c4b2022-12-13 21:55:22 +00001236#if !defined PCIUTILS_PCI_H
Stefan Tauner56734502015-02-08 21:58:04 +00001237#include <pci/pci.h>
1238#else
1239#include <pciutils/pci.h>
1240#endif
1241struct pci_access *pacc;
1242struct pci_dev *dev = {0};
1243int main(int argc, char **argv)
1244{
1245 (void) argc;
1246 (void) argv;
1247 pacc = pci_alloc();
1248 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
1249 return 0;
1250}
1251endef
1252export PCI_GET_DEV_TEST
1253
Stefan Taunere49edbb2016-01-31 22:10:14 +00001254define LIBUSB1_TEST
1255#include <stddef.h>
1256#include <libusb.h>
1257int main(int argc, char **argv)
1258{
1259 (void)argc;
1260 (void)argv;
1261 libusb_init(NULL);
1262 return 0;
1263}
1264endef
1265export LIBUSB1_TEST
1266
Marc Schink3578ec62016-03-17 16:23:03 +01001267define LIBJAYLINK_TEST
1268#include <stddef.h>
1269#include <libjaylink/libjaylink.h>
1270int main(int argc, char **argv)
1271{
1272 struct jaylink_context *ctx;
1273
1274 (void)argc;
1275 (void)argv;
1276
1277 jaylink_init(&ctx);
1278 jaylink_exit(ctx);
1279
1280 return 0;
1281}
1282endef
1283export LIBJAYLINK_TEST
1284
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001285hwlibs: compiler
1286 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001287ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001288 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001289 @echo "$$LIBPCI_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001290 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001291 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1292 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001293 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001294 echo "Please install libpci headers or disable all features"; \
1295 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001296 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001297 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
1298 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +00001299 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001300 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001301 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +00001302 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001303 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1304 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001305 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001306 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
1307 echo "yes." || { echo "no."; \
1308 printf "Checking if libz+libpci are present and sufficient..." ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001309 { printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz" >>$(BUILD_DETAILS_FILE) ; \
1310 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001311 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001312 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001313 echo "Please install libpci (package pciutils) and/or libz or disable all features"; \
1314 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001315 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001316 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 +00001317 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001318endif
Stefan Taunere49edbb2016-01-31 22:10:14 +00001319ifeq ($(CHECK_LIBUSB1), yes)
1320 @printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
1321 @echo "$$LIBUSB1_TEST" > .test.c
1322 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1323 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1324 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001325 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001326 echo "Please install libusb-1.0 headers or disable all features"; \
1327 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001328 echo "See README for more information."; echo; \
1329 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
1330 @printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
1331 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
1332 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
1333 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001334 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001335 echo "Please install libusb-1.0 or disable all features"; \
1336 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001337 echo "See README for more information."; echo; \
1338 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
1339 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1340endif
Marc Schink3578ec62016-03-17 16:23:03 +01001341ifeq ($(CHECK_LIBJAYLINK), yes)
1342 @printf "Checking for libjaylink headers... " | tee -a $(BUILD_DETAILS_FILE)
1343 @echo "$$LIBJAYLINK_TEST" > .test.c
1344 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1345 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1346 echo "found." || { echo "not found."; echo; \
1347 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1348 echo "Please install libjaylink headers or disable the feature"; \
1349 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1350 echo "See README for more information."; echo; \
1351 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
1352 @printf "Checking if libjaylink is usable... " | tee -a $(BUILD_DETAILS_FILE)
1353 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS)" >>$(BUILD_DETAILS_FILE)
1354 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS) >&2 && \
1355 echo "yes." || { echo "no."; \
1356 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1357 echo "Please install libjaylink or disable the feature"; \
1358 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1359 echo "See README for more information."; echo; \
1360 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
1361 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1362endif
Stefan Reinauer53e96252005-12-01 16:19:24 +00001363
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001364.features: features
1365
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001366# If a user does not explicitly request a non-working feature, we should
1367# silently disable it. However, if a non-working (does not compile) feature
1368# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001369# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001370featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001371ifeq ($(PROGRAMMER_OBJS),)
1372 @echo "You have to enable at least one programmer driver!"
1373 @false
1374endif
1375ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001376 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
1377 @false
1378endif
1379
Stefan Tauner56787082011-08-18 02:27:19 +00001380define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +00001381#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +00001382#include <ftdi.h>
1383struct ftdi_context *ftdic = NULL;
1384int main(int argc, char **argv)
1385{
1386 (void) argc;
1387 (void) argv;
1388 return ftdi_init(ftdic);
1389}
1390endef
1391export FTDI_TEST
1392
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001393define FTDI_232H_TEST
1394#include <ftdi.h>
1395enum ftdi_chip_type type = TYPE_232H;
1396endef
1397export FTDI_232H_TEST
1398
Stefan Tauner56787082011-08-18 02:27:19 +00001399define UTSNAME_TEST
1400#include <sys/utsname.h>
1401struct utsname osinfo;
1402int main(int argc, char **argv)
1403{
1404 (void) argc;
1405 (void) argv;
1406 uname (&osinfo);
1407 return 0;
1408}
1409endef
1410export UTSNAME_TEST
1411
David Hendricksf9a30552015-05-23 20:30:30 -07001412define LINUX_MTD_TEST
1413#include <mtd/mtd-user.h>
1414
1415int main(int argc, char **argv)
1416{
1417 (void) argc;
1418 (void) argv;
1419 return 0;
1420}
1421endef
1422export LINUX_MTD_TEST
1423
Stefan Tauner8868db32012-03-13 00:18:19 +00001424define LINUX_SPI_TEST
1425#include <linux/types.h>
1426#include <linux/spi/spidev.h>
1427
1428int main(int argc, char **argv)
1429{
1430 (void) argc;
1431 (void) argv;
1432 return 0;
1433}
1434endef
1435export LINUX_SPI_TEST
1436
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001437define LINUX_I2C_TEST
1438#include <linux/i2c-dev.h>
1439#include <linux/i2c.h>
1440
1441int main(int argc, char **argv)
1442{
1443 (void) argc;
1444 (void) argv;
1445 return 0;
1446}
1447endef
1448export LINUX_I2C_TEST
1449
Nico Huber8624e8c2012-11-05 21:46:33 +01001450define CLOCK_GETTIME_TEST
1451#include <time.h>
1452
1453int main(int argc, char **argv)
1454{
1455 struct timespec res;
1456 clock_gettime(CLOCK_REALTIME, &res);
1457 return 0;
1458}
1459endef
1460export CLOCK_GETTIME_TEST
1461
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001462define NI845X_TEST
1463#include <ni845x.h>
1464
1465int main(int argc, char **argv)
1466{
1467 (void) argc;
1468 (void) argv;
1469 char I2C_Device[256];
1470 NiHandle Dev_Handle;
1471 uInt32 NumberFound = 0;
1472 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
1473 ni845xCloseFindDeviceHandle(Dev_Handle);
1474 return 0;
1475}
1476endef
1477export NI845X_TEST
1478
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001479features: compiler
1480 @echo "FEATURES := yes" > .features.tmp
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001481ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001482 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001483 @echo "$$FTDI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001484 @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 +00001485 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1486 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
1487 printf "Checking for FT232H support in libftdi... " ; \
1488 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001489 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 +00001490 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1491 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1492 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1493 ) || \
1494 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1495 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001496endif
David Hendricksf9a30552015-05-23 20:30:30 -07001497ifeq ($(CONFIG_LINUX_MTD), yes)
1498 @printf "Checking if Linux MTD headers are present... " | tee -a $(BUILD_DETAILS_FILE)
1499 @echo "$$LINUX_MTD_TEST" > .featuretest.c
1500 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1501 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1502 ( echo "yes."; echo "LINUX_MTD_SUPPORT := yes" >> .features.tmp ) || \
1503 ( echo "no."; echo "LINUX_MTD_SUPPORT := no" >> .features.tmp ) } \
1504 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1505endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001506ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001507 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001508 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001509 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001510 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001511 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001512 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1513 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001514endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001515ifneq ($(NEED_LINUX_I2C), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001516 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001517 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001518 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001519 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001520 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001521 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1522 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001523endif
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001524ifeq ($(CONFIG_NI845X_SPI), yes)
1525 @printf "Checking for NI USB-845x installation... " | tee -a $(BUILD_DETAILS_FILE)
1526 @echo "$$NI845X_TEST" > .featuretest.c
1527 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
1528
1529 @ { { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS) >&2 && \
1530 ( echo "yes."; echo "NI845X_SUPPORT := yes" >> .features.tmp ) || \
1531 { echo -e "\nUnable to find NI-845x headers or libraries."; \
1532 echo "Please pass the NI-845x library path to the make with the CONFIG_NI845X_LIBRARY_PATH parameter,"; \
1533 echo "or disable the NI-845x support by specifying make CONFIG_NI845X_SPI=no"; \
1534 echo "For the NI-845x 17.0 the library path is:"; \
1535 echo " On 32 bit systems: C:\Program Files)\National Instruments\NI-845x\MS Visual C"; \
1536 echo " On 64 bit systems: C:\Program Files (x86)\National Instruments\NI-845x\MS Visual C"; \
1537 exit 1; }; } \
1538 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1539endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001540 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001541 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001542 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001543 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001544 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001545 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Nico Huber8624e8c2012-11-05 21:46:33 +01001546 @printf "Checking for clock_gettime support... " | tee -a $(BUILD_DETAILS_FILE)
Martin Lucinac14e3f62020-12-18 14:11:04 +00001547ifeq ($(DISABLE_CLOCK_GETTIME), yes)
1548 @ { ( echo "disabled."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1549 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1550else
Nico Huber8624e8c2012-11-05 21:46:33 +01001551 @echo "$$CLOCK_GETTIME_TEST" >.featuretest.c
1552 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1553 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1554 ( echo "found."; echo "CLOCK_GETTIME := yes" >>.features.tmp ) || \
1555 ( echo "not found."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1556 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Martin Lucinac14e3f62020-12-18 14:11:04 +00001557endif
Stefan Tauner56787082011-08-18 02:27:19 +00001558 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1559 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001560
Stefan Tauner4c723152016-01-14 22:47:55 +00001561$(PROGRAM).8.html: $(PROGRAM).8
1562 @groff -mandoc -Thtml $< >$@
1563
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001564$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Tauner4c723152016-01-14 22:47:55 +00001565 @# Add the man page change date and version to the man page
Stefan Taunerf0cbbb02017-10-01 00:49:05 +02001566 @sed -e 's#.TH FLASHROM 8 .*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)" "$(MAN_DATE)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001567
1568install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001569 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001570 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001571 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001572 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001573
Nico Huber454f6132012-12-10 13:34:10 +00001574libinstall: libflashrom.a libflashrom.h
1575 mkdir -p $(DESTDIR)$(PREFIX)/lib
1576 $(INSTALL) -m 0644 libflashrom.a $(DESTDIR)$(PREFIX)/lib
1577 mkdir -p $(DESTDIR)$(PREFIX)/include
1578 $(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include
1579
Stefan Tauner76347082016-11-27 17:45:49 +01001580_export: $(PROGRAM).8
1581 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1582 @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1583 @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
Stefan Tauner2dc5d292017-10-04 02:18:33 +02001584# Generate versioninfo.inc containing metadata that would not be available in exported sources otherwise.
1585 @echo "VERSION = $(VERSION)" > "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
1586 @echo "MAN_DATE = $(MAN_DATE)" >> "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
Stefan Taunere4136852017-10-01 15:57:25 +02001587# Restore modification date of all tracked files not marked 'export-ignore' in .gitattributes.
1588# sed is required to filter out file names having the attribute set.
1589# The sed program saves the file name in the hold buffer and then checks if the respective value is 'set'.
1590# 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 +01001591 @git ls-tree -r -z -t --full-name --name-only HEAD | \
1592 git check-attr -z --stdin export-ignore | \
Stefan Taunere4136852017-10-01 15:57:25 +02001593 sed -zne 'x;n;n;{/^set$$/b;};x;p;' | \
Stefan Tauner76347082016-11-27 17:45:49 +01001594 xargs -0 sh -c 'for f; do \
1595 touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \
1596 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \
Stefan Taunere4136852017-10-01 15:57:25 +02001597 done' dummy_arg0
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001598
Stefan Tauner76347082016-11-27 17:45:49 +01001599export: _export
1600 @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/"
1601
1602tarball: _export
David Hendrickse1a960e2017-10-19 14:54:44 -07001603 @tar -cj --format=ustar -f "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2" -C $(EXPORTDIR)/ \
Stefan Tauner60f7a222017-10-01 15:45:06 +02001604 $(TAROPTIONS) "flashrom-$(RELEASENAME)/"
Stefan Tauner76347082016-11-27 17:45:49 +01001605# Delete the exported directory again because it is most likely what's expected by the user.
1606 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
David Hendrickse1a960e2017-10-19 14:54:44 -07001607 @echo Created "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2"
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001608
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001609libpayload: clean
1610 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001611
Stefan Tauner76347082016-11-27 17:45:49 +01001612.PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001613
Stefan Tauner23e10b82016-01-23 16:16:49 +00001614# Disable implicit suffixes and built-in rules (for performance and profit)
1615.SUFFIXES:
1616
Stefan Reinauere2f01582010-06-07 11:08:07 +00001617-include $(OBJS:.o=.d)