blob: be6e551697787100f0ac895863cf870859bbba55 [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
Angel Pons02be8512021-04-18 13:19:51 +000033CFLAGS ?= -Os -Wall -Wextra -Wno-unused-parameter -Wshadow -Wmissing-prototypes -Wwrite-strings
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000034EXPORTDIR ?= .
Patrick Georgi97bc95c2011-03-08 07:17:44 +000035RANLIB ?= ranlib
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000036PKG_CONFIG ?= pkg-config
37BUILD_DETAILS_FILE ?= build_details.txt
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000038
Stefan Taunerfd0d4132012-09-25 21:24:55 +000039# The following parameter changes the default programmer that will be used if there is no -p/--programmer
40# argument given when running flashrom. The predefined setting does not enable any default so that every
41# user has to declare the programmer he wants to use on every run. The rationale for this to be not set
42# (to e.g. the internal programmer) is that forgetting to specify this when working with another programmer
43# easily puts the system attached to the default programmer at risk (e.g. you want to flash coreboot to another
44# system attached to an external programmer while the default programmer is set to the internal programmer, and
45# you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer
46# running flashrom). Please do not enable this without thinking about the possible consequences. Possible
Thomas Heijligen732aafd2021-06-01 16:22:14 +020047# values can be found when running 'flashrom --list-supported' under the 'Supported programmers' section.
48CONFIG_DEFAULT_PROGRAMMER_NAME ?=
Stefan Tauner265fcac2014-06-02 00:12:23 +000049# The following adds a default parameter for the default programmer set above (only).
Thomas Heijligen732aafd2021-06-01 16:22:14 +020050CONFIG_DEFAULT_PROGRAMMER_ARGS ?=
Stefan Tauner265fcac2014-06-02 00:12:23 +000051# Example: compiling with
Thomas Heijligen732aafd2021-06-01 16:22:14 +020052# make CONFIG_DEFAULT_PROGRAMMER_NAME=serprog CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000"
Stefan Tauner265fcac2014-06-02 00:12:23 +000053# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000054
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000055# If your compiler spits out excessive warnings, run make WARNERROR=no
56# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000057WARNERROR ?= yes
58
59ifeq ($(WARNERROR), yes)
60CFLAGS += -Werror
61endif
62
Stefan Taunere37735a2015-01-26 22:03:35 +000063ifdef LIBS_BASE
Stefan Taunere37735a2015-01-26 22:03:35 +000064PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig
Stefan Tauner45207062016-02-19 08:17:24 +000065override CPPFLAGS += -I$(LIBS_BASE)/include
66override LDFLAGS += -L$(LIBS_BASE)/lib -Wl,-rpath -Wl,$(LIBS_BASE)/lib
Stefan Taunere37735a2015-01-26 22:03:35 +000067endif
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000068
Stefan Taunerbfb067b2016-01-07 18:13:07 +000069ifeq ($(CONFIG_STATIC),yes)
Stefan Tauner45207062016-02-19 08:17:24 +000070override PKG_CONFIG += --static
71override LDFLAGS += -static
Stefan Taunerbfb067b2016-01-07 18:13:07 +000072endif
73
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000074# Set LC_ALL=C to minimize influences of the locale.
75# However, this won't work for the majority of relevant commands because they use the $(shell) function and
76# GNU make does not relay variables exported within the makefile to their evironment.
77LC_ALL=C
78export LC_ALL
79
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000080dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUILD_DETAILS_FILE))
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000081
82# Provide an easy way to execute a command, print its output to stdout and capture any error message on stderr
83# in the build details file together with the original stdout output.
Pyry Kontioda6b3b72020-07-06 12:57:35 +090084debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(subst ','\'',$(1)) ; }' >&2; \
85 { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE))
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000086
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000087###############################################################################
Stefan Tauner037cd842013-08-25 00:10:56 +000088# General OS-specific settings.
89# 1. Prepare for later by gathering information about host and target OS
90# 2. Set compiler flags and parameters according to OSes
91# 3. Likewise verify user-supplied CONFIG_* variables.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000092
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000093# HOST_OS is only used to work around local toolchain issues.
Stefan Tauner037cd842013-08-25 00:10:56 +000094HOST_OS ?= $(shell uname)
Miklós Mártona75a2ed2018-01-30 20:25:00 +010095ifeq ($(findstring MINGW, $(HOST_OS)), MINGW)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000096# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
97CC = gcc
98endif
Miklós Mártona75a2ed2018-01-30 20:25:00 +010099
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000100ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +0000101STRIP_ARGS = -s
102endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000103
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000104# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000105# IMPORTANT: The following line must be placed before TARGET_OS is ever used
106# (of course), but should come after any lines setting CC because the line
107# below uses CC itself.
Pyry Kontioda6b3b72020-07-06 12:57:35 +0900108override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null \
109 | tail -1 | cut -f 2 -d'"'))
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000110
111ifeq ($(TARGET_OS), Darwin)
Stefan Tauner45207062016-02-19 08:17:24 +0000112override CPPFLAGS += -I/opt/local/include -I/usr/local/include
113override LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +0000114endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000115
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000116ifeq ($(TARGET_OS), FreeBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000117override CPPFLAGS += -I/usr/local/include
118override LDFLAGS += -L/usr/local/lib
Andriy Gapon65c1b862008-05-22 13:22:45 +0000119endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000120
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000121ifeq ($(TARGET_OS), OpenBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000122override CPPFLAGS += -I/usr/local/include
123override LDFLAGS += -L/usr/local/lib
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000124endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000125
Stefan Taunerc65b8552013-09-12 15:48:39 +0000126ifeq ($(TARGET_OS), NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000127override CPPFLAGS += -I/usr/pkg/include
128override LDFLAGS += -L/usr/pkg/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000129endif
130
131ifeq ($(TARGET_OS), DragonFlyBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000132override CPPFLAGS += -I/usr/local/include
133override LDFLAGS += -L/usr/local/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000134endif
135
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000136ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000137EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000138# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Stefan Tauner45207062016-02-19 08:17:24 +0000139override CFLAGS += -Wno-format
Stefan Tauner449abe22013-09-11 23:34:57 +0000140LIBS += -lgetopt
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000141# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000142ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
143UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
144else
145override CONFIG_BUSPIRATE_SPI = no
146endif
147ifeq ($(CONFIG_SERPROG), yes)
148UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
149else
150override CONFIG_SERPROG = no
151endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000152ifeq ($(CONFIG_PONY_SPI), yes)
153UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
154else
155override CONFIG_PONY_SPI = no
156endif
Nico Huber84c6fb52019-06-07 17:35:56 +0200157# Digilent SPI, Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported under DOS (missing USB support).
158ifeq ($(CONFIG_DIGILENT_SPI), yes)
159UNSUPPORTED_FEATURES += CONFIG_DIGILENT_SPI=yes
160else
161override CONFIG_DIGILENT_SPI = no
162endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000163ifeq ($(CONFIG_DEDIPROG), yes)
164UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
165else
166override CONFIG_DEDIPROG = no
167endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100168ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
169UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
170else
171override CONFIG_DEVELOPERBOX_SPI = no
172endif
Victor Ding436b4152020-08-19 22:48:19 +1000173ifeq ($(CONFIG_ENE_LPC), yes)
174UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
175else
176override CONFIG_ENE_LPC = no
177endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000178ifeq ($(CONFIG_FT2232_SPI), yes)
179UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
180else
181override CONFIG_FT2232_SPI = no
182endif
Victor Ding821e44c2020-08-18 18:27:26 +1000183ifeq ($(CONFIG_MEC1308), yes)
184UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
185else
186override CONFIG_MEC1308 = no
187endif
James Lairdc60de0e2013-03-27 13:00:23 +0000188ifeq ($(CONFIG_USBBLASTER_SPI), yes)
189UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
190else
191override CONFIG_USBBLASTER_SPI = no
192endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000193ifeq ($(CONFIG_PICKIT2_SPI), yes)
194UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
195else
196override CONFIG_PICKIT2_SPI = no
197endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000198ifeq ($(CONFIG_CH341A_SPI), yes)
199UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
200else
201override CONFIG_CH341A_SPI = no
202endif
Angel Pons87718aa2021-04-17 17:47:54 +0200203ifeq ($(CONFIG_RAIDEN_DEBUG_SPI), yes)
204UNSUPPORTED_FEATURES += CONFIG_RAIDEN_DEBUG_SPI=yes
205else
206override CONFIG_RAIDEN_DEBUG_SPI = no
207endif
Miklós Márton324929c2019-08-01 19:14:10 +0200208ifeq ($(CONFIG_STLINKV3_SPI), yes)
209UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
210else
211override CONFIG_STLINKV3_SPI = no
212endif
Nico Hubera7246022019-06-07 17:39:18 +0200213# libjaylink is also not available for DOS
214ifeq ($(CONFIG_JLINK_SPI), yes)
215UNSUPPORTED_FEATURES += CONFIG_JLINK_SPI=yes
216else
217override CONFIG_JLINK_SPI = no
218endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000219endif
Ollie Lho184a4042005-11-26 21:55:36 +0000220
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000221# FIXME: Should we check for Cygwin/MSVC as well?
222ifeq ($(TARGET_OS), MinGW)
223EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000224# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000225FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000226# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
Stefan Tauner23e10b82016-01-23 16:16:49 +0000227# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000228FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100229
230# National Instruments USB-845x is Windows only for now
231CONFIG_NI845X_SPI ?= no
232
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000233# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
234ifeq ($(CONFIG_INTERNAL), yes)
235UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
236else
237override CONFIG_INTERNAL = no
238endif
239ifeq ($(CONFIG_RAYER_SPI), yes)
240UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
241else
242override CONFIG_RAYER_SPI = no
243endif
244ifeq ($(CONFIG_NIC3COM), yes)
245UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
246else
247override CONFIG_NIC3COM = no
248endif
249ifeq ($(CONFIG_GFXNVIDIA), yes)
250UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
251else
252override CONFIG_GFXNVIDIA = no
253endif
254ifeq ($(CONFIG_SATASII), yes)
255UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
256else
257override CONFIG_SATASII = no
258endif
259ifeq ($(CONFIG_ATAHPT), yes)
260UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
261else
262override CONFIG_ATAHPT = no
263endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000264ifeq ($(CONFIG_ATAVIA), yes)
265UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
266else
267override CONFIG_ATAVIA = no
268endif
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000269ifeq ($(CONFIG_ATAPROMISE), yes)
270UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
271else
272override CONFIG_ATAPROMISE = no
273endif
Victor Ding436b4152020-08-19 22:48:19 +1000274ifeq ($(CONFIG_ENE_LPC), yes)
275UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
276else
277override CONFIG_ENE_LPC = no
278endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000279ifeq ($(CONFIG_IT8212), yes)
280UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
281else
282override CONFIG_IT8212 = no
283endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000284ifeq ($(CONFIG_DRKAISER), yes)
285UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
286else
287override CONFIG_DRKAISER = no
288endif
Victor Ding821e44c2020-08-18 18:27:26 +1000289ifeq ($(CONFIG_MEC1308), yes)
290UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
291else
292override CONFIG_MEC1308 = no
293endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000294ifeq ($(CONFIG_NICREALTEK), yes)
295UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
296else
297override CONFIG_NICREALTEK = no
298endif
299ifeq ($(CONFIG_NICNATSEMI), yes)
300UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
301else
302override CONFIG_NICNATSEMI = no
303endif
304ifeq ($(CONFIG_NICINTEL), yes)
305UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
306else
307override CONFIG_NICINTEL = no
308endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000309ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
310UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
311else
312override CONFIG_NICINTEL_EEPROM = no
313endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000314ifeq ($(CONFIG_NICINTEL_SPI), yes)
315UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
316else
317override CONFIG_NICINTEL_SPI = no
318endif
319ifeq ($(CONFIG_OGP_SPI), yes)
320UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
321else
322override CONFIG_OGP_SPI = no
323endif
324ifeq ($(CONFIG_SATAMV), yes)
325UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
326else
327override CONFIG_SATAMV = no
328endif
329endif
330
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100331ifneq ($(TARGET_OS), MinGW)
332# NI USB-845x only supported on Windows at the moment
333ifeq ($(CONFIG_NI845X_SPI), yes)
334UNSUPPORTED_FEATURES += CONFIG_NI845X_SPI=yes
335else
336override CONFIG_NI845X_SPI = no
337endif
338endif
339
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000340ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000341ifeq ($(MAKECMDGOALS),)
342.DEFAULT_GOAL := libflashrom.a
343$(info Setting default goal to libflashrom.a)
344endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000345FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000346ifeq ($(CONFIG_DUMMY), yes)
347UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
348else
349override CONFIG_DUMMY = no
350endif
Stefan Taunere0168262016-02-21 11:18:24 +0000351# libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
352ifeq ($(CONFIG_ATAPROMISE), yes)
353UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
354else
355override CONFIG_ATAPROMISE = no
356endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000357# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000358ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
359UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
360else
361override CONFIG_BUSPIRATE_SPI = no
362endif
363ifeq ($(CONFIG_SERPROG), yes)
364UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
365else
366override CONFIG_SERPROG = no
367endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000368ifeq ($(CONFIG_PONY_SPI), yes)
369UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
370else
371override CONFIG_PONY_SPI = no
372endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100373# Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000374ifeq ($(CONFIG_DEDIPROG), yes)
375UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
376else
377override CONFIG_DEDIPROG = no
378endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100379ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
380UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
381else
382override CONFIG_DEVELOPERBOX_SPI = no
383endif
Victor Ding436b4152020-08-19 22:48:19 +1000384ifeq ($(CONFIG_ENE_LPC), yes)
385UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
386else
387override CONFIG_ENE_LPC = no
388endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000389ifeq ($(CONFIG_FT2232_SPI), yes)
390UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
391else
392override CONFIG_FT2232_SPI = no
393endif
Victor Ding821e44c2020-08-18 18:27:26 +1000394ifeq ($(CONFIG_MEC1308), yes)
395UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
396else
397override CONFIG_MEC1308 = no
398endif
James Lairdc60de0e2013-03-27 13:00:23 +0000399ifeq ($(CONFIG_USBBLASTER_SPI), yes)
400UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
401else
402override CONFIG_USBBLASTER_SPI = no
403endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000404ifeq ($(CONFIG_PICKIT2_SPI), yes)
405UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
406else
407override CONFIG_PICKIT2_SPI = no
408endif
Miklós Márton324929c2019-08-01 19:14:10 +0200409ifeq ($(CONFIG_STLINKV3_SPI), yes)
410UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
411else
412override CONFIG_STLINKV3_SPI = no
413endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000414ifeq ($(CONFIG_CH341A_SPI), yes)
415UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
416else
417override CONFIG_CH341A_SPI = no
418endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000419endif
420
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000421ifneq ($(TARGET_OS), Linux)
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000422# Android is handled internally as separate OS, but it supports CONFIG_LINUX_SPI and CONFIG_MSTARDDC_SPI
423ifneq ($(TARGET_OS), Android)
David Hendricksf9a30552015-05-23 20:30:30 -0700424ifeq ($(CONFIG_LINUX_MTD), yes)
425UNSUPPORTED_FEATURES += CONFIG_LINUX_MTD=yes
426else
427override CONFIG_LINUX_MTD = no
428endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000429ifeq ($(CONFIG_LINUX_SPI), yes)
430UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
431else
432override CONFIG_LINUX_SPI = no
433endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000434ifeq ($(CONFIG_MSTARDDC_SPI), yes)
435UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
436else
437override CONFIG_MSTARDDC_SPI = no
Angel Pons78853ff2021-05-09 19:01:54 +0200438ifeq ($(CONFIG_LSPCON_I2C_SPI), yes)
439UNSUPPORTED_FEATURES += CONFIG_LSPCON_I2C_SPI=yes
440else
441override CONFIG_LSPCON_I2C_SPI = no
442endif
443ifeq ($(CONFIG_REALTEK_MST_I2C_SPI), yes)
444UNSUPPORTED_FEATURES += CONFIG_REALTEK_MST_I2C_SPI=yes
445else
446override CONFIG_REALTEK_MST_I2C_SPI = no
447endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000448endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000449endif
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000450endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000451
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000452ifeq ($(TARGET_OS), Android)
453# Android on x86 (currently) does not provide raw PCI port I/O operations
454ifeq ($(CONFIG_RAYER_SPI), yes)
455UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
456else
457override CONFIG_RAYER_SPI = no
458endif
459endif
460
Shiyu Sundc2c83b2020-03-19 16:59:52 +1100461ifeq ($(TARGET_OS), Linux)
462CONFIG_LINUX_I2C_HELPER = yes
463endif
464
Stefan Tauner037cd842013-08-25 00:10:56 +0000465###############################################################################
466# General architecture-specific settings.
467# Like above for the OS, below we verify user-supplied options depending on the target architecture.
468
Uwe Hermann44ffd582011-08-20 14:16:00 +0000469# Determine the destination processor architecture.
470# IMPORTANT: The following line must be placed before ARCH is ever used
471# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000472# below uses CC itself.
Pyry Kontioda6b3b72020-07-06 12:57:35 +0900473override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null \
474 | tail -1 | cut -f 2 -d'"'))
475override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \
476 | tail -1))
Uwe Hermann44ffd582011-08-20 14:16:00 +0000477
Nico Huberc8801732017-12-01 18:19:43 +0000478# Disable the internal programmer on unsupported architectures (everything but x86 and mipsel)
479ifneq ($(ARCH)-little, $(filter $(ARCH),x86 mips)-$(ENDIAN))
480ifeq ($(CONFIG_INTERNAL), yes)
481UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
482else
483override CONFIG_INTERNAL = no
484endif
485endif
486
Stefan Taunerfb2d77c2015-02-10 08:03:10 +0000487# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
David Hendricksb286da72012-02-13 00:35:35 +0000488# Right now this means the drivers below only work on x86.
489ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000490ifeq ($(CONFIG_NIC3COM), yes)
491UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
492else
493override CONFIG_NIC3COM = no
494endif
495ifeq ($(CONFIG_NICREALTEK), yes)
496UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
497else
498override CONFIG_NICREALTEK = no
499endif
500ifeq ($(CONFIG_NICNATSEMI), yes)
501UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
502else
503override CONFIG_NICNATSEMI = no
504endif
505ifeq ($(CONFIG_RAYER_SPI), yes)
506UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
507else
508override CONFIG_RAYER_SPI = no
509endif
510ifeq ($(CONFIG_ATAHPT), yes)
511UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
512else
513override CONFIG_ATAHPT = no
514endif
Carl-Daniel Hailfingerf636ffc2016-02-20 22:04:39 +0000515ifeq ($(CONFIG_ATAPROMISE), yes)
516UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
517else
518override CONFIG_ATAPROMISE = no
519endif
Uwe Hermann21b10c62011-07-29 12:13:01 +0000520ifeq ($(CONFIG_SATAMV), yes)
521UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
522else
523override CONFIG_SATAMV = no
524endif
Victor Ding1b4de5c2020-11-10 23:46:04 +1100525ifeq ($(CONFIG_ENE_LPC), yes)
526UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
527else
528override CONFIG_ENE_LPC = no
529endif
530ifeq ($(CONFIG_MEC1308), yes)
531UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
532else
533override CONFIG_MEC1308 = no
534endif
Uwe Hermann21b10c62011-07-29 12:13:01 +0000535endif
536
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000537# Disable all drivers needing raw access (memory, PCI, port I/O) on
538# architectures with unknown raw access properties.
539# Right now those architectures are alpha hppa m68k sh s390
Rosen Penev34d07f02019-07-02 00:14:01 -0700540ifneq ($(ARCH),$(filter $(ARCH),x86 mips ppc arm sparc arc))
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000541ifeq ($(CONFIG_RAYER_SPI), yes)
542UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
543else
544override CONFIG_RAYER_SPI = no
545endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000546ifeq ($(CONFIG_NIC3COM), yes)
547UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
548else
549override CONFIG_NIC3COM = no
550endif
551ifeq ($(CONFIG_GFXNVIDIA), yes)
552UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
553else
554override CONFIG_GFXNVIDIA = no
555endif
556ifeq ($(CONFIG_SATASII), yes)
557UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
558else
559override CONFIG_SATASII = no
560endif
561ifeq ($(CONFIG_ATAHPT), yes)
562UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
563else
564override CONFIG_ATAHPT = no
565endif
566ifeq ($(CONFIG_ATAVIA), yes)
567UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
568else
569override CONFIG_ATAVIA = no
570endif
571ifeq ($(CONFIG_ATAPROMISE), yes)
572UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
573else
574override CONFIG_ATAPROMISE = no
575endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000576ifeq ($(CONFIG_DRKAISER), yes)
577UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
578else
579override CONFIG_DRKAISER = no
580endif
581ifeq ($(CONFIG_NICREALTEK), yes)
582UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
583else
584override CONFIG_NICREALTEK = no
585endif
586ifeq ($(CONFIG_NICNATSEMI), yes)
587UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
588else
589override CONFIG_NICNATSEMI = no
590endif
591ifeq ($(CONFIG_NICINTEL), yes)
592UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
593else
594override CONFIG_NICINTEL = no
595endif
596ifeq ($(CONFIG_NICINTEL_SPI), yes)
597UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
598else
599override CONFIG_NICINTEL_SPI = no
600endif
601ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
602UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
603else
604override CONFIG_NICINTEL_EEPROM = no
605endif
606ifeq ($(CONFIG_OGP_SPI), yes)
607UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
608else
609override CONFIG_OGP_SPI = no
610endif
611ifeq ($(CONFIG_SATAMV), yes)
612UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
613else
614override CONFIG_SATAMV = no
615endif
616ifeq ($(CONFIG_IT8212), yes)
617UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
618else
619override CONFIG_IT8212 = no
620endif
621endif
622
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000623###############################################################################
624# Flash chip drivers and bus support infrastructure.
625
Stefan Tauner4404f732013-09-12 08:28:56 +0000626CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000627 sst28sf040.o 82802ab.o \
Paul Kocialkowski80ae14e2018-01-15 01:07:46 +0300628 sst49lfxxxc.o sst_fwhub.o edi.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Nikolai Artemievadbae0e2020-10-06 16:59:51 +1100629 spi95.o opaque.o sfdp.o en29lv640b.o at45db.o writeprotect.o s25f.o
Sean Nelson5d134642009-12-24 16:54:21 +0000630
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000631###############################################################################
632# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000633
Thomas Heijligen9e090952021-03-31 20:40:01 +0200634LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o programmer_table.o helpers.o ich_descriptors.o fmap.o
Sean Nelson5d134642009-12-24 16:54:21 +0000635
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000636###############################################################################
637# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000638
Stefan Tauner9b32de92014-08-08 23:52:33 +0000639CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000640
Stefan Taunerfa25bc32017-10-04 03:47:26 +0200641# versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
642# imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
643# be obtained using util/getrevision.sh, which is the common case during development.
644-include versioninfo.inc
Stefan Tauner5bf6b852017-10-04 03:46:51 +0200645VERSION ?= $(shell ./util/getrevision.sh --revision)
Stefan Tauner96209122017-10-01 16:41:35 +0200646MAN_DATE ?= $(shell ./util/getrevision.sh --date $(PROGRAM).8.tmpl 2>/dev/null)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000647
Stefan Tauner76347082016-11-27 17:45:49 +0100648SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000649
Stefan Tauner76347082016-11-27 17:45:49 +0100650# No spaces in release names unless set explicitly
651RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/')
652
653# Inform user of the version string
654$(info Replacing all version templates with $(VERSION).)
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000655
Stefan Tauner96209122017-10-01 16:41:35 +0200656# If a VCS is found then try to install hooks.
657$(shell ./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh)
658
Stefan Tauner037cd842013-08-25 00:10:56 +0000659###############################################################################
660# Default settings of CONFIG_* variables.
661
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000662# Always enable internal/onboard support for now.
663CONFIG_INTERNAL ?= yes
664
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000665# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000666CONFIG_SERPROG ?= yes
667
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000668# RayeR SPIPGM hardware support
669CONFIG_RAYER_SPI ?= yes
670
Edward O'Callaghanad08aef2020-03-02 18:16:14 +1100671# ChromiumOS servo DUT debug board hardware support
Edward O'Callaghan732f2ee2020-11-27 12:54:31 +1100672CONFIG_RAIDEN_DEBUG_SPI ?= yes
Edward O'Callaghanad08aef2020-03-02 18:16:14 +1100673
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000674# PonyProg2000 SPI hardware support
675CONFIG_PONY_SPI ?= yes
676
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000677# Always enable 3Com NICs for now.
678CONFIG_NIC3COM ?= yes
679
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000680# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
681CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000682
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000683# Always enable SiI SATA controllers for now.
684CONFIG_SATASII ?= yes
685
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000686# Highpoint (HPT) ATA/RAID controller support.
687# IMPORTANT: This code is not yet working!
688CONFIG_ATAHPT ?= no
689
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000690# VIA VT6421A LPC memory support
691CONFIG_ATAVIA ?= yes
692
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000693# Promise ATA controller support.
694CONFIG_ATAPROMISE ?= no
695
Victor Ding436b4152020-08-19 22:48:19 +1000696# ENE LPC interface keyboard controller
697CONFIG_ENE_LPC ?= yes
698
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000699# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000700CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000701
Victor Ding821e44c2020-08-18 18:27:26 +1000702# Microchip MEC1308 Embedded Controller
703CONFIG_MEC1308 ?= yes
704
James Lairdc60de0e2013-03-27 13:00:23 +0000705# Always enable Altera USB-Blaster dongles for now.
706CONFIG_USBBLASTER_SPI ?= yes
707
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000708# MSTAR DDC support needs more tests/reviews/cleanups.
709CONFIG_MSTARDDC_SPI ?= no
710
Justin Chevrier66e554b2015-02-08 21:58:10 +0000711# Always enable PICkit2 SPI dongles for now.
712CONFIG_PICKIT2_SPI ?= yes
713
Miklós Márton324929c2019-08-01 19:14:10 +0200714# Always enable STLink V3
715CONFIG_STLINKV3_SPI ?= yes
716
Shiyu Sun13a2ef62020-03-19 14:37:57 +1100717# Disables LSPCON support until the i2c helper supports multiple systems.
718CONFIG_LSPCON_I2C_SPI ?= no
719
Edward O'Callaghand97f87b2020-03-26 00:00:41 +1100720# Disables REALTEK_MST support until the i2c helper supports multiple systems.
721CONFIG_REALTEK_MST_I2C_SPI ?= no
722
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000723# Always enable dummy tracing for now.
724CONFIG_DUMMY ?= yes
725
726# Always enable Dr. Kaiser for now.
727CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000728
Joerg Fischer5665ef32010-05-21 21:54:07 +0000729# Always enable Realtek NICs for now.
730CONFIG_NICREALTEK ?= yes
731
Andrew Morganc29c2e72010-06-07 22:37:54 +0000732# Disable National Semiconductor NICs until support is complete and tested.
733CONFIG_NICNATSEMI ?= no
734
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000735# Always enable Intel NICs for now.
736CONFIG_NICINTEL ?= yes
737
Idwer Vollering004f4b72010-09-03 18:21:21 +0000738# Always enable SPI on Intel NICs for now.
739CONFIG_NICINTEL_SPI ?= yes
740
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000741# Always enable EEPROM on Intel NICs for now.
742CONFIG_NICINTEL_EEPROM ?= yes
743
Mark Marshall90021f22010-12-03 14:48:11 +0000744# Always enable SPI on OGP cards for now.
745CONFIG_OGP_SPI ?= yes
746
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000747# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000748CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000749
Simon Glassae616512016-01-23 23:27:58 +0000750# Always enable Dediprog SF100 for now.
751CONFIG_DEDIPROG ?= yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000752
Daniel Thompson45e91a22018-06-04 13:46:29 +0100753# Always enable Developerbox emergency recovery for now.
754CONFIG_DEVELOPERBOX_SPI ?= yes
755
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000756# Always enable Marvell SATA controllers for now.
757CONFIG_SATAMV ?= yes
758
David Hendricksf9a30552015-05-23 20:30:30 -0700759# Enable Linux spidev and MTD interfaces by default. We disable them on non-Linux targets.
760CONFIG_LINUX_MTD ?= yes
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000761CONFIG_LINUX_SPI ?= yes
762
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000763# Always enable ITE IT8212F PATA controllers for now.
764CONFIG_IT8212 ?= yes
765
Urja Rannikko0870b022016-01-31 22:10:29 +0000766# Winchiphead CH341A
767CONFIG_CH341A_SPI ?= yes
768
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100769# Digilent Development board JTAG
770CONFIG_DIGILENT_SPI ?= yes
771
Marc Schink3578ec62016-03-17 16:23:03 +0100772# Disable J-Link for now.
773CONFIG_JLINK_SPI ?= no
774
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000775# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000776CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000777
Stefan Taunerf3503372016-02-26 23:51:21 +0000778# Disable all features if CONFIG_NOTHING=yes is given unless CONFIG_EVERYTHING was also set
779ifeq ($(CONFIG_NOTHING), yes)
780 ifeq ($(CONFIG_EVERYTHING), yes)
781 $(error Setting CONFIG_NOTHING=yes and CONFIG_EVERYTHING=yes does not make sense)
782 endif
783 $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
784 $(if $(filter yes, $($(var))),\
785 $(eval $(var)=no)))
786endif
787
Patrick Georgiced7ab62015-01-19 19:52:34 +0000788# Enable all features if CONFIG_EVERYTHING=yes is given
789ifeq ($(CONFIG_EVERYTHING), yes)
790$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
791 $(if $(filter no, $($(var))),\
792 $(eval $(var)=yes)))
793endif
794
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000795ifeq ($(CONFIG_ENABLE_LIBUSB1_PROGRAMMERS), no)
796override CONFIG_CH341A_SPI = no
797override CONFIG_DEDIPROG = no
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100798override CONFIG_DIGILENT_SPI = no
Daniel Thompson45e91a22018-06-04 13:46:29 +0100799override CONFIG_DEVELOPERBOX_SPI = no
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200800override CONFIG_PICKIT2_SPI = no
Edward O'Callaghan732f2ee2020-11-27 12:54:31 +1100801override CONFIG_RAIDEN_DEBUG_SPI = no
Miklós Márton324929c2019-08-01 19:14:10 +0200802override CONFIG_STLINKV3_SPI = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000803endif
804ifeq ($(CONFIG_ENABLE_LIBPCI_PROGRAMMERS), no)
Stefan Tauner0be072c2016-03-13 15:16:30 +0000805override CONFIG_INTERNAL = no
806override CONFIG_NIC3COM = no
807override CONFIG_GFXNVIDIA = no
808override CONFIG_SATASII = no
809override CONFIG_ATAHPT = no
810override CONFIG_ATAVIA = no
811override CONFIG_ATAPROMISE = no
Victor Dingcf1e8f72020-10-26 18:42:03 +1100812override CONFIG_ENE_LPC = no
Stefan Tauner0be072c2016-03-13 15:16:30 +0000813override CONFIG_IT8212 = no
814override CONFIG_DRKAISER = no
Victor Dingcf1e8f72020-10-26 18:42:03 +1100815override CONFIG_MEC1308 = no
Stefan Tauner0be072c2016-03-13 15:16:30 +0000816override CONFIG_NICREALTEK = no
817override CONFIG_NICNATSEMI = no
818override CONFIG_NICINTEL = no
819override CONFIG_NICINTEL_SPI = no
820override CONFIG_NICINTEL_EEPROM = no
821override CONFIG_OGP_SPI = no
822override CONFIG_SATAMV = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000823endif
824
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000825# Bitbanging SPI infrastructure, default off unless needed.
826ifeq ($(CONFIG_RAYER_SPI), yes)
827override CONFIG_BITBANG_SPI = yes
828else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000829ifeq ($(CONFIG_PONY_SPI), yes)
830override CONFIG_BITBANG_SPI = yes
831else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000832ifeq ($(CONFIG_INTERNAL), yes)
833override CONFIG_BITBANG_SPI = yes
834else
835ifeq ($(CONFIG_NICINTEL_SPI), yes)
836override CONFIG_BITBANG_SPI = yes
837else
Mark Marshall90021f22010-12-03 14:48:11 +0000838ifeq ($(CONFIG_OGP_SPI), yes)
839override CONFIG_BITBANG_SPI = yes
840else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000841CONFIG_BITBANG_SPI ?= no
842endif
843endif
844endif
Mark Marshall90021f22010-12-03 14:48:11 +0000845endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000846endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000847
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000848###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000849# Handle CONFIG_* variables that depend on others set (and verified) above.
850
851# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
852ifeq ($(TARGET_OS), libpayload)
853ifeq ($(CONFIG_INTERNAL), yes)
854ifeq ($(CONFIG_INTERNAL_DMI), no)
855UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
856else
857override CONFIG_INTERNAL_DMI = yes
858endif
859endif
860endif
861
862# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
863CONFIG_INTERNAL_DMI ?= yes
864
865###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000866# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000867# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000868
Thomas Heijligen732aafd2021-06-01 16:22:14 +0200869ifdef CONFIG_DEFAULT_PROGRAMMER_NAME
870FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_$(CONFIG_DEFAULT_PROGRAMMER_NAME)'
871else
872FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_NAME=NULL'
873endif
874
Stefan Tauner265fcac2014-06-02 00:12:23 +0000875FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000876
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000877ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000878FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000879PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000880ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000881PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Nico Huber305f4172013-06-14 11:55:26 +0200882PROGRAMMER_OBJS += ichspi.o dmi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000883ifeq ($(CONFIG_INTERNAL_DMI), yes)
884FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
885endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000886else
887endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000888NEED_LIBPCI += CONFIG_INTERNAL
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000889endif
890
Victor Ding436b4152020-08-19 22:48:19 +1000891ifeq ($(CONFIG_ENE_LPC), yes)
892FEATURE_CFLAGS += -D'CONFIG_ENE_LPC=1'
893PROGRAMMER_OBJS += ene_lpc.o
Victor Ding6d69c182020-10-26 18:40:07 +1100894NEED_RAW_ACCESS += CONFIG_ENE_LPC
Victor Dingcf1e8f72020-10-26 18:42:03 +1100895NEED_LIBPCI += CONFIG_ENE_LPC
Victor Ding436b4152020-08-19 22:48:19 +1000896endif
897
Victor Ding821e44c2020-08-18 18:27:26 +1000898ifeq ($(CONFIG_MEC1308), yes)
899FEATURE_CFLAGS += -D'CONFIG_MEC1308=1'
900PROGRAMMER_OBJS += mec1308.o
Victor Ding6d69c182020-10-26 18:40:07 +1100901NEED_RAW_ACCESS += CONFIG_MEC1308
Victor Dingcf1e8f72020-10-26 18:42:03 +1100902NEED_LIBPCI += CONFIG_MEC1308
Victor Ding821e44c2020-08-18 18:27:26 +1000903endif
904
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000905ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000906FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000907PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000908NEED_SERIAL += CONFIG_SERPROG
909NEED_POSIX_SOCKETS += CONFIG_SERPROG
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000910endif
911
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000912ifeq ($(CONFIG_RAYER_SPI), yes)
913FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
914PROGRAMMER_OBJS += rayer_spi.o
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000915NEED_RAW_ACCESS += CONFIG_RAYER_SPI
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000916endif
917
Edward O'Callaghan732f2ee2020-11-27 12:54:31 +1100918ifeq ($(CONFIG_RAIDEN_DEBUG_SPI), yes)
919FEATURE_CFLAGS += -D'CONFIG_RAIDEN_DEBUG_SPI=1'
Edward O'Callaghanad08aef2020-03-02 18:16:14 +1100920PROGRAMMER_OBJS += raiden_debug_spi.o
921endif
922
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000923ifeq ($(CONFIG_PONY_SPI), yes)
924FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
925PROGRAMMER_OBJS += pony_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000926NEED_SERIAL += CONFIG_PONY_SPI
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000927endif
928
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000929ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000930FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000931PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000932endif
933
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000934ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000935FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000936PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000937NEED_LIBPCI += CONFIG_NIC3COM
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000938endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000939
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000940ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000941FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000942PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000943NEED_LIBPCI += CONFIG_GFXNVIDIA
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000944endif
945
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000946ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000947FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000948PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000949NEED_LIBPCI += CONFIG_SATASII
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000950endif
951
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000952ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000953FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000954PROGRAMMER_OBJS += atahpt.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000955NEED_LIBPCI += CONFIG_ATAHPT
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000956endif
957
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000958ifeq ($(CONFIG_ATAVIA), yes)
959FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
960PROGRAMMER_OBJS += atavia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000961NEED_LIBPCI += CONFIG_ATAVIA
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000962endif
963
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000964ifeq ($(CONFIG_ATAPROMISE), yes)
965FEATURE_CFLAGS += -D'CONFIG_ATAPROMISE=1'
966PROGRAMMER_OBJS += atapromise.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000967NEED_LIBPCI += CONFIG_ATAPROMISE
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000968endif
969
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000970ifeq ($(CONFIG_IT8212), yes)
971FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
972PROGRAMMER_OBJS += it8212.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000973NEED_LIBPCI += CONFIG_IT8212
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000974endif
975
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000976ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000977# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000978FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000979NEED_LIBFTDI += CONFIG_FT2232_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000980PROGRAMMER_OBJS += ft2232_spi.o
981endif
982
983ifeq ($(CONFIG_USBBLASTER_SPI), yes)
984# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000985FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000986NEED_LIBFTDI += CONFIG_USBBLASTER_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000987PROGRAMMER_OBJS += usbblaster_spi.o
988endif
989
Justin Chevrier66e554b2015-02-08 21:58:10 +0000990ifeq ($(CONFIG_PICKIT2_SPI), yes)
991FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
992PROGRAMMER_OBJS += pickit2_spi.o
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200993NEED_LIBUSB1 += CONFIG_PICKIT2_SPI
Justin Chevrier66e554b2015-02-08 21:58:10 +0000994endif
995
Miklós Márton324929c2019-08-01 19:14:10 +0200996ifeq ($(CONFIG_STLINKV3_SPI), yes)
997FEATURE_CFLAGS += -D'CONFIG_STLINKV3_SPI=1'
998PROGRAMMER_OBJS += stlinkv3_spi.o
999NEED_LIBUSB1 += CONFIG_STLINKV3_SPI
1000endif
1001
Shiyu Sun13a2ef62020-03-19 14:37:57 +11001002ifeq ($(CONFIG_LSPCON_I2C_SPI), yes)
1003FEATURE_CFLAGS += -D'CONFIG_LSPCON_I2C_SPI=1'
1004PROGRAMMER_OBJS += lspcon_i2c_spi.o
Shiyu Sun13a2ef62020-03-19 14:37:57 +11001005endif
1006
Edward O'Callaghand97f87b2020-03-26 00:00:41 +11001007ifeq ($(CONFIG_REALTEK_MST_I2C_SPI), yes)
1008FEATURE_CFLAGS += -D'CONFIG_REALTEK_MST_I2C_SPI=1'
1009PROGRAMMER_OBJS += realtek_mst_i2c_spi.o
1010endif
1011
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001012ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001013FTDILIBS := $(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")
1014FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
1015FTDI_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 +00001016FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001017FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Edward O'Callaghandad2f7c2020-10-28 16:05:18 +11001018# We can't set NEED_LIBUSB1 here because that would transform libftdi auto-enabling
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001019# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +00001020endif
1021
1022ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001023FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001024PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +00001025endif
1026
1027ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001028FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001029PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001030NEED_LIBPCI += CONFIG_DRKAISER
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +00001031endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +00001032
Joerg Fischer5665ef32010-05-21 21:54:07 +00001033ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001034FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +00001035PROGRAMMER_OBJS += nicrealtek.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001036NEED_LIBPCI += CONFIG_NICREALTEK
Joerg Fischer5665ef32010-05-21 21:54:07 +00001037endif
1038
Andrew Morganc29c2e72010-06-07 22:37:54 +00001039ifeq ($(CONFIG_NICNATSEMI), yes)
1040FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
1041PROGRAMMER_OBJS += nicnatsemi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001042NEED_LIBPCI += CONFIG_NICNATSEMI
Andrew Morganc29c2e72010-06-07 22:37:54 +00001043endif
1044
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +00001045ifeq ($(CONFIG_NICINTEL), yes)
1046FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
1047PROGRAMMER_OBJS += nicintel.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001048NEED_LIBPCI += CONFIG_NICINTEL
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +00001049endif
1050
Idwer Vollering004f4b72010-09-03 18:21:21 +00001051ifeq ($(CONFIG_NICINTEL_SPI), yes)
1052FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
1053PROGRAMMER_OBJS += nicintel_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001054NEED_LIBPCI += CONFIG_NICINTEL_SPI
Idwer Vollering004f4b72010-09-03 18:21:21 +00001055endif
1056
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +00001057ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
1058FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
1059PROGRAMMER_OBJS += nicintel_eeprom.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001060NEED_LIBPCI += CONFIG_NICINTEL_EEPROM
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +00001061endif
1062
Mark Marshall90021f22010-12-03 14:48:11 +00001063ifeq ($(CONFIG_OGP_SPI), yes)
1064FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
1065PROGRAMMER_OBJS += ogp_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001066NEED_LIBPCI += CONFIG_OGP_SPI
Mark Marshall90021f22010-12-03 14:48:11 +00001067endif
1068
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001069ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
1070FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001071PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001072NEED_SERIAL += CONFIG_BUSPIRATE_SPI
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001073endif
1074
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +00001075ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001076FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +00001077PROGRAMMER_OBJS += dediprog.o
Nico Huberd99a2bd2016-02-18 21:42:49 +00001078NEED_LIBUSB1 += CONFIG_DEDIPROG
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +00001079endif
1080
Daniel Thompson45e91a22018-06-04 13:46:29 +01001081ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
1082FEATURE_CFLAGS += -D'CONFIG_DEVELOPERBOX_SPI=1'
1083PROGRAMMER_OBJS += developerbox_spi.o
1084NEED_LIBUSB1 += CONFIG_DEVELOPERBOX_SPI
1085endif
1086
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +00001087ifeq ($(CONFIG_SATAMV), yes)
1088FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
1089PROGRAMMER_OBJS += satamv.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001090NEED_LIBPCI += CONFIG_SATAMV
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +00001091endif
1092
David Hendricksf9a30552015-05-23 20:30:30 -07001093ifeq ($(CONFIG_LINUX_MTD), yes)
1094# This is a totally ugly hack.
1095FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_MTD_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_MTD=1'")
1096PROGRAMMER_OBJS += linux_mtd.o
1097endif
1098
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +00001099ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +00001100# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001101FEATURE_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 +00001102PROGRAMMER_OBJS += linux_spi.o
1103endif
1104
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001105ifeq ($(CONFIG_MSTARDDC_SPI), yes)
1106# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001107FEATURE_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 +00001108NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001109PROGRAMMER_OBJS += mstarddc_spi.o
1110endif
1111
Urja Rannikko0870b022016-01-31 22:10:29 +00001112ifeq ($(CONFIG_CH341A_SPI), yes)
1113FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
1114PROGRAMMER_OBJS += ch341a_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001115NEED_LIBUSB1 += CONFIG_CH341A_SPI
Urja Rannikko0870b022016-01-31 22:10:29 +00001116endif
1117
Lubomir Rintelb2154e82018-01-14 17:35:33 +01001118ifeq ($(CONFIG_DIGILENT_SPI), yes)
1119FEATURE_CFLAGS += -D'CONFIG_DIGILENT_SPI=1'
1120PROGRAMMER_OBJS += digilent_spi.o
1121NEED_LIBUSB1 += CONFIG_DIGILENT_SPI
1122endif
1123
Marc Schink3578ec62016-03-17 16:23:03 +01001124ifeq ($(CONFIG_JLINK_SPI), yes)
1125NEED_LIBJAYLINK += CONFIG_JLINK_SPI
1126FEATURE_CFLAGS += -D'CONFIG_JLINK_SPI=1'
1127PROGRAMMER_OBJS += jlink_spi.o
1128endif
1129
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001130ifeq ($(CONFIG_NI845X_SPI), yes)
1131FEATURE_CFLAGS += -D'CONFIG_NI845X_SPI=1'
1132
1133ifeq ($(CONFIG_NI845X_LIBRARY_PATH),)
1134# if the user did not specified the NI-845x headers/lib path
1135# do a guess for both 32 and 64 bit Windows versions
1136NI845X_LIBS += -L'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1137NI845X_LIBS += -L'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1138NI845X_INCLUDES += -I'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1139NI845X_INCLUDES += -I'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1140else
1141NI845X_LIBS += -L'$(CONFIG_NI845X_LIBRARY_PATH)'
1142NI845X_INCLUDES += -I'$(CONFIG_NI845X_LIBRARY_PATH)'
1143endif
1144
1145FEATURE_CFLAGS += $(NI845X_INCLUDES)
1146LIBS += -lni845x
1147PROGRAMMER_OBJS += ni845x_spi.o
1148endif
1149
Shiyu Sundc2c83b2020-03-19 16:59:52 +11001150ifeq ($(CONFIG_LINUX_I2C_HELPER), yes)
1151LIB_OBJS += i2c_helper_linux.o
1152FEATURE_CFLAGS += -D'CONFIG_I2C_SUPPORT=1'
1153endif
1154
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001155ifneq ($(NEED_SERIAL), )
Urja Rannikko615ba182017-06-15 15:28:27 +03001156LIB_OBJS += serial.o custom_baud.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +00001157endif
1158
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001159ifneq ($(NEED_POSIX_SOCKETS), )
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001160ifeq ($(TARGET_OS), SunOS)
Stefan Taunerfc3ecc22016-03-13 12:57:03 +00001161LIBS += -lsocket -lnsl
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001162endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +00001163endif
1164
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001165ifneq ($(NEED_LIBPCI), )
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001166CHECK_LIBPCI = yes
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001167# This is a dirty hack, but it saves us from checking all PCI drivers and all platforms manually.
1168# libpci may need raw memory, MSR or PCI port I/O on some platforms.
1169# Individual drivers might have the same needs as well.
1170NEED_RAW_ACCESS += $(NEED_LIBPCI)
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001171FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001172FEATURE_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 +00001173
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001174PROGRAMMER_OBJS += pcidev.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001175ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001176# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001177PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001178else
1179PCILIBS += -lpci
1180endif
1181endif
1182
1183ifneq ($(NEED_RAW_ACCESS), )
1184# Raw memory, MSR or PCI port I/O access.
1185FEATURE_CFLAGS += -D'NEED_RAW_ACCESS=1'
1186PROGRAMMER_OBJS += physmap.o hwaccess.o
1187
1188ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001189# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001190PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001191else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001192ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001193# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001194PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001195else
1196ifeq ($(TARGET_OS), Darwin)
1197# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +00001198PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001199endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001200endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +00001201endif
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001202
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001203endif
1204
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001205
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001206ifneq ($(NEED_LIBUSB1), )
Stefan Taunere49edbb82016-01-31 22:10:14 +00001207CHECK_LIBUSB1 = yes
1208FEATURE_CFLAGS += -D'NEED_LIBUSB1=1'
Edward O'Callaghand3396402020-02-17 12:47:12 +11001209PROGRAMMER_OBJS += usbdev.o usb_device.o
Stefan Taunere49edbb82016-01-31 22:10:14 +00001210# FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
1211ifeq ($(TARGET_OS),$(filter $(TARGET_OS),FreeBSD DragonFlyBSD))
1212USB1LIBS += -lusb
1213else
1214ifeq ($(TARGET_OS),NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +00001215override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
Stefan Taunere49edbb82016-01-31 22:10:14 +00001216USB1LIBS += -lusb-1.0
1217else
Stefan Tauner45207062016-02-19 08:17:24 +00001218USB1LIBS += $(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")
1219override 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 Taunere49edbb82016-01-31 22:10:14 +00001220endif
1221endif
1222endif
1223
Marc Schink3578ec62016-03-17 16:23:03 +01001224ifneq ($(NEED_LIBJAYLINK), )
1225CHECK_LIBJAYLINK = yes
1226JAYLINKLIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libjaylink)
1227override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libjaylink)
1228endif
1229
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001230ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001231FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001232CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001233endif
1234
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001235FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +00001236
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001237# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001238FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001239
Nico Huber8624e8c2012-11-05 21:46:33 +01001240FEATURE_CFLAGS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-D'HAVE_CLOCK_GETTIME=1'")
1241FEATURE_LIBS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-lrt")
1242
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001243LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +00001244OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +00001245
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001246all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001247ifeq ($(ARCH), x86)
1248 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
1249endif
1250
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001251$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001252 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001253
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001254libflashrom.a: $(LIBFLASHROM_OBJS)
1255 $(AR) rcs $@ $^
1256 $(RANLIB) $@
1257
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +00001258# TAROPTIONS reduces information leakage from the packager's system.
1259# If other tar programs support command line arguments for setting uid/gid of
1260# stored files, they can be handled here as well.
1261TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001262
Paul Fox05dfbe62009-06-16 21:08:06 +00001263%.o: %.c .features
Stefan Tauner76347082016-11-27 17:45:49 +01001264 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +00001265
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +00001266# Make sure to add all names of generated binaries here.
1267# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001268# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001269clean:
Stefan Tauner4c723152016-01-14 22:47:55 +00001270 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 +00001271 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001272
Ollie Lho184a4042005-11-26 21:55:36 +00001273distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +00001274 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +00001275
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001276strip: $(PROGRAM)$(EXEC_SUFFIX)
1277 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001278
Stefan Tauner56787082011-08-18 02:27:19 +00001279# to define test programs we use verbatim variables, which get exported
1280# to environment variables and are referenced with $$<varname> later
1281
1282define COMPILER_TEST
1283int main(int argc, char **argv)
1284{
1285 (void) argc;
1286 (void) argv;
1287 return 0;
1288}
1289endef
1290export COMPILER_TEST
1291
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001292compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001293 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001294 @echo "$$COMPILER_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001295 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001296 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
1297 echo "found." || { echo "not found."; \
1298 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 +00001299 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001300 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001301 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001302 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontioda6b3b72020-07-06 12:57:35 +09001303 ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001304 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001305 @printf "Target OS is "
1306 @# FreeBSD wc will output extraneous whitespace.
1307 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontioda6b3b72020-07-06 12:57:35 +09001308 ( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001309 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +00001310ifeq ($(TARGET_OS), libpayload)
1311 @$(CC) --version 2>&1 | grep -q coreboot || \
1312 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
1313 echo "This might work but usually does not, please beware." )
1314endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +00001315
Stefan Tauner56787082011-08-18 02:27:19 +00001316define LIBPCI_TEST
1317/* Avoid a failing test due to libpci header symbol shadowing breakage */
1318#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +00001319#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +00001320#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +00001321#else
1322#include <pciutils/pci.h>
1323#endif
Stefan Tauner56787082011-08-18 02:27:19 +00001324struct pci_access *pacc;
1325int main(int argc, char **argv)
1326{
1327 (void) argc;
1328 (void) argv;
1329 pacc = pci_alloc();
1330 return 0;
1331}
1332endef
1333export LIBPCI_TEST
1334
Stefan Tauner56734502015-02-08 21:58:04 +00001335define PCI_GET_DEV_TEST
1336/* Avoid a failing test due to libpci header symbol shadowing breakage */
1337#define index shadow_workaround_index
1338#if !defined __NetBSD__
1339#include <pci/pci.h>
1340#else
1341#include <pciutils/pci.h>
1342#endif
1343struct pci_access *pacc;
1344struct pci_dev *dev = {0};
1345int main(int argc, char **argv)
1346{
1347 (void) argc;
1348 (void) argv;
1349 pacc = pci_alloc();
1350 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
1351 return 0;
1352}
1353endef
1354export PCI_GET_DEV_TEST
1355
Stefan Taunere49edbb82016-01-31 22:10:14 +00001356define LIBUSB1_TEST
1357#include <stddef.h>
1358#include <libusb.h>
1359int main(int argc, char **argv)
1360{
1361 (void)argc;
1362 (void)argv;
1363 libusb_init(NULL);
1364 return 0;
1365}
1366endef
1367export LIBUSB1_TEST
1368
Marc Schink3578ec62016-03-17 16:23:03 +01001369define LIBJAYLINK_TEST
1370#include <stddef.h>
1371#include <libjaylink/libjaylink.h>
1372int main(int argc, char **argv)
1373{
1374 struct jaylink_context *ctx;
1375
1376 (void)argc;
1377 (void)argv;
1378
1379 jaylink_init(&ctx);
1380 jaylink_exit(ctx);
1381
1382 return 0;
1383}
1384endef
1385export LIBJAYLINK_TEST
1386
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001387hwlibs: compiler
1388 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001389ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001390 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001391 @echo "$$LIBPCI_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001392 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001393 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1394 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001395 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001396 echo "Please install libpci headers or disable all features"; \
1397 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001398 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001399 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
1400 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +00001401 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001402 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001403 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +00001404 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001405 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1406 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001407 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001408 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
1409 echo "yes." || { echo "no."; \
1410 printf "Checking if libz+libpci are present and sufficient..." ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001411 { printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz" >>$(BUILD_DETAILS_FILE) ; \
1412 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001413 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001414 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001415 echo "Please install libpci (package pciutils) and/or libz or disable all features"; \
1416 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001417 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001418 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 +00001419 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001420endif
Stefan Taunere49edbb82016-01-31 22:10:14 +00001421ifeq ($(CHECK_LIBUSB1), yes)
1422 @printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
1423 @echo "$$LIBUSB1_TEST" > .test.c
1424 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1425 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1426 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001427 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001428 echo "Please install libusb-1.0 headers or disable all features"; \
1429 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb82016-01-31 22:10:14 +00001430 echo "See README for more information."; echo; \
1431 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
1432 @printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
1433 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
1434 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
1435 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001436 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001437 echo "Please install libusb-1.0 or disable all features"; \
1438 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb82016-01-31 22:10:14 +00001439 echo "See README for more information."; echo; \
1440 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
1441 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1442endif
Marc Schink3578ec62016-03-17 16:23:03 +01001443ifeq ($(CHECK_LIBJAYLINK), yes)
1444 @printf "Checking for libjaylink headers... " | tee -a $(BUILD_DETAILS_FILE)
1445 @echo "$$LIBJAYLINK_TEST" > .test.c
1446 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1447 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1448 echo "found." || { echo "not found."; echo; \
1449 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1450 echo "Please install libjaylink headers or disable the feature"; \
1451 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1452 echo "See README for more information."; echo; \
1453 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
1454 @printf "Checking if libjaylink is usable... " | tee -a $(BUILD_DETAILS_FILE)
1455 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS)" >>$(BUILD_DETAILS_FILE)
1456 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS) >&2 && \
1457 echo "yes." || { echo "no."; \
1458 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1459 echo "Please install libjaylink or disable the feature"; \
1460 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1461 echo "See README for more information."; echo; \
1462 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
1463 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1464endif
Stefan Reinauer53e96252005-12-01 16:19:24 +00001465
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001466.features: features
1467
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001468# If a user does not explicitly request a non-working feature, we should
1469# silently disable it. However, if a non-working (does not compile) feature
1470# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001471# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001472featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001473ifeq ($(PROGRAMMER_OBJS),)
1474 @echo "You have to enable at least one programmer driver!"
1475 @false
1476endif
1477ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001478 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
1479 @false
1480endif
1481
Stefan Tauner56787082011-08-18 02:27:19 +00001482define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +00001483#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +00001484#include <ftdi.h>
1485struct ftdi_context *ftdic = NULL;
1486int main(int argc, char **argv)
1487{
1488 (void) argc;
1489 (void) argv;
1490 return ftdi_init(ftdic);
1491}
1492endef
1493export FTDI_TEST
1494
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001495define FTDI_232H_TEST
1496#include <ftdi.h>
1497enum ftdi_chip_type type = TYPE_232H;
1498endef
1499export FTDI_232H_TEST
1500
Stefan Tauner56787082011-08-18 02:27:19 +00001501define UTSNAME_TEST
1502#include <sys/utsname.h>
1503struct utsname osinfo;
1504int main(int argc, char **argv)
1505{
1506 (void) argc;
1507 (void) argv;
1508 uname (&osinfo);
1509 return 0;
1510}
1511endef
1512export UTSNAME_TEST
1513
David Hendricksf9a30552015-05-23 20:30:30 -07001514define LINUX_MTD_TEST
1515#include <mtd/mtd-user.h>
1516
1517int main(int argc, char **argv)
1518{
1519 (void) argc;
1520 (void) argv;
1521 return 0;
1522}
1523endef
1524export LINUX_MTD_TEST
1525
Stefan Tauner8868db32012-03-13 00:18:19 +00001526define LINUX_SPI_TEST
1527#include <linux/types.h>
1528#include <linux/spi/spidev.h>
1529
1530int main(int argc, char **argv)
1531{
1532 (void) argc;
1533 (void) argv;
1534 return 0;
1535}
1536endef
1537export LINUX_SPI_TEST
1538
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001539define LINUX_I2C_TEST
1540#include <linux/i2c-dev.h>
1541#include <linux/i2c.h>
1542
1543int main(int argc, char **argv)
1544{
1545 (void) argc;
1546 (void) argv;
1547 return 0;
1548}
1549endef
1550export LINUX_I2C_TEST
1551
Nico Huber8624e8c2012-11-05 21:46:33 +01001552define CLOCK_GETTIME_TEST
1553#include <time.h>
1554
1555int main(int argc, char **argv)
1556{
1557 struct timespec res;
1558 clock_gettime(CLOCK_REALTIME, &res);
1559 return 0;
1560}
1561endef
1562export CLOCK_GETTIME_TEST
1563
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001564define NI845X_TEST
1565#include <ni845x.h>
1566
1567int main(int argc, char **argv)
1568{
1569 (void) argc;
1570 (void) argv;
1571 char I2C_Device[256];
1572 NiHandle Dev_Handle;
1573 uInt32 NumberFound = 0;
1574 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
1575 ni845xCloseFindDeviceHandle(Dev_Handle);
1576 return 0;
1577}
1578endef
1579export NI845X_TEST
1580
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001581features: compiler
1582 @echo "FEATURES := yes" > .features.tmp
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001583ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001584 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001585 @echo "$$FTDI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001586 @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 +00001587 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1588 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
1589 printf "Checking for FT232H support in libftdi... " ; \
1590 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001591 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 +00001592 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1593 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1594 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1595 ) || \
1596 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1597 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001598endif
David Hendricksf9a30552015-05-23 20:30:30 -07001599ifeq ($(CONFIG_LINUX_MTD), yes)
1600 @printf "Checking if Linux MTD headers are present... " | tee -a $(BUILD_DETAILS_FILE)
1601 @echo "$$LINUX_MTD_TEST" > .featuretest.c
1602 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1603 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1604 ( echo "yes."; echo "LINUX_MTD_SUPPORT := yes" >> .features.tmp ) || \
1605 ( echo "no."; echo "LINUX_MTD_SUPPORT := no" >> .features.tmp ) } \
1606 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1607endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001608ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001609 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001610 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001611 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001612 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001613 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001614 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1615 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001616endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001617ifneq ($(NEED_LINUX_I2C), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001618 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001619 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001620 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001621 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001622 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001623 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1624 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001625endif
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001626ifeq ($(CONFIG_NI845X_SPI), yes)
1627 @printf "Checking for NI USB-845x installation... " | tee -a $(BUILD_DETAILS_FILE)
1628 @echo "$$NI845X_TEST" > .featuretest.c
1629 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
1630
1631 @ { { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS) >&2 && \
1632 ( echo "yes."; echo "NI845X_SUPPORT := yes" >> .features.tmp ) || \
1633 { echo -e "\nUnable to find NI-845x headers or libraries."; \
1634 echo "Please pass the NI-845x library path to the make with the CONFIG_NI845X_LIBRARY_PATH parameter,"; \
1635 echo "or disable the NI-845x support by specifying make CONFIG_NI845X_SPI=no"; \
1636 echo "For the NI-845x 17.0 the library path is:"; \
1637 echo " On 32 bit systems: C:\Program Files)\National Instruments\NI-845x\MS Visual C"; \
1638 echo " On 64 bit systems: C:\Program Files (x86)\National Instruments\NI-845x\MS Visual C"; \
1639 exit 1; }; } \
1640 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1641endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001642 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001643 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001644 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001645 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001646 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001647 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Nico Huber8624e8c2012-11-05 21:46:33 +01001648 @printf "Checking for clock_gettime support... " | tee -a $(BUILD_DETAILS_FILE)
Martin Lucina3170bc32020-12-18 14:11:04 +00001649ifeq ($(DISABLE_CLOCK_GETTIME), yes)
1650 @ { ( echo "disabled."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1651 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1652else
Nico Huber8624e8c2012-11-05 21:46:33 +01001653 @echo "$$CLOCK_GETTIME_TEST" >.featuretest.c
1654 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1655 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1656 ( echo "found."; echo "CLOCK_GETTIME := yes" >>.features.tmp ) || \
1657 ( echo "not found."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1658 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Martin Lucina3170bc32020-12-18 14:11:04 +00001659endif
Stefan Tauner56787082011-08-18 02:27:19 +00001660 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1661 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001662
Stefan Tauner4c723152016-01-14 22:47:55 +00001663$(PROGRAM).8.html: $(PROGRAM).8
1664 @groff -mandoc -Thtml $< >$@
1665
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001666$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Tauner4c723152016-01-14 22:47:55 +00001667 @# Add the man page change date and version to the man page
Stefan Taunerf0cbbb02017-10-01 00:49:05 +02001668 @sed -e 's#.TH FLASHROM 8 .*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)" "$(MAN_DATE)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001669
1670install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001671 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001672 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001673 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001674 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001675
Nico Huber454f6132012-12-10 13:34:10 +00001676libinstall: libflashrom.a libflashrom.h
1677 mkdir -p $(DESTDIR)$(PREFIX)/lib
1678 $(INSTALL) -m 0644 libflashrom.a $(DESTDIR)$(PREFIX)/lib
1679 mkdir -p $(DESTDIR)$(PREFIX)/include
1680 $(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include
1681
Stefan Tauner76347082016-11-27 17:45:49 +01001682_export: $(PROGRAM).8
1683 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1684 @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1685 @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
Stefan Tauner2dc5d292017-10-04 02:18:33 +02001686# Generate versioninfo.inc containing metadata that would not be available in exported sources otherwise.
1687 @echo "VERSION = $(VERSION)" > "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
1688 @echo "MAN_DATE = $(MAN_DATE)" >> "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
Stefan Taunere4136852017-10-01 15:57:25 +02001689# Restore modification date of all tracked files not marked 'export-ignore' in .gitattributes.
1690# sed is required to filter out file names having the attribute set.
1691# The sed program saves the file name in the hold buffer and then checks if the respective value is 'set'.
1692# 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 +01001693 @git ls-tree -r -z -t --full-name --name-only HEAD | \
1694 git check-attr -z --stdin export-ignore | \
Stefan Taunere4136852017-10-01 15:57:25 +02001695 sed -zne 'x;n;n;{/^set$$/b;};x;p;' | \
Stefan Tauner76347082016-11-27 17:45:49 +01001696 xargs -0 sh -c 'for f; do \
1697 touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \
1698 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \
Stefan Taunere4136852017-10-01 15:57:25 +02001699 done' dummy_arg0
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001700
Stefan Tauner76347082016-11-27 17:45:49 +01001701export: _export
1702 @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/"
1703
1704tarball: _export
David Hendrickse1a960e2017-10-19 14:54:44 -07001705 @tar -cj --format=ustar -f "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2" -C $(EXPORTDIR)/ \
Stefan Tauner60f7a222017-10-01 15:45:06 +02001706 $(TAROPTIONS) "flashrom-$(RELEASENAME)/"
Stefan Tauner76347082016-11-27 17:45:49 +01001707# Delete the exported directory again because it is most likely what's expected by the user.
1708 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
David Hendrickse1a960e2017-10-19 14:54:44 -07001709 @echo Created "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2"
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001710
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001711libpayload: clean
1712 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001713
Stefan Tauner76347082016-11-27 17:45:49 +01001714.PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001715
Stefan Tauner23e10b82016-01-23 16:16:49 +00001716# Disable implicit suffixes and built-in rules (for performance and profit)
1717.SUFFIXES:
1718
Stefan Reinauere2f01582010-06-07 11:08:07 +00001719-include $(OBJS:.o=.d)