blob: 774d5b3ae6de1a8508f2f4578278b0e7885bb546 [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.
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +000029CC ?= gcc
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000030STRIP ?= strip
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000031INSTALL = install
Paul Fox05dfbe62009-06-16 21:08:06 +000032DIFF = diff
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000033PREFIX ?= /usr/local
Uwe Hermann56b2cb02009-05-21 15:59:58 +000034MANDIR ?= $(PREFIX)/share/man
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000035CFLAGS ?= -Os -Wall -Wshadow
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000036EXPORTDIR ?= .
Patrick Georgi97bc95c2011-03-08 07:17:44 +000037AR ?= ar
38RANLIB ?= ranlib
Christian Ruppertdb9d9f42009-05-14 14:17:07 +000039
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000040# If your compiler spits out excessive warnings, run make WARNERROR=no
41# You shouldn't have to change this flag.
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000042WARNERROR ?= yes
43
44ifeq ($(WARNERROR), yes)
45CFLAGS += -Werror
46endif
47
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000048###############################################################################
49# General OS/architecture specific settings.
50
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000051# HOST_OS is only used to work around local toolchain issues.
52HOST_OS ?= $(shell uname)
53ifeq ($(HOST_OS), MINGW32_NT-5.1)
54# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
55CC = gcc
56endif
57ifneq ($(HOST_OS), SunOS)
Adam Kaufman064b1f22007-02-06 19:47:50 +000058STRIP_ARGS = -s
59endif
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000060
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000061# Determine the destination OS.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000062# IMPORTANT: The following line must be placed before TARGET_OS is ever used
63# (of course), but should come after any lines setting CC because the line
64# below uses CC itself.
65override TARGET_OS := $(strip $(shell LC_ALL=C $(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
66
67ifeq ($(TARGET_OS), Darwin)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000068CPPFLAGS += -I/opt/local/include -I/usr/local/include
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000069LDFLAGS += -L/opt/local/lib -L/usr/local/lib
Stefan Reinauerf79edb92009-01-26 01:23:31 +000070endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000071
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000072ifeq ($(TARGET_OS), FreeBSD)
Stefan Reinauer2fea3f32010-01-21 20:26:30 +000073CPPFLAGS += -I/usr/local/include
Andriy Gapon65c1b862008-05-22 13:22:45 +000074LDFLAGS += -L/usr/local/lib
75endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000076
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000077ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +000078CPPFLAGS += -I/usr/local/include
79LDFLAGS += -L/usr/local/lib
80endif
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000081
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000082ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +000083EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000084CPPFLAGS += -I../libgetopt
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +000085# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
86CPPFLAGS += -Wno-format
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +000087# FIXME Check if we can achieve the same effect with -L../libgetopt -lgetopt
88LIBS += ../libgetopt/libgetopt.a
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000089# Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +000090ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
91UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
92else
93override CONFIG_BUSPIRATE_SPI = no
94endif
95ifeq ($(CONFIG_SERPROG), yes)
96UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
97else
98override CONFIG_SERPROG = no
99endif
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000100ifeq ($(CONFIG_PONY_SPI), yes)
101UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
102else
103override CONFIG_PONY_SPI = no
104endif
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000105# Dediprog and FT2232 are not supported under DOS (missing USB support).
106ifeq ($(CONFIG_DEDIPROG), yes)
107UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
108else
109override CONFIG_DEDIPROG = no
110endif
111ifeq ($(CONFIG_FT2232_SPI), yes)
112UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
113else
114override CONFIG_FT2232_SPI = no
115endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000116endif
Ollie Lho184a4042005-11-26 21:55:36 +0000117
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000118# FIXME: Should we check for Cygwin/MSVC as well?
119ifeq ($(TARGET_OS), MinGW)
120EXEC_SUFFIX := .exe
Uwe Hermannd5e85d62011-07-03 19:44:12 +0000121# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
122CFLAGS += -Dffs=__builtin_ffs
123# libusb-win32/libftdi stuff is usually installed in /usr/local.
124CPPFLAGS += -I/usr/local/include
125LDFLAGS += -L/usr/local/lib
126# Serprog is not supported under Windows/MinGW (missing sockets support).
127ifeq ($(CONFIG_SERPROG), yes)
128UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
129else
130override CONFIG_SERPROG = no
131endif
132# For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
133ifeq ($(CONFIG_INTERNAL), yes)
134UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
135else
136override CONFIG_INTERNAL = no
137endif
138ifeq ($(CONFIG_RAYER_SPI), yes)
139UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
140else
141override CONFIG_RAYER_SPI = no
142endif
143ifeq ($(CONFIG_NIC3COM), yes)
144UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
145else
146override CONFIG_NIC3COM = no
147endif
148ifeq ($(CONFIG_GFXNVIDIA), yes)
149UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
150else
151override CONFIG_GFXNVIDIA = no
152endif
153ifeq ($(CONFIG_SATASII), yes)
154UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
155else
156override CONFIG_SATASII = no
157endif
158ifeq ($(CONFIG_ATAHPT), yes)
159UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
160else
161override CONFIG_ATAHPT = no
162endif
163ifeq ($(CONFIG_DRKAISER), yes)
164UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
165else
166override CONFIG_DRKAISER = no
167endif
168ifeq ($(CONFIG_NICREALTEK), yes)
169UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
170else
171override CONFIG_NICREALTEK = no
172endif
173ifeq ($(CONFIG_NICNATSEMI), yes)
174UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
175else
176override CONFIG_NICNATSEMI = no
177endif
178ifeq ($(CONFIG_NICINTEL), yes)
179UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
180else
181override CONFIG_NICINTEL = no
182endif
183ifeq ($(CONFIG_NICINTEL_SPI), yes)
184UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
185else
186override CONFIG_NICINTEL_SPI = no
187endif
188ifeq ($(CONFIG_OGP_SPI), yes)
189UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
190else
191override CONFIG_OGP_SPI = no
192endif
193ifeq ($(CONFIG_SATAMV), yes)
194UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
195else
196override CONFIG_SATAMV = no
197endif
198endif
199
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000200ifeq ($(TARGET_OS), libpayload)
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000201CPPFLAGS += -DSTANDALONE
202ifeq ($(CONFIG_DUMMY), yes)
203UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
204else
205override CONFIG_DUMMY = no
206endif
207ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
208UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
209else
210override CONFIG_BUSPIRATE_SPI = no
211endif
212ifeq ($(CONFIG_SERPROG), yes)
213UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
214else
215override CONFIG_SERPROG = no
216endif
217# Dediprog and FT2232 are not supported with libpayload (missing libusb support)
218ifeq ($(CONFIG_DEDIPROG), yes)
219UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
220else
221override CONFIG_DEDIPROG = no
222endif
223ifeq ($(CONFIG_FT2232_SPI), yes)
224UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
225else
226override CONFIG_FT2232_SPI = no
227endif
228endif
229
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000230ifneq ($(TARGET_OS), Linux)
231ifeq ($(CONFIG_LINUX_SPI), yes)
232UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
233else
234override CONFIG_LINUX_SPI = no
235endif
236endif
237
Uwe Hermann44ffd582011-08-20 14:16:00 +0000238# Determine the destination processor architecture.
239# IMPORTANT: The following line must be placed before ARCH is ever used
240# (of course), but should come after any lines setting CC because the line
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000241# below uses CC itself.
242override 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 +0000243
David Hendricksb286da72012-02-13 00:35:35 +0000244# PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM.
245# Right now this means the drivers below only work on x86.
246ifneq ($(ARCH), x86)
Uwe Hermann21b10c62011-07-29 12:13:01 +0000247ifeq ($(CONFIG_NIC3COM), yes)
248UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
249else
250override CONFIG_NIC3COM = no
251endif
252ifeq ($(CONFIG_NICREALTEK), yes)
253UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
254else
255override CONFIG_NICREALTEK = no
256endif
257ifeq ($(CONFIG_NICNATSEMI), yes)
258UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
259else
260override CONFIG_NICNATSEMI = no
261endif
262ifeq ($(CONFIG_RAYER_SPI), yes)
263UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
264else
265override CONFIG_RAYER_SPI = no
266endif
267ifeq ($(CONFIG_ATAHPT), yes)
268UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
269else
270override CONFIG_ATAHPT = no
271endif
272ifeq ($(CONFIG_SATAMV), yes)
273UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
274else
275override CONFIG_SATAMV = no
276endif
277endif
278
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000279###############################################################################
280# Flash chip drivers and bus support infrastructure.
281
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000282CHIP_OBJS = jedec.o stm50flw0x0x.o w39.o w29ee011.o \
Sean Nelson35727f72010-01-28 23:55:12 +0000283 sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
Michael Karcher27c8c6c2012-05-16 00:15:53 +0000284 sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o \
Rudolf Marek47eff6b2012-04-14 22:51:40 +0000285 a25.o at25.o opaque.o sfdp.o en29lv640b.o
Sean Nelson5d134642009-12-24 16:54:21 +0000286
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000287###############################################################################
288# Library code.
Sean Nelson5d134642009-12-24 16:54:21 +0000289
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000290LIB_OBJS = layout.o flashrom.o udelay.o programmer.o
Sean Nelson5d134642009-12-24 16:54:21 +0000291
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000292###############################################################################
293# Frontend related stuff.
Ollie Lho184a4042005-11-26 21:55:36 +0000294
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000295CLI_OBJS = cli_classic.o cli_output.o print.o
Ollie Lho184a4042005-11-26 21:55:36 +0000296
Carl-Daniel Hailfinger9e675852009-05-04 12:29:59 +0000297# Set the flashrom version string from the highest revision number
298# of the checked out flashrom files.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000299# Note to packagers: Any tree exported with "make export" or "make tarball"
300# will not require subversion. The downloadable snapshots are already exported.
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000301SVNVERSION := $(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 +0000302
Carl-Daniel Hailfingera5838532012-08-08 00:13:10 +0000303RELEASE := 0.9.6.1
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000304VERSION := $(RELEASE)-r$(SVNVERSION)
305RELEASENAME ?= $(VERSION)
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000306
307SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'
Bernhard Walle201bde32008-01-21 15:24:22 +0000308
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000309# Always enable internal/onboard support for now.
310CONFIG_INTERNAL ?= yes
311
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000312# Always enable serprog for now. Needs to be disabled on Windows.
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000313CONFIG_SERPROG ?= yes
314
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000315# RayeR SPIPGM hardware support
316CONFIG_RAYER_SPI ?= yes
317
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000318# PonyProg2000 SPI hardware support
319CONFIG_PONY_SPI ?= yes
320
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000321# Always enable 3Com NICs for now.
322CONFIG_NIC3COM ?= yes
323
Carl-Daniel Hailfingerbf3af292010-07-29 14:41:46 +0000324# Enable NVIDIA graphics cards. Note: write and erase do not work properly.
325CONFIG_GFXNVIDIA ?= yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000326
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000327# Always enable SiI SATA controllers for now.
328CONFIG_SATASII ?= yes
329
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000330# Highpoint (HPT) ATA/RAID controller support.
331# IMPORTANT: This code is not yet working!
332CONFIG_ATAHPT ?= no
333
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000334# Always enable FT2232 SPI dongles for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000335CONFIG_FT2232_SPI ?= yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000336
337# Always enable dummy tracing for now.
338CONFIG_DUMMY ?= yes
339
340# Always enable Dr. Kaiser for now.
341CONFIG_DRKAISER ?= yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000342
Joerg Fischer5665ef32010-05-21 21:54:07 +0000343# Always enable Realtek NICs for now.
344CONFIG_NICREALTEK ?= yes
345
Andrew Morganc29c2e72010-06-07 22:37:54 +0000346# Disable National Semiconductor NICs until support is complete and tested.
347CONFIG_NICNATSEMI ?= no
348
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000349# Always enable Intel NICs for now.
350CONFIG_NICINTEL ?= yes
351
Idwer Vollering004f4b72010-09-03 18:21:21 +0000352# Always enable SPI on Intel NICs for now.
353CONFIG_NICINTEL_SPI ?= yes
354
Mark Marshall90021f22010-12-03 14:48:11 +0000355# Always enable SPI on OGP cards for now.
356CONFIG_OGP_SPI ?= yes
357
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000358# Always enable Bus Pirate SPI for now.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000359CONFIG_BUSPIRATE_SPI ?= yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000360
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000361# Disable Dediprog SF100 until support is complete and tested.
362CONFIG_DEDIPROG ?= no
363
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000364# Always enable Marvell SATA controllers for now.
365CONFIG_SATAMV ?= yes
366
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000367# Enable Linux spidev interface by default. We disable it on non-Linux targets.
368CONFIG_LINUX_SPI ?= yes
369
Carl-Daniel Hailfinger6161ff12009-11-16 21:22:24 +0000370# Disable wiki printing by default. It is only useful if you have wiki access.
Uwe Hermann2db77a02010-06-04 17:07:39 +0000371CONFIG_PRINT_WIKI ?= no
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000372
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000373# Bitbanging SPI infrastructure, default off unless needed.
374ifeq ($(CONFIG_RAYER_SPI), yes)
375override CONFIG_BITBANG_SPI = yes
376else
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000377ifeq ($(CONFIG_PONY_SPI), yes)
378override CONFIG_BITBANG_SPI = yes
379else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000380ifeq ($(CONFIG_INTERNAL), yes)
381override CONFIG_BITBANG_SPI = yes
382else
383ifeq ($(CONFIG_NICINTEL_SPI), yes)
384override CONFIG_BITBANG_SPI = yes
385else
Mark Marshall90021f22010-12-03 14:48:11 +0000386ifeq ($(CONFIG_OGP_SPI), yes)
387override CONFIG_BITBANG_SPI = yes
388else
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000389CONFIG_BITBANG_SPI ?= no
390endif
391endif
392endif
Mark Marshall90021f22010-12-03 14:48:11 +0000393endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000394endif
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000395
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000396###############################################################################
397# Programmer drivers and programmer support infrastructure.
398
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000399ifeq ($(CONFIG_INTERNAL), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000400FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Carl-Daniel Hailfingerb5b161b2010-06-04 19:05:39 +0000401PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000402ifeq ($(ARCH), x86)
Stefan Tauner1e146392011-09-15 23:52:55 +0000403PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o wbsio_spi.o mcp6x_spi.o
404PROGRAMMER_OBJS += ichspi.o ich_descriptors.o
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000405else
406endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000407NEED_PCI := yes
408endif
409
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000410ifeq ($(CONFIG_SERPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000411FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000412PROGRAMMER_OBJS += serprog.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000413NEED_SERIAL := yes
414NEED_NET := yes
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000415endif
416
Carl-Daniel Hailfingere7fdd6e2010-07-21 10:26:01 +0000417ifeq ($(CONFIG_RAYER_SPI), yes)
418FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
419PROGRAMMER_OBJS += rayer_spi.o
420# Actually, NEED_PCI is wrong. NEED_IOPORT_ACCESS would be more correct.
421NEED_PCI := yes
422endif
423
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000424ifeq ($(CONFIG_PONY_SPI), yes)
425FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
426PROGRAMMER_OBJS += pony_spi.o
427NEED_SERIAL := yes
428endif
429
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000430ifeq ($(CONFIG_BITBANG_SPI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000431FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000432PROGRAMMER_OBJS += bitbang_spi.o
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000433endif
434
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000435ifeq ($(CONFIG_NIC3COM), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000436FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000437PROGRAMMER_OBJS += nic3com.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000438NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000439endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000440
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000441ifeq ($(CONFIG_GFXNVIDIA), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000442FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000443PROGRAMMER_OBJS += gfxnvidia.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000444NEED_PCI := yes
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000445endif
446
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000447ifeq ($(CONFIG_SATASII), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000448FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000449PROGRAMMER_OBJS += satasii.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000450NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000451endif
452
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000453ifeq ($(CONFIG_ATAHPT), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000454FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000455PROGRAMMER_OBJS += atahpt.o
456NEED_PCI := yes
457endif
458
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000459ifeq ($(CONFIG_FT2232_SPI), yes)
Carl-Daniel Hailfingerc1f00c52010-01-09 14:18:01 +0000460FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" "-lftdi -lusb")
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000461# This is a totally ugly hack.
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000462FEATURE_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 +0000463FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
Sean Nelson5d134642009-12-24 16:54:21 +0000464PROGRAMMER_OBJS += ft2232_spi.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000465endif
466
467ifeq ($(CONFIG_DUMMY), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000468FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000469PROGRAMMER_OBJS += dummyflasher.o
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000470endif
471
472ifeq ($(CONFIG_DRKAISER), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000473FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000474PROGRAMMER_OBJS += drkaiser.o
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000475NEED_PCI := yes
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000476endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +0000477
Joerg Fischer5665ef32010-05-21 21:54:07 +0000478ifeq ($(CONFIG_NICREALTEK), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000479FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
Joerg Fischer5665ef32010-05-21 21:54:07 +0000480PROGRAMMER_OBJS += nicrealtek.o
481NEED_PCI := yes
482endif
483
Andrew Morganc29c2e72010-06-07 22:37:54 +0000484ifeq ($(CONFIG_NICNATSEMI), yes)
485FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
486PROGRAMMER_OBJS += nicnatsemi.o
487NEED_PCI := yes
488endif
489
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000490ifeq ($(CONFIG_NICINTEL), yes)
491FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
492PROGRAMMER_OBJS += nicintel.o
493NEED_PCI := yes
494endif
495
Idwer Vollering004f4b72010-09-03 18:21:21 +0000496ifeq ($(CONFIG_NICINTEL_SPI), yes)
497FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
498PROGRAMMER_OBJS += nicintel_spi.o
499NEED_PCI := yes
500endif
501
Mark Marshall90021f22010-12-03 14:48:11 +0000502ifeq ($(CONFIG_OGP_SPI), yes)
503FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
504PROGRAMMER_OBJS += ogp_spi.o
505NEED_PCI := yes
506endif
507
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000508ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
509FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000510PROGRAMMER_OBJS += buspirate_spi.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000511NEED_SERIAL := yes
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000512endif
513
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000514ifeq ($(CONFIG_DEDIPROG), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000515FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000516FEATURE_LIBS += -lusb
517PROGRAMMER_OBJS += dediprog.o
518endif
519
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000520ifeq ($(CONFIG_SATAMV), yes)
521FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
522PROGRAMMER_OBJS += satamv.o
523NEED_PCI := yes
524endif
525
Carl-Daniel Hailfinger8541d232012-02-16 21:00:27 +0000526ifeq ($(CONFIG_LINUX_SPI), yes)
Stefan Tauner8868db32012-03-13 00:18:19 +0000527# This is a totally ugly hack.
528FEATURE_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 +0000529PROGRAMMER_OBJS += linux_spi.o
530endif
531
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000532ifeq ($(NEED_SERIAL), yes)
Sean Nelson5d134642009-12-24 16:54:21 +0000533LIB_OBJS += serial.o
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000534endif
535
536ifeq ($(NEED_NET), yes)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000537ifeq ($(TARGET_OS), SunOS)
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000538LIBS += -lsocket
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000539endif
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000540endif
541
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000542ifeq ($(NEED_PCI), yes)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000543CHECK_LIBPCI = yes
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000544FEATURE_CFLAGS += -D'NEED_PCI=1'
Carl-Daniel Hailfingerfb0828f2010-02-12 19:35:25 +0000545PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000546ifeq ($(TARGET_OS), NetBSD)
Carl-Daniel Hailfinger460b2822010-06-04 23:24:57 +0000547# The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
548LIBS += -lpciutils -lpci
549# For (i386|x86_64)_iopl(2).
550LIBS += -l$(shell uname -p)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000551else
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000552ifeq ($(TARGET_OS), DOS)
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000553# FIXME There needs to be a better way to do this
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000554CPPFLAGS += -I../libpci/include
Carl-Daniel Hailfinger5bdf2982010-06-14 12:42:05 +0000555LIBS += ../libpci/lib/libpci.a
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000556else
557LIBS += -lpci
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000558ifeq ($(TARGET_OS), OpenBSD)
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000559# For (i386|amd64)_iopl(2).
560LIBS += -l$(shell uname -m)
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000561else
562ifeq ($(TARGET_OS), Darwin)
563# DirectHW framework can be found in the DirectHW library.
564LIBS += -framework IOKit -framework DirectHW
565else
566endif
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000567endif
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000568endif
Jonathan A. Kollasch3646c8f2010-01-08 21:18:08 +0000569endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000570endif
571
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000572ifeq ($(CONFIG_PRINT_WIKI), yes)
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000573FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
Sean Nelson5d134642009-12-24 16:54:21 +0000574CLI_OBJS += print_wiki.o
Carl-Daniel Hailfinger9c8476b2009-09-16 12:19:03 +0000575endif
576
Carl-Daniel Hailfinger132e2ec2010-03-27 16:36:40 +0000577FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
578
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000579# We could use PULLED_IN_LIBS, but that would be ugly.
580FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
581
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000582LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000583OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
Sean Nelson5d134642009-12-24 16:54:21 +0000584
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000585all: pciutils features $(PROGRAM)$(EXEC_SUFFIX)
586ifeq ($(ARCH), x86)
587 @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
588endif
589
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000590$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
591 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(FEATURE_LIBS) $(LIBS)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000592
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000593libflashrom.a: $(LIBFLASHROM_OBJS)
594 $(AR) rcs $@ $^
595 $(RANLIB) $@
596
Carl-Daniel Hailfinger8ef7dce2009-07-10 20:19:48 +0000597# TAROPTIONS reduces information leakage from the packager's system.
598# If other tar programs support command line arguments for setting uid/gid of
599# stored files, they can be handled here as well.
600TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000601
Paul Fox05dfbe62009-06-16 21:08:06 +0000602%.o: %.c .features
Stefan Reinauere2f01582010-06-07 11:08:07 +0000603 $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
Clark Rawlins02016f72008-02-14 23:22:20 +0000604
Carl-Daniel Hailfingera0020df2010-05-30 22:35:14 +0000605# Make sure to add all names of generated binaries here.
606# This includes all frontends and libflashrom.
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000607# We don't use EXEC_SUFFIX here because we want to clean everything.
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000608clean:
Patrick Georgi97bc95c2011-03-08 07:17:44 +0000609 rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000610 @+$(MAKE) -C util/ich_descriptors_tool/ clean
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000611
Ollie Lho184a4042005-11-26 21:55:36 +0000612distclean: clean
Stefan Reinauere2f01582010-06-07 11:08:07 +0000613 rm -f .features .libdeps
Christian Ruppertdb9d9f42009-05-14 14:17:07 +0000614
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000615strip: $(PROGRAM)$(EXEC_SUFFIX)
616 $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000617
Stefan Tauner56787082011-08-18 02:27:19 +0000618# to define test programs we use verbatim variables, which get exported
619# to environment variables and are referenced with $$<varname> later
620
621define COMPILER_TEST
622int main(int argc, char **argv)
623{
624 (void) argc;
625 (void) argv;
626 return 0;
627}
628endef
629export COMPILER_TEST
630
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000631compiler: featuresavailable
Paul Fox05dfbe62009-06-16 21:08:06 +0000632 @printf "Checking for a C compiler... "
Stefan Tauner56787082011-08-18 02:27:19 +0000633 @echo "$$COMPILER_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000634 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >/dev/null && \
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000635 echo "found." || ( echo "not found."; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000636 rm -f .test.c .test$(EXEC_SUFFIX); exit 1)
637 @rm -f .test.c .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000638 @printf "Target arch is "
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000639 @# FreeBSD wc will output extraneous whitespace.
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000640 @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
Carl-Daniel Hailfinger91199a12011-07-07 06:59:18 +0000641 ( echo "unknown. Aborting."; exit 1)
642 @printf "%s\n" '$(ARCH)'
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000643 @printf "Target OS is "
644 @# FreeBSD wc will output extraneous whitespace.
645 @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
646 ( echo "unknown. Aborting."; exit 1)
647 @printf "%s\n" '$(TARGET_OS)'
Carl-Daniel Hailfinger4cb7a962009-06-16 09:31:51 +0000648
Stefan Tauner56787082011-08-18 02:27:19 +0000649define LIBPCI_TEST
650/* Avoid a failing test due to libpci header symbol shadowing breakage */
651#define index shadow_workaround_index
652#include <pci/pci.h>
653struct pci_access *pacc;
654int main(int argc, char **argv)
655{
656 (void) argc;
657 (void) argv;
658 pacc = pci_alloc();
659 return 0;
660}
661endef
662export LIBPCI_TEST
663
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000664ifeq ($(CHECK_LIBPCI), yes)
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000665pciutils: compiler
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000666 @printf "Checking for libpci headers... "
Stefan Tauner56787082011-08-18 02:27:19 +0000667 @echo "$$LIBPCI_TEST" > .test.c
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000668 @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000669 echo "found." || ( echo "not found."; echo; \
670 echo "Please install libpci headers (package pciutils-devel)."; \
671 echo "See README for more information."; echo; \
672 rm -f .test.c .test.o; exit 1)
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000673 @printf "Checking if libpci is present and sufficient... "
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000674 @printf "" > .libdeps
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000675 @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000676 echo "yes." || ( echo "no."; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000677 printf "Checking if libz+libpci are present and sufficient..."; \
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000678 $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) -lz >/dev/null && \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000679 ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \
Carl-Daniel Hailfinger9979eac2010-03-22 12:29:45 +0000680 echo "Please install libpci (package pciutils) and/or libz."; \
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000681 echo "See README for more information."; echo; \
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000682 rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1) )
683 @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000684else
685pciutils: compiler
686 @printf "" > .libdeps
687endif
Stefan Reinauer53e96252005-12-01 16:19:24 +0000688
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000689.features: features
690
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000691# If a user does not explicitly request a non-working feature, we should
692# silently disable it. However, if a non-working (does not compile) feature
693# is explicitly requested, we should bail out with a descriptive error message.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000694# We also have to check that at least one programmer driver is enabled.
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000695featuresavailable:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000696ifeq ($(PROGRAMMER_OBJS),)
697 @echo "You have to enable at least one programmer driver!"
698 @false
699endif
700ifneq ($(UNSUPPORTED_FEATURES), )
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000701 @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
702 @false
703endif
704
Stefan Tauner56787082011-08-18 02:27:19 +0000705define FTDI_TEST
706#include <ftdi.h>
707struct ftdi_context *ftdic = NULL;
708int main(int argc, char **argv)
709{
710 (void) argc;
711 (void) argv;
712 return ftdi_init(ftdic);
713}
714endef
715export FTDI_TEST
716
717define UTSNAME_TEST
718#include <sys/utsname.h>
719struct utsname osinfo;
720int main(int argc, char **argv)
721{
722 (void) argc;
723 (void) argv;
724 uname (&osinfo);
725 return 0;
726}
727endef
728export UTSNAME_TEST
729
Stefan Tauner8868db32012-03-13 00:18:19 +0000730define LINUX_SPI_TEST
731#include <linux/types.h>
732#include <linux/spi/spidev.h>
733
734int main(int argc, char **argv)
735{
736 (void) argc;
737 (void) argv;
738 return 0;
739}
740endef
741export LINUX_SPI_TEST
742
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000743features: compiler
744 @echo "FEATURES := yes" > .features.tmp
Stefan Tauner56787082011-08-18 02:27:19 +0000745ifeq ($(CONFIG_FT2232_SPI), yes)
Paul Fox05dfbe62009-06-16 21:08:06 +0000746 @printf "Checking for FTDI support... "
Stefan Tauner56787082011-08-18 02:27:19 +0000747 @echo "$$FTDI_TEST" > .featuretest.c
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000748 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \
Carl-Daniel Hailfingerb18ecbc2009-06-19 14:20:34 +0000749 ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \
750 ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
Carl-Daniel Hailfinger8a59ff02009-12-24 03:33:11 +0000751endif
Stefan Tauner8868db32012-03-13 00:18:19 +0000752ifeq ($(CONFIG_LINUX_SPI), yes)
753 @printf "Checking if Linux SPI headers are present... "
754 @echo "$$LINUX_SPI_TEST" > .featuretest.c
755 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
756 ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
757 ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp )
758endif
Stefan Tauner56787082011-08-18 02:27:19 +0000759 @printf "Checking for utsname support... "
760 @echo "$$UTSNAME_TEST" > .featuretest.c
761 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 && \
762 ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
763 ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
764 @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
765 @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
Paul Fox05dfbe62009-06-16 21:08:06 +0000766
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000767install: $(PROGRAM)$(EXEC_SUFFIX)
Uwe Hermannc2a9c9c2009-05-14 14:51:14 +0000768 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000769 mkdir -p $(DESTDIR)$(MANDIR)/man8
Carl-Daniel Hailfingerddbab712010-06-14 14:44:08 +0000770 $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
Uwe Hermann56b2cb02009-05-21 15:59:58 +0000771 $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
Uwe Hermannc113b572006-12-14 00:59:41 +0000772
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000773export:
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000774 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
775 @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)
776 @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile
777 @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog
778 @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000779
780tarball: export
Carl-Daniel Hailfinger48e5e092009-08-31 16:25:08 +0000781 @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/
782 @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
783 @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +0000784
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000785djgpp-dos: clean
Carl-Daniel Hailfinger33a65a02011-12-20 00:51:44 +0000786 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
787libpayload: clean
788 make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000789
Carl-Daniel Hailfinger5d3fcb92010-06-14 18:40:59 +0000790.PHONY: all clean distclean compiler pciutils features export tarball dos featuresavailable
Ollie Lho184a4042005-11-26 21:55:36 +0000791
Stefan Reinauere2f01582010-06-07 11:08:07 +0000792-include $(OBJS:.o=.d)