blob: c6841bda7d9dabad245016aa6400cfa5cad4c02e [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 Artemievda1c8342021-10-21 00:58:12 +1100574 spi95.o opaque.o sfdp.o en29lv640b.o at45db.o writeprotect.o
Sean Nelson5d134642009-12-24 16:54:21 +0000575
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000576###############################################################################
577# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000578
Arthur Heymansc82900b2018-01-10 12:48:16 +0100579LIB_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 +0000580
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000581###############################################################################
582# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000583
Stefan Tauner9b32de92014-08-08 23:52:33 +0000584CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000585
Stefan Taunerfa25bc32017-10-04 03:47:26 +0200586# versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
587# imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
588# be obtained using util/getrevision.sh, which is the common case during development.
589-include versioninfo.inc
Stefan Tauner5bf6b852017-10-04 03:46:51 +0200590VERSION ?= $(shell ./util/getrevision.sh --revision)
Stefan Tauner96209122017-10-01 16:41:35 +0200591MAN_DATE ?= $(shell ./util/getrevision.sh --date $(PROGRAM).8.tmpl 2>/dev/null)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000592
Stefan Tauner76347082016-11-27 17:45:49 +0100593SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000594
Stefan Tauner76347082016-11-27 17:45:49 +0100595# No spaces in release names unless set explicitly
596RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/')
597
598# Inform user of the version string
599$(info Replacing all version templates with $(VERSION).)
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000600
Stefan Tauner96209122017-10-01 16:41:35 +0200601# If a VCS is found then try to install hooks.
602$(shell ./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh)
603
Stefan Tauner037cd842013-08-25 00:10:56 +0000604###############################################################################
605# Default settings of CONFIG_* variables.
606
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000607# Always enable internal/onboard support for now.
608CONFIG_INTERNAL ?= yes
609
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000610# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000611CONFIG_SERPROG ?= yes
612
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000613# RayeR SPIPGM hardware support
614CONFIG_RAYER_SPI ?= yes
615
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000616# PonyProg2000 SPI hardware support
617CONFIG_PONY_SPI ?= yes
618
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000619# Always enable 3Com NICs for now.
620CONFIG_NIC3COM ?= yes
621
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000622# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
623CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000624
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000625# Always enable SiI SATA controllers for now.
626CONFIG_SATASII ?= yes
627
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000628# Highpoint (HPT) ATA/RAID controller support.
629# IMPORTANT: This code is not yet working!
630CONFIG_ATAHPT ?= no
631
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000632# VIA VT6421A LPC memory support
633CONFIG_ATAVIA ?= yes
634
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000635# Promise ATA controller support.
636CONFIG_ATAPROMISE ?= no
637
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000638# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000639CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000640
James Lairdc60de0e2013-03-27 13:00:23 +0000641# Always enable Altera USB-Blaster dongles for now.
642CONFIG_USBBLASTER_SPI ?= yes
643
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000644# MSTAR DDC support needs more tests/reviews/cleanups.
645CONFIG_MSTARDDC_SPI ?= no
646
Justin Chevrier66e554b2015-02-08 21:58:10 +0000647# Always enable PICkit2 SPI dongles for now.
648CONFIG_PICKIT2_SPI ?= yes
649
Miklós Márton324929c2019-08-01 19:14:10 +0200650# Always enable STLink V3
651CONFIG_STLINKV3_SPI ?= yes
652
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000653# Always enable dummy tracing for now.
654CONFIG_DUMMY ?= yes
655
656# Always enable Dr. Kaiser for now.
657CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000658
Joerg Fischer5665ef32010-05-21 21:54:07 +0000659# Always enable Realtek NICs for now.
660CONFIG_NICREALTEK ?= yes
661
Andrew Morganc29c2e72010-06-07 22:37:54 +0000662# Disable National Semiconductor NICs until support is complete and tested.
663CONFIG_NICNATSEMI ?= no
664
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000665# Always enable Intel NICs for now.
666CONFIG_NICINTEL ?= yes
667
Idwer Vollering004f4b72010-09-03 18:21:21 +0000668# Always enable SPI on Intel NICs for now.
669CONFIG_NICINTEL_SPI ?= yes
670
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000671# Always enable EEPROM on Intel NICs for now.
672CONFIG_NICINTEL_EEPROM ?= yes
673
Mark Marshall90021f22010-12-03 14:48:11 +0000674# Always enable SPI on OGP cards for now.
675CONFIG_OGP_SPI ?= yes
676
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000677# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000678CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000679
Simon Glassae616512016-01-23 23:27:58 +0000680# Always enable Dediprog SF100 for now.
681CONFIG_DEDIPROG ?= yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000682
Daniel Thompson45e91a22018-06-04 13:46:29 +0100683# Always enable Developerbox emergency recovery for now.
684CONFIG_DEVELOPERBOX_SPI ?= yes
685
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000686# Always enable Marvell SATA controllers for now.
687CONFIG_SATAMV ?= yes
688
David Hendricksf9a30552015-05-23 20:30:30 -0700689# Enable Linux spidev and MTD interfaces by default. We disable them on non-Linux targets.
690CONFIG_LINUX_MTD ?= yes
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000691CONFIG_LINUX_SPI ?= yes
692
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000693# Always enable ITE IT8212F PATA controllers for now.
694CONFIG_IT8212 ?= yes
695
Urja Rannikko0870b022016-01-31 22:10:29 +0000696# Winchiphead CH341A
697CONFIG_CH341A_SPI ?= yes
698
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100699# Digilent Development board JTAG
700CONFIG_DIGILENT_SPI ?= yes
701
Marc Schink3578ec62016-03-17 16:23:03 +0100702# Disable J-Link for now.
703CONFIG_JLINK_SPI ?= no
704
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000705# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000706CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000707
Stefan Taunerf3503372016-02-26 23:51:21 +0000708# Disable all features if CONFIG_NOTHING=yes is given unless CONFIG_EVERYTHING was also set
709ifeq ($(CONFIG_NOTHING), yes)
710 ifeq ($(CONFIG_EVERYTHING), yes)
711 $(error Setting CONFIG_NOTHING=yes and CONFIG_EVERYTHING=yes does not make sense)
712 endif
713 $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
714 $(if $(filter yes, $($(var))),\
715 $(eval $(var)=no)))
716endif
717
Patrick Georgiced7ab62015-01-19 19:52:34 +0000718# Enable all features if CONFIG_EVERYTHING=yes is given
719ifeq ($(CONFIG_EVERYTHING), yes)
720$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
721 $(if $(filter no, $($(var))),\
722 $(eval $(var)=yes)))
723endif
724
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000725ifeq ($(CONFIG_ENABLE_LIBUSB1_PROGRAMMERS), no)
726override CONFIG_CH341A_SPI = no
727override CONFIG_DEDIPROG = no
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100728override CONFIG_DIGILENT_SPI = no
Daniel Thompson45e91a22018-06-04 13:46:29 +0100729override CONFIG_DEVELOPERBOX_SPI = no
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200730override CONFIG_PICKIT2_SPI = no
Miklós Márton324929c2019-08-01 19:14:10 +0200731override CONFIG_STLINKV3_SPI = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000732endif
733ifeq ($(CONFIG_ENABLE_LIBPCI_PROGRAMMERS), no)
Stefan Tauner0be072c2016-03-13 15:16:30 +0000734override CONFIG_INTERNAL = no
735override CONFIG_NIC3COM = no
736override CONFIG_GFXNVIDIA = no
737override CONFIG_SATASII = no
738override CONFIG_ATAHPT = no
739override CONFIG_ATAVIA = no
740override CONFIG_ATAPROMISE = no
741override CONFIG_IT8212 = no
742override CONFIG_DRKAISER = no
743override CONFIG_NICREALTEK = no
744override CONFIG_NICNATSEMI = no
745override CONFIG_NICINTEL = no
746override CONFIG_NICINTEL_SPI = no
747override CONFIG_NICINTEL_EEPROM = no
748override CONFIG_OGP_SPI = no
749override CONFIG_SATAMV = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000750endif
751
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000752# Bitbanging SPI infrastructure, default off unless needed.
753ifeq ($(CONFIG_RAYER_SPI), yes)
754override CONFIG_BITBANG_SPI = yes
755else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000756ifeq ($(CONFIG_PONY_SPI), yes)
757override CONFIG_BITBANG_SPI = yes
758else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000759ifeq ($(CONFIG_INTERNAL), yes)
760override CONFIG_BITBANG_SPI = yes
761else
762ifeq ($(CONFIG_NICINTEL_SPI), yes)
763override CONFIG_BITBANG_SPI = yes
764else
Mark Marshall90021f22010-12-03 14:48:11 +0000765ifeq ($(CONFIG_OGP_SPI), yes)
766override CONFIG_BITBANG_SPI = yes
767else
Felix Singer4cbc1cb2022-07-22 23:23:28 +0200768ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
769override CONFIG_BITBANG_SPI = yes
770else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000771CONFIG_BITBANG_SPI ?= no
772endif
773endif
774endif
Mark Marshall90021f22010-12-03 14:48:11 +0000775endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000776endif
Felix Singer4cbc1cb2022-07-22 23:23:28 +0200777endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000778
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000779###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000780# Handle CONFIG_* variables that depend on others set (and verified) above.
781
782# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
783ifeq ($(TARGET_OS), libpayload)
784ifeq ($(CONFIG_INTERNAL), yes)
785ifeq ($(CONFIG_INTERNAL_DMI), no)
786UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
787else
788override CONFIG_INTERNAL_DMI = yes
789endif
790endif
791endif
792
793# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
794CONFIG_INTERNAL_DMI ?= yes
795
796###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000797# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000798# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000799
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000800FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000801FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000802
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000803ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000804FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000805PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000806ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000807PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Nico Huber305f4172013-06-14 11:55:26 +0200808PROGRAMMER_OBJS += ichspi.o dmi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000809ifeq ($(CONFIG_INTERNAL_DMI), yes)
810FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
811endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000812else
813endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000814NEED_LIBPCI += CONFIG_INTERNAL
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000815endif
816
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000817ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000818FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000819PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000820NEED_SERIAL += CONFIG_SERPROG
821NEED_POSIX_SOCKETS += CONFIG_SERPROG
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000822endif
823
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000824ifeq ($(CONFIG_RAYER_SPI), yes)
825FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
826PROGRAMMER_OBJS += rayer_spi.o
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000827NEED_RAW_ACCESS += CONFIG_RAYER_SPI
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000828endif
829
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000830ifeq ($(CONFIG_PONY_SPI), yes)
831FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
832PROGRAMMER_OBJS += pony_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000833NEED_SERIAL += CONFIG_PONY_SPI
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000834endif
835
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000836ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000837FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000838PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000839endif
840
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000841ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000842FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000843PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000844NEED_LIBPCI += CONFIG_NIC3COM
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000845endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000846
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000847ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000848FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000849PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000850NEED_LIBPCI += CONFIG_GFXNVIDIA
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000851endif
852
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000853ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000854FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000855PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000856NEED_LIBPCI += CONFIG_SATASII
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000857endif
858
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000859ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000860FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000861PROGRAMMER_OBJS += atahpt.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000862NEED_LIBPCI += CONFIG_ATAHPT
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000863endif
864
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000865ifeq ($(CONFIG_ATAVIA), yes)
866FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
867PROGRAMMER_OBJS += atavia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000868NEED_LIBPCI += CONFIG_ATAVIA
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000869endif
870
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000871ifeq ($(CONFIG_ATAPROMISE), yes)
872FEATURE_CFLAGS += -D'CONFIG_ATAPROMISE=1'
873PROGRAMMER_OBJS += atapromise.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000874NEED_LIBPCI += CONFIG_ATAPROMISE
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000875endif
876
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000877ifeq ($(CONFIG_IT8212), yes)
878FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
879PROGRAMMER_OBJS += it8212.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000880NEED_LIBPCI += CONFIG_IT8212
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000881endif
882
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000883ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000884# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000885FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000886NEED_LIBFTDI += CONFIG_FT2232_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000887PROGRAMMER_OBJS += ft2232_spi.o
888endif
889
890ifeq ($(CONFIG_USBBLASTER_SPI), yes)
891# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000892FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000893NEED_LIBFTDI += CONFIG_USBBLASTER_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000894PROGRAMMER_OBJS += usbblaster_spi.o
895endif
896
Justin Chevrier66e554b2015-02-08 21:58:10 +0000897ifeq ($(CONFIG_PICKIT2_SPI), yes)
898FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
899PROGRAMMER_OBJS += pickit2_spi.o
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200900NEED_LIBUSB1 += CONFIG_PICKIT2_SPI
Justin Chevrier66e554b2015-02-08 21:58:10 +0000901endif
902
Miklós Márton324929c2019-08-01 19:14:10 +0200903ifeq ($(CONFIG_STLINKV3_SPI), yes)
904FEATURE_CFLAGS += -D'CONFIG_STLINKV3_SPI=1'
905PROGRAMMER_OBJS += stlinkv3_spi.o
906NEED_LIBUSB1 += CONFIG_STLINKV3_SPI
907endif
908
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000909ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000910FTDILIBS := $(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")
911FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
912FTDI_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 +0000913FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000914FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000915# We can't set NEED_LIBUSB0 here because that would transform libftdi auto-enabling
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000916# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000917endif
918
919ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000920FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000921PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000922endif
923
924ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000925FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000926PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000927NEED_LIBPCI += CONFIG_DRKAISER
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000928endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000929
Joerg Fischer5665ef32010-05-21 21:54:07 +0000930ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000931FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000932PROGRAMMER_OBJS += nicrealtek.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000933NEED_LIBPCI += CONFIG_NICREALTEK
Joerg Fischer5665ef32010-05-21 21:54:07 +0000934endif
935
Andrew Morganc29c2e72010-06-07 22:37:54 +0000936ifeq ($(CONFIG_NICNATSEMI), yes)
937FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
938PROGRAMMER_OBJS += nicnatsemi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000939NEED_LIBPCI += CONFIG_NICNATSEMI
Andrew Morganc29c2e72010-06-07 22:37:54 +0000940endif
941
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000942ifeq ($(CONFIG_NICINTEL), yes)
943FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
944PROGRAMMER_OBJS += nicintel.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000945NEED_LIBPCI += CONFIG_NICINTEL
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000946endif
947
Idwer Vollering004f4b72010-09-03 18:21:21 +0000948ifeq ($(CONFIG_NICINTEL_SPI), yes)
949FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
950PROGRAMMER_OBJS += nicintel_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000951NEED_LIBPCI += CONFIG_NICINTEL_SPI
Idwer Vollering004f4b72010-09-03 18:21:21 +0000952endif
953
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000954ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
955FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
956PROGRAMMER_OBJS += nicintel_eeprom.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000957NEED_LIBPCI += CONFIG_NICINTEL_EEPROM
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000958endif
959
Mark Marshall90021f22010-12-03 14:48:11 +0000960ifeq ($(CONFIG_OGP_SPI), yes)
961FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
962PROGRAMMER_OBJS += ogp_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000963NEED_LIBPCI += CONFIG_OGP_SPI
Mark Marshall90021f22010-12-03 14:48:11 +0000964endif
965
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000966ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
967FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000968PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000969NEED_SERIAL += CONFIG_BUSPIRATE_SPI
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000970endif
971
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000972ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000973FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000974PROGRAMMER_OBJS += dediprog.o
Nico Huberd99a2bd2016-02-18 21:42:49 +0000975NEED_LIBUSB1 += CONFIG_DEDIPROG
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000976endif
977
Daniel Thompson45e91a22018-06-04 13:46:29 +0100978ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
979FEATURE_CFLAGS += -D'CONFIG_DEVELOPERBOX_SPI=1'
980PROGRAMMER_OBJS += developerbox_spi.o
981NEED_LIBUSB1 += CONFIG_DEVELOPERBOX_SPI
982endif
983
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000984ifeq ($(CONFIG_SATAMV), yes)
985FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
986PROGRAMMER_OBJS += satamv.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000987NEED_LIBPCI += CONFIG_SATAMV
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000988endif
989
David Hendricksf9a30552015-05-23 20:30:30 -0700990ifeq ($(CONFIG_LINUX_MTD), yes)
991# This is a totally ugly hack.
992FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_MTD_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_MTD=1'")
993PROGRAMMER_OBJS += linux_mtd.o
994endif
995
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000996ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000997# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000998FEATURE_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 +0000999PROGRAMMER_OBJS += linux_spi.o
1000endif
1001
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001002ifeq ($(CONFIG_MSTARDDC_SPI), yes)
1003# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001004FEATURE_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 +00001005NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001006PROGRAMMER_OBJS += mstarddc_spi.o
1007endif
1008
Urja Rannikko0870b022016-01-31 22:10:29 +00001009ifeq ($(CONFIG_CH341A_SPI), yes)
1010FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
1011PROGRAMMER_OBJS += ch341a_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001012NEED_LIBUSB1 += CONFIG_CH341A_SPI
Urja Rannikko0870b022016-01-31 22:10:29 +00001013endif
1014
Lubomir Rintelb2154e82018-01-14 17:35:33 +01001015ifeq ($(CONFIG_DIGILENT_SPI), yes)
1016FEATURE_CFLAGS += -D'CONFIG_DIGILENT_SPI=1'
1017PROGRAMMER_OBJS += digilent_spi.o
1018NEED_LIBUSB1 += CONFIG_DIGILENT_SPI
1019endif
1020
Marc Schink3578ec62016-03-17 16:23:03 +01001021ifeq ($(CONFIG_JLINK_SPI), yes)
1022NEED_LIBJAYLINK += CONFIG_JLINK_SPI
1023FEATURE_CFLAGS += -D'CONFIG_JLINK_SPI=1'
1024PROGRAMMER_OBJS += jlink_spi.o
1025endif
1026
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001027ifeq ($(CONFIG_NI845X_SPI), yes)
1028FEATURE_CFLAGS += -D'CONFIG_NI845X_SPI=1'
1029
1030ifeq ($(CONFIG_NI845X_LIBRARY_PATH),)
1031# if the user did not specified the NI-845x headers/lib path
1032# do a guess for both 32 and 64 bit Windows versions
1033NI845X_LIBS += -L'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1034NI845X_LIBS += -L'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1035NI845X_INCLUDES += -I'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1036NI845X_INCLUDES += -I'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1037else
1038NI845X_LIBS += -L'$(CONFIG_NI845X_LIBRARY_PATH)'
1039NI845X_INCLUDES += -I'$(CONFIG_NI845X_LIBRARY_PATH)'
1040endif
1041
1042FEATURE_CFLAGS += $(NI845X_INCLUDES)
1043LIBS += -lni845x
1044PROGRAMMER_OBJS += ni845x_spi.o
1045endif
1046
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001047ifneq ($(NEED_SERIAL), )
Urja Rannikko615ba182017-06-15 15:28:27 +03001048LIB_OBJS += serial.o custom_baud.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +00001049endif
1050
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001051ifneq ($(NEED_POSIX_SOCKETS), )
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001052ifeq ($(TARGET_OS), SunOS)
Stefan Taunerfc3ecc22016-03-13 12:57:03 +00001053LIBS += -lsocket -lnsl
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001054endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +00001055endif
1056
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001057ifneq ($(NEED_LIBPCI), )
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001058CHECK_LIBPCI = yes
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001059# This is a dirty hack, but it saves us from checking all PCI drivers and all platforms manually.
1060# libpci may need raw memory, MSR or PCI port I/O on some platforms.
1061# Individual drivers might have the same needs as well.
1062NEED_RAW_ACCESS += $(NEED_LIBPCI)
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001063FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001064FEATURE_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 +00001065
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001066PROGRAMMER_OBJS += pcidev.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001067ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001068# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001069PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001070else
1071PCILIBS += -lpci
1072endif
1073endif
1074
1075ifneq ($(NEED_RAW_ACCESS), )
1076# Raw memory, MSR or PCI port I/O access.
1077FEATURE_CFLAGS += -D'NEED_RAW_ACCESS=1'
1078PROGRAMMER_OBJS += physmap.o hwaccess.o
1079
1080ifeq ($(TARGET_OS), NetBSD)
Nico Huber9245b882021-04-18 20:50:32 +02001081ifeq ($(ARCH), x86)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001082PCILIBS += -l$(shell uname -p)
Nico Huber9245b882021-04-18 20:50:32 +02001083endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001084else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001085ifeq ($(TARGET_OS), OpenBSD)
Nico Huber9245b882021-04-18 20:50:32 +02001086ifeq ($(ARCH), x86)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001087PCILIBS += -l$(shell uname -m)
Nico Huber9245b882021-04-18 20:50:32 +02001088endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001089else
1090ifeq ($(TARGET_OS), Darwin)
1091# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +00001092PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001093endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001094endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +00001095endif
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001096
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001097endif
1098
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001099
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001100ifneq ($(NEED_LIBUSB1), )
Stefan Taunere49edbb2016-01-31 22:10:14 +00001101CHECK_LIBUSB1 = yes
1102FEATURE_CFLAGS += -D'NEED_LIBUSB1=1'
Daniel Thompson1d507a02018-07-12 11:02:28 +01001103PROGRAMMER_OBJS += usbdev.o
Stefan Taunere49edbb2016-01-31 22:10:14 +00001104# FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
1105ifeq ($(TARGET_OS),$(filter $(TARGET_OS),FreeBSD DragonFlyBSD))
1106USB1LIBS += -lusb
1107else
1108ifeq ($(TARGET_OS),NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +00001109override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
Stefan Taunere49edbb2016-01-31 22:10:14 +00001110USB1LIBS += -lusb-1.0
1111else
Stefan Tauner45207062016-02-19 08:17:24 +00001112USB1LIBS += $(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")
1113override 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 +00001114endif
1115endif
1116endif
1117
Marc Schink3578ec62016-03-17 16:23:03 +01001118ifneq ($(NEED_LIBJAYLINK), )
1119CHECK_LIBJAYLINK = yes
1120JAYLINKLIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libjaylink)
1121override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libjaylink)
1122endif
1123
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001124ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001125FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001126CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001127endif
1128
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001129FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +00001130
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001131# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001132FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001133
Nico Huber8624e8c2012-11-05 21:46:33 +01001134FEATURE_CFLAGS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-D'HAVE_CLOCK_GETTIME=1'")
1135FEATURE_LIBS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-lrt")
1136
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001137LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +00001138OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +00001139
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001140all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001141ifeq ($(ARCH), x86)
1142 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
1143endif
1144
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001145$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001146 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001147
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001148libflashrom.a: $(LIBFLASHROM_OBJS)
1149 $(AR) rcs $@ $^
1150 $(RANLIB) $@
1151
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +00001152# TAROPTIONS reduces information leakage from the packager's system.
1153# If other tar programs support command line arguments for setting uid/gid of
1154# stored files, they can be handled here as well.
1155TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001156
Paul Fox05dfbe62009-06-16 21:08:06 +00001157%.o: %.c .features
Stefan Tauner76347082016-11-27 17:45:49 +01001158 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +00001159
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +00001160# Make sure to add all names of generated binaries here.
1161# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001162# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001163clean:
Stefan Tauner4c723152016-01-14 22:47:55 +00001164 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 +00001165 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001166
Ollie Lho184a4042005-11-26 21:55:36 +00001167distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +00001168 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +00001169
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001170strip: $(PROGRAM)$(EXEC_SUFFIX)
1171 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001172
Stefan Tauner56787082011-08-18 02:27:19 +00001173# to define test programs we use verbatim variables, which get exported
1174# to environment variables and are referenced with $$<varname> later
1175
1176define COMPILER_TEST
1177int main(int argc, char **argv)
1178{
1179 (void) argc;
1180 (void) argv;
1181 return 0;
1182}
1183endef
1184export COMPILER_TEST
1185
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001186compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001187 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001188 @echo "$$COMPILER_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001189 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001190 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
1191 echo "found." || { echo "not found."; \
1192 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 +00001193 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001194 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001195 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001196 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001197 ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001198 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001199 @printf "Target OS is "
1200 @# FreeBSD wc will output extraneous whitespace.
1201 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontio89cc73b2020-07-06 12:57:35 +09001202 ( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001203 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +00001204ifeq ($(TARGET_OS), libpayload)
1205 @$(CC) --version 2>&1 | grep -q coreboot || \
1206 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
1207 echo "This might work but usually does not, please beware." )
1208endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +00001209
Stefan Tauner56787082011-08-18 02:27:19 +00001210define LIBPCI_TEST
1211/* Avoid a failing test due to libpci header symbol shadowing breakage */
1212#define index shadow_workaround_index
Nico Huberc0e1c4b2022-12-13 21:55:22 +00001213#if !defined PCIUTILS_PCI_H
Stefan Tauner56787082011-08-18 02:27:19 +00001214#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +00001215#else
1216#include <pciutils/pci.h>
1217#endif
Stefan Tauner56787082011-08-18 02:27:19 +00001218struct pci_access *pacc;
1219int main(int argc, char **argv)
1220{
1221 (void) argc;
1222 (void) argv;
1223 pacc = pci_alloc();
1224 return 0;
1225}
1226endef
1227export LIBPCI_TEST
1228
Stefan Tauner56734502015-02-08 21:58:04 +00001229define PCI_GET_DEV_TEST
1230/* Avoid a failing test due to libpci header symbol shadowing breakage */
1231#define index shadow_workaround_index
Nico Huberc0e1c4b2022-12-13 21:55:22 +00001232#if !defined PCIUTILS_PCI_H
Stefan Tauner56734502015-02-08 21:58:04 +00001233#include <pci/pci.h>
1234#else
1235#include <pciutils/pci.h>
1236#endif
1237struct pci_access *pacc;
1238struct pci_dev *dev = {0};
1239int main(int argc, char **argv)
1240{
1241 (void) argc;
1242 (void) argv;
1243 pacc = pci_alloc();
1244 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
1245 return 0;
1246}
1247endef
1248export PCI_GET_DEV_TEST
1249
Stefan Taunere49edbb2016-01-31 22:10:14 +00001250define LIBUSB1_TEST
1251#include <stddef.h>
1252#include <libusb.h>
1253int main(int argc, char **argv)
1254{
1255 (void)argc;
1256 (void)argv;
1257 libusb_init(NULL);
1258 return 0;
1259}
1260endef
1261export LIBUSB1_TEST
1262
Marc Schink3578ec62016-03-17 16:23:03 +01001263define LIBJAYLINK_TEST
1264#include <stddef.h>
1265#include <libjaylink/libjaylink.h>
1266int main(int argc, char **argv)
1267{
1268 struct jaylink_context *ctx;
1269
1270 (void)argc;
1271 (void)argv;
1272
1273 jaylink_init(&ctx);
1274 jaylink_exit(ctx);
1275
1276 return 0;
1277}
1278endef
1279export LIBJAYLINK_TEST
1280
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001281hwlibs: compiler
1282 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001283ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001284 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001285 @echo "$$LIBPCI_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001286 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001287 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1288 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001289 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001290 echo "Please install libpci headers or disable all features"; \
1291 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001292 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001293 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
1294 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +00001295 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001296 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001297 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +00001298 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001299 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1300 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001301 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001302 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
1303 echo "yes." || { echo "no."; \
1304 printf "Checking if libz+libpci are present and sufficient..." ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001305 { printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz" >>$(BUILD_DETAILS_FILE) ; \
1306 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001307 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001308 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001309 echo "Please install libpci (package pciutils) and/or libz or disable all features"; \
1310 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001311 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001312 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 +00001313 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001314endif
Stefan Taunere49edbb2016-01-31 22:10:14 +00001315ifeq ($(CHECK_LIBUSB1), yes)
1316 @printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
1317 @echo "$$LIBUSB1_TEST" > .test.c
1318 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1319 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1320 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001321 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001322 echo "Please install libusb-1.0 headers or disable all features"; \
1323 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001324 echo "See README for more information."; echo; \
1325 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
1326 @printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
1327 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
1328 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
1329 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001330 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001331 echo "Please install libusb-1.0 or disable all features"; \
1332 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb2016-01-31 22:10:14 +00001333 echo "See README for more information."; echo; \
1334 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
1335 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1336endif
Marc Schink3578ec62016-03-17 16:23:03 +01001337ifeq ($(CHECK_LIBJAYLINK), yes)
1338 @printf "Checking for libjaylink headers... " | tee -a $(BUILD_DETAILS_FILE)
1339 @echo "$$LIBJAYLINK_TEST" > .test.c
1340 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1341 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1342 echo "found." || { echo "not found."; echo; \
1343 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1344 echo "Please install libjaylink headers or disable the feature"; \
1345 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1346 echo "See README for more information."; echo; \
1347 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
1348 @printf "Checking if libjaylink is usable... " | tee -a $(BUILD_DETAILS_FILE)
1349 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS)" >>$(BUILD_DETAILS_FILE)
1350 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS) >&2 && \
1351 echo "yes." || { echo "no."; \
1352 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1353 echo "Please install libjaylink or disable the feature"; \
1354 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1355 echo "See README for more information."; echo; \
1356 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
1357 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1358endif
Stefan Reinauer53e96252005-12-01 16:19:24 +00001359
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001360.features: features
1361
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001362# If a user does not explicitly request a non-working feature, we should
1363# silently disable it. However, if a non-working (does not compile) feature
1364# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001365# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001366featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001367ifeq ($(PROGRAMMER_OBJS),)
1368 @echo "You have to enable at least one programmer driver!"
1369 @false
1370endif
1371ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001372 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
1373 @false
1374endif
1375
Stefan Tauner56787082011-08-18 02:27:19 +00001376define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +00001377#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +00001378#include <ftdi.h>
1379struct ftdi_context *ftdic = NULL;
1380int main(int argc, char **argv)
1381{
1382 (void) argc;
1383 (void) argv;
1384 return ftdi_init(ftdic);
1385}
1386endef
1387export FTDI_TEST
1388
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001389define FTDI_232H_TEST
1390#include <ftdi.h>
1391enum ftdi_chip_type type = TYPE_232H;
1392endef
1393export FTDI_232H_TEST
1394
Stefan Tauner56787082011-08-18 02:27:19 +00001395define UTSNAME_TEST
1396#include <sys/utsname.h>
1397struct utsname osinfo;
1398int main(int argc, char **argv)
1399{
1400 (void) argc;
1401 (void) argv;
1402 uname (&osinfo);
1403 return 0;
1404}
1405endef
1406export UTSNAME_TEST
1407
David Hendricksf9a30552015-05-23 20:30:30 -07001408define LINUX_MTD_TEST
1409#include <mtd/mtd-user.h>
1410
1411int main(int argc, char **argv)
1412{
1413 (void) argc;
1414 (void) argv;
1415 return 0;
1416}
1417endef
1418export LINUX_MTD_TEST
1419
Stefan Tauner8868db32012-03-13 00:18:19 +00001420define LINUX_SPI_TEST
1421#include <linux/types.h>
1422#include <linux/spi/spidev.h>
1423
1424int main(int argc, char **argv)
1425{
1426 (void) argc;
1427 (void) argv;
1428 return 0;
1429}
1430endef
1431export LINUX_SPI_TEST
1432
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001433define LINUX_I2C_TEST
1434#include <linux/i2c-dev.h>
1435#include <linux/i2c.h>
1436
1437int main(int argc, char **argv)
1438{
1439 (void) argc;
1440 (void) argv;
1441 return 0;
1442}
1443endef
1444export LINUX_I2C_TEST
1445
Nico Huber8624e8c2012-11-05 21:46:33 +01001446define CLOCK_GETTIME_TEST
1447#include <time.h>
1448
1449int main(int argc, char **argv)
1450{
1451 struct timespec res;
1452 clock_gettime(CLOCK_REALTIME, &res);
1453 return 0;
1454}
1455endef
1456export CLOCK_GETTIME_TEST
1457
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001458define NI845X_TEST
1459#include <ni845x.h>
1460
1461int main(int argc, char **argv)
1462{
1463 (void) argc;
1464 (void) argv;
1465 char I2C_Device[256];
1466 NiHandle Dev_Handle;
1467 uInt32 NumberFound = 0;
1468 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
1469 ni845xCloseFindDeviceHandle(Dev_Handle);
1470 return 0;
1471}
1472endef
1473export NI845X_TEST
1474
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001475features: compiler
1476 @echo "FEATURES := yes" > .features.tmp
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001477ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001478 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001479 @echo "$$FTDI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001480 @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 +00001481 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1482 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
1483 printf "Checking for FT232H support in libftdi... " ; \
1484 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001485 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 +00001486 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1487 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1488 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1489 ) || \
1490 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1491 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001492endif
David Hendricksf9a30552015-05-23 20:30:30 -07001493ifeq ($(CONFIG_LINUX_MTD), yes)
1494 @printf "Checking if Linux MTD headers are present... " | tee -a $(BUILD_DETAILS_FILE)
1495 @echo "$$LINUX_MTD_TEST" > .featuretest.c
1496 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1497 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1498 ( echo "yes."; echo "LINUX_MTD_SUPPORT := yes" >> .features.tmp ) || \
1499 ( echo "no."; echo "LINUX_MTD_SUPPORT := no" >> .features.tmp ) } \
1500 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1501endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001502ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001503 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001504 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001505 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001506 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001507 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001508 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1509 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001510endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001511ifneq ($(NEED_LINUX_I2C), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001512 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001513 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001514 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001515 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001516 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001517 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1518 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001519endif
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001520ifeq ($(CONFIG_NI845X_SPI), yes)
1521 @printf "Checking for NI USB-845x installation... " | tee -a $(BUILD_DETAILS_FILE)
1522 @echo "$$NI845X_TEST" > .featuretest.c
1523 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
1524
1525 @ { { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS) >&2 && \
1526 ( echo "yes."; echo "NI845X_SUPPORT := yes" >> .features.tmp ) || \
1527 { echo -e "\nUnable to find NI-845x headers or libraries."; \
1528 echo "Please pass the NI-845x library path to the make with the CONFIG_NI845X_LIBRARY_PATH parameter,"; \
1529 echo "or disable the NI-845x support by specifying make CONFIG_NI845X_SPI=no"; \
1530 echo "For the NI-845x 17.0 the library path is:"; \
1531 echo " On 32 bit systems: C:\Program Files)\National Instruments\NI-845x\MS Visual C"; \
1532 echo " On 64 bit systems: C:\Program Files (x86)\National Instruments\NI-845x\MS Visual C"; \
1533 exit 1; }; } \
1534 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1535endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001536 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001537 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001538 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001539 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001540 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001541 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Nico Huber8624e8c2012-11-05 21:46:33 +01001542 @printf "Checking for clock_gettime support... " | tee -a $(BUILD_DETAILS_FILE)
1543 @echo "$$CLOCK_GETTIME_TEST" >.featuretest.c
1544 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1545 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1546 ( echo "found."; echo "CLOCK_GETTIME := yes" >>.features.tmp ) || \
1547 ( echo "not found."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1548 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001549 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1550 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001551
Stefan Tauner4c723152016-01-14 22:47:55 +00001552$(PROGRAM).8.html: $(PROGRAM).8
1553 @groff -mandoc -Thtml $< >$@
1554
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001555$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Tauner4c723152016-01-14 22:47:55 +00001556 @# Add the man page change date and version to the man page
Stefan Taunerf0cbbb02017-10-01 00:49:05 +02001557 @sed -e 's#.TH FLASHROM 8 .*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)" "$(MAN_DATE)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001558
1559install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001560 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001561 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001562 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001563 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001564
Nico Huber454f6132012-12-10 13:34:10 +00001565libinstall: libflashrom.a libflashrom.h
1566 mkdir -p $(DESTDIR)$(PREFIX)/lib
1567 $(INSTALL) -m 0644 libflashrom.a $(DESTDIR)$(PREFIX)/lib
1568 mkdir -p $(DESTDIR)$(PREFIX)/include
1569 $(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include
1570
Stefan Tauner76347082016-11-27 17:45:49 +01001571_export: $(PROGRAM).8
1572 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1573 @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1574 @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
Stefan Tauner2dc5d292017-10-04 02:18:33 +02001575# Generate versioninfo.inc containing metadata that would not be available in exported sources otherwise.
1576 @echo "VERSION = $(VERSION)" > "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
1577 @echo "MAN_DATE = $(MAN_DATE)" >> "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
Stefan Taunere4136852017-10-01 15:57:25 +02001578# Restore modification date of all tracked files not marked 'export-ignore' in .gitattributes.
1579# sed is required to filter out file names having the attribute set.
1580# The sed program saves the file name in the hold buffer and then checks if the respective value is 'set'.
1581# 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 +01001582 @git ls-tree -r -z -t --full-name --name-only HEAD | \
1583 git check-attr -z --stdin export-ignore | \
Stefan Taunere4136852017-10-01 15:57:25 +02001584 sed -zne 'x;n;n;{/^set$$/b;};x;p;' | \
Stefan Tauner76347082016-11-27 17:45:49 +01001585 xargs -0 sh -c 'for f; do \
1586 touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \
1587 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \
Stefan Taunere4136852017-10-01 15:57:25 +02001588 done' dummy_arg0
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001589
Stefan Tauner76347082016-11-27 17:45:49 +01001590export: _export
1591 @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/"
1592
1593tarball: _export
David Hendrickse1a960e2017-10-19 14:54:44 -07001594 @tar -cj --format=ustar -f "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2" -C $(EXPORTDIR)/ \
Stefan Tauner60f7a222017-10-01 15:45:06 +02001595 $(TAROPTIONS) "flashrom-$(RELEASENAME)/"
Stefan Tauner76347082016-11-27 17:45:49 +01001596# Delete the exported directory again because it is most likely what's expected by the user.
1597 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
David Hendrickse1a960e2017-10-19 14:54:44 -07001598 @echo Created "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2"
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001599
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001600libpayload: clean
1601 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001602
Stefan Tauner76347082016-11-27 17:45:49 +01001603.PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001604
Stefan Tauner23e10b82016-01-23 16:16:49 +00001605# Disable implicit suffixes and built-in rules (for performance and profit)
1606.SUFFIXES:
1607
Stefan Reinauere2f01582010-06-07 11:08:07 +00001608-include $(OBJS:.o=.d)