blob: 9309ce57888c629b8698c719595cab83c37a760f [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
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000042
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000043# If your compiler spits out excessive warnings, run make WARNERROR=no
44# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000045WARNERROR ?= yes
46
47ifeq ($(WARNERROR), yes)
48CFLAGS += -Werror
49endif
50
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000051###############################################################################
52# General OS/architecture specific settings.
53
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000054# HOST_OS is only used to work around local toolchain issues.
55HOST_OS ?= $(shell uname)
56ifeq ($(HOST_OS), MINGW32_NT-5.1)
57# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
58CC = gcc
59endif
60ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +000061STRIP_ARGS = -s
62endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000063
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000064# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000065# IMPORTANT: The following line must be placed before TARGET_OS is ever used
66# (of course), but should come after any lines setting CC because the line
67# below uses CC itself.
68override TARGET_OS := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
69
70ifeq ($(TARGET_OS), Darwin)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000071CPPFLAGS += -I/opt/local/include -I/usr/local/include
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000072LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +000073endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000074
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000075ifeq ($(TARGET_OS), FreeBSD)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000076CPPFLAGS += -I/usr/local/include
Andriy Gapon65c1b862008-05-22 13:22:45 +000077LDFLAGS += -L/usr/local/lib
78endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000079
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000080ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +000081CPPFLAGS += -I/usr/local/include
82LDFLAGS += -L/usr/local/lib
83endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000084
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000085ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +000086EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000087CPPFLAGS += -I../libgetopt
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000088# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000089CFLAGS += -Wno-format
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +000090# FIXME Check if we can achieve the same effect with -L../libgetopt -lgetopt
91LIBS += ../libgetopt/libgetopt.a
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000092# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +000093ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
94UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
95else
96override CONFIG_BUSPIRATE_SPI = no
97endif
98ifeq ($(CONFIG_SERPROG), yes)
99UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
100else
101override CONFIG_SERPROG = no
102endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000103ifeq ($(CONFIG_PONY_SPI), yes)
104UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
105else
106override CONFIG_PONY_SPI = no
107endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000108# Dediprog and FT2232 are not supported under DOS (missing USB support).
109ifeq ($(CONFIG_DEDIPROG), yes)
110UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
111else
112override CONFIG_DEDIPROG = no
113endif
114ifeq ($(CONFIG_FT2232_SPI), yes)
115UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
116else
117override CONFIG_FT2232_SPI = no
118endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000119endif
Ollie Lho184a4042005-11-26 21:55:36 +0000120
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000121# FIXME: Should we check for Cygwin/MSVC as well?
122ifeq ($(TARGET_OS), MinGW)
123EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000124# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000125FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000126# libusb-win32/libftdi stuff is usually installed in /usr/local.
127CPPFLAGS += -I/usr/local/include
128LDFLAGS += -L/usr/local/lib
129# Serprog is not supported under Windows/MinGW (missing sockets support).
130ifeq ($(CONFIG_SERPROG), yes)
131UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
132else
133override CONFIG_SERPROG = no
134endif
135# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
136ifeq ($(CONFIG_INTERNAL), yes)
137UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
138else
139override CONFIG_INTERNAL = no
140endif
141ifeq ($(CONFIG_RAYER_SPI), yes)
142UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
143else
144override CONFIG_RAYER_SPI = no
145endif
146ifeq ($(CONFIG_NIC3COM), yes)
147UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
148else
149override CONFIG_NIC3COM = no
150endif
151ifeq ($(CONFIG_GFXNVIDIA), yes)
152UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
153else
154override CONFIG_GFXNVIDIA = no
155endif
156ifeq ($(CONFIG_SATASII), yes)
157UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
158else
159override CONFIG_SATASII = no
160endif
161ifeq ($(CONFIG_ATAHPT), yes)
162UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
163else
164override CONFIG_ATAHPT = no
165endif
166ifeq ($(CONFIG_DRKAISER), yes)
167UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
168else
169override CONFIG_DRKAISER = no
170endif
171ifeq ($(CONFIG_NICREALTEK), yes)
172UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
173else
174override CONFIG_NICREALTEK = no
175endif
176ifeq ($(CONFIG_NICNATSEMI), yes)
177UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
178else
179override CONFIG_NICNATSEMI = no
180endif
181ifeq ($(CONFIG_NICINTEL), yes)
182UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
183else
184override CONFIG_NICINTEL = no
185endif
186ifeq ($(CONFIG_NICINTEL_SPI), yes)
187UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
188else
189override CONFIG_NICINTEL_SPI = no
190endif
191ifeq ($(CONFIG_OGP_SPI), yes)
192UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
193else
194override CONFIG_OGP_SPI = no
195endif
196ifeq ($(CONFIG_SATAMV), yes)
197UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
198else
199override CONFIG_SATAMV = no
200endif
201endif
202
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000203ifeq ($(TARGET_OS), libpayload)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000204FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000205ifeq ($(CONFIG_DUMMY), yes)
206UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
207else
208override CONFIG_DUMMY = no
209endif
210ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
211UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
212else
213override CONFIG_BUSPIRATE_SPI = no
214endif
215ifeq ($(CONFIG_SERPROG), yes)
216UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
217else
218override CONFIG_SERPROG = no
219endif
220# Dediprog and FT2232 are not supported with libpayload (missing libusb support)
221ifeq ($(CONFIG_DEDIPROG), yes)
222UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
223else
224override CONFIG_DEDIPROG = no
225endif
226ifeq ($(CONFIG_FT2232_SPI), yes)
227UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
228else
229override CONFIG_FT2232_SPI = no
230endif
231endif
232
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000233ifneq ($(TARGET_OS), Linux)
234ifeq ($(CONFIG_LINUX_SPI), yes)
235UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
236else
237override CONFIG_LINUX_SPI = no
238endif
239endif
240
Uwe Hermann44ffd582011-08-20 14:16:00 +0000241# Determine the destination processor architecture.
242# IMPORTANT: The following line must be placed before ARCH is ever used
243# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000244# below uses CC itself.
245override 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 +0000246
David Hendricksb286da72012-02-13 00:35:35 +0000247# PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM.
248# Right now this means the drivers below only work on x86.
249ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000250ifeq ($(CONFIG_NIC3COM), yes)
251UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
252else
253override CONFIG_NIC3COM = no
254endif
255ifeq ($(CONFIG_NICREALTEK), yes)
256UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
257else
258override CONFIG_NICREALTEK = no
259endif
260ifeq ($(CONFIG_NICNATSEMI), yes)
261UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
262else
263override CONFIG_NICNATSEMI = no
264endif
265ifeq ($(CONFIG_RAYER_SPI), yes)
266UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
267else
268override CONFIG_RAYER_SPI = no
269endif
270ifeq ($(CONFIG_ATAHPT), yes)
271UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
272else
273override CONFIG_ATAHPT = no
274endif
275ifeq ($(CONFIG_SATAMV), yes)
276UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
277else
278override CONFIG_SATAMV = no
279endif
280endif
281
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000282###############################################################################
283# Flash chip drivers and bus support infrastructure.
284
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000285CHIP_OBJS = jedec.o stm50flw0x0x.o w39.o w29ee011.o \
Sean Nelson35727f72010-01-28 23:55:12 +0000286 sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
Michael Karcher27c8c6c2012-05-16 00:15:53 +0000287 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o \
Rudolf Marek47eff6b2012-04-14 22:51:40 +0000288 a25.o at25.o opaque.o sfdp.o en29lv640b.o
Sean Nelson5d134642009-12-24 16:54:21 +0000289
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000290###############################################################################
291# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000292
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000293LIB_OBJS = layout.o flashrom.o udelay.o programmer.o
Sean Nelson5d134642009-12-24 16:54:21 +0000294
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000295###############################################################################
296# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000297
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000298CLI_OBJS = cli_classic.o cli_output.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000299
Carl-Daniel Hailfinger9e675852009-05-04 12:29:59 +0000300# Set the flashrom version string from the highest revision number
301# of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000302# Note to packagers: Any tree exported with "make export" or "make tarball"
303# will not require subversion. The downloadable snapshots are already exported.
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000304SVNVERSION := $(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 +0000305
Carl-Daniel Hailfingera5838532012-08-08 00:13:10 +0000306RELEASE := 0.9.6.1
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000307VERSION := $(RELEASE)-r$(SVNVERSION)
308RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000309
310SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000311
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000312# Always enable internal/onboard support for now.
313CONFIG_INTERNAL ?= yes
314
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000315# Always enable serprog for now. Needs to be disabled on Windows.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000316CONFIG_SERPROG ?= yes
317
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000318# RayeR SPIPGM hardware support
319CONFIG_RAYER_SPI ?= yes
320
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000321# PonyProg2000 SPI hardware support
322CONFIG_PONY_SPI ?= yes
323
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000324# Always enable 3Com NICs for now.
325CONFIG_NIC3COM ?= yes
326
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000327# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
328CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000329
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000330# Always enable SiI SATA controllers for now.
331CONFIG_SATASII ?= yes
332
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000333# Highpoint (HPT) ATA/RAID controller support.
334# IMPORTANT: This code is not yet working!
335CONFIG_ATAHPT ?= no
336
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000337# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000338CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000339
340# Always enable dummy tracing for now.
341CONFIG_DUMMY ?= yes
342
343# Always enable Dr. Kaiser for now.
344CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000345
Joerg Fischer5665ef32010-05-21 21:54:07 +0000346# Always enable Realtek NICs for now.
347CONFIG_NICREALTEK ?= yes
348
Andrew Morganc29c2e72010-06-07 22:37:54 +0000349# Disable National Semiconductor NICs until support is complete and tested.
350CONFIG_NICNATSEMI ?= no
351
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000352# Always enable Intel NICs for now.
353CONFIG_NICINTEL ?= yes
354
Idwer Vollering004f4b72010-09-03 18:21:21 +0000355# Always enable SPI on Intel NICs for now.
356CONFIG_NICINTEL_SPI ?= yes
357
Mark Marshall90021f22010-12-03 14:48:11 +0000358# Always enable SPI on OGP cards for now.
359CONFIG_OGP_SPI ?= yes
360
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000361# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000362CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000363
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000364# Disable Dediprog SF100 until support is complete and tested.
365CONFIG_DEDIPROG ?= no
366
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000367# Always enable Marvell SATA controllers for now.
368CONFIG_SATAMV ?= yes
369
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000370# Enable Linux spidev interface by default. We disable it on non-Linux targets.
371CONFIG_LINUX_SPI ?= yes
372
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000373# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000374CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000375
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000376# Bitbanging SPI infrastructure, default off unless needed.
377ifeq ($(CONFIG_RAYER_SPI), yes)
378override CONFIG_BITBANG_SPI = yes
379else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000380ifeq ($(CONFIG_PONY_SPI), yes)
381override CONFIG_BITBANG_SPI = yes
382else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000383ifeq ($(CONFIG_INTERNAL), yes)
384override CONFIG_BITBANG_SPI = yes
385else
386ifeq ($(CONFIG_NICINTEL_SPI), yes)
387override CONFIG_BITBANG_SPI = yes
388else
Mark Marshall90021f22010-12-03 14:48:11 +0000389ifeq ($(CONFIG_OGP_SPI), yes)
390override CONFIG_BITBANG_SPI = yes
391else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000392CONFIG_BITBANG_SPI ?= no
393endif
394endif
395endif
Mark Marshall90021f22010-12-03 14:48:11 +0000396endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000397endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000398
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000399###############################################################################
400# Programmer drivers and programmer support infrastructure.
401
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000402ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000403FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Carl-Daniel Hailfingerb5b161b2010-06-04 19:05:39 +0000404PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000405ifeq ($(ARCH), x86)
Stefan Tauner1e146392011-09-15 23:52:55 +0000406PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o wbsio_spi.o mcp6x_spi.o
407PROGRAMMER_OBJS += ichspi.o ich_descriptors.o
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000408else
409endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000410NEED_PCI := yes
411endif
412
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000413ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000414FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000415PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000416NEED_SERIAL := yes
417NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000418endif
419
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000420ifeq ($(CONFIG_RAYER_SPI), yes)
421FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
422PROGRAMMER_OBJS += rayer_spi.o
423# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
424NEED_PCI := yes
425endif
426
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000427ifeq ($(CONFIG_PONY_SPI), yes)
428FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
429PROGRAMMER_OBJS += pony_spi.o
430NEED_SERIAL := yes
431endif
432
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000433ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000434FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000435PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000436endif
437
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000438ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000439FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000440PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000441NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000442endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000443
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000444ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000445FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000446PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000447NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000448endif
449
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000450ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000451FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000452PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000453NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000454endif
455
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000456ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000457FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000458PROGRAMMER_OBJS += atahpt.o
459NEED_PCI := yes
460endif
461
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000462ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfingerc1f00c52010-01-09 14:18:01 +0000463FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000464# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000465FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Jörg Mayer8776db22009-11-16 14:05:13 +0000466FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Sean Nelson5d134642009-12-24 16:54:21 +0000467PROGRAMMER_OBJS += ft2232_spi.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000468endif
469
470ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000471FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000472PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000473endif
474
475ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000476FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000477PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000478NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000479endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000480
Joerg Fischer5665ef32010-05-21 21:54:07 +0000481ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000482FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000483PROGRAMMER_OBJS += nicrealtek.o
484NEED_PCI := yes
485endif
486
Andrew Morganc29c2e72010-06-07 22:37:54 +0000487ifeq ($(CONFIG_NICNATSEMI), yes)
488FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
489PROGRAMMER_OBJS += nicnatsemi.o
490NEED_PCI := yes
491endif
492
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000493ifeq ($(CONFIG_NICINTEL), yes)
494FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
495PROGRAMMER_OBJS += nicintel.o
496NEED_PCI := yes
497endif
498
Idwer Vollering004f4b72010-09-03 18:21:21 +0000499ifeq ($(CONFIG_NICINTEL_SPI), yes)
500FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
501PROGRAMMER_OBJS += nicintel_spi.o
502NEED_PCI := yes
503endif
504
Mark Marshall90021f22010-12-03 14:48:11 +0000505ifeq ($(CONFIG_OGP_SPI), yes)
506FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
507PROGRAMMER_OBJS += ogp_spi.o
508NEED_PCI := yes
509endif
510
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000511ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
512FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000513PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000514NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000515endif
516
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000517ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000518FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000519FEATURE_LIBS += -lusb
520PROGRAMMER_OBJS += dediprog.o
521endif
522
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000523ifeq ($(CONFIG_SATAMV), yes)
524FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
525PROGRAMMER_OBJS += satamv.o
526NEED_PCI := yes
527endif
528
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000529ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000530# This is a totally ugly hack.
531FEATURE_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 +0000532PROGRAMMER_OBJS += linux_spi.o
533endif
534
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000535ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000536LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000537endif
538
539ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000540ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000541LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000542endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000543endif
544
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000545ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000546CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000547FEATURE_CFLAGS += -D'NEED_PCI=1'
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000548PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000549ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000550# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
551LIBS += -lpciutils -lpci
552# For (i386|x86_64)_iopl(2).
553LIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000554else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000555ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000556# FIXME There needs to be a better way to do this
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000557CPPFLAGS += -I../libpci/include
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000558LIBS += ../libpci/lib/libpci.a
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000559else
560LIBS += -lpci
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000561ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000562# For (i386|amd64)_iopl(2).
563LIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000564else
565ifeq ($(TARGET_OS), Darwin)
566# DirectHW framework can be found in the DirectHW library.
567LIBS += -framework IOKit -framework DirectHW
568else
569endif
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000570endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000571endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000572endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000573endif
574
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000575ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000576FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000577CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000578endif
579
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000580FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
581
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000582# We could use PULLED_IN_LIBS, but that would be ugly.
583FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
584
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000585LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000586OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000587
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000588all: pciutils features $(PROGRAM)$(EXEC_SUFFIX)
589ifeq ($(ARCH), x86)
590 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
591endif
592
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000593$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
594 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(FEATURE_LIBS) $(LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000595
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000596libflashrom.a: $(LIBFLASHROM_OBJS)
597 $(AR) rcs $@ $^
598 $(RANLIB) $@
599
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000600# TAROPTIONS reduces information leakage from the packager's system.
601# If other tar programs support command line arguments for setting uid/gid of
602# stored files, they can be handled here as well.
603TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000604
Paul Fox05dfbe62009-06-16 21:08:06 +0000605%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000606 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000607
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000608# Make sure to add all names of generated binaries here.
609# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000610# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000611clean:
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000612 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000613 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000614
Ollie Lho184a4042005-11-26 21:55:36 +0000615distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000616 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000617
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000618strip: $(PROGRAM)$(EXEC_SUFFIX)
619 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000620
Stefan Tauner56787082011-08-18 02:27:19 +0000621# to define test programs we use verbatim variables, which get exported
622# to environment variables and are referenced with $$<varname> later
623
624define COMPILER_TEST
625int main(int argc, char **argv)
626{
627 (void) argc;
628 (void) argv;
629 return 0;
630}
631endef
632export COMPILER_TEST
633
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000634compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000635 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000636 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000637 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000638 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000639 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
640 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000641 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000642 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000643 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000644 ( echo "unknown. Aborting."; exit 1)
645 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000646 @printf "Target OS is "
647 @# FreeBSD wc will output extraneous whitespace.
648 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
649 ( echo "unknown. Aborting."; exit 1)
650 @printf "%s\n" '$(TARGET_OS)'
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000651
Stefan Tauner56787082011-08-18 02:27:19 +0000652define LIBPCI_TEST
653/* Avoid a failing test due to libpci header symbol shadowing breakage */
654#define index shadow_workaround_index
655#include <pci/pci.h>
656struct pci_access *pacc;
657int main(int argc, char **argv)
658{
659 (void) argc;
660 (void) argv;
661 pacc = pci_alloc();
662 return 0;
663}
664endef
665export LIBPCI_TEST
666
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000667ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000668pciutils: compiler
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000669 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000670 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000671 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000672 echo "found." || ( echo "not found."; echo; \
673 echo "Please install libpci headers (package pciutils-devel)."; \
674 echo "See README for more information."; echo; \
675 rm -f .test.c .test.o; exit 1)
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000676 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000677 @printf "" > .libdeps
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000678 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000679 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000680 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000681 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000682 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000683 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000684 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000685 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
686 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000687else
688pciutils: compiler
689 @printf "" > .libdeps
690endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000691
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000692.features: features
693
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000694# If a user does not explicitly request a non-working feature, we should
695# silently disable it. However, if a non-working (does not compile) feature
696# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000697# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000698featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000699ifeq ($(PROGRAMMER_OBJS),)
700 @echo "You have to enable at least one programmer driver!"
701 @false
702endif
703ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000704 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
705 @false
706endif
707
Stefan Tauner56787082011-08-18 02:27:19 +0000708define FTDI_TEST
709#include <ftdi.h>
710struct ftdi_context *ftdic = NULL;
711int main(int argc, char **argv)
712{
713 (void) argc;
714 (void) argv;
715 return ftdi_init(ftdic);
716}
717endef
718export FTDI_TEST
719
720define UTSNAME_TEST
721#include <sys/utsname.h>
722struct utsname osinfo;
723int main(int argc, char **argv)
724{
725 (void) argc;
726 (void) argv;
727 uname (&osinfo);
728 return 0;
729}
730endef
731export UTSNAME_TEST
732
Stefan Tauner8868db32012-03-13 00:18:19 +0000733define LINUX_SPI_TEST
734#include <linux/types.h>
735#include <linux/spi/spidev.h>
736
737int main(int argc, char **argv)
738{
739 (void) argc;
740 (void) argv;
741 return 0;
742}
743endef
744export LINUX_SPI_TEST
745
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000746features: compiler
747 @echo "FEATURES := yes" > .features.tmp
Stefan Tauner56787082011-08-18 02:27:19 +0000748ifeq ($(CONFIG_FT2232_SPI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +0000749 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +0000750 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000751 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000752 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
753 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000754endif
Stefan Tauner8868db32012-03-13 00:18:19 +0000755ifeq ($(CONFIG_LINUX_SPI), yes)
756 @printf "Checking if Linux SPI headers are present... "
757 @echo "$$LINUX_SPI_TEST" > .featuretest.c
758 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
759 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
760 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
761endif
Stefan Tauner56787082011-08-18 02:27:19 +0000762 @printf "Checking for utsname support... "
763 @echo "$$UTSNAME_TEST" > .featuretest.c
764 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
765 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
766 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
767 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
768 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +0000769
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000770install: $(PROGRAM)$(EXEC_SUFFIX)
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +0000771 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000772 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000773 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000774 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +0000775
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000776export:
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000777 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
778 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
779 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
780 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
781 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000782
783tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000784 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
785 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
786 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000787
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000788djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000789 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
790libpayload: clean
791 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000792
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000793.PHONY: all clean distclean compiler pciutils features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +0000794
Stefan Reinauere2f01582010-06-07 11:08:07 +0000795-include $(OBJS:.o=.d)