blob: ed46b13069ab761d0dc2bedf29a18dc4ce641444 [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)
Nico Huberc0e1c4b2022-12-13 21:55:22 +0000129# Needs special `pciutils/pci.h` for older NetBSD packages
130PCIUTILS_PCI_H := $(shell [ -f /usr/pkg/include/pciutils/pci.h ] && echo -DPCIUTILS_PCI_H)
131override CPPFLAGS += -I/usr/pkg/include $(PCIUTILS_PCI_H)
Stefan Tauner45207062016-02-19 08:17:24 +0000132override LDFLAGS += -L/usr/pkg/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000133endif
134
135ifeq ($(TARGET_OS), DragonFlyBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000136override CPPFLAGS += -I/usr/local/include
137override LDFLAGS += -L/usr/local/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000138endif
139
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000140ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000141EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000142# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Stefan Tauner45207062016-02-19 08:17:24 +0000143override CFLAGS += -Wno-format
Stefan Tauner449abe22013-09-11 23:34:57 +0000144LIBS += -lgetopt
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000145# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000146ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
147UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
148else
149override CONFIG_BUSPIRATE_SPI = no
150endif
151ifeq ($(CONFIG_SERPROG), yes)
152UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
153else
154override CONFIG_SERPROG = no
155endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000156ifeq ($(CONFIG_PONY_SPI), yes)
157UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
158else
159override CONFIG_PONY_SPI = no
160endif
Nico Huber84c6fb52019-06-07 17:35:56 +0200161# Digilent SPI, Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported under DOS (missing USB support).
162ifeq ($(CONFIG_DIGILENT_SPI), yes)
163UNSUPPORTED_FEATURES += CONFIG_DIGILENT_SPI=yes
164else
165override CONFIG_DIGILENT_SPI = no
166endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000167ifeq ($(CONFIG_DEDIPROG), yes)
168UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
169else
170override CONFIG_DEDIPROG = no
171endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100172ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
173UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
174else
175override CONFIG_DEVELOPERBOX_SPI = no
176endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000177ifeq ($(CONFIG_FT2232_SPI), yes)
178UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
179else
180override CONFIG_FT2232_SPI = no
181endif
James Lairdc60de0e2013-03-27 13:00:23 +0000182ifeq ($(CONFIG_USBBLASTER_SPI), yes)
183UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
184else
185override CONFIG_USBBLASTER_SPI = no
186endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000187ifeq ($(CONFIG_PICKIT2_SPI), yes)
188UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
189else
190override CONFIG_PICKIT2_SPI = no
191endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000192ifeq ($(CONFIG_CH341A_SPI), yes)
193UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
194else
195override CONFIG_CH341A_SPI = no
196endif
Miklós Márton324929c2019-08-01 19:14:10 +0200197ifeq ($(CONFIG_STLINKV3_SPI), yes)
198UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
199else
200override CONFIG_STLINKV3_SPI = no
201endif
Nico Hubera7246022019-06-07 17:39:18 +0200202# libjaylink is also not available for DOS
203ifeq ($(CONFIG_JLINK_SPI), yes)
204UNSUPPORTED_FEATURES += CONFIG_JLINK_SPI=yes
205else
206override CONFIG_JLINK_SPI = no
207endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000208endif
Ollie Lho184a4042005-11-26 21:55:36 +0000209
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000210# FIXME: Should we check for Cygwin/MSVC as well?
211ifeq ($(TARGET_OS), MinGW)
212EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000213# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000214FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000215# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
Stefan Tauner23e10b82016-01-23 16:16:49 +0000216# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000217FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100218
219# National Instruments USB-845x is Windows only for now
220CONFIG_NI845X_SPI ?= no
221
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000222# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
223ifeq ($(CONFIG_INTERNAL), yes)
224UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
225else
226override CONFIG_INTERNAL = no
227endif
228ifeq ($(CONFIG_RAYER_SPI), yes)
229UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
230else
231override CONFIG_RAYER_SPI = no
232endif
233ifeq ($(CONFIG_NIC3COM), yes)
234UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
235else
236override CONFIG_NIC3COM = no
237endif
238ifeq ($(CONFIG_GFXNVIDIA), yes)
239UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
240else
241override CONFIG_GFXNVIDIA = no
242endif
243ifeq ($(CONFIG_SATASII), yes)
244UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
245else
246override CONFIG_SATASII = no
247endif
248ifeq ($(CONFIG_ATAHPT), yes)
249UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
250else
251override CONFIG_ATAHPT = no
252endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000253ifeq ($(CONFIG_ATAVIA), yes)
254UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
255else
256override CONFIG_ATAVIA = no
257endif
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000258ifeq ($(CONFIG_ATAPROMISE), yes)
259UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
260else
261override CONFIG_ATAPROMISE = no
262endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000263ifeq ($(CONFIG_IT8212), yes)
264UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
265else
266override CONFIG_IT8212 = no
267endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000268ifeq ($(CONFIG_DRKAISER), yes)
269UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
270else
271override CONFIG_DRKAISER = no
272endif
273ifeq ($(CONFIG_NICREALTEK), yes)
274UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
275else
276override CONFIG_NICREALTEK = no
277endif
278ifeq ($(CONFIG_NICNATSEMI), yes)
279UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
280else
281override CONFIG_NICNATSEMI = no
282endif
283ifeq ($(CONFIG_NICINTEL), yes)
284UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
285else
286override CONFIG_NICINTEL = no
287endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000288ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
289UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
290else
291override CONFIG_NICINTEL_EEPROM = no
292endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000293ifeq ($(CONFIG_NICINTEL_SPI), yes)
294UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
295else
296override CONFIG_NICINTEL_SPI = no
297endif
298ifeq ($(CONFIG_OGP_SPI), yes)
299UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
300else
301override CONFIG_OGP_SPI = no
302endif
303ifeq ($(CONFIG_SATAMV), yes)
304UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
305else
306override CONFIG_SATAMV = no
307endif
308endif
309
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100310ifneq ($(TARGET_OS), MinGW)
311# NI USB-845x only supported on Windows at the moment
312ifeq ($(CONFIG_NI845X_SPI), yes)
313UNSUPPORTED_FEATURES += CONFIG_NI845X_SPI=yes
314else
315override CONFIG_NI845X_SPI = no
316endif
317endif
318
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000319ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000320ifeq ($(MAKECMDGOALS),)
321.DEFAULT_GOAL := libflashrom.a
322$(info Setting default goal to libflashrom.a)
323endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000324FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000325ifeq ($(CONFIG_DUMMY), yes)
326UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
327else
328override CONFIG_DUMMY = no
329endif
Stefan Taunere0168262016-02-21 11:18:24 +0000330# libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
331ifeq ($(CONFIG_ATAPROMISE), yes)
332UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
333else
334override CONFIG_ATAPROMISE = no
335endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000336# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000337ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
338UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
339else
340override CONFIG_BUSPIRATE_SPI = no
341endif
342ifeq ($(CONFIG_SERPROG), yes)
343UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
344else
345override CONFIG_SERPROG = no
346endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000347ifeq ($(CONFIG_PONY_SPI), yes)
348UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
349else
350override CONFIG_PONY_SPI = no
351endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100352# Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000353ifeq ($(CONFIG_DEDIPROG), yes)
354UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
355else
356override CONFIG_DEDIPROG = no
357endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100358ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
359UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
360else
361override CONFIG_DEVELOPERBOX_SPI = no
362endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000363ifeq ($(CONFIG_FT2232_SPI), yes)
364UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
365else
366override CONFIG_FT2232_SPI = no
367endif
James Lairdc60de0e2013-03-27 13:00:23 +0000368ifeq ($(CONFIG_USBBLASTER_SPI), yes)
369UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
370else
371override CONFIG_USBBLASTER_SPI = no
372endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000373ifeq ($(CONFIG_PICKIT2_SPI), yes)
374UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
375else
376override CONFIG_PICKIT2_SPI = no
377endif
Miklós Márton324929c2019-08-01 19:14:10 +0200378ifeq ($(CONFIG_STLINKV3_SPI), yes)
379UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
380else
381override CONFIG_STLINKV3_SPI = no
382endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000383ifeq ($(CONFIG_CH341A_SPI), yes)
384UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
385else
386override CONFIG_CH341A_SPI = no
387endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000388endif
389
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000390ifneq ($(TARGET_OS), Linux)
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000391# Android is handled internally as separate OS, but it supports CONFIG_LINUX_SPI and CONFIG_MSTARDDC_SPI
392ifneq ($(TARGET_OS), Android)
David Hendricksf9a30552015-05-23 20:30:30 -0700393ifeq ($(CONFIG_LINUX_MTD), yes)
394UNSUPPORTED_FEATURES += CONFIG_LINUX_MTD=yes
395else
396override CONFIG_LINUX_MTD = no
397endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000398ifeq ($(CONFIG_LINUX_SPI), yes)
399UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
400else
401override CONFIG_LINUX_SPI = no
402endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000403ifeq ($(CONFIG_MSTARDDC_SPI), yes)
404UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
405else
406override CONFIG_MSTARDDC_SPI = no
407endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000408endif
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000409endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000410
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000411ifeq ($(TARGET_OS), Android)
412# Android on x86 (currently) does not provide raw PCI port I/O operations
413ifeq ($(CONFIG_RAYER_SPI), yes)
414UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
415else
416override CONFIG_RAYER_SPI = no
417endif
418endif
419
Stefan Tauner037cd842013-08-25 00:10:56 +0000420###############################################################################
421# General architecture-specific settings.
422# Like above for the OS, below we verify user-supplied options depending on the target architecture.
423
Uwe Hermann44ffd582011-08-20 14:16:00 +0000424# Determine the destination processor architecture.
425# IMPORTANT: The following line must be placed before ARCH is ever used
426# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000427# below uses CC itself.
Pyry Kontio89cc73b2020-07-06 12:57:35 +0900428override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null \
429 | tail -1 | cut -f 2 -d'"'))
430override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \
431 | tail -1))
Uwe Hermann44ffd582011-08-20 14:16:00 +0000432
Nico Huberc8801732017-12-01 18:19:43 +0000433# Disable the internal programmer on unsupported architectures (everything but x86 and mipsel)
434ifneq ($(ARCH)-little, $(filter $(ARCH),x86 mips)-$(ENDIAN))
435ifeq ($(CONFIG_INTERNAL), yes)
436UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
437else
438override CONFIG_INTERNAL = no
439endif
440endif
441
Stefan Taunerfb2d77c2015-02-10 08:03:10 +0000442# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
David Hendricksb286da72012-02-13 00:35:35 +0000443# Right now this means the drivers below only work on x86.
444ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000445ifeq ($(CONFIG_NIC3COM), yes)
446UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
447else
448override CONFIG_NIC3COM = no
449endif
450ifeq ($(CONFIG_NICREALTEK), yes)
451UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
452else
453override CONFIG_NICREALTEK = no
454endif
455ifeq ($(CONFIG_NICNATSEMI), yes)
456UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
457else
458override CONFIG_NICNATSEMI = no
459endif
460ifeq ($(CONFIG_RAYER_SPI), yes)
461UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
462else
463override CONFIG_RAYER_SPI = no
464endif
465ifeq ($(CONFIG_ATAHPT), yes)
466UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
467else
468override CONFIG_ATAHPT = no
469endif
Carl-Daniel Hailfingerf636ffc2016-02-20 22:04:39 +0000470ifeq ($(CONFIG_ATAPROMISE), yes)
471UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
472else
473override CONFIG_ATAPROMISE = no
474endif
Uwe Hermann21b10c62011-07-29 12:13:01 +0000475ifeq ($(CONFIG_SATAMV), yes)
476UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
477else
478override CONFIG_SATAMV = no
479endif
480endif
481
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000482# Disable all drivers needing raw access (memory, PCI, port I/O) on
483# architectures with unknown raw access properties.
484# Right now those architectures are alpha hppa m68k sh s390
Rosen Penev34d07f02019-07-02 00:14:01 -0700485ifneq ($(ARCH),$(filter $(ARCH),x86 mips ppc arm sparc arc))
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000486ifeq ($(CONFIG_RAYER_SPI), yes)
487UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
488else
489override CONFIG_RAYER_SPI = no
490endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000491ifeq ($(CONFIG_NIC3COM), yes)
492UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
493else
494override CONFIG_NIC3COM = no
495endif
496ifeq ($(CONFIG_GFXNVIDIA), yes)
497UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
498else
499override CONFIG_GFXNVIDIA = no
500endif
501ifeq ($(CONFIG_SATASII), yes)
502UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
503else
504override CONFIG_SATASII = no
505endif
506ifeq ($(CONFIG_ATAHPT), yes)
507UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
508else
509override CONFIG_ATAHPT = no
510endif
511ifeq ($(CONFIG_ATAVIA), yes)
512UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
513else
514override CONFIG_ATAVIA = no
515endif
516ifeq ($(CONFIG_ATAPROMISE), yes)
517UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
518else
519override CONFIG_ATAPROMISE = no
520endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000521ifeq ($(CONFIG_DRKAISER), yes)
522UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
523else
524override CONFIG_DRKAISER = no
525endif
526ifeq ($(CONFIG_NICREALTEK), yes)
527UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
528else
529override CONFIG_NICREALTEK = no
530endif
531ifeq ($(CONFIG_NICNATSEMI), yes)
532UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
533else
534override CONFIG_NICNATSEMI = no
535endif
536ifeq ($(CONFIG_NICINTEL), yes)
537UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
538else
539override CONFIG_NICINTEL = no
540endif
541ifeq ($(CONFIG_NICINTEL_SPI), yes)
542UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
543else
544override CONFIG_NICINTEL_SPI = no
545endif
546ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
547UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
548else
549override CONFIG_NICINTEL_EEPROM = no
550endif
551ifeq ($(CONFIG_OGP_SPI), yes)
552UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
553else
554override CONFIG_OGP_SPI = no
555endif
556ifeq ($(CONFIG_SATAMV), yes)
557UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
558else
559override CONFIG_SATAMV = no
560endif
561ifeq ($(CONFIG_IT8212), yes)
562UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
563else
564override CONFIG_IT8212 = no
565endif
566endif
567
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000568###############################################################################
569# Flash chip drivers and bus support infrastructure.
570
Stefan Tauner4404f732013-09-12 08:28:56 +0000571CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000572 sst28sf040.o 82802ab.o \
Paul Kocialkowski80ae14e2018-01-15 01:07:46 +0300573 sst49lfxxxc.o sst_fwhub.o edi.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Nikolai Artemievc9feb1b2021-10-21 01:35:13 +1100574 spi95.o opaque.o sfdp.o en29lv640b.o at45db.o \
575 writeprotect.o writeprotect_ranges.o
Sean Nelson5d134642009-12-24 16:54:21 +0000576
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000577###############################################################################
578# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000579
Arthur Heymansc82900b2018-01-10 12:48:16 +0100580LIB_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 +0000581
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000582###############################################################################
583# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000584
Stefan Tauner9b32de92014-08-08 23:52:33 +0000585CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000586
Stefan Taunerfa25bc32017-10-04 03:47:26 +0200587# versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
588# imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
589# be obtained using util/getrevision.sh, which is the common case during development.
590-include versioninfo.inc
Stefan Tauner5bf6b852017-10-04 03:46:51 +0200591VERSION ?= $(shell ./util/getrevision.sh --revision)
Stefan Tauner96209122017-10-01 16:41:35 +0200592MAN_DATE ?= $(shell ./util/getrevision.sh --date $(PROGRAM).8.tmpl 2>/dev/null)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000593
Stefan Tauner76347082016-11-27 17:45:49 +0100594SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000595
Stefan Tauner76347082016-11-27 17:45:49 +0100596# No spaces in release names unless set explicitly
597RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/')
598
599# Inform user of the version string
600$(info Replacing all version templates with $(VERSION).)
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000601
Stefan Tauner96209122017-10-01 16:41:35 +0200602# If a VCS is found then try to install hooks.
603$(shell ./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh)
604
Stefan Tauner037cd842013-08-25 00:10:56 +0000605###############################################################################
606# Default settings of CONFIG_* variables.
607
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000608# Always enable internal/onboard support for now.
609CONFIG_INTERNAL ?= yes
610
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000611# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000612CONFIG_SERPROG ?= yes
613
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000614# RayeR SPIPGM hardware support
615CONFIG_RAYER_SPI ?= yes
616
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000617# PonyProg2000 SPI hardware support
618CONFIG_PONY_SPI ?= yes
619
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000620# Always enable 3Com NICs for now.
621CONFIG_NIC3COM ?= yes
622
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000623# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
624CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000625
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000626# Always enable SiI SATA controllers for now.
627CONFIG_SATASII ?= yes
628
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000629# Highpoint (HPT) ATA/RAID controller support.
630# IMPORTANT: This code is not yet working!
631CONFIG_ATAHPT ?= no
632
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000633# VIA VT6421A LPC memory support
634CONFIG_ATAVIA ?= yes
635
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000636# Promise ATA controller support.
637CONFIG_ATAPROMISE ?= no
638
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000639# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000640CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000641
James Lairdc60de0e2013-03-27 13:00:23 +0000642# Always enable Altera USB-Blaster dongles for now.
643CONFIG_USBBLASTER_SPI ?= yes
644
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000645# MSTAR DDC support needs more tests/reviews/cleanups.
646CONFIG_MSTARDDC_SPI ?= no
647
Justin Chevrier66e554b2015-02-08 21:58:10 +0000648# Always enable PICkit2 SPI dongles for now.
649CONFIG_PICKIT2_SPI ?= yes
650
Miklós Márton324929c2019-08-01 19:14:10 +0200651# Always enable STLink V3
652CONFIG_STLINKV3_SPI ?= yes
653
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000654# Always enable dummy tracing for now.
655CONFIG_DUMMY ?= yes
656
657# Always enable Dr. Kaiser for now.
658CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000659
Joerg Fischer5665ef32010-05-21 21:54:07 +0000660# Always enable Realtek NICs for now.
661CONFIG_NICREALTEK ?= yes
662
Andrew Morganc29c2e72010-06-07 22:37:54 +0000663# Disable National Semiconductor NICs until support is complete and tested.
664CONFIG_NICNATSEMI ?= no
665
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000666# Always enable Intel NICs for now.
667CONFIG_NICINTEL ?= yes
668
Idwer Vollering004f4b72010-09-03 18:21:21 +0000669# Always enable SPI on Intel NICs for now.
670CONFIG_NICINTEL_SPI ?= yes
671
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000672# Always enable EEPROM on Intel NICs for now.
673CONFIG_NICINTEL_EEPROM ?= yes
674
Mark Marshall90021f22010-12-03 14:48:11 +0000675# Always enable SPI on OGP cards for now.
676CONFIG_OGP_SPI ?= yes
677
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000678# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000679CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000680
Simon Glassae616512016-01-23 23:27:58 +0000681# Always enable Dediprog SF100 for now.
682CONFIG_DEDIPROG ?= yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000683
Daniel Thompson45e91a22018-06-04 13:46:29 +0100684# Always enable Developerbox emergency recovery for now.
685CONFIG_DEVELOPERBOX_SPI ?= yes
686
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000687# Always enable Marvell SATA controllers for now.
688CONFIG_SATAMV ?= yes
689
David Hendricksf9a30552015-05-23 20:30:30 -0700690# Enable Linux spidev and MTD interfaces by default. We disable them on non-Linux targets.
691CONFIG_LINUX_MTD ?= yes
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000692CONFIG_LINUX_SPI ?= yes
693
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000694# Always enable ITE IT8212F PATA controllers for now.
695CONFIG_IT8212 ?= yes
696
Urja Rannikko0870b022016-01-31 22:10:29 +0000697# Winchiphead CH341A
698CONFIG_CH341A_SPI ?= yes
699
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100700# Digilent Development board JTAG
701CONFIG_DIGILENT_SPI ?= yes
702
Marc Schink3578ec62016-03-17 16:23:03 +0100703# Disable J-Link for now.
704CONFIG_JLINK_SPI ?= no
705
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000706# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000707CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000708
Stefan Taunerf3503372016-02-26 23:51:21 +0000709# Disable all features if CONFIG_NOTHING=yes is given unless CONFIG_EVERYTHING was also set
710ifeq ($(CONFIG_NOTHING), yes)
711 ifeq ($(CONFIG_EVERYTHING), yes)
712 $(error Setting CONFIG_NOTHING=yes and CONFIG_EVERYTHING=yes does not make sense)
713 endif
714 $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
715 $(if $(filter yes, $($(var))),\
716 $(eval $(var)=no)))
717endif
718
Patrick Georgiced7ab62015-01-19 19:52:34 +0000719# Enable all features if CONFIG_EVERYTHING=yes is given
720ifeq ($(CONFIG_EVERYTHING), yes)
721$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
722 $(if $(filter no, $($(var))),\
723 $(eval $(var)=yes)))
724endif
725
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000726ifeq ($(CONFIG_ENABLE_LIBUSB1_PROGRAMMERS), no)
727override CONFIG_CH341A_SPI = no
728override CONFIG_DEDIPROG = no
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100729override CONFIG_DIGILENT_SPI = no
Daniel Thompson45e91a22018-06-04 13:46:29 +0100730override CONFIG_DEVELOPERBOX_SPI = no
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200731override CONFIG_PICKIT2_SPI = no
Miklós Márton324929c2019-08-01 19:14:10 +0200732override CONFIG_STLINKV3_SPI = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000733endif
734ifeq ($(CONFIG_ENABLE_LIBPCI_PROGRAMMERS), no)
Stefan Tauner0be072c2016-03-13 15:16:30 +0000735override CONFIG_INTERNAL = no
736override CONFIG_NIC3COM = no
737override CONFIG_GFXNVIDIA = no
738override CONFIG_SATASII = no
739override CONFIG_ATAHPT = no
740override CONFIG_ATAVIA = no
741override CONFIG_ATAPROMISE = no
742override CONFIG_IT8212 = no
743override CONFIG_DRKAISER = no
744override CONFIG_NICREALTEK = no
745override CONFIG_NICNATSEMI = no
746override CONFIG_NICINTEL = no
747override CONFIG_NICINTEL_SPI = no
748override CONFIG_NICINTEL_EEPROM = no
749override CONFIG_OGP_SPI = no
750override CONFIG_SATAMV = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000751endif
752
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000753# Bitbanging SPI infrastructure, default off unless needed.
754ifeq ($(CONFIG_RAYER_SPI), yes)
755override CONFIG_BITBANG_SPI = yes
756else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000757ifeq ($(CONFIG_PONY_SPI), yes)
758override CONFIG_BITBANG_SPI = yes
759else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000760ifeq ($(CONFIG_INTERNAL), yes)
761override CONFIG_BITBANG_SPI = yes
762else
763ifeq ($(CONFIG_NICINTEL_SPI), yes)
764override CONFIG_BITBANG_SPI = yes
765else
Mark Marshall90021f22010-12-03 14:48:11 +0000766ifeq ($(CONFIG_OGP_SPI), yes)
767override CONFIG_BITBANG_SPI = yes
768else
Felix Singer4cbc1cb2022-07-22 23:23:28 +0200769ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
770override CONFIG_BITBANG_SPI = yes
771else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000772CONFIG_BITBANG_SPI ?= no
773endif
774endif
775endif
Mark Marshall90021f22010-12-03 14:48:11 +0000776endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000777endif
Felix Singer4cbc1cb2022-07-22 23:23:28 +0200778endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000779
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000780###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000781# Handle CONFIG_* variables that depend on others set (and verified) above.
782
783# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
784ifeq ($(TARGET_OS), libpayload)
785ifeq ($(CONFIG_INTERNAL), yes)
786ifeq ($(CONFIG_INTERNAL_DMI), no)
787UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
788else
789override CONFIG_INTERNAL_DMI = yes
790endif
791endif
792endif
793
794# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
795CONFIG_INTERNAL_DMI ?= yes
796
797###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000798# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000799# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000800
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000801FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000802FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000803
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000804ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000805FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000806PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000807ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000808PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Nico Huber305f4172013-06-14 11:55:26 +0200809PROGRAMMER_OBJS += ichspi.o dmi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000810ifeq ($(CONFIG_INTERNAL_DMI), yes)
811FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
812endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000813else
814endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000815NEED_LIBPCI += CONFIG_INTERNAL
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000816endif
817
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000818ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000819FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000820PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000821NEED_SERIAL += CONFIG_SERPROG
822NEED_POSIX_SOCKETS += CONFIG_SERPROG
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000823endif
824
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000825ifeq ($(CONFIG_RAYER_SPI), yes)
826FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
827PROGRAMMER_OBJS += rayer_spi.o
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000828NEED_RAW_ACCESS += CONFIG_RAYER_SPI
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000829endif
830
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000831ifeq ($(CONFIG_PONY_SPI), yes)
832FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
833PROGRAMMER_OBJS += pony_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000834NEED_SERIAL += CONFIG_PONY_SPI
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000835endif
836
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000837ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000838FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000839PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000840endif
841
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000842ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000843FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000844PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000845NEED_LIBPCI += CONFIG_NIC3COM
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000846endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000847
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000848ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000849FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000850PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000851NEED_LIBPCI += CONFIG_GFXNVIDIA
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000852endif
853
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000854ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000855FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000856PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000857NEED_LIBPCI += CONFIG_SATASII
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000858endif
859
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000860ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000861FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000862PROGRAMMER_OBJS += atahpt.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000863NEED_LIBPCI += CONFIG_ATAHPT
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000864endif
865
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000866ifeq ($(CONFIG_ATAVIA), yes)
867FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
868PROGRAMMER_OBJS += atavia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000869NEED_LIBPCI += CONFIG_ATAVIA
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000870endif
871
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000872ifeq ($(CONFIG_ATAPROMISE), yes)
873FEATURE_CFLAGS += -D'CONFIG_ATAPROMISE=1'
874PROGRAMMER_OBJS += atapromise.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000875NEED_LIBPCI += CONFIG_ATAPROMISE
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000876endif
877
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000878ifeq ($(CONFIG_IT8212), yes)
879FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
880PROGRAMMER_OBJS += it8212.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000881NEED_LIBPCI += CONFIG_IT8212
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000882endif
883
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000884ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000885# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000886FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000887NEED_LIBFTDI += CONFIG_FT2232_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000888PROGRAMMER_OBJS += ft2232_spi.o
889endif
890
891ifeq ($(CONFIG_USBBLASTER_SPI), yes)
892# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000893FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000894NEED_LIBFTDI += CONFIG_USBBLASTER_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000895PROGRAMMER_OBJS += usbblaster_spi.o
896endif
897
Justin Chevrier66e554b2015-02-08 21:58:10 +0000898ifeq ($(CONFIG_PICKIT2_SPI), yes)
899FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
900PROGRAMMER_OBJS += pickit2_spi.o
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200901NEED_LIBUSB1 += CONFIG_PICKIT2_SPI
Justin Chevrier66e554b2015-02-08 21:58:10 +0000902endif
903
Miklós Márton324929c2019-08-01 19:14:10 +0200904ifeq ($(CONFIG_STLINKV3_SPI), yes)
905FEATURE_CFLAGS += -D'CONFIG_STLINKV3_SPI=1'
906PROGRAMMER_OBJS += stlinkv3_spi.o
907NEED_LIBUSB1 += CONFIG_STLINKV3_SPI
908endif
909
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000910ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000911FTDILIBS := $(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")
912FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
913FTDI_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 +0000914FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000915FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000916# We can't set NEED_LIBUSB0 here because that would transform libftdi auto-enabling
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000917# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000918endif
919
920ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000921FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000922PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000923endif
924
925ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000926FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000927PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000928NEED_LIBPCI += CONFIG_DRKAISER
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000929endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000930
Joerg Fischer5665ef32010-05-21 21:54:07 +0000931ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000932FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000933PROGRAMMER_OBJS += nicrealtek.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000934NEED_LIBPCI += CONFIG_NICREALTEK
Joerg Fischer5665ef32010-05-21 21:54:07 +0000935endif
936
Andrew Morganc29c2e72010-06-07 22:37:54 +0000937ifeq ($(CONFIG_NICNATSEMI), yes)
938FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
939PROGRAMMER_OBJS += nicnatsemi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000940NEED_LIBPCI += CONFIG_NICNATSEMI
Andrew Morganc29c2e72010-06-07 22:37:54 +0000941endif
942
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000943ifeq ($(CONFIG_NICINTEL), yes)
944FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
945PROGRAMMER_OBJS += nicintel.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000946NEED_LIBPCI += CONFIG_NICINTEL
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000947endif
948
Idwer Vollering004f4b72010-09-03 18:21:21 +0000949ifeq ($(CONFIG_NICINTEL_SPI), yes)
950FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
951PROGRAMMER_OBJS += nicintel_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000952NEED_LIBPCI += CONFIG_NICINTEL_SPI
Idwer Vollering004f4b72010-09-03 18:21:21 +0000953endif
954
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000955ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
956FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
957PROGRAMMER_OBJS += nicintel_eeprom.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000958NEED_LIBPCI += CONFIG_NICINTEL_EEPROM
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000959endif
960
Mark Marshall90021f22010-12-03 14:48:11 +0000961ifeq ($(CONFIG_OGP_SPI), yes)
962FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
963PROGRAMMER_OBJS += ogp_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000964NEED_LIBPCI += CONFIG_OGP_SPI
Mark Marshall90021f22010-12-03 14:48:11 +0000965endif
966
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000967ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
968FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000969PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000970NEED_SERIAL += CONFIG_BUSPIRATE_SPI
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000971endif
972
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000973ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000974FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000975PROGRAMMER_OBJS += dediprog.o
Nico Huberd99a2bd2016-02-18 21:42:49 +0000976NEED_LIBUSB1 += CONFIG_DEDIPROG
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000977endif
978
Daniel Thompson45e91a22018-06-04 13:46:29 +0100979ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
980FEATURE_CFLAGS += -D'CONFIG_DEVELOPERBOX_SPI=1'
981PROGRAMMER_OBJS += developerbox_spi.o
982NEED_LIBUSB1 += CONFIG_DEVELOPERBOX_SPI
983endif
984
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000985ifeq ($(CONFIG_SATAMV), yes)
986FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
987PROGRAMMER_OBJS += satamv.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000988NEED_LIBPCI += CONFIG_SATAMV
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000989endif
990
David Hendricksf9a30552015-05-23 20:30:30 -0700991ifeq ($(CONFIG_LINUX_MTD), yes)
992# This is a totally ugly hack.
993FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_MTD_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_MTD=1'")
994PROGRAMMER_OBJS += linux_mtd.o
995endif
996
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000997ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000998# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000999FEATURE_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 +00001000PROGRAMMER_OBJS += linux_spi.o
1001endif
1002
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001003ifeq ($(CONFIG_MSTARDDC_SPI), yes)
1004# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001005FEATURE_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 +00001006NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001007PROGRAMMER_OBJS += mstarddc_spi.o
1008endif
1009
Urja Rannikko0870b022016-01-31 22:10:29 +00001010ifeq ($(CONFIG_CH341A_SPI), yes)
1011FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
1012PROGRAMMER_OBJS += ch341a_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001013NEED_LIBUSB1 += CONFIG_CH341A_SPI
Urja Rannikko0870b022016-01-31 22:10:29 +00001014endif
1015
Lubomir Rintelb2154e82018-01-14 17:35:33 +01001016ifeq ($(CONFIG_DIGILENT_SPI), yes)
1017FEATURE_CFLAGS += -D'CONFIG_DIGILENT_SPI=1'
1018PROGRAMMER_OBJS += digilent_spi.o
1019NEED_LIBUSB1 += CONFIG_DIGILENT_SPI
1020endif
1021
Marc Schink3578ec62016-03-17 16:23:03 +01001022ifeq ($(CONFIG_JLINK_SPI), yes)
1023NEED_LIBJAYLINK += CONFIG_JLINK_SPI
1024FEATURE_CFLAGS += -D'CONFIG_JLINK_SPI=1'
1025PROGRAMMER_OBJS += jlink_spi.o
1026endif
1027
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001028ifeq ($(CONFIG_NI845X_SPI), yes)
1029FEATURE_CFLAGS += -D'CONFIG_NI845X_SPI=1'
1030
1031ifeq ($(CONFIG_NI845X_LIBRARY_PATH),)
1032# if the user did not specified the NI-845x headers/lib path
1033# do a guess for both 32 and 64 bit Windows versions
1034NI845X_LIBS += -L'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1035NI845X_LIBS += -L'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1036NI845X_INCLUDES += -I'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1037NI845X_INCLUDES += -I'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1038else
1039NI845X_LIBS += -L'$(CONFIG_NI845X_LIBRARY_PATH)'
1040NI845X_INCLUDES += -I'$(CONFIG_NI845X_LIBRARY_PATH)'
1041endif
1042
1043FEATURE_CFLAGS += $(NI845X_INCLUDES)
1044LIBS += -lni845x
1045PROGRAMMER_OBJS += ni845x_spi.o
1046endif
1047
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001048ifneq ($(NEED_SERIAL), )
Urja Rannikko615ba182017-06-15 15:28:27 +03001049LIB_OBJS += serial.o custom_baud.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +00001050endif
1051
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001052ifneq ($(NEED_POSIX_SOCKETS), )
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001053ifeq ($(TARGET_OS), SunOS)
Stefan Taunerfc3ecc22016-03-13 12:57:03 +00001054LIBS += -lsocket -lnsl
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001055endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +00001056endif
1057
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001058ifneq ($(NEED_LIBPCI), )
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001059CHECK_LIBPCI = yes
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001060# This is a dirty hack, but it saves us from checking all PCI drivers and all platforms manually.
1061# libpci may need raw memory, MSR or PCI port I/O on some platforms.
1062# Individual drivers might have the same needs as well.
1063NEED_RAW_ACCESS += $(NEED_LIBPCI)
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001064FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001065FEATURE_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 +00001066
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001067PROGRAMMER_OBJS += pcidev.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001068ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001069# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001070PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001071else
1072PCILIBS += -lpci
1073endif
1074endif
1075
1076ifneq ($(NEED_RAW_ACCESS), )
1077# Raw memory, MSR or PCI port I/O access.
1078FEATURE_CFLAGS += -D'NEED_RAW_ACCESS=1'
1079PROGRAMMER_OBJS += physmap.o hwaccess.o
1080
1081ifeq ($(TARGET_OS), NetBSD)
Nico Huber9245b882021-04-18 20:50:32 +02001082ifeq ($(ARCH), x86)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001083PCILIBS += -l$(shell uname -p)
Nico Huber9245b882021-04-18 20:50:32 +02001084endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001085else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001086ifeq ($(TARGET_OS), OpenBSD)
Nico Huber9245b882021-04-18 20:50:32 +02001087ifeq ($(ARCH), x86)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001088PCILIBS += -l$(shell uname -m)
Nico Huber9245b882021-04-18 20:50:32 +02001089endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001090else
1091ifeq ($(TARGET_OS), Darwin)
1092# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +00001093PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001094endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001095endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +00001096endif
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001097
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001098endif
1099
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001100
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001101ifneq ($(NEED_LIBUSB1), )
Stefan Taunere49edbb2016-01-31 22:10:14 +00001102CHECK_LIBUSB1 = yes
1103FEATURE_CFLAGS += -D'NEED_LIBUSB1=1'
Daniel Thompson1d507a02018-07-12 11:02:28 +01001104PROGRAMMER_OBJS += usbdev.o
Stefan Taunere49edbb2016-01-31 22:10:14 +00001105# FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
1106ifeq ($(TARGET_OS),$(filter $(TARGET_OS),FreeBSD DragonFlyBSD))
1107USB1LIBS += -lusb
1108else
1109ifeq ($(TARGET_OS),NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +00001110override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
Stefan Taunere49edbb2016-01-31 22:10:14 +00001111USB1LIBS += -lusb-1.0
1112else
Stefan Tauner45207062016-02-19 08:17:24 +00001113USB1LIBS += $(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")
1114override 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 +00001115endif
1116endif
1117endif
1118
Marc Schink3578ec62016-03-17 16:23:03 +01001119ifneq ($(NEED_LIBJAYLINK), )
1120CHECK_LIBJAYLINK = yes
1121JAYLINKLIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libjaylink)
1122override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libjaylink)
1123endif
1124
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001125ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001126FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001127CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001128endif
1129
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001130FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +00001131
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001132# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001133FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001134
Nico Huber8624e8c2012-11-05 21:46:33 +01001135FEATURE_CFLAGS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-D'HAVE_CLOCK_GETTIME=1'")
1136FEATURE_LIBS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-lrt")
1137
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001138LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +00001139OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +00001140
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001141all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001142ifeq ($(ARCH), x86)
1143 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
1144endif
1145
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001146$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001147 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001148
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001149libflashrom.a: $(LIBFLASHROM_OBJS)
1150 $(AR) rcs $@ $^
1151 $(RANLIB) $@
1152
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +00001153# TAROPTIONS reduces information leakage from the packager's system.
1154# If other tar programs support command line arguments for setting uid/gid of
1155# stored files, they can be handled here as well.
1156TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001157
Paul Fox05dfbe62009-06-16 21:08:06 +00001158%.o: %.c .features
Stefan Tauner76347082016-11-27 17:45:49 +01001159 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +00001160
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +00001161# Make sure to add all names of generated binaries here.
1162# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001163# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001164clean:
Stefan Tauner4c723152016-01-14 22:47:55 +00001165 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 +00001166 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001167
Ollie Lho184a4042005-11-26 21:55:36 +00001168distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +00001169 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +00001170
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001171strip: $(PROGRAM)$(EXEC_SUFFIX)
1172 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001173
Stefan Tauner56787082011-08-18 02:27:19 +00001174# to define test programs we use verbatim variables, which get exported
1175# to environment variables and are referenced with $$<varname> later
1176
1177define COMPILER_TEST
1178int main(int argc, char **argv)
1179{
1180 (void) argc;
1181 (void) argv;
1182 return 0;
1183}
1184endef
1185export COMPILER_TEST
1186
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001187compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001188 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001189 @echo "$$COMPILER_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001190 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001191 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
1192 echo "found." || { echo "not found."; \
1193 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 +00001194 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001195 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001196 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001197 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001198 ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001199 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001200 @printf "Target OS is "
1201 @# FreeBSD wc will output extraneous whitespace.
1202 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001203 ( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001204 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +00001205ifeq ($(TARGET_OS), libpayload)
1206 @$(CC) --version 2>&1 | grep -q coreboot || \
1207 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
1208 echo "This might work but usually does not, please beware." )
1209endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +00001210
Stefan Tauner56787082011-08-18 02:27:19 +00001211define LIBPCI_TEST
1212/* Avoid a failing test due to libpci header symbol shadowing breakage */
1213#define index shadow_workaround_index
Nico Huberc0e1c4b2022-12-13 21:55:22 +00001214#if !defined PCIUTILS_PCI_H
Stefan Tauner56787082011-08-18 02:27:19 +00001215#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +00001216#else
1217#include <pciutils/pci.h>
1218#endif
Stefan Tauner56787082011-08-18 02:27:19 +00001219struct pci_access *pacc;
1220int main(int argc, char **argv)
1221{
1222 (void) argc;
1223 (void) argv;
1224 pacc = pci_alloc();
1225 return 0;
1226}
1227endef
1228export LIBPCI_TEST
1229
Stefan Tauner56734502015-02-08 21:58:04 +00001230define PCI_GET_DEV_TEST
1231/* Avoid a failing test due to libpci header symbol shadowing breakage */
1232#define index shadow_workaround_index
Nico Huberc0e1c4b2022-12-13 21:55:22 +00001233#if !defined PCIUTILS_PCI_H
Stefan Tauner56734502015-02-08 21:58:04 +00001234#include <pci/pci.h>
1235#else
1236#include <pciutils/pci.h>
1237#endif
1238struct pci_access *pacc;
1239struct pci_dev *dev = {0};
1240int main(int argc, char **argv)
1241{
1242 (void) argc;
1243 (void) argv;
1244 pacc = pci_alloc();
1245 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
1246 return 0;
1247}
1248endef
1249export PCI_GET_DEV_TEST
1250
Stefan Taunere49edbb2016-01-31 22:10:14 +00001251define LIBUSB1_TEST
1252#include <stddef.h>
1253#include <libusb.h>
1254int main(int argc, char **argv)
1255{
1256 (void)argc;
1257 (void)argv;
1258 libusb_init(NULL);
1259 return 0;
1260}
1261endef
1262export LIBUSB1_TEST
1263
Marc Schink3578ec62016-03-17 16:23:03 +01001264define LIBJAYLINK_TEST
1265#include <stddef.h>
1266#include <libjaylink/libjaylink.h>
1267int main(int argc, char **argv)
1268{
1269 struct jaylink_context *ctx;
1270
1271 (void)argc;
1272 (void)argv;
1273
1274 jaylink_init(&ctx);
1275 jaylink_exit(ctx);
1276
1277 return 0;
1278}
1279endef
1280export LIBJAYLINK_TEST
1281
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001282hwlibs: compiler
1283 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001284ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001285 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001286 @echo "$$LIBPCI_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001287 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001288 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1289 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001290 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001291 echo "Please install libpci headers or disable all features"; \
1292 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001293 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001294 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
1295 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +00001296 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001297 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001298 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +00001299 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001300 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1301 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001302 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001303 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
1304 echo "yes." || { echo "no."; \
1305 printf "Checking if libz+libpci are present and sufficient..." ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001306 { printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz" >>$(BUILD_DETAILS_FILE) ; \
1307 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001308 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001309 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001310 echo "Please install libpci (package pciutils) and/or libz or disable all features"; \
1311 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001312 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001313 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 +00001314 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001315endif
Stefan Taunere49edbb2016-01-31 22:10:14 +00001316ifeq ($(CHECK_LIBUSB1), yes)
1317 @printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
1318 @echo "$$LIBUSB1_TEST" > .test.c
1319 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1320 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1321 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001322 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001323 echo "Please install libusb-1.0 headers or disable all features"; \
1324 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001325 echo "See README for more information."; echo; \
1326 rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1327 @printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
1328 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
1329 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
1330 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001331 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001332 echo "Please install libusb-1.0 or disable all features"; \
1333 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001334 echo "See README for more information."; echo; \
1335 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
1336 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1337endif
Marc Schink3578ec62016-03-17 16:23:03 +01001338ifeq ($(CHECK_LIBJAYLINK), yes)
1339 @printf "Checking for libjaylink headers... " | tee -a $(BUILD_DETAILS_FILE)
1340 @echo "$$LIBJAYLINK_TEST" > .test.c
1341 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1342 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1343 echo "found." || { echo "not found."; echo; \
1344 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1345 echo "Please install libjaylink headers or disable the feature"; \
1346 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1347 echo "See README for more information."; echo; \
1348 rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1349 @printf "Checking if libjaylink is usable... " | tee -a $(BUILD_DETAILS_FILE)
1350 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS)" >>$(BUILD_DETAILS_FILE)
1351 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS) >&2 && \
1352 echo "yes." || { echo "no."; \
1353 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1354 echo "Please install libjaylink or disable the feature"; \
1355 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1356 echo "See README for more information."; echo; \
1357 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
1358 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1359endif
Stefan Reinauer53e96252005-12-01 16:19:24 +00001360
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001361.features: features
1362
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001363# If a user does not explicitly request a non-working feature, we should
1364# silently disable it. However, if a non-working (does not compile) feature
1365# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001366# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001367featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001368ifeq ($(PROGRAMMER_OBJS),)
1369 @echo "You have to enable at least one programmer driver!"
1370 @false
1371endif
1372ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001373 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
1374 @false
1375endif
1376
Stefan Tauner56787082011-08-18 02:27:19 +00001377define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +00001378#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +00001379#include <ftdi.h>
1380struct ftdi_context *ftdic = NULL;
1381int main(int argc, char **argv)
1382{
1383 (void) argc;
1384 (void) argv;
1385 return ftdi_init(ftdic);
1386}
1387endef
1388export FTDI_TEST
1389
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001390define FTDI_232H_TEST
1391#include <ftdi.h>
1392enum ftdi_chip_type type = TYPE_232H;
1393endef
1394export FTDI_232H_TEST
1395
Stefan Tauner56787082011-08-18 02:27:19 +00001396define UTSNAME_TEST
1397#include <sys/utsname.h>
1398struct utsname osinfo;
1399int main(int argc, char **argv)
1400{
1401 (void) argc;
1402 (void) argv;
1403 uname (&osinfo);
1404 return 0;
1405}
1406endef
1407export UTSNAME_TEST
1408
David Hendricksf9a30552015-05-23 20:30:30 -07001409define LINUX_MTD_TEST
1410#include <mtd/mtd-user.h>
1411
1412int main(int argc, char **argv)
1413{
1414 (void) argc;
1415 (void) argv;
1416 return 0;
1417}
1418endef
1419export LINUX_MTD_TEST
1420
Stefan Tauner8868db32012-03-13 00:18:19 +00001421define LINUX_SPI_TEST
1422#include <linux/types.h>
1423#include <linux/spi/spidev.h>
1424
1425int main(int argc, char **argv)
1426{
1427 (void) argc;
1428 (void) argv;
1429 return 0;
1430}
1431endef
1432export LINUX_SPI_TEST
1433
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001434define LINUX_I2C_TEST
1435#include <linux/i2c-dev.h>
1436#include <linux/i2c.h>
1437
1438int main(int argc, char **argv)
1439{
1440 (void) argc;
1441 (void) argv;
1442 return 0;
1443}
1444endef
1445export LINUX_I2C_TEST
1446
Nico Huber8624e8c2012-11-05 21:46:33 +01001447define CLOCK_GETTIME_TEST
1448#include <time.h>
1449
1450int main(int argc, char **argv)
1451{
1452 struct timespec res;
1453 clock_gettime(CLOCK_REALTIME, &res);
1454 return 0;
1455}
1456endef
1457export CLOCK_GETTIME_TEST
1458
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001459define NI845X_TEST
1460#include <ni845x.h>
1461
1462int main(int argc, char **argv)
1463{
1464 (void) argc;
1465 (void) argv;
1466 char I2C_Device[256];
1467 NiHandle Dev_Handle;
1468 uInt32 NumberFound = 0;
1469 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
1470 ni845xCloseFindDeviceHandle(Dev_Handle);
1471 return 0;
1472}
1473endef
1474export NI845X_TEST
1475
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001476features: compiler
1477 @echo "FEATURES := yes" > .features.tmp
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001478ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001479 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001480 @echo "$$FTDI_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 "FTDISUPPORT := yes" >> .features.tmp ; \
1484 printf "Checking for FT232H support in libftdi... " ; \
1485 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001486 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 +00001487 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1488 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1489 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1490 ) || \
1491 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1492 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001493endif
David Hendricksf9a30552015-05-23 20:30:30 -07001494ifeq ($(CONFIG_LINUX_MTD), yes)
1495 @printf "Checking if Linux MTD headers are present... " | tee -a $(BUILD_DETAILS_FILE)
1496 @echo "$$LINUX_MTD_TEST" > .featuretest.c
1497 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1498 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1499 ( echo "yes."; echo "LINUX_MTD_SUPPORT := yes" >> .features.tmp ) || \
1500 ( echo "no."; echo "LINUX_MTD_SUPPORT := no" >> .features.tmp ) } \
1501 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1502endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001503ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001504 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001505 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001506 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001507 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001508 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001509 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1510 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001511endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001512ifneq ($(NEED_LINUX_I2C), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001513 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001514 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001515 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001516 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001517 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001518 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1519 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001520endif
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001521ifeq ($(CONFIG_NI845X_SPI), yes)
1522 @printf "Checking for NI USB-845x installation... " | tee -a $(BUILD_DETAILS_FILE)
1523 @echo "$$NI845X_TEST" > .featuretest.c
1524 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
1525
1526 @ { { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS) >&2 && \
1527 ( echo "yes."; echo "NI845X_SUPPORT := yes" >> .features.tmp ) || \
1528 { echo -e "\nUnable to find NI-845x headers or libraries."; \
1529 echo "Please pass the NI-845x library path to the make with the CONFIG_NI845X_LIBRARY_PATH parameter,"; \
1530 echo "or disable the NI-845x support by specifying make CONFIG_NI845X_SPI=no"; \
1531 echo "For the NI-845x 17.0 the library path is:"; \
1532 echo " On 32 bit systems: C:\Program Files)\National Instruments\NI-845x\MS Visual C"; \
1533 echo " On 64 bit systems: C:\Program Files (x86)\National Instruments\NI-845x\MS Visual C"; \
1534 exit 1; }; } \
1535 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1536endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001537 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001538 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001539 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001540 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001541 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001542 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Nico Huber8624e8c2012-11-05 21:46:33 +01001543 @printf "Checking for clock_gettime support... " | tee -a $(BUILD_DETAILS_FILE)
1544 @echo "$$CLOCK_GETTIME_TEST" >.featuretest.c
1545 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1546 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1547 ( echo "found."; echo "CLOCK_GETTIME := yes" >>.features.tmp ) || \
1548 ( echo "not found."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1549 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001550 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1551 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001552
Stefan Tauner4c723152016-01-14 22:47:55 +00001553$(PROGRAM).8.html: $(PROGRAM).8
1554 @groff -mandoc -Thtml $< >$@
1555
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001556$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Tauner4c723152016-01-14 22:47:55 +00001557 @# Add the man page change date and version to the man page
Stefan Taunerf0cbbb02017-10-01 00:49:05 +02001558 @sed -e 's#.TH FLASHROM 8 .*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)" "$(MAN_DATE)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001559
1560install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001561 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001562 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001563 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001564 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001565
Nico Huber454f6132012-12-10 13:34:10 +00001566libinstall: libflashrom.a libflashrom.h
1567 mkdir -p $(DESTDIR)$(PREFIX)/lib
1568 $(INSTALL) -m 0644 libflashrom.a $(DESTDIR)$(PREFIX)/lib
1569 mkdir -p $(DESTDIR)$(PREFIX)/include
1570 $(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include
1571
Stefan Tauner76347082016-11-27 17:45:49 +01001572_export: $(PROGRAM).8
1573 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1574 @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1575 @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
Stefan Tauner2dc5d292017-10-04 02:18:33 +02001576# Generate versioninfo.inc containing metadata that would not be available in exported sources otherwise.
1577 @echo "VERSION = $(VERSION)" > "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
1578 @echo "MAN_DATE = $(MAN_DATE)" >> "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
Stefan Taunere4136852017-10-01 15:57:25 +02001579# Restore modification date of all tracked files not marked 'export-ignore' in .gitattributes.
1580# sed is required to filter out file names having the attribute set.
1581# The sed program saves the file name in the hold buffer and then checks if the respective value is 'set'.
1582# 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 +01001583 @git ls-tree -r -z -t --full-name --name-only HEAD | \
1584 git check-attr -z --stdin export-ignore | \
Stefan Taunere4136852017-10-01 15:57:25 +02001585 sed -zne 'x;n;n;{/^set$$/b;};x;p;' | \
Stefan Tauner76347082016-11-27 17:45:49 +01001586 xargs -0 sh -c 'for f; do \
1587 touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \
1588 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \
Stefan Taunere4136852017-10-01 15:57:25 +02001589 done' dummy_arg0
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001590
Stefan Tauner76347082016-11-27 17:45:49 +01001591export: _export
1592 @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/"
1593
1594tarball: _export
David Hendrickse1a960e2017-10-19 14:54:44 -07001595 @tar -cj --format=ustar -f "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2" -C $(EXPORTDIR)/ \
Stefan Tauner60f7a222017-10-01 15:45:06 +02001596 $(TAROPTIONS) "flashrom-$(RELEASENAME)/"
Stefan Tauner76347082016-11-27 17:45:49 +01001597# Delete the exported directory again because it is most likely what's expected by the user.
1598 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
David Hendrickse1a960e2017-10-19 14:54:44 -07001599 @echo Created "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2"
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001600
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001601libpayload: clean
1602 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001603
Stefan Tauner76347082016-11-27 17:45:49 +01001604.PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001605
Stefan Tauner23e10b82016-01-23 16:16:49 +00001606# Disable implicit suffixes and built-in rules (for performance and profit)
1607.SUFFIXES:
1608
Stefan Reinauere2f01582010-06-07 11:08:07 +00001609-include $(OBJS:.o=.d)