blob: 805290c7650c85840dfdcd5160abf2136b266e6b [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
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000143# libusb-win32/libftdi stuff is usually installed in /usr/local.
144CPPFLAGS += -I/usr/local/include
145LDFLAGS += -L/usr/local/lib
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000146# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
147ifeq ($(CONFIG_INTERNAL), yes)
148UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
149else
150override CONFIG_INTERNAL = no
151endif
152ifeq ($(CONFIG_RAYER_SPI), yes)
153UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
154else
155override CONFIG_RAYER_SPI = no
156endif
157ifeq ($(CONFIG_NIC3COM), yes)
158UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
159else
160override CONFIG_NIC3COM = no
161endif
162ifeq ($(CONFIG_GFXNVIDIA), yes)
163UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
164else
165override CONFIG_GFXNVIDIA = no
166endif
167ifeq ($(CONFIG_SATASII), yes)
168UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
169else
170override CONFIG_SATASII = no
171endif
172ifeq ($(CONFIG_ATAHPT), yes)
173UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
174else
175override CONFIG_ATAHPT = no
176endif
177ifeq ($(CONFIG_DRKAISER), yes)
178UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
179else
180override CONFIG_DRKAISER = no
181endif
182ifeq ($(CONFIG_NICREALTEK), yes)
183UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
184else
185override CONFIG_NICREALTEK = no
186endif
187ifeq ($(CONFIG_NICNATSEMI), yes)
188UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
189else
190override CONFIG_NICNATSEMI = no
191endif
192ifeq ($(CONFIG_NICINTEL), yes)
193UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
194else
195override CONFIG_NICINTEL = no
196endif
197ifeq ($(CONFIG_NICINTEL_SPI), yes)
198UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
199else
200override CONFIG_NICINTEL_SPI = no
201endif
202ifeq ($(CONFIG_OGP_SPI), yes)
203UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
204else
205override CONFIG_OGP_SPI = no
206endif
207ifeq ($(CONFIG_SATAMV), yes)
208UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
209else
210override CONFIG_SATAMV = no
211endif
212endif
213
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000214ifeq ($(TARGET_OS), libpayload)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000215FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000216ifeq ($(CONFIG_DUMMY), yes)
217UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
218else
219override CONFIG_DUMMY = no
220endif
221ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
222UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
223else
224override CONFIG_BUSPIRATE_SPI = no
225endif
226ifeq ($(CONFIG_SERPROG), yes)
227UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
228else
229override CONFIG_SERPROG = no
230endif
231# Dediprog and FT2232 are not supported with libpayload (missing libusb support)
232ifeq ($(CONFIG_DEDIPROG), yes)
233UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
234else
235override CONFIG_DEDIPROG = no
236endif
237ifeq ($(CONFIG_FT2232_SPI), yes)
238UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
239else
240override CONFIG_FT2232_SPI = no
241endif
James Lairdc60de0e2013-03-27 13:00:23 +0000242ifeq ($(CONFIG_USBBLASTER_SPI), yes)
243UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
244else
245override CONFIG_USBBLASTER_SPI = no
246endif
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000247endif
248
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000249ifneq ($(TARGET_OS), Linux)
250ifeq ($(CONFIG_LINUX_SPI), yes)
251UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
252else
253override CONFIG_LINUX_SPI = no
254endif
255endif
256
Uwe Hermann44ffd582011-08-20 14:16:00 +0000257# Determine the destination processor architecture.
258# IMPORTANT: The following line must be placed before ARCH is ever used
259# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000260# below uses CC itself.
261override 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 +0000262
David Hendricksb286da72012-02-13 00:35:35 +0000263# PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM.
264# Right now this means the drivers below only work on x86.
265ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000266ifeq ($(CONFIG_NIC3COM), yes)
267UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
268else
269override CONFIG_NIC3COM = no
270endif
271ifeq ($(CONFIG_NICREALTEK), yes)
272UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
273else
274override CONFIG_NICREALTEK = no
275endif
276ifeq ($(CONFIG_NICNATSEMI), yes)
277UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
278else
279override CONFIG_NICNATSEMI = no
280endif
281ifeq ($(CONFIG_RAYER_SPI), yes)
282UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
283else
284override CONFIG_RAYER_SPI = no
285endif
286ifeq ($(CONFIG_ATAHPT), yes)
287UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
288else
289override CONFIG_ATAHPT = no
290endif
291ifeq ($(CONFIG_SATAMV), yes)
292UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
293else
294override CONFIG_SATAMV = no
295endif
296endif
297
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000298###############################################################################
299# Flash chip drivers and bus support infrastructure.
300
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000301CHIP_OBJS = jedec.o stm50flw0x0x.o w39.o w29ee011.o \
Sean Nelson35727f72010-01-28 23:55:12 +0000302 sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000303 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
304 opaque.o sfdp.o en29lv640b.o
Sean Nelson5d134642009-12-24 16:54:21 +0000305
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000306###############################################################################
307# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000308
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000309LIB_OBJS = layout.o flashrom.o udelay.o programmer.o
Sean Nelson5d134642009-12-24 16:54:21 +0000310
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000311###############################################################################
312# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000313
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000314CLI_OBJS = cli_classic.o cli_output.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000315
Carl-Daniel Hailfinger9e675852009-05-04 12:29:59 +0000316# Set the flashrom version string from the highest revision number
317# of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000318# Note to packagers: Any tree exported with "make export" or "make tarball"
319# will not require subversion. The downloadable snapshots are already exported.
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000320SVNVERSION := $(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 +0000321
Carl-Daniel Hailfingera5838532012-08-08 00:13:10 +0000322RELEASE := 0.9.6.1
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000323VERSION := $(RELEASE)-r$(SVNVERSION)
324RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000325
326SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000327
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000328# Always enable internal/onboard support for now.
329CONFIG_INTERNAL ?= yes
330
Stefan Tauner52b6e9d2013-04-01 00:46:05 +0000331# Always enable serprog for now.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000332CONFIG_SERPROG ?= yes
333
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000334# RayeR SPIPGM hardware support
335CONFIG_RAYER_SPI ?= yes
336
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000337# PonyProg2000 SPI hardware support
338CONFIG_PONY_SPI ?= yes
339
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000340# Always enable 3Com NICs for now.
341CONFIG_NIC3COM ?= yes
342
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000343# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
344CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000345
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000346# Always enable SiI SATA controllers for now.
347CONFIG_SATASII ?= yes
348
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000349# Highpoint (HPT) ATA/RAID controller support.
350# IMPORTANT: This code is not yet working!
351CONFIG_ATAHPT ?= no
352
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000353# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000354CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000355
James Lairdc60de0e2013-03-27 13:00:23 +0000356# Always enable Altera USB-Blaster dongles for now.
357CONFIG_USBBLASTER_SPI ?= yes
358
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000359# Always enable dummy tracing for now.
360CONFIG_DUMMY ?= yes
361
362# Always enable Dr. Kaiser for now.
363CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000364
Joerg Fischer5665ef32010-05-21 21:54:07 +0000365# Always enable Realtek NICs for now.
366CONFIG_NICREALTEK ?= yes
367
Andrew Morganc29c2e72010-06-07 22:37:54 +0000368# Disable National Semiconductor NICs until support is complete and tested.
369CONFIG_NICNATSEMI ?= no
370
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000371# Always enable Intel NICs for now.
372CONFIG_NICINTEL ?= yes
373
Idwer Vollering004f4b72010-09-03 18:21:21 +0000374# Always enable SPI on Intel NICs for now.
375CONFIG_NICINTEL_SPI ?= yes
376
Mark Marshall90021f22010-12-03 14:48:11 +0000377# Always enable SPI on OGP cards for now.
378CONFIG_OGP_SPI ?= yes
379
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000380# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000381CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000382
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000383# Disable Dediprog SF100 until support is complete and tested.
384CONFIG_DEDIPROG ?= no
385
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000386# Always enable Marvell SATA controllers for now.
387CONFIG_SATAMV ?= yes
388
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000389# Enable Linux spidev interface by default. We disable it on non-Linux targets.
390CONFIG_LINUX_SPI ?= yes
391
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000392# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000393CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000394
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000395# Bitbanging SPI infrastructure, default off unless needed.
396ifeq ($(CONFIG_RAYER_SPI), yes)
397override CONFIG_BITBANG_SPI = yes
398else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000399ifeq ($(CONFIG_PONY_SPI), yes)
400override CONFIG_BITBANG_SPI = yes
401else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000402ifeq ($(CONFIG_INTERNAL), yes)
403override CONFIG_BITBANG_SPI = yes
404else
405ifeq ($(CONFIG_NICINTEL_SPI), yes)
406override CONFIG_BITBANG_SPI = yes
407else
Mark Marshall90021f22010-12-03 14:48:11 +0000408ifeq ($(CONFIG_OGP_SPI), yes)
409override CONFIG_BITBANG_SPI = yes
410else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000411CONFIG_BITBANG_SPI ?= no
412endif
413endif
414endif
Mark Marshall90021f22010-12-03 14:48:11 +0000415endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000416endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000417
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000418###############################################################################
419# Programmer drivers and programmer support infrastructure.
420
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000421FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
422
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000423ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000424FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Carl-Daniel Hailfingerb5b161b2010-06-04 19:05:39 +0000425PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000426ifeq ($(ARCH), x86)
Stefan Tauner1e146392011-09-15 23:52:55 +0000427PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o wbsio_spi.o mcp6x_spi.o
428PROGRAMMER_OBJS += ichspi.o ich_descriptors.o
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000429else
430endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000431NEED_PCI := yes
432endif
433
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000434ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000435FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000436PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000437NEED_SERIAL := yes
438NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000439endif
440
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000441ifeq ($(CONFIG_RAYER_SPI), yes)
442FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
443PROGRAMMER_OBJS += rayer_spi.o
444# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
445NEED_PCI := yes
446endif
447
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000448ifeq ($(CONFIG_PONY_SPI), yes)
449FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
450PROGRAMMER_OBJS += pony_spi.o
451NEED_SERIAL := yes
452endif
453
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000454ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000455FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000456PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000457endif
458
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000459ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000460FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000461PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000462NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000463endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000464
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000465ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000466FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000467PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000468NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000469endif
470
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000471ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000472FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000473PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000474NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000475endif
476
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000477ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000478FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000479PROGRAMMER_OBJS += atahpt.o
480NEED_PCI := yes
481endif
482
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000483ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000484# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000485FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
James Lairdc60de0e2013-03-27 13:00:23 +0000486NEED_FTDI := yes
487PROGRAMMER_OBJS += ft2232_spi.o
488endif
489
490ifeq ($(CONFIG_USBBLASTER_SPI), yes)
491# This is a totally ugly hack.
492FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
493NEED_FTDI := yes
494PROGRAMMER_OBJS += usbblaster_spi.o
495endif
496
497ifeq ($(NEED_FTDI), yes)
498FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000499FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
Jörg Mayer8776db22009-11-16 14:05:13 +0000500FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000501# We can't set NEED_USB here because that would transform libftdi auto-enabling
502# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000503endif
504
505ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000506FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000507PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000508endif
509
510ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000511FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000512PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000513NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000514endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000515
Joerg Fischer5665ef32010-05-21 21:54:07 +0000516ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000517FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000518PROGRAMMER_OBJS += nicrealtek.o
519NEED_PCI := yes
520endif
521
Andrew Morganc29c2e72010-06-07 22:37:54 +0000522ifeq ($(CONFIG_NICNATSEMI), yes)
523FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
524PROGRAMMER_OBJS += nicnatsemi.o
525NEED_PCI := yes
526endif
527
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000528ifeq ($(CONFIG_NICINTEL), yes)
529FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
530PROGRAMMER_OBJS += nicintel.o
531NEED_PCI := yes
532endif
533
Idwer Vollering004f4b72010-09-03 18:21:21 +0000534ifeq ($(CONFIG_NICINTEL_SPI), yes)
535FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
536PROGRAMMER_OBJS += nicintel_spi.o
537NEED_PCI := yes
538endif
539
Mark Marshall90021f22010-12-03 14:48:11 +0000540ifeq ($(CONFIG_OGP_SPI), yes)
541FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
542PROGRAMMER_OBJS += ogp_spi.o
543NEED_PCI := yes
544endif
545
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000546ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
547FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000548PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000549NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000550endif
551
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000552ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000553FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000554PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000555NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000556endif
557
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000558ifeq ($(CONFIG_SATAMV), yes)
559FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
560PROGRAMMER_OBJS += satamv.o
561NEED_PCI := yes
562endif
563
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000564ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000565# This is a totally ugly hack.
566FEATURE_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 +0000567PROGRAMMER_OBJS += linux_spi.o
568endif
569
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000570ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000571LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000572endif
573
574ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000575ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000576LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000577endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000578endif
579
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000580ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000581CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000582FEATURE_CFLAGS += -D'NEED_PCI=1'
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000583PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000584ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000585# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000586PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000587# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000588PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000589else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000590ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000591# FIXME There needs to be a better way to do this
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000592CPPFLAGS += -I../libpci/include
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000593PCILIBS += ../libpci/lib/libpci.a
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000594else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000595PCILIBS += -lpci
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000596ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000597# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000598PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000599else
600ifeq ($(TARGET_OS), Darwin)
601# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000602PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000603else
604endif
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000605endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000606endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000607endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000608endif
609
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000610ifeq ($(NEED_USB), yes)
611CHECK_LIBUSB0 = yes
612FEATURE_CFLAGS += -D'NEED_USB=1'
613USBLIBS := $(shell pkg-config --libs libusb 2>/dev/null || printf "%s" "-lusb")
614endif
615
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000616ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000617FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000618CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000619endif
620
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000621FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
622
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000623# We could use PULLED_IN_LIBS, but that would be ugly.
624FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
625
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000626LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000627OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000628
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000629all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000630ifeq ($(ARCH), x86)
631 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
632endif
633
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000634$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000635 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(FEATURE_LIBS) $(LIBS) $(PCILIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000636
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000637libflashrom.a: $(LIBFLASHROM_OBJS)
638 $(AR) rcs $@ $^
639 $(RANLIB) $@
640
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000641# TAROPTIONS reduces information leakage from the packager's system.
642# If other tar programs support command line arguments for setting uid/gid of
643# stored files, they can be handled here as well.
644TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000645
Paul Fox05dfbe62009-06-16 21:08:06 +0000646%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000647 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000648
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000649# Make sure to add all names of generated binaries here.
650# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000651# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000652clean:
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000653 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000654 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000655
Ollie Lho184a4042005-11-26 21:55:36 +0000656distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000657 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000658
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000659strip: $(PROGRAM)$(EXEC_SUFFIX)
660 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000661
Stefan Tauner56787082011-08-18 02:27:19 +0000662# to define test programs we use verbatim variables, which get exported
663# to environment variables and are referenced with $$<varname> later
664
665define COMPILER_TEST
666int main(int argc, char **argv)
667{
668 (void) argc;
669 (void) argv;
670 return 0;
671}
672endef
673export COMPILER_TEST
674
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000675compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000676 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000677 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000678 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000679 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000680 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
681 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000682 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000683 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000684 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000685 ( echo "unknown. Aborting."; exit 1)
686 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000687 @printf "Target OS is "
688 @# FreeBSD wc will output extraneous whitespace.
689 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
690 ( echo "unknown. Aborting."; exit 1)
691 @printf "%s\n" '$(TARGET_OS)'
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000692
Stefan Tauner56787082011-08-18 02:27:19 +0000693define LIBPCI_TEST
694/* Avoid a failing test due to libpci header symbol shadowing breakage */
695#define index shadow_workaround_index
696#include <pci/pci.h>
697struct pci_access *pacc;
698int main(int argc, char **argv)
699{
700 (void) argc;
701 (void) argv;
702 pacc = pci_alloc();
703 return 0;
704}
705endef
706export LIBPCI_TEST
707
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000708define LIBUSB0_TEST
709#include <usb.h>
710int main(int argc, char **argv)
711{
712 (void) argc;
713 (void) argv;
714 usb_init();
715 return 0;
716}
717endef
718export LIBUSB0_TEST
719
720hwlibs: compiler
721 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000722ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000723 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000724 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000725 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000726 echo "found." || ( echo "not found."; echo; \
727 echo "Please install libpci headers (package pciutils-devel)."; \
728 echo "See README for more information."; echo; \
729 rm -f .test.c .test.o; exit 1)
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000730 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000731 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000732 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000733 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000734 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000735 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000736 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000737 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000738 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
739 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000740endif
741ifeq ($(CHECK_LIBUSB0), yes)
742 @printf "Checking for libusb-0.1/libusb-compat headers... "
743 @echo "$$LIBUSB0_TEST" > .test.c
744 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
745 echo "found." || ( echo "not found."; echo; \
746 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
747 echo "See README for more information."; echo; \
748 rm -f .test.c .test.o; exit 1)
749 @printf "Checking if libusb-0.1 is usable... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000750 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000751 echo "yes." || ( echo "no."; \
752 echo "Please install libusb-0.1 or libusb-compat."; \
753 echo "See README for more information."; echo; \
754 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1)
755 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000756endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000757
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000758.features: features
759
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000760# If a user does not explicitly request a non-working feature, we should
761# silently disable it. However, if a non-working (does not compile) feature
762# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000763# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000764featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000765ifeq ($(PROGRAMMER_OBJS),)
766 @echo "You have to enable at least one programmer driver!"
767 @false
768endif
769ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000770 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
771 @false
772endif
773
Stefan Tauner56787082011-08-18 02:27:19 +0000774define FTDI_TEST
775#include <ftdi.h>
776struct ftdi_context *ftdic = NULL;
777int main(int argc, char **argv)
778{
779 (void) argc;
780 (void) argv;
781 return ftdi_init(ftdic);
782}
783endef
784export FTDI_TEST
785
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000786define FTDI_232H_TEST
787#include <ftdi.h>
788enum ftdi_chip_type type = TYPE_232H;
789endef
790export FTDI_232H_TEST
791
Stefan Tauner56787082011-08-18 02:27:19 +0000792define UTSNAME_TEST
793#include <sys/utsname.h>
794struct utsname osinfo;
795int main(int argc, char **argv)
796{
797 (void) argc;
798 (void) argv;
799 uname (&osinfo);
800 return 0;
801}
802endef
803export UTSNAME_TEST
804
Stefan Tauner8868db32012-03-13 00:18:19 +0000805define LINUX_SPI_TEST
806#include <linux/types.h>
807#include <linux/spi/spidev.h>
808
809int main(int argc, char **argv)
810{
811 (void) argc;
812 (void) argv;
813 return 0;
814}
815endef
816export LINUX_SPI_TEST
817
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000818features: compiler
819 @echo "FEATURES := yes" > .features.tmp
James Lairdc60de0e2013-03-27 13:00:23 +0000820ifeq ($(NEED_FTDI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +0000821 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +0000822 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000823 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000824 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
825 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000826 @printf "Checking for FT232H support in libftdi... "
827 @echo "$$FTDI_232H_TEST" >> .featuretest.c
828 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
829 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
830 ( echo "not found."; echo "FT232H := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000831endif
Stefan Tauner8868db32012-03-13 00:18:19 +0000832ifeq ($(CONFIG_LINUX_SPI), yes)
833 @printf "Checking if Linux SPI headers are present... "
834 @echo "$$LINUX_SPI_TEST" > .featuretest.c
835 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
836 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
837 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
838endif
Stefan Tauner56787082011-08-18 02:27:19 +0000839 @printf "Checking for utsname support... "
840 @echo "$$UTSNAME_TEST" > .featuretest.c
841 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
842 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
843 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
844 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
845 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +0000846
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000847install: $(PROGRAM)$(EXEC_SUFFIX)
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +0000848 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000849 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000850 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000851 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +0000852
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000853export:
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000854 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
855 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
856 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
857 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
858 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000859
860tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000861 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
862 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
863 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000864
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000865djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000866 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
867libpayload: clean
868 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000869
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000870.PHONY: all clean distclean compiler hwlibs features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +0000871
Stefan Reinauere2f01582010-06-07 11:08:07 +0000872-include $(OBJS:.o=.d)