blob: b9489961afb66d51cb8cd211ed4a8231be90c512 [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
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000131endif
Ollie Lho184a4042005-11-26 21:55:36 +0000132
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000133# FIXME: Should we check for Cygwin/MSVC as well?
134ifeq ($(TARGET_OS), MinGW)
135EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000136# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000137FLASHROM_CFLAGS += -Dffs=__builtin_ffs
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000138# libusb-win32/libftdi stuff is usually installed in /usr/local.
139CPPFLAGS += -I/usr/local/include
140LDFLAGS += -L/usr/local/lib
141# Serprog is not supported under Windows/MinGW (missing sockets support).
142ifeq ($(CONFIG_SERPROG), yes)
143UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
144else
145override CONFIG_SERPROG = no
146endif
147# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
148ifeq ($(CONFIG_INTERNAL), yes)
149UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
150else
151override CONFIG_INTERNAL = no
152endif
153ifeq ($(CONFIG_RAYER_SPI), yes)
154UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
155else
156override CONFIG_RAYER_SPI = no
157endif
158ifeq ($(CONFIG_NIC3COM), yes)
159UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
160else
161override CONFIG_NIC3COM = no
162endif
163ifeq ($(CONFIG_GFXNVIDIA), yes)
164UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
165else
166override CONFIG_GFXNVIDIA = no
167endif
168ifeq ($(CONFIG_SATASII), yes)
169UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
170else
171override CONFIG_SATASII = no
172endif
173ifeq ($(CONFIG_ATAHPT), yes)
174UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
175else
176override CONFIG_ATAHPT = no
177endif
178ifeq ($(CONFIG_DRKAISER), yes)
179UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
180else
181override CONFIG_DRKAISER = no
182endif
183ifeq ($(CONFIG_NICREALTEK), yes)
184UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
185else
186override CONFIG_NICREALTEK = no
187endif
188ifeq ($(CONFIG_NICNATSEMI), yes)
189UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
190else
191override CONFIG_NICNATSEMI = no
192endif
193ifeq ($(CONFIG_NICINTEL), yes)
194UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
195else
196override CONFIG_NICINTEL = no
197endif
198ifeq ($(CONFIG_NICINTEL_SPI), yes)
199UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
200else
201override CONFIG_NICINTEL_SPI = no
202endif
203ifeq ($(CONFIG_OGP_SPI), yes)
204UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
205else
206override CONFIG_OGP_SPI = no
207endif
208ifeq ($(CONFIG_SATAMV), yes)
209UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
210else
211override CONFIG_SATAMV = no
212endif
213endif
214
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000215ifeq ($(TARGET_OS), libpayload)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000216FLASHROM_CFLAGS += -DSTANDALONE
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000217ifeq ($(CONFIG_DUMMY), yes)
218UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
219else
220override CONFIG_DUMMY = no
221endif
222ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
223UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
224else
225override CONFIG_BUSPIRATE_SPI = no
226endif
227ifeq ($(CONFIG_SERPROG), yes)
228UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
229else
230override CONFIG_SERPROG = no
231endif
232# Dediprog and FT2232 are not supported with libpayload (missing libusb support)
233ifeq ($(CONFIG_DEDIPROG), yes)
234UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
235else
236override CONFIG_DEDIPROG = no
237endif
238ifeq ($(CONFIG_FT2232_SPI), yes)
239UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
240else
241override CONFIG_FT2232_SPI = no
242endif
243endif
244
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000245ifneq ($(TARGET_OS), Linux)
246ifeq ($(CONFIG_LINUX_SPI), yes)
247UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
248else
249override CONFIG_LINUX_SPI = no
250endif
251endif
252
Uwe Hermann44ffd582011-08-20 14:16:00 +0000253# Determine the destination processor architecture.
254# IMPORTANT: The following line must be placed before ARCH is ever used
255# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000256# below uses CC itself.
257override 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 +0000258
David Hendricksb286da72012-02-13 00:35:35 +0000259# PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM.
260# Right now this means the drivers below only work on x86.
261ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000262ifeq ($(CONFIG_NIC3COM), yes)
263UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
264else
265override CONFIG_NIC3COM = no
266endif
267ifeq ($(CONFIG_NICREALTEK), yes)
268UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
269else
270override CONFIG_NICREALTEK = no
271endif
272ifeq ($(CONFIG_NICNATSEMI), yes)
273UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
274else
275override CONFIG_NICNATSEMI = no
276endif
277ifeq ($(CONFIG_RAYER_SPI), yes)
278UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
279else
280override CONFIG_RAYER_SPI = no
281endif
282ifeq ($(CONFIG_ATAHPT), yes)
283UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
284else
285override CONFIG_ATAHPT = no
286endif
287ifeq ($(CONFIG_SATAMV), yes)
288UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
289else
290override CONFIG_SATAMV = no
291endif
292endif
293
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000294###############################################################################
295# Flash chip drivers and bus support infrastructure.
296
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000297CHIP_OBJS = jedec.o stm50flw0x0x.o w39.o w29ee011.o \
Sean Nelson35727f72010-01-28 23:55:12 +0000298 sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000299 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
300 opaque.o sfdp.o en29lv640b.o
Sean Nelson5d134642009-12-24 16:54:21 +0000301
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000302###############################################################################
303# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000304
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000305LIB_OBJS = layout.o flashrom.o udelay.o programmer.o
Sean Nelson5d134642009-12-24 16:54:21 +0000306
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000307###############################################################################
308# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000309
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000310CLI_OBJS = cli_classic.o cli_output.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000311
Carl-Daniel Hailfinger9e675852009-05-04 12:29:59 +0000312# Set the flashrom version string from the highest revision number
313# of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000314# Note to packagers: Any tree exported with "make export" or "make tarball"
315# will not require subversion. The downloadable snapshots are already exported.
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000316SVNVERSION := $(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 +0000317
Carl-Daniel Hailfingera5838532012-08-08 00:13:10 +0000318RELEASE := 0.9.6.1
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000319VERSION := $(RELEASE)-r$(SVNVERSION)
320RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000321
322SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000323
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000324# Always enable internal/onboard support for now.
325CONFIG_INTERNAL ?= yes
326
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000327# Always enable serprog for now. Needs to be disabled on Windows.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000328CONFIG_SERPROG ?= yes
329
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000330# RayeR SPIPGM hardware support
331CONFIG_RAYER_SPI ?= yes
332
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000333# PonyProg2000 SPI hardware support
334CONFIG_PONY_SPI ?= yes
335
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000336# Always enable 3Com NICs for now.
337CONFIG_NIC3COM ?= yes
338
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000339# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
340CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000341
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000342# Always enable SiI SATA controllers for now.
343CONFIG_SATASII ?= yes
344
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000345# Highpoint (HPT) ATA/RAID controller support.
346# IMPORTANT: This code is not yet working!
347CONFIG_ATAHPT ?= no
348
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000349# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000350CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000351
352# Always enable dummy tracing for now.
353CONFIG_DUMMY ?= yes
354
355# Always enable Dr. Kaiser for now.
356CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000357
Joerg Fischer5665ef32010-05-21 21:54:07 +0000358# Always enable Realtek NICs for now.
359CONFIG_NICREALTEK ?= yes
360
Andrew Morganc29c2e72010-06-07 22:37:54 +0000361# Disable National Semiconductor NICs until support is complete and tested.
362CONFIG_NICNATSEMI ?= no
363
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000364# Always enable Intel NICs for now.
365CONFIG_NICINTEL ?= yes
366
Idwer Vollering004f4b72010-09-03 18:21:21 +0000367# Always enable SPI on Intel NICs for now.
368CONFIG_NICINTEL_SPI ?= yes
369
Mark Marshall90021f22010-12-03 14:48:11 +0000370# Always enable SPI on OGP cards for now.
371CONFIG_OGP_SPI ?= yes
372
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000373# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000374CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000375
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000376# Disable Dediprog SF100 until support is complete and tested.
377CONFIG_DEDIPROG ?= no
378
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000379# Always enable Marvell SATA controllers for now.
380CONFIG_SATAMV ?= yes
381
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000382# Enable Linux spidev interface by default. We disable it on non-Linux targets.
383CONFIG_LINUX_SPI ?= yes
384
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000385# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000386CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000387
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000388# Bitbanging SPI infrastructure, default off unless needed.
389ifeq ($(CONFIG_RAYER_SPI), yes)
390override CONFIG_BITBANG_SPI = yes
391else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000392ifeq ($(CONFIG_PONY_SPI), yes)
393override CONFIG_BITBANG_SPI = yes
394else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000395ifeq ($(CONFIG_INTERNAL), yes)
396override CONFIG_BITBANG_SPI = yes
397else
398ifeq ($(CONFIG_NICINTEL_SPI), yes)
399override CONFIG_BITBANG_SPI = yes
400else
Mark Marshall90021f22010-12-03 14:48:11 +0000401ifeq ($(CONFIG_OGP_SPI), yes)
402override CONFIG_BITBANG_SPI = yes
403else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000404CONFIG_BITBANG_SPI ?= no
405endif
406endif
407endif
Mark Marshall90021f22010-12-03 14:48:11 +0000408endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000409endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000410
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000411###############################################################################
412# Programmer drivers and programmer support infrastructure.
413
Stefan Taunerfd0d4132012-09-25 21:24:55 +0000414FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
415
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000416ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000417FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Carl-Daniel Hailfingerb5b161b2010-06-04 19:05:39 +0000418PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000419ifeq ($(ARCH), x86)
Stefan Tauner1e146392011-09-15 23:52:55 +0000420PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o wbsio_spi.o mcp6x_spi.o
421PROGRAMMER_OBJS += ichspi.o ich_descriptors.o
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000422else
423endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000424NEED_PCI := yes
425endif
426
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000427ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000428FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000429PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000430NEED_SERIAL := yes
431NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000432endif
433
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000434ifeq ($(CONFIG_RAYER_SPI), yes)
435FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
436PROGRAMMER_OBJS += rayer_spi.o
437# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
438NEED_PCI := yes
439endif
440
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000441ifeq ($(CONFIG_PONY_SPI), yes)
442FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
443PROGRAMMER_OBJS += pony_spi.o
444NEED_SERIAL := yes
445endif
446
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000447ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000448FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000449PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000450endif
451
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000452ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000453FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000454PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000455NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000456endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000457
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000458ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000459FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000460PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000461NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000462endif
463
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000464ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000465FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000466PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000467NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000468endif
469
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000470ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000471FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000472PROGRAMMER_OBJS += atahpt.o
473NEED_PCI := yes
474endif
475
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000476ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfingerc1f00c52010-01-09 14:18:01 +0000477FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000478# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000479FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000480FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
Jörg Mayer8776db22009-11-16 14:05:13 +0000481FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Sean Nelson5d134642009-12-24 16:54:21 +0000482PROGRAMMER_OBJS += ft2232_spi.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000483# We can't set NEED_USB here because that would transform libftdi auto-enabling
484# into a hard requirement for libusb, defeating the purpose of auto-enabling.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000485endif
486
487ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000488FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000489PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000490endif
491
492ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000493FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000494PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000495NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000496endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000497
Joerg Fischer5665ef32010-05-21 21:54:07 +0000498ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000499FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000500PROGRAMMER_OBJS += nicrealtek.o
501NEED_PCI := yes
502endif
503
Andrew Morganc29c2e72010-06-07 22:37:54 +0000504ifeq ($(CONFIG_NICNATSEMI), yes)
505FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
506PROGRAMMER_OBJS += nicnatsemi.o
507NEED_PCI := yes
508endif
509
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000510ifeq ($(CONFIG_NICINTEL), yes)
511FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
512PROGRAMMER_OBJS += nicintel.o
513NEED_PCI := yes
514endif
515
Idwer Vollering004f4b72010-09-03 18:21:21 +0000516ifeq ($(CONFIG_NICINTEL_SPI), yes)
517FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
518PROGRAMMER_OBJS += nicintel_spi.o
519NEED_PCI := yes
520endif
521
Mark Marshall90021f22010-12-03 14:48:11 +0000522ifeq ($(CONFIG_OGP_SPI), yes)
523FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
524PROGRAMMER_OBJS += ogp_spi.o
525NEED_PCI := yes
526endif
527
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000528ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
529FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000530PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000531NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000532endif
533
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000534ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000535FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000536PROGRAMMER_OBJS += dediprog.o
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000537NEED_USB := yes
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000538endif
539
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000540ifeq ($(CONFIG_SATAMV), yes)
541FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
542PROGRAMMER_OBJS += satamv.o
543NEED_PCI := yes
544endif
545
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000546ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000547# This is a totally ugly hack.
548FEATURE_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 +0000549PROGRAMMER_OBJS += linux_spi.o
550endif
551
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000552ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000553LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000554endif
555
556ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000557ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000558LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000559endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000560endif
561
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000562ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000563CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000564FEATURE_CFLAGS += -D'NEED_PCI=1'
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000565PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000566ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000567# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000568PCILIBS += -lpciutils -lpci
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000569# For (i386|x86_64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000570PCILIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000571else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000572ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000573# FIXME There needs to be a better way to do this
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000574CPPFLAGS += -I../libpci/include
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000575PCILIBS += ../libpci/lib/libpci.a
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000576else
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000577PCILIBS += -lpci
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000578ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000579# For (i386|amd64)_iopl(2).
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000580PCILIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000581else
582ifeq ($(TARGET_OS), Darwin)
583# DirectHW framework can be found in the DirectHW library.
Stefan Taunere34e3e82013-01-01 00:06:51 +0000584PCILIBS += -framework IOKit -framework DirectHW
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000585else
586endif
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000587endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000588endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000589endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000590endif
591
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000592ifeq ($(NEED_USB), yes)
593CHECK_LIBUSB0 = yes
594FEATURE_CFLAGS += -D'NEED_USB=1'
595USBLIBS := $(shell pkg-config --libs libusb 2>/dev/null || printf "%s" "-lusb")
596endif
597
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000598ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000599FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000600CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000601endif
602
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000603FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
604
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000605# We could use PULLED_IN_LIBS, but that would be ugly.
606FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
607
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000608LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000609OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000610
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000611all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000612ifeq ($(ARCH), x86)
613 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
614endif
615
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000616$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000617 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(FEATURE_LIBS) $(LIBS) $(PCILIBS) $(USBLIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000618
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000619libflashrom.a: $(LIBFLASHROM_OBJS)
620 $(AR) rcs $@ $^
621 $(RANLIB) $@
622
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000623# TAROPTIONS reduces information leakage from the packager's system.
624# If other tar programs support command line arguments for setting uid/gid of
625# stored files, they can be handled here as well.
626TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000627
Paul Fox05dfbe62009-06-16 21:08:06 +0000628%.o: %.c .features
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +0000629 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000630
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000631# Make sure to add all names of generated binaries here.
632# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000633# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000634clean:
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000635 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000636 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000637
Ollie Lho184a4042005-11-26 21:55:36 +0000638distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000639 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000640
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000641strip: $(PROGRAM)$(EXEC_SUFFIX)
642 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000643
Stefan Tauner56787082011-08-18 02:27:19 +0000644# to define test programs we use verbatim variables, which get exported
645# to environment variables and are referenced with $$<varname> later
646
647define COMPILER_TEST
648int main(int argc, char **argv)
649{
650 (void) argc;
651 (void) argv;
652 return 0;
653}
654endef
655export COMPILER_TEST
656
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000657compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000658 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000659 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000660 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000661 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000662 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
663 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000664 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000665 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000666 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000667 ( echo "unknown. Aborting."; exit 1)
668 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000669 @printf "Target OS is "
670 @# FreeBSD wc will output extraneous whitespace.
671 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
672 ( echo "unknown. Aborting."; exit 1)
673 @printf "%s\n" '$(TARGET_OS)'
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000674
Stefan Tauner56787082011-08-18 02:27:19 +0000675define LIBPCI_TEST
676/* Avoid a failing test due to libpci header symbol shadowing breakage */
677#define index shadow_workaround_index
678#include <pci/pci.h>
679struct pci_access *pacc;
680int main(int argc, char **argv)
681{
682 (void) argc;
683 (void) argv;
684 pacc = pci_alloc();
685 return 0;
686}
687endef
688export LIBPCI_TEST
689
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000690define LIBUSB0_TEST
691#include <usb.h>
692int main(int argc, char **argv)
693{
694 (void) argc;
695 (void) argv;
696 usb_init();
697 return 0;
698}
699endef
700export LIBUSB0_TEST
701
702hwlibs: compiler
703 @printf "" > .libdeps
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000704ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000705 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000706 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000707 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000708 echo "found." || ( echo "not found."; echo; \
709 echo "Please install libpci headers (package pciutils-devel)."; \
710 echo "See README for more information."; echo; \
711 rm -f .test.c .test.o; exit 1)
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000712 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000713 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000714 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000715 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000716 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000717 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000718 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000719 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000720 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
721 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000722endif
723ifeq ($(CHECK_LIBUSB0), yes)
724 @printf "Checking for libusb-0.1/libusb-compat headers... "
725 @echo "$$LIBUSB0_TEST" > .test.c
726 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
727 echo "found." || ( echo "not found."; echo; \
728 echo "Please install libusb-0.1 headers or libusb-compat headers."; \
729 echo "See README for more information."; echo; \
730 rm -f .test.c .test.o; exit 1)
731 @printf "Checking if libusb-0.1 is usable... "
Carl-Daniel Hailfinger26148ae2012-11-29 22:22:04 +0000732 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >/dev/null && \
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000733 echo "yes." || ( echo "no."; \
734 echo "Please install libusb-0.1 or libusb-compat."; \
735 echo "See README for more information."; echo; \
736 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1)
737 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000738endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000739
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000740.features: features
741
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000742# If a user does not explicitly request a non-working feature, we should
743# silently disable it. However, if a non-working (does not compile) feature
744# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000745# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000746featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000747ifeq ($(PROGRAMMER_OBJS),)
748 @echo "You have to enable at least one programmer driver!"
749 @false
750endif
751ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000752 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
753 @false
754endif
755
Stefan Tauner56787082011-08-18 02:27:19 +0000756define FTDI_TEST
757#include <ftdi.h>
758struct ftdi_context *ftdic = NULL;
759int main(int argc, char **argv)
760{
761 (void) argc;
762 (void) argv;
763 return ftdi_init(ftdic);
764}
765endef
766export FTDI_TEST
767
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000768define FTDI_232H_TEST
769#include <ftdi.h>
770enum ftdi_chip_type type = TYPE_232H;
771endef
772export FTDI_232H_TEST
773
Stefan Tauner56787082011-08-18 02:27:19 +0000774define UTSNAME_TEST
775#include <sys/utsname.h>
776struct utsname osinfo;
777int main(int argc, char **argv)
778{
779 (void) argc;
780 (void) argv;
781 uname (&osinfo);
782 return 0;
783}
784endef
785export UTSNAME_TEST
786
Stefan Tauner8868db32012-03-13 00:18:19 +0000787define LINUX_SPI_TEST
788#include <linux/types.h>
789#include <linux/spi/spidev.h>
790
791int main(int argc, char **argv)
792{
793 (void) argc;
794 (void) argv;
795 return 0;
796}
797endef
798export LINUX_SPI_TEST
799
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000800features: compiler
801 @echo "FEATURES := yes" > .features.tmp
Stefan Tauner56787082011-08-18 02:27:19 +0000802ifeq ($(CONFIG_FT2232_SPI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +0000803 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +0000804 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000805 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000806 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
807 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Ilya A. Volynets-Evenbakh2c714ab2012-09-26 00:47:09 +0000808 @printf "Checking for FT232H support in libftdi... "
809 @echo "$$FTDI_232H_TEST" >> .featuretest.c
810 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
811 ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
812 ( echo "not found."; echo "FT232H := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000813endif
Stefan Tauner8868db32012-03-13 00:18:19 +0000814ifeq ($(CONFIG_LINUX_SPI), yes)
815 @printf "Checking if Linux SPI headers are present... "
816 @echo "$$LINUX_SPI_TEST" > .featuretest.c
817 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
818 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
819 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
820endif
Stefan Tauner56787082011-08-18 02:27:19 +0000821 @printf "Checking for utsname support... "
822 @echo "$$UTSNAME_TEST" > .featuretest.c
823 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
824 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
825 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
826 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
827 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +0000828
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000829install: $(PROGRAM)$(EXEC_SUFFIX)
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +0000830 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000831 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000832 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000833 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +0000834
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000835export:
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000836 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
837 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
838 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
839 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
840 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000841
842tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000843 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
844 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
845 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000846
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000847djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000848 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
849libpayload: clean
850 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000851
Carl-Daniel Hailfingere7a39bf2012-11-20 21:06:16 +0000852.PHONY: all clean distclean compiler hwlibs features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +0000853
Stefan Reinauere2f01582010-06-07 11:08:07 +0000854-include $(OBJS:.o=.d)