blob: 0cd4e75c2fdd003482e92dec50627ce70fac3c2a [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###############################################################################
64# General OS/architecture specific settings.
65
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000066# HOST_OS is only used to work around local toolchain issues.
67HOST_OS ?= $(shell uname)
68ifeq ($(HOST_OS), MINGW32_NT-5.1)
69# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
70CC = gcc
71endif
72ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +000073STRIP_ARGS = -s
74endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000075
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000076# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000077# IMPORTANT: The following line must be placed before TARGET_OS is ever used
78# (of course), but should come after any lines setting CC because the line
79# below uses CC itself.
80override TARGET_OS := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
81
82ifeq ($(TARGET_OS), Darwin)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000083CPPFLAGS += -I/opt/local/include -I/usr/local/include
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000084LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +000085endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000086
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000087ifeq ($(TARGET_OS), FreeBSD)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000088CPPFLAGS += -I/usr/local/include
Andriy Gapon65c1b862008-05-22 13:22:45 +000089LDFLAGS += -L/usr/local/lib
90endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000091
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000092ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +000093CPPFLAGS += -I/usr/local/include
94LDFLAGS += -L/usr/local/lib
95endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000096
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000097ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +000098EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000099CPPFLAGS += -I../libgetopt
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000100# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +0000101CFLAGS += -Wno-format
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000102# FIXME Check if we can achieve the same effect with -L../libgetopt -lgetopt
103LIBS += ../libgetopt/libgetopt.a
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000104# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000105ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
106UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
107else
108override CONFIG_BUSPIRATE_SPI = no
109endif
110ifeq ($(CONFIG_SERPROG), yes)
111UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
112else
113override CONFIG_SERPROG = no
114endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000115ifeq ($(CONFIG_PONY_SPI), yes)
116UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
117else
118override CONFIG_PONY_SPI = no
119endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000120# Dediprog and FT2232 are not supported under DOS (missing USB support).
121ifeq ($(CONFIG_DEDIPROG), yes)
122UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
123else
124override CONFIG_DEDIPROG = no
125endif
126ifeq ($(CONFIG_FT2232_SPI), yes)
127UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
128else
129override CONFIG_FT2232_SPI = no
130endif
James Lairdc60de0e2013-03-27 13:00:23 +0000131ifeq ($(CONFIG_USBBLASTER_SPI), yes)
132UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
133else
134override CONFIG_USBBLASTER_SPI = no
135endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000136endif
Ollie Lho184a4042005-11-26 21:55:36 +0000137
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000138# FIXME: Should we check for Cygwin/MSVC as well?
139ifeq ($(TARGET_OS), MinGW)
140EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000141# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000142FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000143# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
144# for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */
145FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000146# libusb-win32/libftdi stuff is usually installed in /usr/local.
147CPPFLAGS += -I/usr/local/include
148LDFLAGS += -L/usr/local/lib
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000149# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
150ifeq ($(CONFIG_INTERNAL), yes)
151UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
152else
153override CONFIG_INTERNAL = no
154endif
155ifeq ($(CONFIG_RAYER_SPI), yes)
156UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
157else
158override CONFIG_RAYER_SPI = no
159endif
160ifeq ($(CONFIG_NIC3COM), yes)
161UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
162else
163override CONFIG_NIC3COM = no
164endif
165ifeq ($(CONFIG_GFXNVIDIA), yes)
166UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
167else
168override CONFIG_GFXNVIDIA = no
169endif
170ifeq ($(CONFIG_SATASII), yes)
171UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
172else
173override CONFIG_SATASII = no
174endif
175ifeq ($(CONFIG_ATAHPT), yes)
176UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
177else
178override CONFIG_ATAHPT = no
179endif
180ifeq ($(CONFIG_DRKAISER), yes)
181UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
182else
183override CONFIG_DRKAISER = no
184endif
185ifeq ($(CONFIG_NICREALTEK), yes)
186UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
187else
188override CONFIG_NICREALTEK = no
189endif
190ifeq ($(CONFIG_NICNATSEMI), yes)
191UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
192else
193override CONFIG_NICNATSEMI = no
194endif
195ifeq ($(CONFIG_NICINTEL), yes)
196UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
197else
198override CONFIG_NICINTEL = no
199endif
200ifeq ($(CONFIG_NICINTEL_SPI), yes)
201UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
202else
203override CONFIG_NICINTEL_SPI = no
204endif
205ifeq ($(CONFIG_OGP_SPI), yes)
206UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
207else
208override CONFIG_OGP_SPI = no
209endif
210ifeq ($(CONFIG_SATAMV), yes)
211UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
212else
213override CONFIG_SATAMV = no
214endif
215endif
216
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000217ifeq ($(TARGET_OS), libpayload)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000218FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000219ifeq ($(CONFIG_DUMMY), yes)
220UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
221else
222override CONFIG_DUMMY = no
223endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000224# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000225ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
226UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
227else
228override CONFIG_BUSPIRATE_SPI = no
229endif
230ifeq ($(CONFIG_SERPROG), yes)
231UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
232else
233override CONFIG_SERPROG = no
234endif
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000235ifeq ($(CONFIG_PONY_SPI), yes)
236UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
237else
238override CONFIG_PONY_SPI = no
239endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000240# Dediprog and FT2232 are not supported with libpayload (missing libusb support)
241ifeq ($(CONFIG_DEDIPROG), yes)
242UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
243else
244override CONFIG_DEDIPROG = no
245endif
246ifeq ($(CONFIG_FT2232_SPI), yes)
247UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
248else
249override CONFIG_FT2232_SPI = no
250endif
James Lairdc60de0e2013-03-27 13:00:23 +0000251ifeq ($(CONFIG_USBBLASTER_SPI), yes)
252UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
253else
254override CONFIG_USBBLASTER_SPI = no
255endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000256endif
257
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000258ifneq ($(TARGET_OS), Linux)
259ifeq ($(CONFIG_LINUX_SPI), yes)
260UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
261else
262override CONFIG_LINUX_SPI = no
263endif
264endif
265
Uwe Hermann44ffd582011-08-20 14:16:00 +0000266# Determine the destination processor architecture.
267# IMPORTANT: The following line must be placed before ARCH is ever used
268# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000269# below uses CC itself.
270override 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 +0000271
David Hendricksb286da72012-02-13 00:35:35 +0000272# PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM.
273# Right now this means the drivers below only work on x86.
274ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000275ifeq ($(CONFIG_NIC3COM), yes)
276UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
277else
278override CONFIG_NIC3COM = no
279endif
280ifeq ($(CONFIG_NICREALTEK), yes)
281UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
282else
283override CONFIG_NICREALTEK = no
284endif
285ifeq ($(CONFIG_NICNATSEMI), yes)
286UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
287else
288override CONFIG_NICNATSEMI = no
289endif
290ifeq ($(CONFIG_RAYER_SPI), yes)
291UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
292else
293override CONFIG_RAYER_SPI = no
294endif
295ifeq ($(CONFIG_ATAHPT), yes)
296UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
297else
298override CONFIG_ATAHPT = no
299endif
300ifeq ($(CONFIG_SATAMV), yes)
301UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
302else
303override CONFIG_SATAMV = no
304endif
305endif
306
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000307###############################################################################
308# Flash chip drivers and bus support infrastructure.
309
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000310CHIP_OBJS = jedec.o stm50flw0x0x.o w39.o w29ee011.o \
Sean Nelson35727f72010-01-28 23:55:12 +0000311 sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000312 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
313 opaque.o sfdp.o en29lv640b.o
Sean Nelson5d134642009-12-24 16:54:21 +0000314
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000315###############################################################################
316# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000317
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000318LIB_OBJS = layout.o flashrom.o udelay.o programmer.o
Sean Nelson5d134642009-12-24 16:54:21 +0000319
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000320###############################################################################
321# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000322
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000323CLI_OBJS = cli_classic.o cli_output.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000324
Carl-Daniel Hailfinger9e675852009-05-04 12:29:59 +0000325# Set the flashrom version string from the highest revision number
326# of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000327# Note to packagers: Any tree exported with "make export" or "make tarball"
328# will not require subversion. The downloadable snapshots are already exported.
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000329SVNVERSION := $(shell LC_ALL=C svnversion -cn . 2>/dev/null | sed -e "s/.*://" -e "s/\([0-9]*\).*/\1/" | grep "[0-9]" || LC_ALL=C svn info . 2>/dev/null | awk '/^Revision:/ {print $$2 }' | grep "[0-9]" || LC_ALL=C git svn info . 2>/dev/null | awk '/^Revision:/ {print $$2 }' | grep "[0-9]" || echo unknown)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000330
Carl-Daniel Hailfingera5838532012-08-08 00:13:10 +0000331RELEASE := 0.9.6.1
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000332VERSION := $(RELEASE)-r$(SVNVERSION)
333RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000334
335SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000336
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000337# Always enable internal/onboard support for now.
338CONFIG_INTERNAL ?= yes
339
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000340# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000341CONFIG_SERPROG ?= yes
342
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000343# RayeR SPIPGM hardware support
344CONFIG_RAYER_SPI ?= yes
345
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000346# PonyProg2000 SPI hardware support
347CONFIG_PONY_SPI ?= yes
348
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000349# Always enable 3Com NICs for now.
350CONFIG_NIC3COM ?= yes
351
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000352# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
353CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000354
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000355# Always enable SiI SATA controllers for now.
356CONFIG_SATASII ?= yes
357
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000358# Highpoint (HPT) ATA/RAID controller support.
359# IMPORTANT: This code is not yet working!
360CONFIG_ATAHPT ?= no
361
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000362# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000363CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000364
James Lairdc60de0e2013-03-27 13:00:23 +0000365# Always enable Altera USB-Blaster dongles for now.
366CONFIG_USBBLASTER_SPI ?= yes
367
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000368# Always enable dummy tracing for now.
369CONFIG_DUMMY ?= yes
370
371# Always enable Dr. Kaiser for now.
372CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000373
Joerg Fischer5665ef32010-05-21 21:54:07 +0000374# Always enable Realtek NICs for now.
375CONFIG_NICREALTEK ?= yes
376
Andrew Morganc29c2e72010-06-07 22:37:54 +0000377# Disable National Semiconductor NICs until support is complete and tested.
378CONFIG_NICNATSEMI ?= no
379
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000380# Always enable Intel NICs for now.
381CONFIG_NICINTEL ?= yes
382
Idwer Vollering004f4b72010-09-03 18:21:21 +0000383# Always enable SPI on Intel NICs for now.
384CONFIG_NICINTEL_SPI ?= yes
385
Mark Marshall90021f22010-12-03 14:48:11 +0000386# Always enable SPI on OGP cards for now.
387CONFIG_OGP_SPI ?= yes
388
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000389# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000390CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000391
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000392# Disable Dediprog SF100 until support is complete and tested.
393CONFIG_DEDIPROG ?= no
394
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000395# Always enable Marvell SATA controllers for now.
396CONFIG_SATAMV ?= yes
397
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000398# Enable Linux spidev interface by default. We disable it on non-Linux targets.
399CONFIG_LINUX_SPI ?= yes
400
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000401# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000402CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000403
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000404# Bitbanging SPI infrastructure, default off unless needed.
405ifeq ($(CONFIG_RAYER_SPI), yes)
406override CONFIG_BITBANG_SPI = yes
407else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000408ifeq ($(CONFIG_PONY_SPI), yes)
409override CONFIG_BITBANG_SPI = yes
410else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000411ifeq ($(CONFIG_INTERNAL), yes)
412override CONFIG_BITBANG_SPI = yes
413else
414ifeq ($(CONFIG_NICINTEL_SPI), yes)
415override CONFIG_BITBANG_SPI = yes
416else
Mark Marshall90021f22010-12-03 14:48:11 +0000417ifeq ($(CONFIG_OGP_SPI), yes)
418override CONFIG_BITBANG_SPI = yes
419else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000420CONFIG_BITBANG_SPI ?= no
421endif
422endif
423endif
Mark Marshall90021f22010-12-03 14:48:11 +0000424endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000425endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000426
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000427###############################################################################
428# Programmer drivers and programmer support infrastructure.
429
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000430FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
431
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000432ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000433FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Carl-Daniel Hailfingerb5b161b2010-06-04 19:05:39 +0000434PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000435ifeq ($(ARCH), x86)
Stefan Tauner1e146392011-09-15 23:52:55 +0000436PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o wbsio_spi.o mcp6x_spi.o
437PROGRAMMER_OBJS += ichspi.o ich_descriptors.o
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000438else
439endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000440NEED_PCI := yes
441endif
442
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000443ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000444FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000445PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000446NEED_SERIAL := yes
447NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000448endif
449
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000450ifeq ($(CONFIG_RAYER_SPI), yes)
451FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
452PROGRAMMER_OBJS += rayer_spi.o
453# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
454NEED_PCI := yes
455endif
456
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000457ifeq ($(CONFIG_PONY_SPI), yes)
458FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
459PROGRAMMER_OBJS += pony_spi.o
460NEED_SERIAL := yes
461endif
462
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000463ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000464FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000465PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000466endif
467
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000468ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000469FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000470PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000471NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000472endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000473
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000474ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000475FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000476PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000477NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000478endif
479
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000480ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000481FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000482PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000483NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000484endif
485
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000486ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000487FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000488PROGRAMMER_OBJS += atahpt.o
489NEED_PCI := yes
490endif
491
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000492ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000493# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000494FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000495NEED_FTDI := yes
496PROGRAMMER_OBJS += ft2232_spi.o
497endif
498
499ifeq ($(CONFIG_USBBLASTER_SPI), yes)
500# This is a totally ugly hack.
501FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
502NEED_FTDI := yes
503PROGRAMMER_OBJS += usbblaster_spi.o
504endif
505
506ifeq ($(NEED_FTDI), yes)
507FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000508FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
Jörg Mayer8776db22009-11-16 14:05:13 +0000509FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000510# We can't set NEED_USB here because that would transform libftdi auto-enabling
511# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000512endif
513
514ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000515FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000516PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000517endif
518
519ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000520FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000521PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000522NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000523endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000524
Joerg Fischer5665ef32010-05-21 21:54:07 +0000525ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000526FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000527PROGRAMMER_OBJS += nicrealtek.o
528NEED_PCI := yes
529endif
530
Andrew Morganc29c2e72010-06-07 22:37:54 +0000531ifeq ($(CONFIG_NICNATSEMI), yes)
532FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
533PROGRAMMER_OBJS += nicnatsemi.o
534NEED_PCI := yes
535endif
536
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000537ifeq ($(CONFIG_NICINTEL), yes)
538FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
539PROGRAMMER_OBJS += nicintel.o
540NEED_PCI := yes
541endif
542
Idwer Vollering004f4b72010-09-03 18:21:21 +0000543ifeq ($(CONFIG_NICINTEL_SPI), yes)
544FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
545PROGRAMMER_OBJS += nicintel_spi.o
546NEED_PCI := yes
547endif
548
Mark Marshall90021f22010-12-03 14:48:11 +0000549ifeq ($(CONFIG_OGP_SPI), yes)
550FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
551PROGRAMMER_OBJS += ogp_spi.o
552NEED_PCI := yes
553endif
554
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000555ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
556FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000557PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000558NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000559endif
560
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000561ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000562FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000563PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000564NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000565endif
566
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000567ifeq ($(CONFIG_SATAMV), yes)
568FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
569PROGRAMMER_OBJS += satamv.o
570NEED_PCI := yes
571endif
572
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000573ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000574# This is a totally ugly hack.
575FEATURE_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 +0000576PROGRAMMER_OBJS += linux_spi.o
577endif
578
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000579ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000580LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000581endif
582
583ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000584ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000585LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000586endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000587endif
588
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000589ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000590CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000591FEATURE_CFLAGS += -D'NEED_PCI=1'
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000592PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000593ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000594# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000595PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000596# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000597PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000598else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000599ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000600# FIXME There needs to be a better way to do this
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000601CPPFLAGS += -I../libpci/include
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000602PCILIBS += ../libpci/lib/libpci.a
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000603else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000604PCILIBS += -lpci
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000605ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000606# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000607PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000608else
609ifeq ($(TARGET_OS), Darwin)
610# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000611PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000612else
613endif
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000614endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000615endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000616endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000617endif
618
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000619ifeq ($(NEED_USB), yes)
620CHECK_LIBUSB0 = yes
621FEATURE_CFLAGS += -D'NEED_USB=1'
622USBLIBS := $(shell pkg-config --libs libusb 2>/dev/null || printf "%s" "-lusb")
623endif
624
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000625ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000626FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000627CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000628endif
629
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000630FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
631
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000632# We could use PULLED_IN_LIBS, but that would be ugly.
633FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
634
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000635LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000636OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000637
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000638all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000639ifeq ($(ARCH), x86)
640 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
641endif
642
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000643$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfinger11990da2013-07-13 23:21:05 +0000644 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000645
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000646libflashrom.a: $(LIBFLASHROM_OBJS)
647 $(AR) rcs $@ $^
648 $(RANLIB) $@
649
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000650# TAROPTIONS reduces information leakage from the packager's system.
651# If other tar programs support command line arguments for setting uid/gid of
652# stored files, they can be handled here as well.
653TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000654
Paul Fox05dfbe62009-06-16 21:08:06 +0000655%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000656 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000657
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000658# Make sure to add all names of generated binaries here.
659# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000660# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000661clean:
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000662 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000663 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000664
Ollie Lho184a4042005-11-26 21:55:36 +0000665distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000666 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000667
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000668strip: $(PROGRAM)$(EXEC_SUFFIX)
669 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000670
Stefan Tauner56787082011-08-18 02:27:19 +0000671# to define test programs we use verbatim variables, which get exported
672# to environment variables and are referenced with $$<varname> later
673
674define COMPILER_TEST
675int main(int argc, char **argv)
676{
677 (void) argc;
678 (void) argv;
679 return 0;
680}
681endef
682export COMPILER_TEST
683
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000684compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000685 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000686 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000687 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000688 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000689 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
690 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000691 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000692 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000693 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000694 ( echo "unknown. Aborting."; exit 1)
695 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000696 @printf "Target OS is "
697 @# FreeBSD wc will output extraneous whitespace.
698 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
699 ( echo "unknown. Aborting."; exit 1)
700 @printf "%s\n" '$(TARGET_OS)'
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000701
Stefan Tauner56787082011-08-18 02:27:19 +0000702define LIBPCI_TEST
703/* Avoid a failing test due to libpci header symbol shadowing breakage */
704#define index shadow_workaround_index
705#include <pci/pci.h>
706struct pci_access *pacc;
707int main(int argc, char **argv)
708{
709 (void) argc;
710 (void) argv;
711 pacc = pci_alloc();
712 return 0;
713}
714endef
715export LIBPCI_TEST
716
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000717define LIBUSB0_TEST
718#include <usb.h>
719int main(int argc, char **argv)
720{
721 (void) argc;
722 (void) argv;
723 usb_init();
724 return 0;
725}
726endef
727export LIBUSB0_TEST
728
729hwlibs: compiler
730 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000731ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000732 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000733 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000734 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000735 echo "found." || ( echo "not found."; echo; \
736 echo "Please install libpci headers (package pciutils-devel)."; \
737 echo "See README for more information."; echo; \
738 rm -f .test.c .test.o; exit 1)
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000739 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000740 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000741 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000742 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000743 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000744 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000745 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000746 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000747 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
748 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000749endif
750ifeq ($(CHECK_LIBUSB0), yes)
751 @printf "Checking for libusb-0.1/libusb-compat headers... "
752 @echo "$$LIBUSB0_TEST" > .test.c
753 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
754 echo "found." || ( echo "not found."; echo; \
755 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
756 echo "See README for more information."; echo; \
757 rm -f .test.c .test.o; exit 1)
758 @printf "Checking if libusb-0.1 is usable... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000759 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000760 echo "yes." || ( echo "no."; \
761 echo "Please install libusb-0.1 or libusb-compat."; \
762 echo "See README for more information."; echo; \
763 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1)
764 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000765endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000766
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000767.features: features
768
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000769# If a user does not explicitly request a non-working feature, we should
770# silently disable it. However, if a non-working (does not compile) feature
771# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000772# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000773featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000774ifeq ($(PROGRAMMER_OBJS),)
775 @echo "You have to enable at least one programmer driver!"
776 @false
777endif
778ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000779 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
780 @false
781endif
782
Stefan Tauner56787082011-08-18 02:27:19 +0000783define FTDI_TEST
784#include <ftdi.h>
785struct ftdi_context *ftdic = NULL;
786int main(int argc, char **argv)
787{
788 (void) argc;
789 (void) argv;
790 return ftdi_init(ftdic);
791}
792endef
793export FTDI_TEST
794
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000795define FTDI_232H_TEST
796#include <ftdi.h>
797enum ftdi_chip_type type = TYPE_232H;
798endef
799export FTDI_232H_TEST
800
Stefan Tauner56787082011-08-18 02:27:19 +0000801define UTSNAME_TEST
802#include <sys/utsname.h>
803struct utsname osinfo;
804int main(int argc, char **argv)
805{
806 (void) argc;
807 (void) argv;
808 uname (&osinfo);
809 return 0;
810}
811endef
812export UTSNAME_TEST
813
Stefan Tauner8868db32012-03-13 00:18:19 +0000814define LINUX_SPI_TEST
815#include <linux/types.h>
816#include <linux/spi/spidev.h>
817
818int main(int argc, char **argv)
819{
820 (void) argc;
821 (void) argv;
822 return 0;
823}
824endef
825export LINUX_SPI_TEST
826
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000827features: compiler
828 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +0000829ifeq ($(NEED_FTDI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +0000830 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +0000831 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000832 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000833 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
834 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000835 @printf "Checking for FT232H support in libftdi... "
836 @echo "$$FTDI_232H_TEST" >> .featuretest.c
837 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
838 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
839 ( echo "not found."; echo "FT232H := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000840endif
Stefan Tauner8868db32012-03-13 00:18:19 +0000841ifeq ($(CONFIG_LINUX_SPI), yes)
842 @printf "Checking if Linux SPI headers are present... "
843 @echo "$$LINUX_SPI_TEST" > .featuretest.c
844 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
845 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
846 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
847endif
Stefan Tauner56787082011-08-18 02:27:19 +0000848 @printf "Checking for utsname support... "
849 @echo "$$UTSNAME_TEST" > .featuretest.c
850 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
851 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
852 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
853 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
854 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +0000855
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000856install: $(PROGRAM)$(EXEC_SUFFIX)
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +0000857 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000858 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000859 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000860 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +0000861
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000862export:
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000863 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
864 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
865 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
866 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
867 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000868
869tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000870 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
871 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
872 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000873
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000874djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000875 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
876libpayload: clean
877 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000878
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000879.PHONY: all clean distclean compiler hwlibs features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +0000880
Stefan Reinauere2f01582010-06-07 11:08:07 +0000881-include $(OBJS:.o=.d)