blob: b8b40ca60d54b99d168893c331f3f1a9d0c8edde [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
47# values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options
48# evaluated below, namely those that enable/disable the various programmers).
49# Compilation will fail for unspecified values.
50CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID
Stefan Tauner265fcac2014-06-02 00:12:23 +000051# The following adds a default parameter for the default programmer set above (only).
52CONFIG_DEFAULT_PROGRAMMER_ARGS ?= ''
53# Example: compiling with
54# make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000"
55# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000056
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000057# If your compiler spits out excessive warnings, run make WARNERROR=no
58# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000059WARNERROR ?= yes
60
61ifeq ($(WARNERROR), yes)
62CFLAGS += -Werror
63endif
64
Stefan Taunere37735a2015-01-26 22:03:35 +000065ifdef LIBS_BASE
Stefan Taunere37735a2015-01-26 22:03:35 +000066PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig
Stefan Tauner45207062016-02-19 08:17:24 +000067override CPPFLAGS += -I$(LIBS_BASE)/include
68override LDFLAGS += -L$(LIBS_BASE)/lib -Wl,-rpath -Wl,$(LIBS_BASE)/lib
Stefan Taunere37735a2015-01-26 22:03:35 +000069endif
Stefan Taunerbe62d3f2015-01-10 09:32:44 +000070
Stefan Taunerbfb067b2016-01-07 18:13:07 +000071ifeq ($(CONFIG_STATIC),yes)
Stefan Tauner45207062016-02-19 08:17:24 +000072override PKG_CONFIG += --static
73override LDFLAGS += -static
Stefan Taunerbfb067b2016-01-07 18:13:07 +000074endif
75
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000076# Set LC_ALL=C to minimize influences of the locale.
77# However, this won't work for the majority of relevant commands because they use the $(shell) function and
78# GNU make does not relay variables exported within the makefile to their evironment.
79LC_ALL=C
80export LC_ALL
81
Stefan Tauner3f73ffe2016-01-07 17:45:59 +000082dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUILD_DETAILS_FILE))
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000083
84# Provide an easy way to execute a command, print its output to stdout and capture any error message on stderr
85# in the build details file together with the original stdout output.
Pyry Kontioda6b3b72020-07-06 12:57:35 +090086debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(subst ','\'',$(1)) ; }' >&2; \
87 { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE))
Stefan Tauner1ca7c7f2016-01-14 23:05:55 +000088
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000089###############################################################################
Stefan Tauner037cd842013-08-25 00:10:56 +000090# General OS-specific settings.
91# 1. Prepare for later by gathering information about host and target OS
92# 2. Set compiler flags and parameters according to OSes
93# 3. Likewise verify user-supplied CONFIG_* variables.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000094
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000095# HOST_OS is only used to work around local toolchain issues.
Stefan Tauner037cd842013-08-25 00:10:56 +000096HOST_OS ?= $(shell uname)
Miklós Mártona75a2ed2018-01-30 20:25:00 +010097ifeq ($(findstring MINGW, $(HOST_OS)), MINGW)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000098# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
99CC = gcc
100endif
Miklós Mártona75a2ed2018-01-30 20:25:00 +0100101
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000102ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +0000103STRIP_ARGS = -s
104endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000105
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000106# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000107# IMPORTANT: The following line must be placed before TARGET_OS is ever used
108# (of course), but should come after any lines setting CC because the line
109# below uses CC itself.
Pyry Kontioda6b3b72020-07-06 12:57:35 +0900110override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null \
111 | tail -1 | cut -f 2 -d'"'))
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000112
113ifeq ($(TARGET_OS), Darwin)
Stefan Tauner45207062016-02-19 08:17:24 +0000114override CPPFLAGS += -I/opt/local/include -I/usr/local/include
115override LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +0000116endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000117
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000118ifeq ($(TARGET_OS), FreeBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000119override CPPFLAGS += -I/usr/local/include
120override LDFLAGS += -L/usr/local/lib
Andriy Gapon65c1b862008-05-22 13:22:45 +0000121endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000122
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000123ifeq ($(TARGET_OS), OpenBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000124override CPPFLAGS += -I/usr/local/include
125override LDFLAGS += -L/usr/local/lib
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000126endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000127
Stefan Taunerc65b8552013-09-12 15:48:39 +0000128ifeq ($(TARGET_OS), NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000129override CPPFLAGS += -I/usr/pkg/include
130override LDFLAGS += -L/usr/pkg/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000131endif
132
133ifeq ($(TARGET_OS), DragonFlyBSD)
Stefan Tauner45207062016-02-19 08:17:24 +0000134override CPPFLAGS += -I/usr/local/include
135override LDFLAGS += -L/usr/local/lib
Stefan Taunerc65b8552013-09-12 15:48:39 +0000136endif
137
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000138ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000139EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000140# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Stefan Tauner45207062016-02-19 08:17:24 +0000141override CFLAGS += -Wno-format
Stefan Tauner449abe22013-09-11 23:34:57 +0000142LIBS += -lgetopt
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000143# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000144ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
145UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
146else
147override CONFIG_BUSPIRATE_SPI = no
148endif
149ifeq ($(CONFIG_SERPROG), yes)
150UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
151else
152override CONFIG_SERPROG = no
153endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000154ifeq ($(CONFIG_PONY_SPI), yes)
155UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
156else
157override CONFIG_PONY_SPI = no
158endif
Nico Huber84c6fb52019-06-07 17:35:56 +0200159# Digilent SPI, Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported under DOS (missing USB support).
160ifeq ($(CONFIG_DIGILENT_SPI), yes)
161UNSUPPORTED_FEATURES += CONFIG_DIGILENT_SPI=yes
162else
163override CONFIG_DIGILENT_SPI = no
164endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000165ifeq ($(CONFIG_DEDIPROG), yes)
166UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
167else
168override CONFIG_DEDIPROG = no
169endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100170ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
171UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
172else
173override CONFIG_DEVELOPERBOX_SPI = no
174endif
Victor Ding436b4152020-08-19 22:48:19 +1000175ifeq ($(CONFIG_ENE_LPC), yes)
176UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
177else
178override CONFIG_ENE_LPC = no
179endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000180ifeq ($(CONFIG_FT2232_SPI), yes)
181UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
182else
183override CONFIG_FT2232_SPI = no
184endif
Victor Ding821e44c2020-08-18 18:27:26 +1000185ifeq ($(CONFIG_MEC1308), yes)
186UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
187else
188override CONFIG_MEC1308 = no
189endif
James Lairdc60de0e2013-03-27 13:00:23 +0000190ifeq ($(CONFIG_USBBLASTER_SPI), yes)
191UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
192else
193override CONFIG_USBBLASTER_SPI = no
194endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000195ifeq ($(CONFIG_PICKIT2_SPI), yes)
196UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
197else
198override CONFIG_PICKIT2_SPI = no
199endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000200ifeq ($(CONFIG_CH341A_SPI), yes)
201UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
202else
203override CONFIG_CH341A_SPI = no
204endif
Angel Pons87718aa2021-04-17 17:47:54 +0200205ifeq ($(CONFIG_RAIDEN_DEBUG_SPI), yes)
206UNSUPPORTED_FEATURES += CONFIG_RAIDEN_DEBUG_SPI=yes
207else
208override CONFIG_RAIDEN_DEBUG_SPI = no
209endif
Miklós Márton324929c2019-08-01 19:14:10 +0200210ifeq ($(CONFIG_STLINKV3_SPI), yes)
211UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
212else
213override CONFIG_STLINKV3_SPI = no
214endif
Nico Hubera7246022019-06-07 17:39:18 +0200215# libjaylink is also not available for DOS
216ifeq ($(CONFIG_JLINK_SPI), yes)
217UNSUPPORTED_FEATURES += CONFIG_JLINK_SPI=yes
218else
219override CONFIG_JLINK_SPI = no
220endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000221endif
Ollie Lho184a4042005-11-26 21:55:36 +0000222
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000223# FIXME: Should we check for Cygwin/MSVC as well?
224ifeq ($(TARGET_OS), MinGW)
225EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000226# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000227FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000228# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
Stefan Tauner23e10b82016-01-23 16:16:49 +0000229# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000230FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100231
232# National Instruments USB-845x is Windows only for now
233CONFIG_NI845X_SPI ?= no
234
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000235# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
236ifeq ($(CONFIG_INTERNAL), yes)
237UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
238else
239override CONFIG_INTERNAL = no
240endif
241ifeq ($(CONFIG_RAYER_SPI), yes)
242UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
243else
244override CONFIG_RAYER_SPI = no
245endif
246ifeq ($(CONFIG_NIC3COM), yes)
247UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
248else
249override CONFIG_NIC3COM = no
250endif
251ifeq ($(CONFIG_GFXNVIDIA), yes)
252UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
253else
254override CONFIG_GFXNVIDIA = no
255endif
256ifeq ($(CONFIG_SATASII), yes)
257UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
258else
259override CONFIG_SATASII = no
260endif
261ifeq ($(CONFIG_ATAHPT), yes)
262UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
263else
264override CONFIG_ATAHPT = no
265endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000266ifeq ($(CONFIG_ATAVIA), yes)
267UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
268else
269override CONFIG_ATAVIA = no
270endif
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000271ifeq ($(CONFIG_ATAPROMISE), yes)
272UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
273else
274override CONFIG_ATAPROMISE = no
275endif
Victor Ding436b4152020-08-19 22:48:19 +1000276ifeq ($(CONFIG_ENE_LPC), yes)
277UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
278else
279override CONFIG_ENE_LPC = no
280endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000281ifeq ($(CONFIG_IT8212), yes)
282UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
283else
284override CONFIG_IT8212 = no
285endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000286ifeq ($(CONFIG_DRKAISER), yes)
287UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
288else
289override CONFIG_DRKAISER = no
290endif
Victor Ding821e44c2020-08-18 18:27:26 +1000291ifeq ($(CONFIG_MEC1308), yes)
292UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
293else
294override CONFIG_MEC1308 = no
295endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000296ifeq ($(CONFIG_NICREALTEK), yes)
297UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
298else
299override CONFIG_NICREALTEK = no
300endif
301ifeq ($(CONFIG_NICNATSEMI), yes)
302UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
303else
304override CONFIG_NICNATSEMI = no
305endif
306ifeq ($(CONFIG_NICINTEL), yes)
307UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
308else
309override CONFIG_NICINTEL = no
310endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000311ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
312UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
313else
314override CONFIG_NICINTEL_EEPROM = no
315endif
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000316ifeq ($(CONFIG_NICINTEL_SPI), yes)
317UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
318else
319override CONFIG_NICINTEL_SPI = no
320endif
321ifeq ($(CONFIG_OGP_SPI), yes)
322UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
323else
324override CONFIG_OGP_SPI = no
325endif
326ifeq ($(CONFIG_SATAMV), yes)
327UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
328else
329override CONFIG_SATAMV = no
330endif
331endif
332
Miklós Márton2d20d6d2018-01-30 20:20:15 +0100333ifneq ($(TARGET_OS), MinGW)
334# NI USB-845x only supported on Windows at the moment
335ifeq ($(CONFIG_NI845X_SPI), yes)
336UNSUPPORTED_FEATURES += CONFIG_NI845X_SPI=yes
337else
338override CONFIG_NI845X_SPI = no
339endif
340endif
341
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000342ifeq ($(TARGET_OS), libpayload)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000343ifeq ($(MAKECMDGOALS),)
344.DEFAULT_GOAL := libflashrom.a
345$(info Setting default goal to libflashrom.a)
346endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000347FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000348ifeq ($(CONFIG_DUMMY), yes)
349UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
350else
351override CONFIG_DUMMY = no
352endif
Stefan Taunere0168262016-02-21 11:18:24 +0000353# libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
354ifeq ($(CONFIG_ATAPROMISE), yes)
355UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
356else
357override CONFIG_ATAPROMISE = no
358endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000359# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000360ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
361UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
362else
363override CONFIG_BUSPIRATE_SPI = no
364endif
365ifeq ($(CONFIG_SERPROG), yes)
366UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
367else
368override CONFIG_SERPROG = no
369endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000370ifeq ($(CONFIG_PONY_SPI), yes)
371UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
372else
373override CONFIG_PONY_SPI = no
374endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100375# Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000376ifeq ($(CONFIG_DEDIPROG), yes)
377UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
378else
379override CONFIG_DEDIPROG = no
380endif
Daniel Thompson45e91a22018-06-04 13:46:29 +0100381ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
382UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
383else
384override CONFIG_DEVELOPERBOX_SPI = no
385endif
Victor Ding436b4152020-08-19 22:48:19 +1000386ifeq ($(CONFIG_ENE_LPC), yes)
387UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
388else
389override CONFIG_ENE_LPC = no
390endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000391ifeq ($(CONFIG_FT2232_SPI), yes)
392UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
393else
394override CONFIG_FT2232_SPI = no
395endif
Victor Ding821e44c2020-08-18 18:27:26 +1000396ifeq ($(CONFIG_MEC1308), yes)
397UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
398else
399override CONFIG_MEC1308 = no
400endif
James Lairdc60de0e2013-03-27 13:00:23 +0000401ifeq ($(CONFIG_USBBLASTER_SPI), yes)
402UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
403else
404override CONFIG_USBBLASTER_SPI = no
405endif
Justin Chevrier66e554b2015-02-08 21:58:10 +0000406ifeq ($(CONFIG_PICKIT2_SPI), yes)
407UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
408else
409override CONFIG_PICKIT2_SPI = no
410endif
Miklós Márton324929c2019-08-01 19:14:10 +0200411ifeq ($(CONFIG_STLINKV3_SPI), yes)
412UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
413else
414override CONFIG_STLINKV3_SPI = no
415endif
Urja Rannikko0870b022016-01-31 22:10:29 +0000416ifeq ($(CONFIG_CH341A_SPI), yes)
417UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
418else
419override CONFIG_CH341A_SPI = no
420endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000421endif
422
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000423ifneq ($(TARGET_OS), Linux)
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000424# Android is handled internally as separate OS, but it supports CONFIG_LINUX_SPI and CONFIG_MSTARDDC_SPI
425ifneq ($(TARGET_OS), Android)
David Hendricksf9a30552015-05-23 20:30:30 -0700426ifeq ($(CONFIG_LINUX_MTD), yes)
427UNSUPPORTED_FEATURES += CONFIG_LINUX_MTD=yes
428else
429override CONFIG_LINUX_MTD = no
430endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000431ifeq ($(CONFIG_LINUX_SPI), yes)
432UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
433else
434override CONFIG_LINUX_SPI = no
435endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000436ifeq ($(CONFIG_MSTARDDC_SPI), yes)
437UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
438else
439override CONFIG_MSTARDDC_SPI = no
Angel Pons78853ff2021-05-09 19:01:54 +0200440ifeq ($(CONFIG_LSPCON_I2C_SPI), yes)
441UNSUPPORTED_FEATURES += CONFIG_LSPCON_I2C_SPI=yes
442else
443override CONFIG_LSPCON_I2C_SPI = no
444endif
445ifeq ($(CONFIG_REALTEK_MST_I2C_SPI), yes)
446UNSUPPORTED_FEATURES += CONFIG_REALTEK_MST_I2C_SPI=yes
447else
448override CONFIG_REALTEK_MST_I2C_SPI = no
449endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000450endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000451endif
Carl-Daniel Hailfinger601f4cd2016-02-28 22:04:51 +0000452endif
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000453
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000454ifeq ($(TARGET_OS), Android)
455# Android on x86 (currently) does not provide raw PCI port I/O operations
456ifeq ($(CONFIG_RAYER_SPI), yes)
457UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
458else
459override CONFIG_RAYER_SPI = no
460endif
461endif
462
Shiyu Sundc2c83b2020-03-19 16:59:52 +1100463ifeq ($(TARGET_OS), Linux)
464CONFIG_LINUX_I2C_HELPER = yes
465endif
466
Stefan Tauner037cd842013-08-25 00:10:56 +0000467###############################################################################
468# General architecture-specific settings.
469# Like above for the OS, below we verify user-supplied options depending on the target architecture.
470
Uwe Hermann44ffd582011-08-20 14:16:00 +0000471# Determine the destination processor architecture.
472# IMPORTANT: The following line must be placed before ARCH is ever used
473# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000474# below uses CC itself.
Pyry Kontioda6b3b72020-07-06 12:57:35 +0900475override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null \
476 | tail -1 | cut -f 2 -d'"'))
477override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \
478 | tail -1))
Uwe Hermann44ffd582011-08-20 14:16:00 +0000479
Nico Huberc8801732017-12-01 18:19:43 +0000480# Disable the internal programmer on unsupported architectures (everything but x86 and mipsel)
481ifneq ($(ARCH)-little, $(filter $(ARCH),x86 mips)-$(ENDIAN))
482ifeq ($(CONFIG_INTERNAL), yes)
483UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
484else
485override CONFIG_INTERNAL = no
486endif
487endif
488
Stefan Taunerfb2d77c2015-02-10 08:03:10 +0000489# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
David Hendricksb286da72012-02-13 00:35:35 +0000490# Right now this means the drivers below only work on x86.
491ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000492ifeq ($(CONFIG_NIC3COM), yes)
493UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
494else
495override CONFIG_NIC3COM = no
496endif
497ifeq ($(CONFIG_NICREALTEK), yes)
498UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
499else
500override CONFIG_NICREALTEK = no
501endif
502ifeq ($(CONFIG_NICNATSEMI), yes)
503UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
504else
505override CONFIG_NICNATSEMI = no
506endif
507ifeq ($(CONFIG_RAYER_SPI), yes)
508UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
509else
510override CONFIG_RAYER_SPI = no
511endif
512ifeq ($(CONFIG_ATAHPT), yes)
513UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
514else
515override CONFIG_ATAHPT = no
516endif
Carl-Daniel Hailfingerf636ffc2016-02-20 22:04:39 +0000517ifeq ($(CONFIG_ATAPROMISE), yes)
518UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
519else
520override CONFIG_ATAPROMISE = no
521endif
Uwe Hermann21b10c62011-07-29 12:13:01 +0000522ifeq ($(CONFIG_SATAMV), yes)
523UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
524else
525override CONFIG_SATAMV = no
526endif
Victor Ding1b4de5c2020-11-10 23:46:04 +1100527ifeq ($(CONFIG_ENE_LPC), yes)
528UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
529else
530override CONFIG_ENE_LPC = no
531endif
532ifeq ($(CONFIG_MEC1308), yes)
533UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
534else
535override CONFIG_MEC1308 = no
536endif
Uwe Hermann21b10c62011-07-29 12:13:01 +0000537endif
538
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000539# Disable all drivers needing raw access (memory, PCI, port I/O) on
540# architectures with unknown raw access properties.
541# Right now those architectures are alpha hppa m68k sh s390
Rosen Penev34d07f02019-07-02 00:14:01 -0700542ifneq ($(ARCH),$(filter $(ARCH),x86 mips ppc arm sparc arc))
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000543ifeq ($(CONFIG_RAYER_SPI), yes)
544UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
545else
546override CONFIG_RAYER_SPI = no
547endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000548ifeq ($(CONFIG_NIC3COM), yes)
549UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
550else
551override CONFIG_NIC3COM = no
552endif
553ifeq ($(CONFIG_GFXNVIDIA), yes)
554UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
555else
556override CONFIG_GFXNVIDIA = no
557endif
558ifeq ($(CONFIG_SATASII), yes)
559UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
560else
561override CONFIG_SATASII = no
562endif
563ifeq ($(CONFIG_ATAHPT), yes)
564UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
565else
566override CONFIG_ATAHPT = no
567endif
568ifeq ($(CONFIG_ATAVIA), yes)
569UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
570else
571override CONFIG_ATAVIA = no
572endif
573ifeq ($(CONFIG_ATAPROMISE), yes)
574UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
575else
576override CONFIG_ATAPROMISE = no
577endif
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +0000578ifeq ($(CONFIG_DRKAISER), yes)
579UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
580else
581override CONFIG_DRKAISER = no
582endif
583ifeq ($(CONFIG_NICREALTEK), yes)
584UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
585else
586override CONFIG_NICREALTEK = no
587endif
588ifeq ($(CONFIG_NICNATSEMI), yes)
589UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
590else
591override CONFIG_NICNATSEMI = no
592endif
593ifeq ($(CONFIG_NICINTEL), yes)
594UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
595else
596override CONFIG_NICINTEL = no
597endif
598ifeq ($(CONFIG_NICINTEL_SPI), yes)
599UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
600else
601override CONFIG_NICINTEL_SPI = no
602endif
603ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
604UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
605else
606override CONFIG_NICINTEL_EEPROM = no
607endif
608ifeq ($(CONFIG_OGP_SPI), yes)
609UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
610else
611override CONFIG_OGP_SPI = no
612endif
613ifeq ($(CONFIG_SATAMV), yes)
614UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
615else
616override CONFIG_SATAMV = no
617endif
618ifeq ($(CONFIG_IT8212), yes)
619UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
620else
621override CONFIG_IT8212 = no
622endif
623endif
624
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000625###############################################################################
626# Flash chip drivers and bus support infrastructure.
627
Stefan Tauner4404f732013-09-12 08:28:56 +0000628CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
Carl-Daniel Hailfingera8cf3622014-08-08 08:33:01 +0000629 sst28sf040.o 82802ab.o \
Paul Kocialkowski80ae14e2018-01-15 01:07:46 +0300630 sst49lfxxxc.o sst_fwhub.o edi.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Nikolai Artemievadbae0e2020-10-06 16:59:51 +1100631 spi95.o opaque.o sfdp.o en29lv640b.o at45db.o writeprotect.o s25f.o
Sean Nelson5d134642009-12-24 16:54:21 +0000632
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000633###############################################################################
634# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000635
Arthur Heymansc82900b2018-01-10 12:48:16 +0100636LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o helpers.o ich_descriptors.o fmap.o
Sean Nelson5d134642009-12-24 16:54:21 +0000637
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000638###############################################################################
639# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000640
Stefan Tauner9b32de92014-08-08 23:52:33 +0000641CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000642
Stefan Taunerfa25bc32017-10-04 03:47:26 +0200643# versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
644# imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
645# be obtained using util/getrevision.sh, which is the common case during development.
646-include versioninfo.inc
Stefan Tauner5bf6b852017-10-04 03:46:51 +0200647VERSION ?= $(shell ./util/getrevision.sh --revision)
Stefan Tauner96209122017-10-01 16:41:35 +0200648MAN_DATE ?= $(shell ./util/getrevision.sh --date $(PROGRAM).8.tmpl 2>/dev/null)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000649
Stefan Tauner76347082016-11-27 17:45:49 +0100650SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000651
Stefan Tauner76347082016-11-27 17:45:49 +0100652# No spaces in release names unless set explicitly
653RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/')
654
655# Inform user of the version string
656$(info Replacing all version templates with $(VERSION).)
Stefan Taunerd5ff8452015-01-10 09:32:07 +0000657
Stefan Tauner96209122017-10-01 16:41:35 +0200658# If a VCS is found then try to install hooks.
659$(shell ./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh)
660
Stefan Tauner037cd842013-08-25 00:10:56 +0000661###############################################################################
662# Default settings of CONFIG_* variables.
663
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000664# Always enable internal/onboard support for now.
665CONFIG_INTERNAL ?= yes
666
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000667# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000668CONFIG_SERPROG ?= yes
669
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000670# RayeR SPIPGM hardware support
671CONFIG_RAYER_SPI ?= yes
672
Edward O'Callaghanad08aef2020-03-02 18:16:14 +1100673# ChromiumOS servo DUT debug board hardware support
Edward O'Callaghan732f2ee2020-11-27 12:54:31 +1100674CONFIG_RAIDEN_DEBUG_SPI ?= yes
Edward O'Callaghanad08aef2020-03-02 18:16:14 +1100675
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000676# PonyProg2000 SPI hardware support
677CONFIG_PONY_SPI ?= yes
678
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000679# Always enable 3Com NICs for now.
680CONFIG_NIC3COM ?= yes
681
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000682# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
683CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000684
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000685# Always enable SiI SATA controllers for now.
686CONFIG_SATASII ?= yes
687
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000688# Highpoint (HPT) ATA/RAID controller support.
689# IMPORTANT: This code is not yet working!
690CONFIG_ATAHPT ?= no
691
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000692# VIA VT6421A LPC memory support
693CONFIG_ATAVIA ?= yes
694
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000695# Promise ATA controller support.
696CONFIG_ATAPROMISE ?= no
697
Victor Ding436b4152020-08-19 22:48:19 +1000698# ENE LPC interface keyboard controller
699CONFIG_ENE_LPC ?= yes
700
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000701# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000702CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000703
Victor Ding821e44c2020-08-18 18:27:26 +1000704# Microchip MEC1308 Embedded Controller
705CONFIG_MEC1308 ?= yes
706
James Lairdc60de0e2013-03-27 13:00:23 +0000707# Always enable Altera USB-Blaster dongles for now.
708CONFIG_USBBLASTER_SPI ?= yes
709
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000710# MSTAR DDC support needs more tests/reviews/cleanups.
711CONFIG_MSTARDDC_SPI ?= no
712
Justin Chevrier66e554b2015-02-08 21:58:10 +0000713# Always enable PICkit2 SPI dongles for now.
714CONFIG_PICKIT2_SPI ?= yes
715
Miklós Márton324929c2019-08-01 19:14:10 +0200716# Always enable STLink V3
717CONFIG_STLINKV3_SPI ?= yes
718
Shiyu Sun13a2ef62020-03-19 14:37:57 +1100719# Disables LSPCON support until the i2c helper supports multiple systems.
720CONFIG_LSPCON_I2C_SPI ?= no
721
Edward O'Callaghand97f87b2020-03-26 00:00:41 +1100722# Disables REALTEK_MST support until the i2c helper supports multiple systems.
723CONFIG_REALTEK_MST_I2C_SPI ?= no
724
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000725# Always enable dummy tracing for now.
726CONFIG_DUMMY ?= yes
727
728# Always enable Dr. Kaiser for now.
729CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000730
Joerg Fischer5665ef32010-05-21 21:54:07 +0000731# Always enable Realtek NICs for now.
732CONFIG_NICREALTEK ?= yes
733
Andrew Morganc29c2e72010-06-07 22:37:54 +0000734# Disable National Semiconductor NICs until support is complete and tested.
735CONFIG_NICNATSEMI ?= no
736
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000737# Always enable Intel NICs for now.
738CONFIG_NICINTEL ?= yes
739
Idwer Vollering004f4b72010-09-03 18:21:21 +0000740# Always enable SPI on Intel NICs for now.
741CONFIG_NICINTEL_SPI ?= yes
742
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000743# Always enable EEPROM on Intel NICs for now.
744CONFIG_NICINTEL_EEPROM ?= yes
745
Mark Marshall90021f22010-12-03 14:48:11 +0000746# Always enable SPI on OGP cards for now.
747CONFIG_OGP_SPI ?= yes
748
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000749# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000750CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000751
Simon Glassae616512016-01-23 23:27:58 +0000752# Always enable Dediprog SF100 for now.
753CONFIG_DEDIPROG ?= yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000754
Daniel Thompson45e91a22018-06-04 13:46:29 +0100755# Always enable Developerbox emergency recovery for now.
756CONFIG_DEVELOPERBOX_SPI ?= yes
757
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000758# Always enable Marvell SATA controllers for now.
759CONFIG_SATAMV ?= yes
760
David Hendricksf9a30552015-05-23 20:30:30 -0700761# Enable Linux spidev and MTD interfaces by default. We disable them on non-Linux targets.
762CONFIG_LINUX_MTD ?= yes
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000763CONFIG_LINUX_SPI ?= yes
764
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000765# Always enable ITE IT8212F PATA controllers for now.
766CONFIG_IT8212 ?= yes
767
Urja Rannikko0870b022016-01-31 22:10:29 +0000768# Winchiphead CH341A
769CONFIG_CH341A_SPI ?= yes
770
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100771# Digilent Development board JTAG
772CONFIG_DIGILENT_SPI ?= yes
773
Marc Schink3578ec62016-03-17 16:23:03 +0100774# Disable J-Link for now.
775CONFIG_JLINK_SPI ?= no
776
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000777# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000778CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000779
Stefan Taunerf3503372016-02-26 23:51:21 +0000780# Disable all features if CONFIG_NOTHING=yes is given unless CONFIG_EVERYTHING was also set
781ifeq ($(CONFIG_NOTHING), yes)
782 ifeq ($(CONFIG_EVERYTHING), yes)
783 $(error Setting CONFIG_NOTHING=yes and CONFIG_EVERYTHING=yes does not make sense)
784 endif
785 $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
786 $(if $(filter yes, $($(var))),\
787 $(eval $(var)=no)))
788endif
789
Patrick Georgiced7ab62015-01-19 19:52:34 +0000790# Enable all features if CONFIG_EVERYTHING=yes is given
791ifeq ($(CONFIG_EVERYTHING), yes)
792$(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
793 $(if $(filter no, $($(var))),\
794 $(eval $(var)=yes)))
795endif
796
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000797ifeq ($(CONFIG_ENABLE_LIBUSB1_PROGRAMMERS), no)
798override CONFIG_CH341A_SPI = no
799override CONFIG_DEDIPROG = no
Lubomir Rintelb2154e82018-01-14 17:35:33 +0100800override CONFIG_DIGILENT_SPI = no
Daniel Thompson45e91a22018-06-04 13:46:29 +0100801override CONFIG_DEVELOPERBOX_SPI = no
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200802override CONFIG_PICKIT2_SPI = no
Edward O'Callaghan732f2ee2020-11-27 12:54:31 +1100803override CONFIG_RAIDEN_DEBUG_SPI = no
Miklós Márton324929c2019-08-01 19:14:10 +0200804override CONFIG_STLINKV3_SPI = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000805endif
806ifeq ($(CONFIG_ENABLE_LIBPCI_PROGRAMMERS), no)
Stefan Tauner0be072c2016-03-13 15:16:30 +0000807override CONFIG_INTERNAL = no
808override CONFIG_NIC3COM = no
809override CONFIG_GFXNVIDIA = no
810override CONFIG_SATASII = no
811override CONFIG_ATAHPT = no
812override CONFIG_ATAVIA = no
813override CONFIG_ATAPROMISE = no
Victor Dingcf1e8f72020-10-26 18:42:03 +1100814override CONFIG_ENE_LPC = no
Stefan Tauner0be072c2016-03-13 15:16:30 +0000815override CONFIG_IT8212 = no
816override CONFIG_DRKAISER = no
Victor Dingcf1e8f72020-10-26 18:42:03 +1100817override CONFIG_MEC1308 = no
Stefan Tauner0be072c2016-03-13 15:16:30 +0000818override CONFIG_NICREALTEK = no
819override CONFIG_NICNATSEMI = no
820override CONFIG_NICINTEL = no
821override CONFIG_NICINTEL_SPI = no
822override CONFIG_NICINTEL_EEPROM = no
823override CONFIG_OGP_SPI = no
824override CONFIG_SATAMV = no
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +0000825endif
826
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000827# Bitbanging SPI infrastructure, default off unless needed.
828ifeq ($(CONFIG_RAYER_SPI), yes)
829override CONFIG_BITBANG_SPI = yes
830else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000831ifeq ($(CONFIG_PONY_SPI), yes)
832override CONFIG_BITBANG_SPI = yes
833else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000834ifeq ($(CONFIG_INTERNAL), yes)
835override CONFIG_BITBANG_SPI = yes
836else
837ifeq ($(CONFIG_NICINTEL_SPI), yes)
838override CONFIG_BITBANG_SPI = yes
839else
Mark Marshall90021f22010-12-03 14:48:11 +0000840ifeq ($(CONFIG_OGP_SPI), yes)
841override CONFIG_BITBANG_SPI = yes
842else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000843CONFIG_BITBANG_SPI ?= no
844endif
845endif
846endif
Mark Marshall90021f22010-12-03 14:48:11 +0000847endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000848endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000849
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000850###############################################################################
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000851# Handle CONFIG_* variables that depend on others set (and verified) above.
852
853# The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
854ifeq ($(TARGET_OS), libpayload)
855ifeq ($(CONFIG_INTERNAL), yes)
856ifeq ($(CONFIG_INTERNAL_DMI), no)
857UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
858else
859override CONFIG_INTERNAL_DMI = yes
860endif
861endif
862endif
863
864# Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
865CONFIG_INTERNAL_DMI ?= yes
866
867###############################################################################
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000868# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000869# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000870
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000871FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
Stefan Tauner265fcac2014-06-02 00:12:23 +0000872FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000873
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000874ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000875FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000876PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000877ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000878PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Nico Huber305f4172013-06-14 11:55:26 +0200879PROGRAMMER_OBJS += ichspi.o dmi.o
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000880ifeq ($(CONFIG_INTERNAL_DMI), yes)
881FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
882endif
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000883else
884endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000885NEED_LIBPCI += CONFIG_INTERNAL
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000886endif
887
Victor Ding436b4152020-08-19 22:48:19 +1000888ifeq ($(CONFIG_ENE_LPC), yes)
889FEATURE_CFLAGS += -D'CONFIG_ENE_LPC=1'
890PROGRAMMER_OBJS += ene_lpc.o
Victor Ding6d69c182020-10-26 18:40:07 +1100891NEED_RAW_ACCESS += CONFIG_ENE_LPC
Victor Dingcf1e8f72020-10-26 18:42:03 +1100892NEED_LIBPCI += CONFIG_ENE_LPC
Victor Ding436b4152020-08-19 22:48:19 +1000893endif
894
Victor Ding821e44c2020-08-18 18:27:26 +1000895ifeq ($(CONFIG_MEC1308), yes)
896FEATURE_CFLAGS += -D'CONFIG_MEC1308=1'
897PROGRAMMER_OBJS += mec1308.o
Victor Ding6d69c182020-10-26 18:40:07 +1100898NEED_RAW_ACCESS += CONFIG_MEC1308
Victor Dingcf1e8f72020-10-26 18:42:03 +1100899NEED_LIBPCI += CONFIG_MEC1308
Victor Ding821e44c2020-08-18 18:27:26 +1000900endif
901
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000902ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000903FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000904PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000905NEED_SERIAL += CONFIG_SERPROG
906NEED_POSIX_SOCKETS += CONFIG_SERPROG
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000907endif
908
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000909ifeq ($(CONFIG_RAYER_SPI), yes)
910FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
911PROGRAMMER_OBJS += rayer_spi.o
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +0000912NEED_RAW_ACCESS += CONFIG_RAYER_SPI
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000913endif
914
Edward O'Callaghan732f2ee2020-11-27 12:54:31 +1100915ifeq ($(CONFIG_RAIDEN_DEBUG_SPI), yes)
916FEATURE_CFLAGS += -D'CONFIG_RAIDEN_DEBUG_SPI=1'
Edward O'Callaghanad08aef2020-03-02 18:16:14 +1100917PROGRAMMER_OBJS += raiden_debug_spi.o
918endif
919
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000920ifeq ($(CONFIG_PONY_SPI), yes)
921FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
922PROGRAMMER_OBJS += pony_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000923NEED_SERIAL += CONFIG_PONY_SPI
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000924endif
925
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000926ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000927FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000928PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000929endif
930
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000931ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000932FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000933PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000934NEED_LIBPCI += CONFIG_NIC3COM
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000935endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000936
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000937ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000938FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000939PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000940NEED_LIBPCI += CONFIG_GFXNVIDIA
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000941endif
942
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000943ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000944FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000945PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000946NEED_LIBPCI += CONFIG_SATASII
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000947endif
948
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000949ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000950FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000951PROGRAMMER_OBJS += atahpt.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000952NEED_LIBPCI += CONFIG_ATAHPT
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000953endif
954
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000955ifeq ($(CONFIG_ATAVIA), yes)
956FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
957PROGRAMMER_OBJS += atavia.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000958NEED_LIBPCI += CONFIG_ATAVIA
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000959endif
960
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000961ifeq ($(CONFIG_ATAPROMISE), yes)
962FEATURE_CFLAGS += -D'CONFIG_ATAPROMISE=1'
963PROGRAMMER_OBJS += atapromise.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000964NEED_LIBPCI += CONFIG_ATAPROMISE
Joseph C. Lehnerc2644a32016-01-16 23:45:25 +0000965endif
966
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000967ifeq ($(CONFIG_IT8212), yes)
968FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
969PROGRAMMER_OBJS += it8212.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000970NEED_LIBPCI += CONFIG_IT8212
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000971endif
972
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000973ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000974# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000975FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000976NEED_LIBFTDI += CONFIG_FT2232_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000977PROGRAMMER_OBJS += ft2232_spi.o
978endif
979
980ifeq ($(CONFIG_USBBLASTER_SPI), yes)
981# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +0000982FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +0000983NEED_LIBFTDI += CONFIG_USBBLASTER_SPI
James Lairdc60de0e2013-03-27 13:00:23 +0000984PROGRAMMER_OBJS += usbblaster_spi.o
985endif
986
Justin Chevrier66e554b2015-02-08 21:58:10 +0000987ifeq ($(CONFIG_PICKIT2_SPI), yes)
988FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
989PROGRAMMER_OBJS += pickit2_spi.o
Thomas Heijligenb221cd72019-04-05 15:08:35 +0200990NEED_LIBUSB1 += CONFIG_PICKIT2_SPI
Justin Chevrier66e554b2015-02-08 21:58:10 +0000991endif
992
Miklós Márton324929c2019-08-01 19:14:10 +0200993ifeq ($(CONFIG_STLINKV3_SPI), yes)
994FEATURE_CFLAGS += -D'CONFIG_STLINKV3_SPI=1'
995PROGRAMMER_OBJS += stlinkv3_spi.o
996NEED_LIBUSB1 += CONFIG_STLINKV3_SPI
997endif
998
Shiyu Sun13a2ef62020-03-19 14:37:57 +1100999ifeq ($(CONFIG_LSPCON_I2C_SPI), yes)
1000FEATURE_CFLAGS += -D'CONFIG_LSPCON_I2C_SPI=1'
1001PROGRAMMER_OBJS += lspcon_i2c_spi.o
Shiyu Sun13a2ef62020-03-19 14:37:57 +11001002endif
1003
Edward O'Callaghand97f87b2020-03-26 00:00:41 +11001004ifeq ($(CONFIG_REALTEK_MST_I2C_SPI), yes)
1005FEATURE_CFLAGS += -D'CONFIG_REALTEK_MST_I2C_SPI=1'
1006PROGRAMMER_OBJS += realtek_mst_i2c_spi.o
1007endif
1008
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001009ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001010FTDILIBS := $(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")
1011FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
1012FTDI_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 +00001013FEATURE_CFLAGS += $(FTDI_INCLUDES)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001014FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Edward O'Callaghandad2f7c2020-10-28 16:05:18 +11001015# We can't set NEED_LIBUSB1 here because that would transform libftdi auto-enabling
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001016# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +00001017endif
1018
1019ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001020FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001021PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +00001022endif
1023
1024ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001025FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001026PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001027NEED_LIBPCI += CONFIG_DRKAISER
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +00001028endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +00001029
Joerg Fischer5665ef32010-05-21 21:54:07 +00001030ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001031FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +00001032PROGRAMMER_OBJS += nicrealtek.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001033NEED_LIBPCI += CONFIG_NICREALTEK
Joerg Fischer5665ef32010-05-21 21:54:07 +00001034endif
1035
Andrew Morganc29c2e72010-06-07 22:37:54 +00001036ifeq ($(CONFIG_NICNATSEMI), yes)
1037FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
1038PROGRAMMER_OBJS += nicnatsemi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001039NEED_LIBPCI += CONFIG_NICNATSEMI
Andrew Morganc29c2e72010-06-07 22:37:54 +00001040endif
1041
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +00001042ifeq ($(CONFIG_NICINTEL), yes)
1043FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
1044PROGRAMMER_OBJS += nicintel.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001045NEED_LIBPCI += CONFIG_NICINTEL
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +00001046endif
1047
Idwer Vollering004f4b72010-09-03 18:21:21 +00001048ifeq ($(CONFIG_NICINTEL_SPI), yes)
1049FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
1050PROGRAMMER_OBJS += nicintel_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001051NEED_LIBPCI += CONFIG_NICINTEL_SPI
Idwer Vollering004f4b72010-09-03 18:21:21 +00001052endif
1053
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +00001054ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
1055FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
1056PROGRAMMER_OBJS += nicintel_eeprom.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001057NEED_LIBPCI += CONFIG_NICINTEL_EEPROM
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +00001058endif
1059
Mark Marshall90021f22010-12-03 14:48:11 +00001060ifeq ($(CONFIG_OGP_SPI), yes)
1061FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
1062PROGRAMMER_OBJS += ogp_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001063NEED_LIBPCI += CONFIG_OGP_SPI
Mark Marshall90021f22010-12-03 14:48:11 +00001064endif
1065
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001066ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
1067FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001068PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001069NEED_SERIAL += CONFIG_BUSPIRATE_SPI
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001070endif
1071
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +00001072ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001073FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +00001074PROGRAMMER_OBJS += dediprog.o
Nico Huberd99a2bd2016-02-18 21:42:49 +00001075NEED_LIBUSB1 += CONFIG_DEDIPROG
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +00001076endif
1077
Daniel Thompson45e91a22018-06-04 13:46:29 +01001078ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
1079FEATURE_CFLAGS += -D'CONFIG_DEVELOPERBOX_SPI=1'
1080PROGRAMMER_OBJS += developerbox_spi.o
1081NEED_LIBUSB1 += CONFIG_DEVELOPERBOX_SPI
1082endif
1083
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +00001084ifeq ($(CONFIG_SATAMV), yes)
1085FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
1086PROGRAMMER_OBJS += satamv.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001087NEED_LIBPCI += CONFIG_SATAMV
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +00001088endif
1089
David Hendricksf9a30552015-05-23 20:30:30 -07001090ifeq ($(CONFIG_LINUX_MTD), yes)
1091# This is a totally ugly hack.
1092FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_MTD_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_MTD=1'")
1093PROGRAMMER_OBJS += linux_mtd.o
1094endif
1095
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +00001096ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +00001097# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001098FEATURE_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 +00001099PROGRAMMER_OBJS += linux_spi.o
1100endif
1101
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001102ifeq ($(CONFIG_MSTARDDC_SPI), yes)
1103# This is a totally ugly hack.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001104FEATURE_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 +00001105NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001106PROGRAMMER_OBJS += mstarddc_spi.o
1107endif
1108
Urja Rannikko0870b022016-01-31 22:10:29 +00001109ifeq ($(CONFIG_CH341A_SPI), yes)
1110FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
1111PROGRAMMER_OBJS += ch341a_spi.o
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001112NEED_LIBUSB1 += CONFIG_CH341A_SPI
Urja Rannikko0870b022016-01-31 22:10:29 +00001113endif
1114
Lubomir Rintelb2154e82018-01-14 17:35:33 +01001115ifeq ($(CONFIG_DIGILENT_SPI), yes)
1116FEATURE_CFLAGS += -D'CONFIG_DIGILENT_SPI=1'
1117PROGRAMMER_OBJS += digilent_spi.o
1118NEED_LIBUSB1 += CONFIG_DIGILENT_SPI
1119endif
1120
Marc Schink3578ec62016-03-17 16:23:03 +01001121ifeq ($(CONFIG_JLINK_SPI), yes)
1122NEED_LIBJAYLINK += CONFIG_JLINK_SPI
1123FEATURE_CFLAGS += -D'CONFIG_JLINK_SPI=1'
1124PROGRAMMER_OBJS += jlink_spi.o
1125endif
1126
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001127ifeq ($(CONFIG_NI845X_SPI), yes)
1128FEATURE_CFLAGS += -D'CONFIG_NI845X_SPI=1'
1129
1130ifeq ($(CONFIG_NI845X_LIBRARY_PATH),)
1131# if the user did not specified the NI-845x headers/lib path
1132# do a guess for both 32 and 64 bit Windows versions
1133NI845X_LIBS += -L'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1134NI845X_LIBS += -L'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1135NI845X_INCLUDES += -I'${PROGRAMFILES}\National Instruments\NI-845x\MS Visual C'
1136NI845X_INCLUDES += -I'${PROGRAMFILES(x86)}\National Instruments\NI-845x\MS Visual C'
1137else
1138NI845X_LIBS += -L'$(CONFIG_NI845X_LIBRARY_PATH)'
1139NI845X_INCLUDES += -I'$(CONFIG_NI845X_LIBRARY_PATH)'
1140endif
1141
1142FEATURE_CFLAGS += $(NI845X_INCLUDES)
1143LIBS += -lni845x
1144PROGRAMMER_OBJS += ni845x_spi.o
1145endif
1146
Shiyu Sundc2c83b2020-03-19 16:59:52 +11001147ifeq ($(CONFIG_LINUX_I2C_HELPER), yes)
1148LIB_OBJS += i2c_helper_linux.o
1149FEATURE_CFLAGS += -D'CONFIG_I2C_SUPPORT=1'
1150endif
1151
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001152ifneq ($(NEED_SERIAL), )
Urja Rannikko615ba182017-06-15 15:28:27 +03001153LIB_OBJS += serial.o custom_baud.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +00001154endif
1155
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001156ifneq ($(NEED_POSIX_SOCKETS), )
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001157ifeq ($(TARGET_OS), SunOS)
Stefan Taunerfc3ecc22016-03-13 12:57:03 +00001158LIBS += -lsocket -lnsl
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +00001159endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +00001160endif
1161
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001162ifneq ($(NEED_LIBPCI), )
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001163CHECK_LIBPCI = yes
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001164# This is a dirty hack, but it saves us from checking all PCI drivers and all platforms manually.
1165# libpci may need raw memory, MSR or PCI port I/O on some platforms.
1166# Individual drivers might have the same needs as well.
1167NEED_RAW_ACCESS += $(NEED_LIBPCI)
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001168FEATURE_CFLAGS += -D'NEED_PCI=1'
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001169FEATURE_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 +00001170
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001171PROGRAMMER_OBJS += pcidev.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001172ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001173# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001174PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001175else
1176PCILIBS += -lpci
1177endif
1178endif
1179
1180ifneq ($(NEED_RAW_ACCESS), )
1181# Raw memory, MSR or PCI port I/O access.
1182FEATURE_CFLAGS += -D'NEED_RAW_ACCESS=1'
1183PROGRAMMER_OBJS += physmap.o hwaccess.o
1184
1185ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +00001186# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001187PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001188else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001189ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001190# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001191PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001192else
1193ifeq ($(TARGET_OS), Darwin)
1194# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +00001195PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +00001196endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001197endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +00001198endif
Carl-Daniel Hailfinger16c0aec2016-02-20 21:43:56 +00001199
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +00001200endif
1201
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001202
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001203ifneq ($(NEED_LIBUSB1), )
Stefan Taunere49edbb82016-01-31 22:10:14 +00001204CHECK_LIBUSB1 = yes
1205FEATURE_CFLAGS += -D'NEED_LIBUSB1=1'
Edward O'Callaghand3396402020-02-17 12:47:12 +11001206PROGRAMMER_OBJS += usbdev.o usb_device.o
Stefan Taunere49edbb82016-01-31 22:10:14 +00001207# FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
1208ifeq ($(TARGET_OS),$(filter $(TARGET_OS),FreeBSD DragonFlyBSD))
1209USB1LIBS += -lusb
1210else
1211ifeq ($(TARGET_OS),NetBSD)
Stefan Tauner45207062016-02-19 08:17:24 +00001212override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
Stefan Taunere49edbb82016-01-31 22:10:14 +00001213USB1LIBS += -lusb-1.0
1214else
Stefan Tauner45207062016-02-19 08:17:24 +00001215USB1LIBS += $(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")
1216override 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 +00001217endif
1218endif
1219endif
1220
Marc Schink3578ec62016-03-17 16:23:03 +01001221ifneq ($(NEED_LIBJAYLINK), )
1222CHECK_LIBJAYLINK = yes
1223JAYLINKLIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libjaylink)
1224override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libjaylink)
1225endif
1226
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001227ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +00001228FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +00001229CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +00001230endif
1231
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001232FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +00001233
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001234# We could use PULLED_IN_LIBS, but that would be ugly.
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001235FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001236
Nico Huber8624e8c2012-11-05 21:46:33 +01001237FEATURE_CFLAGS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-D'HAVE_CLOCK_GETTIME=1'")
1238FEATURE_LIBS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-lrt")
1239
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001240LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +00001241OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +00001242
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001243all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001244ifeq ($(ARCH), x86)
1245 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
1246endif
1247
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001248$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001249 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS) $(JAYLINKLIBS) $(NI845X_LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001250
Patrick Georgi97bc95c2011-03-08 07:17:44 +00001251libflashrom.a: $(LIBFLASHROM_OBJS)
1252 $(AR) rcs $@ $^
1253 $(RANLIB) $@
1254
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +00001255# TAROPTIONS reduces information leakage from the packager's system.
1256# If other tar programs support command line arguments for setting uid/gid of
1257# stored files, they can be handled here as well.
1258TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001259
Paul Fox05dfbe62009-06-16 21:08:06 +00001260%.o: %.c .features
Stefan Tauner76347082016-11-27 17:45:49 +01001261 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +00001262
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +00001263# Make sure to add all names of generated binaries here.
1264# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001265# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00001266clean:
Stefan Tauner4c723152016-01-14 22:47:55 +00001267 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 +00001268 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001269
Ollie Lho184a4042005-11-26 21:55:36 +00001270distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +00001271 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +00001272
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001273strip: $(PROGRAM)$(EXEC_SUFFIX)
1274 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001275
Stefan Tauner56787082011-08-18 02:27:19 +00001276# to define test programs we use verbatim variables, which get exported
1277# to environment variables and are referenced with $$<varname> later
1278
1279define COMPILER_TEST
1280int main(int argc, char **argv)
1281{
1282 (void) argc;
1283 (void) argv;
1284 return 0;
1285}
1286endef
1287export COMPILER_TEST
1288
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001289compiler: featuresavailable
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001290 @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001291 @echo "$$COMPILER_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001292 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001293 @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
1294 echo "found." || { echo "not found."; \
1295 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 +00001296 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001297 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001298 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001299 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontioda6b3b72020-07-06 12:57:35 +09001300 ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +00001301 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001302 @printf "Target OS is "
1303 @# FreeBSD wc will output extraneous whitespace.
1304 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Pyry Kontioda6b3b72020-07-06 12:57:35 +09001305 ( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001306 @printf "%s\n" '$(TARGET_OS)'
Stefan Taunerd6c17f62013-09-12 14:04:31 +00001307ifeq ($(TARGET_OS), libpayload)
1308 @$(CC) --version 2>&1 | grep -q coreboot || \
1309 ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
1310 echo "This might work but usually does not, please beware." )
1311endif
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +00001312
Stefan Tauner56787082011-08-18 02:27:19 +00001313define LIBPCI_TEST
1314/* Avoid a failing test due to libpci header symbol shadowing breakage */
1315#define index shadow_workaround_index
Stefan Tauner8d21ff12015-01-10 09:33:06 +00001316#if !defined __NetBSD__
Stefan Tauner56787082011-08-18 02:27:19 +00001317#include <pci/pci.h>
Stefan Taunerc65b8552013-09-12 15:48:39 +00001318#else
1319#include <pciutils/pci.h>
1320#endif
Stefan Tauner56787082011-08-18 02:27:19 +00001321struct pci_access *pacc;
1322int main(int argc, char **argv)
1323{
1324 (void) argc;
1325 (void) argv;
1326 pacc = pci_alloc();
1327 return 0;
1328}
1329endef
1330export LIBPCI_TEST
1331
Stefan Tauner56734502015-02-08 21:58:04 +00001332define PCI_GET_DEV_TEST
1333/* Avoid a failing test due to libpci header symbol shadowing breakage */
1334#define index shadow_workaround_index
1335#if !defined __NetBSD__
1336#include <pci/pci.h>
1337#else
1338#include <pciutils/pci.h>
1339#endif
1340struct pci_access *pacc;
1341struct pci_dev *dev = {0};
1342int main(int argc, char **argv)
1343{
1344 (void) argc;
1345 (void) argv;
1346 pacc = pci_alloc();
1347 dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
1348 return 0;
1349}
1350endef
1351export PCI_GET_DEV_TEST
1352
Stefan Taunere49edbb82016-01-31 22:10:14 +00001353define LIBUSB1_TEST
1354#include <stddef.h>
1355#include <libusb.h>
1356int main(int argc, char **argv)
1357{
1358 (void)argc;
1359 (void)argv;
1360 libusb_init(NULL);
1361 return 0;
1362}
1363endef
1364export LIBUSB1_TEST
1365
Marc Schink3578ec62016-03-17 16:23:03 +01001366define LIBJAYLINK_TEST
1367#include <stddef.h>
1368#include <libjaylink/libjaylink.h>
1369int main(int argc, char **argv)
1370{
1371 struct jaylink_context *ctx;
1372
1373 (void)argc;
1374 (void)argv;
1375
1376 jaylink_init(&ctx);
1377 jaylink_exit(ctx);
1378
1379 return 0;
1380}
1381endef
1382export LIBJAYLINK_TEST
1383
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001384hwlibs: compiler
1385 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001386ifeq ($(CHECK_LIBPCI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001387 @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001388 @echo "$$LIBPCI_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001389 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001390 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1391 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001392 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001393 echo "Please install libpci headers or disable all features"; \
1394 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001395 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001396 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
1397 @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56734502015-02-08 21:58:04 +00001398 @echo "$$PCI_GET_DEV_TEST" > .test.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001399 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001400 @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
Stefan Tauner56734502015-02-08 21:58:04 +00001401 ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001402 ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1403 @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001404 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001405 @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
1406 echo "yes." || { echo "no."; \
1407 printf "Checking if libz+libpci are present and sufficient..." ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001408 { printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz" >>$(BUILD_DETAILS_FILE) ; \
1409 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001410 echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001411 echo "The following features require libpci: $(NEED_LIBPCI)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001412 echo "Please install libpci (package pciutils) and/or libz or disable all features"; \
1413 echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +00001414 echo "See README for more information."; echo; \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001415 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 +00001416 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +00001417endif
Stefan Taunere49edbb82016-01-31 22:10:14 +00001418ifeq ($(CHECK_LIBUSB1), yes)
1419 @printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
1420 @echo "$$LIBUSB1_TEST" > .test.c
1421 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1422 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1423 echo "found." || { echo "not found."; echo; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001424 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001425 echo "Please install libusb-1.0 headers or disable all features"; \
1426 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb82016-01-31 22:10:14 +00001427 echo "See README for more information."; echo; \
1428 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
1429 @printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
1430 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
1431 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
1432 echo "yes." || { echo "no."; \
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001433 echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
Carl-Daniel Hailfinger4b2b3152016-02-20 22:28:16 +00001434 echo "Please install libusb-1.0 or disable all features"; \
1435 echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
Stefan Taunere49edbb82016-01-31 22:10:14 +00001436 echo "See README for more information."; echo; \
1437 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
1438 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1439endif
Marc Schink3578ec62016-03-17 16:23:03 +01001440ifeq ($(CHECK_LIBJAYLINK), yes)
1441 @printf "Checking for libjaylink headers... " | tee -a $(BUILD_DETAILS_FILE)
1442 @echo "$$LIBJAYLINK_TEST" > .test.c
1443 @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
1444 @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
1445 echo "found." || { echo "not found."; echo; \
1446 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1447 echo "Please install libjaylink headers or disable the feature"; \
1448 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1449 echo "See README for more information."; echo; \
1450 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
1451 @printf "Checking if libjaylink is usable... " | tee -a $(BUILD_DETAILS_FILE)
1452 @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS)" >>$(BUILD_DETAILS_FILE)
1453 @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(JAYLINKLIBS) >&2 && \
1454 echo "yes." || { echo "no."; \
1455 echo "The following feature requires libjaylink: $(NEED_LIBJAYLINK)."; \
1456 echo "Please install libjaylink or disable the feature"; \
1457 echo "mentioned above by specifying make CONFIG_JLINK_SPI=no"; \
1458 echo "See README for more information."; echo; \
1459 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
1460 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
1461endif
Stefan Reinauer53e96252005-12-01 16:19:24 +00001462
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001463.features: features
1464
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001465# If a user does not explicitly request a non-working feature, we should
1466# silently disable it. However, if a non-working (does not compile) feature
1467# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001468# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001469featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +00001470ifeq ($(PROGRAMMER_OBJS),)
1471 @echo "You have to enable at least one programmer driver!"
1472 @false
1473endif
1474ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +00001475 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
1476 @false
1477endif
1478
Stefan Tauner56787082011-08-18 02:27:19 +00001479define FTDI_TEST
Stefan Tauner5c316f92015-02-08 21:57:52 +00001480#include <stdlib.h>
Stefan Tauner56787082011-08-18 02:27:19 +00001481#include <ftdi.h>
1482struct ftdi_context *ftdic = NULL;
1483int main(int argc, char **argv)
1484{
1485 (void) argc;
1486 (void) argv;
1487 return ftdi_init(ftdic);
1488}
1489endef
1490export FTDI_TEST
1491
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +00001492define FTDI_232H_TEST
1493#include <ftdi.h>
1494enum ftdi_chip_type type = TYPE_232H;
1495endef
1496export FTDI_232H_TEST
1497
Stefan Tauner56787082011-08-18 02:27:19 +00001498define UTSNAME_TEST
1499#include <sys/utsname.h>
1500struct utsname osinfo;
1501int main(int argc, char **argv)
1502{
1503 (void) argc;
1504 (void) argv;
1505 uname (&osinfo);
1506 return 0;
1507}
1508endef
1509export UTSNAME_TEST
1510
David Hendricksf9a30552015-05-23 20:30:30 -07001511define LINUX_MTD_TEST
1512#include <mtd/mtd-user.h>
1513
1514int main(int argc, char **argv)
1515{
1516 (void) argc;
1517 (void) argv;
1518 return 0;
1519}
1520endef
1521export LINUX_MTD_TEST
1522
Stefan Tauner8868db32012-03-13 00:18:19 +00001523define LINUX_SPI_TEST
1524#include <linux/types.h>
1525#include <linux/spi/spidev.h>
1526
1527int main(int argc, char **argv)
1528{
1529 (void) argc;
1530 (void) argv;
1531 return 0;
1532}
1533endef
1534export LINUX_SPI_TEST
1535
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001536define LINUX_I2C_TEST
1537#include <linux/i2c-dev.h>
1538#include <linux/i2c.h>
1539
1540int main(int argc, char **argv)
1541{
1542 (void) argc;
1543 (void) argv;
1544 return 0;
1545}
1546endef
1547export LINUX_I2C_TEST
1548
Nico Huber8624e8c2012-11-05 21:46:33 +01001549define CLOCK_GETTIME_TEST
1550#include <time.h>
1551
1552int main(int argc, char **argv)
1553{
1554 struct timespec res;
1555 clock_gettime(CLOCK_REALTIME, &res);
1556 return 0;
1557}
1558endef
1559export CLOCK_GETTIME_TEST
1560
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001561define NI845X_TEST
1562#include <ni845x.h>
1563
1564int main(int argc, char **argv)
1565{
1566 (void) argc;
1567 (void) argv;
1568 char I2C_Device[256];
1569 NiHandle Dev_Handle;
1570 uInt32 NumberFound = 0;
1571 ni845xFindDevice(I2C_Device, &Dev_Handle, &NumberFound);
1572 ni845xCloseFindDeviceHandle(Dev_Handle);
1573 return 0;
1574}
1575endef
1576export NI845X_TEST
1577
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +00001578features: compiler
1579 @echo "FEATURES := yes" > .features.tmp
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001580ifneq ($(NEED_LIBFTDI), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001581 @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001582 @echo "$$FTDI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001583 @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 +00001584 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1585 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
1586 printf "Checking for FT232H support in libftdi... " ; \
1587 echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001588 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 +00001589 { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
1590 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
1591 ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
1592 ) || \
1593 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
1594 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +00001595endif
David Hendricksf9a30552015-05-23 20:30:30 -07001596ifeq ($(CONFIG_LINUX_MTD), yes)
1597 @printf "Checking if Linux MTD headers are present... " | tee -a $(BUILD_DETAILS_FILE)
1598 @echo "$$LINUX_MTD_TEST" > .featuretest.c
1599 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1600 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1601 ( echo "yes."; echo "LINUX_MTD_SUPPORT := yes" >> .features.tmp ) || \
1602 ( echo "no."; echo "LINUX_MTD_SUPPORT := no" >> .features.tmp ) } \
1603 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1604endif
Stefan Tauner8868db32012-03-13 00:18:19 +00001605ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001606 @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001607 @echo "$$LINUX_SPI_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001608 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001609 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner8868db32012-03-13 00:18:19 +00001610 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001611 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
1612 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner8868db32012-03-13 00:18:19 +00001613endif
Carl-Daniel Hailfingerf2daaca2016-02-17 22:25:12 +00001614ifneq ($(NEED_LINUX_I2C), )
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001615 @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001616 @echo "$$LINUX_I2C_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001617 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001618 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001619 ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001620 ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
1621 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Alexandre Boeglin80e64712014-12-20 20:25:19 +00001622endif
Miklós Márton2d20d6d2018-01-30 20:20:15 +01001623ifeq ($(CONFIG_NI845X_SPI), yes)
1624 @printf "Checking for NI USB-845x installation... " | tee -a $(BUILD_DETAILS_FILE)
1625 @echo "$$NI845X_TEST" > .featuretest.c
1626 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
1627
1628 @ { { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(NI845X_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(NI845X_LIBS) $(LIBS) >&2 && \
1629 ( echo "yes."; echo "NI845X_SUPPORT := yes" >> .features.tmp ) || \
1630 { echo -e "\nUnable to find NI-845x headers or libraries."; \
1631 echo "Please pass the NI-845x library path to the make with the CONFIG_NI845X_LIBRARY_PATH parameter,"; \
1632 echo "or disable the NI-845x support by specifying make CONFIG_NI845X_SPI=no"; \
1633 echo "For the NI-845x 17.0 the library path is:"; \
1634 echo " On 32 bit systems: C:\Program Files)\National Instruments\NI-845x\MS Visual C"; \
1635 echo " On 64 bit systems: C:\Program Files (x86)\National Instruments\NI-845x\MS Visual C"; \
1636 exit 1; }; } \
1637 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
1638endif
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001639 @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
Stefan Tauner56787082011-08-18 02:27:19 +00001640 @echo "$$UTSNAME_TEST" > .featuretest.c
Stefan Taunerc83ddc12016-01-24 22:37:10 +00001641 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001642 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
Stefan Tauner56787082011-08-18 02:27:19 +00001643 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
Stefan Tauner3f73ffe2016-01-07 17:45:59 +00001644 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Nico Huber8624e8c2012-11-05 21:46:33 +01001645 @printf "Checking for clock_gettime support... " | tee -a $(BUILD_DETAILS_FILE)
Martin Lucina3170bc32020-12-18 14:11:04 +00001646ifeq ($(DISABLE_CLOCK_GETTIME), yes)
1647 @ { ( echo "disabled."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1648 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
1649else
Nico Huber8624e8c2012-11-05 21:46:33 +01001650 @echo "$$CLOCK_GETTIME_TEST" >.featuretest.c
1651 @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
1652 @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
1653 ( echo "found."; echo "CLOCK_GETTIME := yes" >>.features.tmp ) || \
1654 ( echo "not found."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
1655 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
Martin Lucina3170bc32020-12-18 14:11:04 +00001656endif
Stefan Tauner56787082011-08-18 02:27:19 +00001657 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
1658 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +00001659
Stefan Tauner4c723152016-01-14 22:47:55 +00001660$(PROGRAM).8.html: $(PROGRAM).8
1661 @groff -mandoc -Thtml $< >$@
1662
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001663$(PROGRAM).8: $(PROGRAM).8.tmpl
Stefan Tauner4c723152016-01-14 22:47:55 +00001664 @# Add the man page change date and version to the man page
Stefan Taunerf0cbbb02017-10-01 00:49:05 +02001665 @sed -e 's#.TH FLASHROM 8 .*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)" "$(MAN_DATE)"#' <$< >$@
Joerg Mayera93d9dc2013-08-29 00:38:19 +00001666
1667install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +00001668 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001669 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +00001670 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +00001671 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +00001672
Nico Huber454f6132012-12-10 13:34:10 +00001673libinstall: libflashrom.a libflashrom.h
1674 mkdir -p $(DESTDIR)$(PREFIX)/lib
1675 $(INSTALL) -m 0644 libflashrom.a $(DESTDIR)$(PREFIX)/lib
1676 mkdir -p $(DESTDIR)$(PREFIX)/include
1677 $(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include
1678
Stefan Tauner76347082016-11-27 17:45:49 +01001679_export: $(PROGRAM).8
1680 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1681 @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
1682 @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
Stefan Tauner2dc5d292017-10-04 02:18:33 +02001683# Generate versioninfo.inc containing metadata that would not be available in exported sources otherwise.
1684 @echo "VERSION = $(VERSION)" > "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
1685 @echo "MAN_DATE = $(MAN_DATE)" >> "$(EXPORTDIR)/flashrom-$(RELEASENAME)/versioninfo.inc"
Stefan Taunere4136852017-10-01 15:57:25 +02001686# Restore modification date of all tracked files not marked 'export-ignore' in .gitattributes.
1687# sed is required to filter out file names having the attribute set.
1688# The sed program saves the file name in the hold buffer and then checks if the respective value is 'set'.
1689# 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 +01001690 @git ls-tree -r -z -t --full-name --name-only HEAD | \
1691 git check-attr -z --stdin export-ignore | \
Stefan Taunere4136852017-10-01 15:57:25 +02001692 sed -zne 'x;n;n;{/^set$$/b;};x;p;' | \
Stefan Tauner76347082016-11-27 17:45:49 +01001693 xargs -0 sh -c 'for f; do \
1694 touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \
1695 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \
Stefan Taunere4136852017-10-01 15:57:25 +02001696 done' dummy_arg0
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001697
Stefan Tauner76347082016-11-27 17:45:49 +01001698export: _export
1699 @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/"
1700
1701tarball: _export
David Hendrickse1a960e2017-10-19 14:54:44 -07001702 @tar -cj --format=ustar -f "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2" -C $(EXPORTDIR)/ \
Stefan Tauner60f7a222017-10-01 15:45:06 +02001703 $(TAROPTIONS) "flashrom-$(RELEASENAME)/"
Stefan Tauner76347082016-11-27 17:45:49 +01001704# Delete the exported directory again because it is most likely what's expected by the user.
1705 @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
David Hendrickse1a960e2017-10-19 14:54:44 -07001706 @echo Created "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2"
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +00001707
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +00001708libpayload: clean
1709 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +00001710
Stefan Tauner76347082016-11-27 17:45:49 +01001711.PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload
Ollie Lho184a4042005-11-26 21:55:36 +00001712
Stefan Tauner23e10b82016-01-23 16:16:49 +00001713# Disable implicit suffixes and built-in rules (for performance and profit)
1714.SUFFIXES:
1715
Stefan Reinauere2f01582010-06-07 11:08:07 +00001716-include $(OBJS:.o=.d)