blob: 70ef6407b7aab7635cf7d8d37fc33319dd67efe0 [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)
Stefan Tauner8e19b042013-08-28 09:55:04 +0000221ifeq ($(MAKECMDGOALS),)
222.DEFAULT_GOAL := libflashrom.a
223$(info Setting default goal to libflashrom.a)
224endif
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000225FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000226ifeq ($(CONFIG_DUMMY), yes)
227UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
228else
229override CONFIG_DUMMY = no
230endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000231# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000232ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
233UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
234else
235override CONFIG_BUSPIRATE_SPI = no
236endif
237ifeq ($(CONFIG_SERPROG), yes)
238UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
239else
240override CONFIG_SERPROG = no
241endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000242ifeq ($(CONFIG_PONY_SPI), yes)
243UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
244else
245override CONFIG_PONY_SPI = no
246endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000247# Dediprog and FT2232 are not supported with libpayload (missing libusb support)
248ifeq ($(CONFIG_DEDIPROG), yes)
249UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
250else
251override CONFIG_DEDIPROG = no
252endif
253ifeq ($(CONFIG_FT2232_SPI), yes)
254UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
255else
256override CONFIG_FT2232_SPI = no
257endif
James Lairdc60de0e2013-03-27 13:00:23 +0000258ifeq ($(CONFIG_USBBLASTER_SPI), yes)
259UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
260else
261override CONFIG_USBBLASTER_SPI = no
262endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000263endif
264
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000265ifneq ($(TARGET_OS), Linux)
266ifeq ($(CONFIG_LINUX_SPI), yes)
267UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
268else
269override CONFIG_LINUX_SPI = no
270endif
271endif
272
Stefan Tauner037cd842013-08-25 00:10:56 +0000273###############################################################################
274# General architecture-specific settings.
275# Like above for the OS, below we verify user-supplied options depending on the target architecture.
276
Uwe Hermann44ffd582011-08-20 14:16:00 +0000277# Determine the destination processor architecture.
278# IMPORTANT: The following line must be placed before ARCH is ever used
279# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000280# below uses CC itself.
281override 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 +0000282
David Hendricksb286da72012-02-13 00:35:35 +0000283# PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM.
284# Right now this means the drivers below only work on x86.
285ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000286ifeq ($(CONFIG_NIC3COM), yes)
287UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
288else
289override CONFIG_NIC3COM = no
290endif
291ifeq ($(CONFIG_NICREALTEK), yes)
292UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
293else
294override CONFIG_NICREALTEK = no
295endif
296ifeq ($(CONFIG_NICNATSEMI), yes)
297UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
298else
299override CONFIG_NICNATSEMI = no
300endif
301ifeq ($(CONFIG_RAYER_SPI), yes)
302UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
303else
304override CONFIG_RAYER_SPI = no
305endif
306ifeq ($(CONFIG_ATAHPT), yes)
307UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
308else
309override CONFIG_ATAHPT = no
310endif
311ifeq ($(CONFIG_SATAMV), yes)
312UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
313else
314override CONFIG_SATAMV = no
315endif
316endif
317
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000318###############################################################################
319# Flash chip drivers and bus support infrastructure.
320
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000321CHIP_OBJS = jedec.o stm50flw0x0x.o w39.o w29ee011.o \
Sean Nelson35727f72010-01-28 23:55:12 +0000322 sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000323 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
Aidan Thorntondb4e87d2013-08-27 18:01:53 +0000324 opaque.o sfdp.o en29lv640b.o at45db.o
Sean Nelson5d134642009-12-24 16:54:21 +0000325
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000326###############################################################################
327# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000328
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000329LIB_OBJS = layout.o flashrom.o udelay.o programmer.o
Sean Nelson5d134642009-12-24 16:54:21 +0000330
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000331###############################################################################
332# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000333
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000334CLI_OBJS = cli_classic.o cli_output.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000335
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000336# Set the flashrom version string from the highest revision number of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000337# Note to packagers: Any tree exported with "make export" or "make tarball"
338# will not require subversion. The downloadable snapshots are already exported.
David Hendricks36e9f4b2013-08-14 14:47:26 +0000339SVNVERSION := $(shell ./util/getrevision.sh -u)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000340
Stefan Tauner241e9d52013-08-13 22:13:01 +0000341RELEASE := 0.9.7
Stefan Taunerec7a35f2013-08-29 00:38:14 +0000342VERSION := $(RELEASE)-$(SVNVERSION)
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000343RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000344
345SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000346
Stefan Tauner037cd842013-08-25 00:10:56 +0000347###############################################################################
348# Default settings of CONFIG_* variables.
349
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000350# Always enable internal/onboard support for now.
351CONFIG_INTERNAL ?= yes
352
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000353# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000354CONFIG_SERPROG ?= yes
355
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000356# RayeR SPIPGM hardware support
357CONFIG_RAYER_SPI ?= yes
358
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000359# PonyProg2000 SPI hardware support
360CONFIG_PONY_SPI ?= yes
361
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000362# Always enable 3Com NICs for now.
363CONFIG_NIC3COM ?= yes
364
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000365# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
366CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000367
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000368# Always enable SiI SATA controllers for now.
369CONFIG_SATASII ?= yes
370
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000371# Highpoint (HPT) ATA/RAID controller support.
372# IMPORTANT: This code is not yet working!
373CONFIG_ATAHPT ?= no
374
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000375# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000376CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000377
James Lairdc60de0e2013-03-27 13:00:23 +0000378# Always enable Altera USB-Blaster dongles for now.
379CONFIG_USBBLASTER_SPI ?= yes
380
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000381# Always enable dummy tracing for now.
382CONFIG_DUMMY ?= yes
383
384# Always enable Dr. Kaiser for now.
385CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000386
Joerg Fischer5665ef32010-05-21 21:54:07 +0000387# Always enable Realtek NICs for now.
388CONFIG_NICREALTEK ?= yes
389
Andrew Morganc29c2e72010-06-07 22:37:54 +0000390# Disable National Semiconductor NICs until support is complete and tested.
391CONFIG_NICNATSEMI ?= no
392
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000393# Always enable Intel NICs for now.
394CONFIG_NICINTEL ?= yes
395
Idwer Vollering004f4b72010-09-03 18:21:21 +0000396# Always enable SPI on Intel NICs for now.
397CONFIG_NICINTEL_SPI ?= yes
398
Mark Marshall90021f22010-12-03 14:48:11 +0000399# Always enable SPI on OGP cards for now.
400CONFIG_OGP_SPI ?= yes
401
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000402# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000403CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000404
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000405# Disable Dediprog SF100 until support is complete and tested.
406CONFIG_DEDIPROG ?= no
407
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000408# Always enable Marvell SATA controllers for now.
409CONFIG_SATAMV ?= yes
410
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000411# Enable Linux spidev interface by default. We disable it on non-Linux targets.
412CONFIG_LINUX_SPI ?= yes
413
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000414# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000415CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000416
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000417# Bitbanging SPI infrastructure, default off unless needed.
418ifeq ($(CONFIG_RAYER_SPI), yes)
419override CONFIG_BITBANG_SPI = yes
420else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000421ifeq ($(CONFIG_PONY_SPI), yes)
422override CONFIG_BITBANG_SPI = yes
423else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000424ifeq ($(CONFIG_INTERNAL), yes)
425override CONFIG_BITBANG_SPI = yes
426else
427ifeq ($(CONFIG_NICINTEL_SPI), yes)
428override CONFIG_BITBANG_SPI = yes
429else
Mark Marshall90021f22010-12-03 14:48:11 +0000430ifeq ($(CONFIG_OGP_SPI), yes)
431override CONFIG_BITBANG_SPI = yes
432else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000433CONFIG_BITBANG_SPI ?= no
434endif
435endif
436endif
Mark Marshall90021f22010-12-03 14:48:11 +0000437endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000438endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000439
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000440###############################################################################
441# Programmer drivers and programmer support infrastructure.
Stefan Tauner037cd842013-08-25 00:10:56 +0000442# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000443
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000444FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
445
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000446ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000447FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Carl-Daniel Hailfingerb5b161b2010-06-04 19:05:39 +0000448PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000449ifeq ($(ARCH), x86)
Rudolf Marek70e14592013-07-25 22:58:56 +0000450PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
Stefan Tauner1e146392011-09-15 23:52:55 +0000451PROGRAMMER_OBJS += ichspi.o ich_descriptors.o
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000452else
453endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000454NEED_PCI := yes
455endif
456
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000457ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000458FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000459PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000460NEED_SERIAL := yes
461NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000462endif
463
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000464ifeq ($(CONFIG_RAYER_SPI), yes)
465FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
466PROGRAMMER_OBJS += rayer_spi.o
467# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
468NEED_PCI := yes
469endif
470
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000471ifeq ($(CONFIG_PONY_SPI), yes)
472FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
473PROGRAMMER_OBJS += pony_spi.o
474NEED_SERIAL := yes
475endif
476
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000477ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000478FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000479PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000480endif
481
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000482ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000483FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000484PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000485NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000486endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000487
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000488ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000489FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000490PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000491NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000492endif
493
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000494ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000495FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000496PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000497NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000498endif
499
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000500ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000501FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000502PROGRAMMER_OBJS += atahpt.o
503NEED_PCI := yes
504endif
505
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000506ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000507# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000508FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000509NEED_FTDI := yes
510PROGRAMMER_OBJS += ft2232_spi.o
511endif
512
513ifeq ($(CONFIG_USBBLASTER_SPI), yes)
514# This is a totally ugly hack.
515FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
516NEED_FTDI := yes
517PROGRAMMER_OBJS += usbblaster_spi.o
518endif
519
520ifeq ($(NEED_FTDI), yes)
521FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000522FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
Jörg Mayer8776db22009-11-16 14:05:13 +0000523FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000524# We can't set NEED_USB here because that would transform libftdi auto-enabling
525# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000526endif
527
528ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000529FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000530PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000531endif
532
533ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000534FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000535PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000536NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000537endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000538
Joerg Fischer5665ef32010-05-21 21:54:07 +0000539ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000540FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000541PROGRAMMER_OBJS += nicrealtek.o
542NEED_PCI := yes
543endif
544
Andrew Morganc29c2e72010-06-07 22:37:54 +0000545ifeq ($(CONFIG_NICNATSEMI), yes)
546FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
547PROGRAMMER_OBJS += nicnatsemi.o
548NEED_PCI := yes
549endif
550
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000551ifeq ($(CONFIG_NICINTEL), yes)
552FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
553PROGRAMMER_OBJS += nicintel.o
554NEED_PCI := yes
555endif
556
Idwer Vollering004f4b72010-09-03 18:21:21 +0000557ifeq ($(CONFIG_NICINTEL_SPI), yes)
558FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
559PROGRAMMER_OBJS += nicintel_spi.o
560NEED_PCI := yes
561endif
562
Mark Marshall90021f22010-12-03 14:48:11 +0000563ifeq ($(CONFIG_OGP_SPI), yes)
564FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
565PROGRAMMER_OBJS += ogp_spi.o
566NEED_PCI := yes
567endif
568
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000569ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
570FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000571PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000572NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000573endif
574
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000575ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000576FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000577PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000578NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000579endif
580
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000581ifeq ($(CONFIG_SATAMV), yes)
582FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
583PROGRAMMER_OBJS += satamv.o
584NEED_PCI := yes
585endif
586
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000587ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000588# This is a totally ugly hack.
589FEATURE_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 +0000590PROGRAMMER_OBJS += linux_spi.o
591endif
592
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000593ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000594LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000595endif
596
597ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000598ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000599LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000600endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000601endif
602
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000603ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000604CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000605FEATURE_CFLAGS += -D'NEED_PCI=1'
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000606PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000607ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000608# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000609PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000610# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000611PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000612else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000613ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000614# FIXME There needs to be a better way to do this
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000615CPPFLAGS += -I../libpci/include
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000616PCILIBS += ../libpci/lib/libpci.a
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000617else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000618PCILIBS += -lpci
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000619ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000620# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000621PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000622else
623ifeq ($(TARGET_OS), Darwin)
624# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000625PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000626else
627endif
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000628endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000629endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000630endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000631endif
632
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000633ifeq ($(NEED_USB), yes)
634CHECK_LIBUSB0 = yes
635FEATURE_CFLAGS += -D'NEED_USB=1'
636USBLIBS := $(shell pkg-config --libs libusb 2>/dev/null || printf "%s" "-lusb")
637endif
638
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000639ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000640FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000641CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000642endif
643
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000644FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
645
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000646# We could use PULLED_IN_LIBS, but that would be ugly.
647FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
648
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000649LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000650OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000651
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000652all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000653ifeq ($(ARCH), x86)
654 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
655endif
656
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000657$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000658 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000659
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000660libflashrom.a: $(LIBFLASHROM_OBJS)
661 $(AR) rcs $@ $^
662 $(RANLIB) $@
663
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000664# TAROPTIONS reduces information leakage from the packager's system.
665# If other tar programs support command line arguments for setting uid/gid of
666# stored files, they can be handled here as well.
667TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000668
Paul Fox05dfbe62009-06-16 21:08:06 +0000669%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000670 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000671
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000672# Make sure to add all names of generated binaries here.
673# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000674# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000675clean:
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000676 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000677 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000678
Ollie Lho184a4042005-11-26 21:55:36 +0000679distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000680 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000681
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000682strip: $(PROGRAM)$(EXEC_SUFFIX)
683 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000684
Stefan Tauner56787082011-08-18 02:27:19 +0000685# to define test programs we use verbatim variables, which get exported
686# to environment variables and are referenced with $$<varname> later
687
688define COMPILER_TEST
689int main(int argc, char **argv)
690{
691 (void) argc;
692 (void) argv;
693 return 0;
694}
695endef
696export COMPILER_TEST
697
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000698compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000699 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000700 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000701 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000702 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000703 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
704 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000705 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000706 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000707 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000708 ( echo "unknown. Aborting."; exit 1)
709 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000710 @printf "Target OS is "
711 @# FreeBSD wc will output extraneous whitespace.
712 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
713 ( echo "unknown. Aborting."; exit 1)
714 @printf "%s\n" '$(TARGET_OS)'
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000715
Stefan Tauner56787082011-08-18 02:27:19 +0000716define LIBPCI_TEST
717/* Avoid a failing test due to libpci header symbol shadowing breakage */
718#define index shadow_workaround_index
719#include <pci/pci.h>
720struct pci_access *pacc;
721int main(int argc, char **argv)
722{
723 (void) argc;
724 (void) argv;
725 pacc = pci_alloc();
726 return 0;
727}
728endef
729export LIBPCI_TEST
730
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000731define LIBUSB0_TEST
732#include <usb.h>
733int main(int argc, char **argv)
734{
735 (void) argc;
736 (void) argv;
737 usb_init();
738 return 0;
739}
740endef
741export LIBUSB0_TEST
742
743hwlibs: compiler
744 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000745ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000746 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000747 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000748 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000749 echo "found." || ( echo "not found."; echo; \
750 echo "Please install libpci headers (package pciutils-devel)."; \
751 echo "See README for more information."; echo; \
752 rm -f .test.c .test.o; exit 1)
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000753 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000754 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000755 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000756 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000757 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000758 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000759 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000760 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000761 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
762 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000763endif
764ifeq ($(CHECK_LIBUSB0), yes)
765 @printf "Checking for libusb-0.1/libusb-compat headers... "
766 @echo "$$LIBUSB0_TEST" > .test.c
767 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
768 echo "found." || ( echo "not found."; echo; \
769 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
770 echo "See README for more information."; echo; \
771 rm -f .test.c .test.o; exit 1)
772 @printf "Checking if libusb-0.1 is usable... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000773 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000774 echo "yes." || ( echo "no."; \
775 echo "Please install libusb-0.1 or libusb-compat."; \
776 echo "See README for more information."; echo; \
777 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1)
778 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000779endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000780
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000781.features: features
782
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000783# If a user does not explicitly request a non-working feature, we should
784# silently disable it. However, if a non-working (does not compile) feature
785# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000786# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000787featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000788ifeq ($(PROGRAMMER_OBJS),)
789 @echo "You have to enable at least one programmer driver!"
790 @false
791endif
792ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000793 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
794 @false
795endif
796
Stefan Tauner56787082011-08-18 02:27:19 +0000797define FTDI_TEST
798#include <ftdi.h>
799struct ftdi_context *ftdic = NULL;
800int main(int argc, char **argv)
801{
802 (void) argc;
803 (void) argv;
804 return ftdi_init(ftdic);
805}
806endef
807export FTDI_TEST
808
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000809define FTDI_232H_TEST
810#include <ftdi.h>
811enum ftdi_chip_type type = TYPE_232H;
812endef
813export FTDI_232H_TEST
814
Stefan Tauner56787082011-08-18 02:27:19 +0000815define UTSNAME_TEST
816#include <sys/utsname.h>
817struct utsname osinfo;
818int main(int argc, char **argv)
819{
820 (void) argc;
821 (void) argv;
822 uname (&osinfo);
823 return 0;
824}
825endef
826export UTSNAME_TEST
827
Stefan Tauner8868db32012-03-13 00:18:19 +0000828define LINUX_SPI_TEST
829#include <linux/types.h>
830#include <linux/spi/spidev.h>
831
832int main(int argc, char **argv)
833{
834 (void) argc;
835 (void) argv;
836 return 0;
837}
838endef
839export LINUX_SPI_TEST
840
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000841features: compiler
842 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +0000843ifeq ($(NEED_FTDI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +0000844 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +0000845 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000846 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000847 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
848 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000849 @printf "Checking for FT232H support in libftdi... "
850 @echo "$$FTDI_232H_TEST" >> .featuretest.c
851 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
852 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
853 ( echo "not found."; echo "FT232H := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000854endif
Stefan Tauner8868db32012-03-13 00:18:19 +0000855ifeq ($(CONFIG_LINUX_SPI), yes)
856 @printf "Checking if Linux SPI headers are present... "
857 @echo "$$LINUX_SPI_TEST" > .featuretest.c
858 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
859 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
860 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
861endif
Stefan Tauner56787082011-08-18 02:27:19 +0000862 @printf "Checking for utsname support... "
863 @echo "$$UTSNAME_TEST" > .featuretest.c
864 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
865 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
866 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
867 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
868 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +0000869
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000870$(PROGRAM).8: $(PROGRAM).8.tmpl
871 @sed -e '1 s#".*".*#"$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl)" "$(VERSION)"#' <$< >$@
872
873install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +0000874 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000875 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000876 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000877 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +0000878
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000879export: $(PROGRAM).8
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000880 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
881 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
882 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000883 @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8"
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000884 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
885 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000886
887tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000888 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
889 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
890 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000891
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000892djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000893 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
894libpayload: clean
895 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000896
Joerg Mayera93d9dc2013-08-29 00:38:19 +0000897.PHONY: all install clean distclean compiler hwlibs features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +0000898
Stefan Reinauere2f01582010-06-07 11:08:07 +0000899-include $(OBJS:.o=.d)