blob: 3b24bc427f6ba5201ffc5fe2b2c63e566f3de8fd [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#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Ollie Lho184a4042005-11-26 21:55:36 +000019#
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000020
Ollie Lho184a4042005-11-26 21:55:36 +000021PROGRAM = flashrom
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000022
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000023###############################################################################
24# Defaults for the toolchain.
25
26# If you want to cross-compile, just run e.g.
27# make CC=i586-pc-msdosdjgpp-gcc
28# You may have to specify STRIP/AR/RANLIB as well.
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000029#
30# Note for anyone editing this Makefile: gnumake will happily ignore any
31# changes in this Makefile to variables set on the command line.
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +000032CC ?= gcc
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000033STRIP ?= strip
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000034INSTALL = install
Paul Fox05dfbe62009-06-16 21:08:06 +000035DIFF = diff
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000036PREFIX ?= /usr/local
Uwe Hermann56b2cb02009-05-21 15:59:58 +000037MANDIR ?= $(PREFIX)/share/man
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000038CFLAGS ?= -Os -Wall -Wshadow
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000039EXPORTDIR ?= .
Patrick Georgi97bc95c2011-03-08 07:17:44 +000040AR ?= ar
41RANLIB ?= ranlib
Stefan Taunerfd0d4132012-09-25 21:24:55 +000042# The following parameter changes the default programmer that will be used if there is no -p/--programmer
43# argument given when running flashrom. The predefined setting does not enable any default so that every
44# user has to declare the programmer he wants to use on every run. The rationale for this to be not set
45# (to e.g. the internal programmer) is that forgetting to specify this when working with another programmer
46# easily puts the system attached to the default programmer at risk (e.g. you want to flash coreboot to another
47# system attached to an external programmer while the default programmer is set to the internal programmer, and
48# you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer
49# running flashrom). Please do not enable this without thinking about the possible consequences. Possible
50# values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options
51# evaluated below, namely those that enable/disable the various programmers).
52# Compilation will fail for unspecified values.
53CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000054
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000055# If your compiler spits out excessive warnings, run make WARNERROR=no
56# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000057WARNERROR ?= yes
58
59ifeq ($(WARNERROR), yes)
60CFLAGS += -Werror
61endif
62
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000063###############################################################################
Stefan Tauner037cd842013-08-25 00:10:56 +000064# General OS-specific settings.
65# 1. Prepare for later by gathering information about host and target OS
66# 2. Set compiler flags and parameters according to OSes
67# 3. Likewise verify user-supplied CONFIG_* variables.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000068
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000069# HOST_OS is only used to work around local toolchain issues.
Stefan Tauner037cd842013-08-25 00:10:56 +000070HOST_OS ?= $(shell uname)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000071ifeq ($(HOST_OS), MINGW32_NT-5.1)
72# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
73CC = gcc
74endif
75ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +000076STRIP_ARGS = -s
77endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000078
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000079# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000080# IMPORTANT: The following line must be placed before TARGET_OS is ever used
81# (of course), but should come after any lines setting CC because the line
82# below uses CC itself.
83override TARGET_OS := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
84
85ifeq ($(TARGET_OS), Darwin)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000086CPPFLAGS += -I/opt/local/include -I/usr/local/include
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000087LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +000088endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000089
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000090ifeq ($(TARGET_OS), FreeBSD)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000091CPPFLAGS += -I/usr/local/include
Andriy Gapon65c1b862008-05-22 13:22:45 +000092LDFLAGS += -L/usr/local/lib
93endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000094
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000095ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +000096CPPFLAGS += -I/usr/local/include
97LDFLAGS += -L/usr/local/lib
98endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000099
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000100ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000101EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000102CPPFLAGS += -I../libgetopt
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000103# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +0000104CFLAGS += -Wno-format
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000105# FIXME Check if we can achieve the same effect with -L../libgetopt -lgetopt
106LIBS += ../libgetopt/libgetopt.a
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000107# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000108ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
109UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
110else
111override CONFIG_BUSPIRATE_SPI = no
112endif
113ifeq ($(CONFIG_SERPROG), yes)
114UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
115else
116override CONFIG_SERPROG = no
117endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000118ifeq ($(CONFIG_PONY_SPI), yes)
119UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
120else
121override CONFIG_PONY_SPI = no
122endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000123# Dediprog and FT2232 are not supported under DOS (missing USB support).
124ifeq ($(CONFIG_DEDIPROG), yes)
125UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
126else
127override CONFIG_DEDIPROG = no
128endif
129ifeq ($(CONFIG_FT2232_SPI), yes)
130UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
131else
132override CONFIG_FT2232_SPI = no
133endif
James Lairdc60de0e2013-03-27 13:00:23 +0000134ifeq ($(CONFIG_USBBLASTER_SPI), yes)
135UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
136else
137override CONFIG_USBBLASTER_SPI = no
138endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000139endif
Ollie Lho184a4042005-11-26 21:55:36 +0000140
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000141# FIXME: Should we check for Cygwin/MSVC as well?
142ifeq ($(TARGET_OS), MinGW)
143EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000144# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000145FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000146# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
147# for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */
148FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000149# libusb-win32/libftdi stuff is usually installed in /usr/local.
150CPPFLAGS += -I/usr/local/include
151LDFLAGS += -L/usr/local/lib
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000152# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
153ifeq ($(CONFIG_INTERNAL), yes)
154UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
155else
156override CONFIG_INTERNAL = no
157endif
158ifeq ($(CONFIG_RAYER_SPI), yes)
159UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
160else
161override CONFIG_RAYER_SPI = no
162endif
163ifeq ($(CONFIG_NIC3COM), yes)
164UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
165else
166override CONFIG_NIC3COM = no
167endif
168ifeq ($(CONFIG_GFXNVIDIA), yes)
169UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
170else
171override CONFIG_GFXNVIDIA = no
172endif
173ifeq ($(CONFIG_SATASII), yes)
174UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
175else
176override CONFIG_SATASII = no
177endif
178ifeq ($(CONFIG_ATAHPT), yes)
179UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
180else
181override CONFIG_ATAHPT = no
182endif
183ifeq ($(CONFIG_DRKAISER), yes)
184UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
185else
186override CONFIG_DRKAISER = no
187endif
188ifeq ($(CONFIG_NICREALTEK), yes)
189UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
190else
191override CONFIG_NICREALTEK = no
192endif
193ifeq ($(CONFIG_NICNATSEMI), yes)
194UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
195else
196override CONFIG_NICNATSEMI = no
197endif
198ifeq ($(CONFIG_NICINTEL), yes)
199UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
200else
201override CONFIG_NICINTEL = no
202endif
203ifeq ($(CONFIG_NICINTEL_SPI), yes)
204UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
205else
206override CONFIG_NICINTEL_SPI = no
207endif
208ifeq ($(CONFIG_OGP_SPI), yes)
209UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
210else
211override CONFIG_OGP_SPI = no
212endif
213ifeq ($(CONFIG_SATAMV), yes)
214UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
215else
216override CONFIG_SATAMV = no
217endif
218endif
219
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000220ifeq ($(TARGET_OS), libpayload)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000221FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000222ifeq ($(CONFIG_DUMMY), yes)
223UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
224else
225override CONFIG_DUMMY = no
226endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000227# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000228ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
229UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
230else
231override CONFIG_BUSPIRATE_SPI = no
232endif
233ifeq ($(CONFIG_SERPROG), yes)
234UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
235else
236override CONFIG_SERPROG = no
237endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000238ifeq ($(CONFIG_PONY_SPI), yes)
239UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
240else
241override CONFIG_PONY_SPI = no
242endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000243# Dediprog and FT2232 are not supported with libpayload (missing libusb support)
244ifeq ($(CONFIG_DEDIPROG), yes)
245UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
246else
247override CONFIG_DEDIPROG = no
248endif
249ifeq ($(CONFIG_FT2232_SPI), yes)
250UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
251else
252override CONFIG_FT2232_SPI = no
253endif
James Lairdc60de0e2013-03-27 13:00:23 +0000254ifeq ($(CONFIG_USBBLASTER_SPI), yes)
255UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
256else
257override CONFIG_USBBLASTER_SPI = no
258endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000259endif
260
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000261ifneq ($(TARGET_OS), Linux)
262ifeq ($(CONFIG_LINUX_SPI), yes)
263UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
264else
265override CONFIG_LINUX_SPI = no
266endif
267endif
268
Stefan Tauner037cd842013-08-25 00:10:56 +0000269###############################################################################
270# General architecture-specific settings.
271# Like above for the OS, below we verify user-supplied options depending on the target architecture.
272
Uwe Hermann44ffd582011-08-20 14:16:00 +0000273# Determine the destination processor architecture.
274# IMPORTANT: The following line must be placed before ARCH is ever used
275# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000276# below uses CC itself.
277override ARCH := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E arch.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
Uwe Hermann44ffd582011-08-20 14:16:00 +0000278
David Hendricksb286da72012-02-13 00:35:35 +0000279# PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM.
280# Right now this means the drivers below only work on x86.
281ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000282ifeq ($(CONFIG_NIC3COM), yes)
283UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
284else
285override CONFIG_NIC3COM = no
286endif
287ifeq ($(CONFIG_NICREALTEK), yes)
288UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
289else
290override CONFIG_NICREALTEK = no
291endif
292ifeq ($(CONFIG_NICNATSEMI), yes)
293UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
294else
295override CONFIG_NICNATSEMI = no
296endif
297ifeq ($(CONFIG_RAYER_SPI), yes)
298UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
299else
300override CONFIG_RAYER_SPI = no
301endif
302ifeq ($(CONFIG_ATAHPT), yes)
303UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
304else
305override CONFIG_ATAHPT = no
306endif
307ifeq ($(CONFIG_SATAMV), yes)
308UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
309else
310override CONFIG_SATAMV = no
311endif
312endif
313
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000314###############################################################################
315# Flash chip drivers and bus support infrastructure.
316
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000317CHIP_OBJS = jedec.o stm50flw0x0x.o w39.o w29ee011.o \
Sean Nelson35727f72010-01-28 23:55:12 +0000318 sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000319 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
320 opaque.o sfdp.o en29lv640b.o
Sean Nelson5d134642009-12-24 16:54:21 +0000321
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000322###############################################################################
323# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000324
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000325LIB_OBJS = layout.o flashrom.o udelay.o programmer.o
Sean Nelson5d134642009-12-24 16:54:21 +0000326
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000327###############################################################################
328# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000329
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000330CLI_OBJS = cli_classic.o cli_output.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000331
Carl-Daniel Hailfinger9e675852009-05-04 12:29:59 +0000332# Set the flashrom version string from the highest revision number
333# of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000334# Note to packagers: Any tree exported with "make export" or "make tarball"
335# will not require subversion. The downloadable snapshots are already exported.
David Hendricks36e9f4b2013-08-14 14:47:26 +0000336SVNVERSION := $(shell ./util/getrevision.sh -u)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000337
Stefan Tauner241e9d52013-08-13 22:13:01 +0000338RELEASE := 0.9.7
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000339VERSION := $(RELEASE)-r$(SVNVERSION)
340RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000341
342SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000343
Stefan Tauner037cd842013-08-25 00:10:56 +0000344###############################################################################
345# Default settings of CONFIG_* variables.
346
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000347# Always enable internal/onboard support for now.
348CONFIG_INTERNAL ?= yes
349
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000350# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000351CONFIG_SERPROG ?= yes
352
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000353# RayeR SPIPGM hardware support
354CONFIG_RAYER_SPI ?= yes
355
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000356# PonyProg2000 SPI hardware support
357CONFIG_PONY_SPI ?= yes
358
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000359# Always enable 3Com NICs for now.
360CONFIG_NIC3COM ?= yes
361
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000362# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
363CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000364
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000365# Always enable SiI SATA controllers for now.
366CONFIG_SATASII ?= yes
367
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000368# Highpoint (HPT) ATA/RAID controller support.
369# IMPORTANT: This code is not yet working!
370CONFIG_ATAHPT ?= no
371
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000372# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000373CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000374
James Lairdc60de0e2013-03-27 13:00:23 +0000375# Always enable Altera USB-Blaster dongles for now.
376CONFIG_USBBLASTER_SPI ?= yes
377
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000378# Always enable dummy tracing for now.
379CONFIG_DUMMY ?= yes
380
381# Always enable Dr. Kaiser for now.
382CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000383
Joerg Fischer5665ef32010-05-21 21:54:07 +0000384# Always enable Realtek NICs for now.
385CONFIG_NICREALTEK ?= yes
386
Andrew Morganc29c2e72010-06-07 22:37:54 +0000387# Disable National Semiconductor NICs until support is complete and tested.
388CONFIG_NICNATSEMI ?= no
389
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000390# Always enable Intel NICs for now.
391CONFIG_NICINTEL ?= yes
392
Idwer Vollering004f4b72010-09-03 18:21:21 +0000393# Always enable SPI on Intel NICs for now.
394CONFIG_NICINTEL_SPI ?= yes
395
Mark Marshall90021f22010-12-03 14:48:11 +0000396# Always enable SPI on OGP cards for now.
397CONFIG_OGP_SPI ?= yes
398
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000399# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000400CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000401
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000402# Disable Dediprog SF100 until support is complete and tested.
403CONFIG_DEDIPROG ?= no
404
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000405# Always enable Marvell SATA controllers for now.
406CONFIG_SATAMV ?= yes
407
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000408# Enable Linux spidev interface by default. We disable it on non-Linux targets.
409CONFIG_LINUX_SPI ?= yes
410
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000411# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000412CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000413
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000414# Bitbanging SPI infrastructure, default off unless needed.
415ifeq ($(CONFIG_RAYER_SPI), yes)
416override CONFIG_BITBANG_SPI = yes
417else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000418ifeq ($(CONFIG_PONY_SPI), yes)
419override CONFIG_BITBANG_SPI = yes
420else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000421ifeq ($(CONFIG_INTERNAL), yes)
422override CONFIG_BITBANG_SPI = yes
423else
424ifeq ($(CONFIG_NICINTEL_SPI), yes)
425override CONFIG_BITBANG_SPI = yes
426else
Mark Marshall90021f22010-12-03 14:48:11 +0000427ifeq ($(CONFIG_OGP_SPI), yes)
428override CONFIG_BITBANG_SPI = yes
429else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000430CONFIG_BITBANG_SPI ?= no
431endif
432endif
433endif
Mark Marshall90021f22010-12-03 14:48:11 +0000434endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000435endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000436
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000437###############################################################################
438# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000439# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000440
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000441FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
442
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000443ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000444FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Carl-Daniel Hailfingerb5b161b2010-06-04 19:05:39 +0000445PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000446ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000447PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Stefan Tauner1e146392011-09-15 23:52:55 +0000448PROGRAMMER_OBJS += ichspi.o ich_descriptors.o
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000449else
450endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000451NEED_PCI := yes
452endif
453
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000454ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000455FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000456PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000457NEED_SERIAL := yes
458NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000459endif
460
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000461ifeq ($(CONFIG_RAYER_SPI), yes)
462FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
463PROGRAMMER_OBJS += rayer_spi.o
464# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
465NEED_PCI := yes
466endif
467
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000468ifeq ($(CONFIG_PONY_SPI), yes)
469FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
470PROGRAMMER_OBJS += pony_spi.o
471NEED_SERIAL := yes
472endif
473
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000474ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000475FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000476PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000477endif
478
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000479ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000480FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000481PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000482NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000483endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000484
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000485ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000486FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000487PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000488NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000489endif
490
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000491ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000492FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000493PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000494NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000495endif
496
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000497ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000498FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000499PROGRAMMER_OBJS += atahpt.o
500NEED_PCI := yes
501endif
502
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000503ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000504# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000505FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000506NEED_FTDI := yes
507PROGRAMMER_OBJS += ft2232_spi.o
508endif
509
510ifeq ($(CONFIG_USBBLASTER_SPI), yes)
511# This is a totally ugly hack.
512FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
513NEED_FTDI := yes
514PROGRAMMER_OBJS += usbblaster_spi.o
515endif
516
517ifeq ($(NEED_FTDI), yes)
518FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000519FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
Jörg Mayer8776db22009-11-16 14:05:13 +0000520FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000521# We can't set NEED_USB here because that would transform libftdi auto-enabling
522# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000523endif
524
525ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000526FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000527PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000528endif
529
530ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000531FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000532PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000533NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000534endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000535
Joerg Fischer5665ef32010-05-21 21:54:07 +0000536ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000537FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000538PROGRAMMER_OBJS += nicrealtek.o
539NEED_PCI := yes
540endif
541
Andrew Morganc29c2e72010-06-07 22:37:54 +0000542ifeq ($(CONFIG_NICNATSEMI), yes)
543FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
544PROGRAMMER_OBJS += nicnatsemi.o
545NEED_PCI := yes
546endif
547
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000548ifeq ($(CONFIG_NICINTEL), yes)
549FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
550PROGRAMMER_OBJS += nicintel.o
551NEED_PCI := yes
552endif
553
Idwer Vollering004f4b72010-09-03 18:21:21 +0000554ifeq ($(CONFIG_NICINTEL_SPI), yes)
555FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
556PROGRAMMER_OBJS += nicintel_spi.o
557NEED_PCI := yes
558endif
559
Mark Marshall90021f22010-12-03 14:48:11 +0000560ifeq ($(CONFIG_OGP_SPI), yes)
561FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
562PROGRAMMER_OBJS += ogp_spi.o
563NEED_PCI := yes
564endif
565
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000566ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
567FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000568PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000569NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000570endif
571
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000572ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000573FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000574PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000575NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000576endif
577
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000578ifeq ($(CONFIG_SATAMV), yes)
579FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
580PROGRAMMER_OBJS += satamv.o
581NEED_PCI := yes
582endif
583
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000584ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000585# This is a totally ugly hack.
586FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "LINUX_SPI_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_SPI=1'")
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000587PROGRAMMER_OBJS += linux_spi.o
588endif
589
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000590ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000591LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000592endif
593
594ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000595ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000596LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000597endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000598endif
599
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000600ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000601CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000602FEATURE_CFLAGS += -D'NEED_PCI=1'
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000603PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000604ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000605# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000606PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000607# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000608PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000609else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000610ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000611# FIXME There needs to be a better way to do this
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000612CPPFLAGS += -I../libpci/include
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000613PCILIBS += ../libpci/lib/libpci.a
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000614else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000615PCILIBS += -lpci
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000616ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000617# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000618PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000619else
620ifeq ($(TARGET_OS), Darwin)
621# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000622PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000623else
624endif
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000625endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000626endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000627endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000628endif
629
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000630ifeq ($(NEED_USB), yes)
631CHECK_LIBUSB0 = yes
632FEATURE_CFLAGS += -D'NEED_USB=1'
633USBLIBS := $(shell pkg-config --libs libusb 2>/dev/null || printf "%s" "-lusb")
634endif
635
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000636ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000637FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000638CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000639endif
640
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000641FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
642
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000643# We could use PULLED_IN_LIBS, but that would be ugly.
644FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
645
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000646LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000647OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000648
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000649all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000650ifeq ($(ARCH), x86)
651 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
652endif
653
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000654$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000655 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000656
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000657libflashrom.a: $(LIBFLASHROM_OBJS)
658 $(AR) rcs $@ $^
659 $(RANLIB) $@
660
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000661# TAROPTIONS reduces information leakage from the packager's system.
662# If other tar programs support command line arguments for setting uid/gid of
663# stored files, they can be handled here as well.
664TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000665
Paul Fox05dfbe62009-06-16 21:08:06 +0000666%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000667 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000668
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000669# Make sure to add all names of generated binaries here.
670# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000671# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000672clean:
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000673 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000674 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000675
Ollie Lho184a4042005-11-26 21:55:36 +0000676distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000677 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000678
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000679strip: $(PROGRAM)$(EXEC_SUFFIX)
680 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000681
Stefan Tauner56787082011-08-18 02:27:19 +0000682# to define test programs we use verbatim variables, which get exported
683# to environment variables and are referenced with $$<varname> later
684
685define COMPILER_TEST
686int main(int argc, char **argv)
687{
688 (void) argc;
689 (void) argv;
690 return 0;
691}
692endef
693export COMPILER_TEST
694
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000695compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000696 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000697 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000698 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000699 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000700 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
701 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000702 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000703 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000704 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000705 ( echo "unknown. Aborting."; exit 1)
706 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000707 @printf "Target OS is "
708 @# FreeBSD wc will output extraneous whitespace.
709 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
710 ( echo "unknown. Aborting."; exit 1)
711 @printf "%s\n" '$(TARGET_OS)'
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000712
Stefan Tauner56787082011-08-18 02:27:19 +0000713define LIBPCI_TEST
714/* Avoid a failing test due to libpci header symbol shadowing breakage */
715#define index shadow_workaround_index
716#include <pci/pci.h>
717struct pci_access *pacc;
718int main(int argc, char **argv)
719{
720 (void) argc;
721 (void) argv;
722 pacc = pci_alloc();
723 return 0;
724}
725endef
726export LIBPCI_TEST
727
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000728define LIBUSB0_TEST
729#include <usb.h>
730int main(int argc, char **argv)
731{
732 (void) argc;
733 (void) argv;
734 usb_init();
735 return 0;
736}
737endef
738export LIBUSB0_TEST
739
740hwlibs: compiler
741 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000742ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000743 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000744 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000745 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000746 echo "found." || ( echo "not found."; echo; \
747 echo "Please install libpci headers (package pciutils-devel)."; \
748 echo "See README for more information."; echo; \
749 rm -f .test.c .test.o; exit 1)
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000750 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000751 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000752 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000753 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000754 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000755 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000756 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000757 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000758 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
759 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000760endif
761ifeq ($(CHECK_LIBUSB0), yes)
762 @printf "Checking for libusb-0.1/libusb-compat headers... "
763 @echo "$$LIBUSB0_TEST" > .test.c
764 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
765 echo "found." || ( echo "not found."; echo; \
766 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
767 echo "See README for more information."; echo; \
768 rm -f .test.c .test.o; exit 1)
769 @printf "Checking if libusb-0.1 is usable... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000770 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000771 echo "yes." || ( echo "no."; \
772 echo "Please install libusb-0.1 or libusb-compat."; \
773 echo "See README for more information."; echo; \
774 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1)
775 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000776endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000777
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000778.features: features
779
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000780# If a user does not explicitly request a non-working feature, we should
781# silently disable it. However, if a non-working (does not compile) feature
782# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000783# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000784featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000785ifeq ($(PROGRAMMER_OBJS),)
786 @echo "You have to enable at least one programmer driver!"
787 @false
788endif
789ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000790 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
791 @false
792endif
793
Stefan Tauner56787082011-08-18 02:27:19 +0000794define FTDI_TEST
795#include <ftdi.h>
796struct ftdi_context *ftdic = NULL;
797int main(int argc, char **argv)
798{
799 (void) argc;
800 (void) argv;
801 return ftdi_init(ftdic);
802}
803endef
804export FTDI_TEST
805
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000806define FTDI_232H_TEST
807#include <ftdi.h>
808enum ftdi_chip_type type = TYPE_232H;
809endef
810export FTDI_232H_TEST
811
Stefan Tauner56787082011-08-18 02:27:19 +0000812define UTSNAME_TEST
813#include <sys/utsname.h>
814struct utsname osinfo;
815int main(int argc, char **argv)
816{
817 (void) argc;
818 (void) argv;
819 uname (&osinfo);
820 return 0;
821}
822endef
823export UTSNAME_TEST
824
Stefan Tauner8868db32012-03-13 00:18:19 +0000825define LINUX_SPI_TEST
826#include <linux/types.h>
827#include <linux/spi/spidev.h>
828
829int main(int argc, char **argv)
830{
831 (void) argc;
832 (void) argv;
833 return 0;
834}
835endef
836export LINUX_SPI_TEST
837
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000838features: compiler
839 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +0000840ifeq ($(NEED_FTDI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +0000841 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +0000842 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000843 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000844 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
845 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000846 @printf "Checking for FT232H support in libftdi... "
847 @echo "$$FTDI_232H_TEST" >> .featuretest.c
848 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
849 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
850 ( echo "not found."; echo "FT232H := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000851endif
Stefan Tauner8868db32012-03-13 00:18:19 +0000852ifeq ($(CONFIG_LINUX_SPI), yes)
853 @printf "Checking if Linux SPI headers are present... "
854 @echo "$$LINUX_SPI_TEST" > .featuretest.c
855 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
856 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
857 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
858endif
Stefan Tauner56787082011-08-18 02:27:19 +0000859 @printf "Checking for utsname support... "
860 @echo "$$UTSNAME_TEST" > .featuretest.c
861 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
862 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
863 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
864 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
865 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +0000866
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000867install: $(PROGRAM)$(EXEC_SUFFIX)
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +0000868 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000869 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000870 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000871 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +0000872
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000873export:
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000874 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
875 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
876 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
877 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
878 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000879
880tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000881 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
882 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
883 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000884
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000885djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000886 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
887libpayload: clean
888 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000889
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000890.PHONY: all clean distclean compiler hwlibs features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +0000891
Stefan Reinauere2f01582010-06-07 11:08:07 +0000892-include $(OBJS:.o=.d)