Makefile 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442
  1. #
  2. # This file is part of the flashrom project.
  3. #
  4. # Copyright (C) 2005 coresystems GmbH <stepan@coresystems.de>
  5. # Copyright (C) 2009,2010,2012 Carl-Daniel Hailfinger
  6. #
  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
  19. #
  20. PROGRAM = flashrom
  21. ###############################################################################
  22. # Defaults for the toolchain.
  23. # If you want to cross-compile, just run e.g.
  24. # make CC=i586-pc-msdosdjgpp-gcc
  25. # You may have to specify STRIP/AR/RANLIB as well.
  26. #
  27. # Note for anyone editing this Makefile: gnumake will happily ignore any
  28. # changes in this Makefile to variables set on the command line.
  29. STRIP ?= strip
  30. INSTALL = install
  31. DIFF = diff
  32. PREFIX ?= /usr/local
  33. MANDIR ?= $(PREFIX)/share/man
  34. CFLAGS ?= -Os -Wall -Wshadow
  35. EXPORTDIR ?= .
  36. RANLIB ?= ranlib
  37. PKG_CONFIG ?= pkg-config
  38. BUILD_DETAILS_FILE ?= build_details.txt
  39. # The following parameter changes the default programmer that will be used if there is no -p/--programmer
  40. # argument given when running flashrom. The predefined setting does not enable any default so that every
  41. # user has to declare the programmer he wants to use on every run. The rationale for this to be not set
  42. # (to e.g. the internal programmer) is that forgetting to specify this when working with another programmer
  43. # easily puts the system attached to the default programmer at risk (e.g. you want to flash coreboot to another
  44. # system attached to an external programmer while the default programmer is set to the internal programmer, and
  45. # you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer
  46. # running flashrom). Please do not enable this without thinking about the possible consequences. Possible
  47. # values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options
  48. # evaluated below, namely those that enable/disable the various programmers).
  49. # Compilation will fail for unspecified values.
  50. CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID
  51. # The following adds a default parameter for the default programmer set above (only).
  52. CONFIG_DEFAULT_PROGRAMMER_ARGS ?= ''
  53. # Example: compiling with
  54. # make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000"
  55. # would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
  56. # If your compiler spits out excessive warnings, run make WARNERROR=no
  57. # You shouldn't have to change this flag.
  58. WARNERROR ?= yes
  59. ifeq ($(WARNERROR), yes)
  60. CFLAGS += -Werror
  61. endif
  62. ifdef LIBS_BASE
  63. PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig
  64. override CPPFLAGS += -I$(LIBS_BASE)/include
  65. override LDFLAGS += -L$(LIBS_BASE)/lib -Wl,-rpath -Wl,$(LIBS_BASE)/lib
  66. endif
  67. ifeq ($(CONFIG_STATIC),yes)
  68. override PKG_CONFIG += --static
  69. override LDFLAGS += -static
  70. endif
  71. # Set LC_ALL=C to minimize influences of the locale.
  72. # However, this won't work for the majority of relevant commands because they use the $(shell) function and
  73. # GNU make does not relay variables exported within the makefile to their evironment.
  74. LC_ALL=C
  75. export LC_ALL
  76. dummy_for_make_3_80:=$(shell printf "Build started on %s\n\n" "$$(date)" >$(BUILD_DETAILS_FILE))
  77. # Provide an easy way to execute a command, print its output to stdout and capture any error message on stderr
  78. # in the build details file together with the original stdout output.
  79. debug_shell = $(shell export LC_ALL=C ; { echo 'exec: export LC_ALL=C ; { $(1) ; }' >&2; { $(1) ; } | tee -a $(BUILD_DETAILS_FILE) ; echo >&2 ; } 2>>$(BUILD_DETAILS_FILE))
  80. ###############################################################################
  81. # General OS-specific settings.
  82. # 1. Prepare for later by gathering information about host and target OS
  83. # 2. Set compiler flags and parameters according to OSes
  84. # 3. Likewise verify user-supplied CONFIG_* variables.
  85. # HOST_OS is only used to work around local toolchain issues.
  86. HOST_OS ?= $(shell uname)
  87. ifeq ($(HOST_OS), MINGW32_NT-5.1)
  88. # Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
  89. CC = gcc
  90. endif
  91. ifneq ($(HOST_OS), SunOS)
  92. STRIP_ARGS = -s
  93. endif
  94. # Determine the destination OS.
  95. # IMPORTANT: The following line must be placed before TARGET_OS is ever used
  96. # (of course), but should come after any lines setting CC because the line
  97. # below uses CC itself.
  98. override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
  99. ifeq ($(TARGET_OS), Darwin)
  100. override CPPFLAGS += -I/opt/local/include -I/usr/local/include
  101. override LDFLAGS += -L/opt/local/lib -L/usr/local/lib
  102. endif
  103. ifeq ($(TARGET_OS), FreeBSD)
  104. override CPPFLAGS += -I/usr/local/include
  105. override LDFLAGS += -L/usr/local/lib
  106. endif
  107. ifeq ($(TARGET_OS), OpenBSD)
  108. override CPPFLAGS += -I/usr/local/include
  109. override LDFLAGS += -L/usr/local/lib
  110. endif
  111. ifeq ($(TARGET_OS), NetBSD)
  112. override CPPFLAGS += -I/usr/pkg/include
  113. override LDFLAGS += -L/usr/pkg/lib
  114. endif
  115. ifeq ($(TARGET_OS), DragonFlyBSD)
  116. override CPPFLAGS += -I/usr/local/include
  117. override LDFLAGS += -L/usr/local/lib
  118. endif
  119. ifeq ($(TARGET_OS), DOS)
  120. EXEC_SUFFIX := .exe
  121. # DJGPP has odd uint*_t definitions which cause lots of format string warnings.
  122. override CFLAGS += -Wno-format
  123. LIBS += -lgetopt
  124. # Bus Pirate, Serprog and PonyProg are not supported under DOS (missing serial support).
  125. ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
  126. UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
  127. else
  128. override CONFIG_BUSPIRATE_SPI = no
  129. endif
  130. ifeq ($(CONFIG_SERPROG), yes)
  131. UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
  132. else
  133. override CONFIG_SERPROG = no
  134. endif
  135. ifeq ($(CONFIG_PONY_SPI), yes)
  136. UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
  137. else
  138. override CONFIG_PONY_SPI = no
  139. endif
  140. # Dediprog, USB-Blaster, PICkit2, CH341A and FT2232 are not supported under DOS (missing USB support).
  141. ifeq ($(CONFIG_DEDIPROG), yes)
  142. UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
  143. else
  144. override CONFIG_DEDIPROG = no
  145. endif
  146. ifeq ($(CONFIG_FT2232_SPI), yes)
  147. UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
  148. else
  149. override CONFIG_FT2232_SPI = no
  150. endif
  151. ifeq ($(CONFIG_USBBLASTER_SPI), yes)
  152. UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
  153. else
  154. override CONFIG_USBBLASTER_SPI = no
  155. endif
  156. ifeq ($(CONFIG_PICKIT2_SPI), yes)
  157. UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
  158. else
  159. override CONFIG_PICKIT2_SPI = no
  160. endif
  161. ifeq ($(CONFIG_CH341A_SPI), yes)
  162. UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
  163. else
  164. override CONFIG_CH341A_SPI = no
  165. endif
  166. endif
  167. # FIXME: Should we check for Cygwin/MSVC as well?
  168. ifeq ($(TARGET_OS), MinGW)
  169. EXEC_SUFFIX := .exe
  170. # MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
  171. FLASHROM_CFLAGS += -Dffs=__builtin_ffs
  172. # Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
  173. # for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */
  174. FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
  175. # For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
  176. ifeq ($(CONFIG_INTERNAL), yes)
  177. UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
  178. else
  179. override CONFIG_INTERNAL = no
  180. endif
  181. ifeq ($(CONFIG_RAYER_SPI), yes)
  182. UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
  183. else
  184. override CONFIG_RAYER_SPI = no
  185. endif
  186. ifeq ($(CONFIG_NIC3COM), yes)
  187. UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
  188. else
  189. override CONFIG_NIC3COM = no
  190. endif
  191. ifeq ($(CONFIG_GFXNVIDIA), yes)
  192. UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
  193. else
  194. override CONFIG_GFXNVIDIA = no
  195. endif
  196. ifeq ($(CONFIG_AST1100), yes)
  197. UNSUPPORTED_FEATURES += CONFIG_AST1100=yes
  198. else
  199. override CONFIG_AST1100 = no
  200. endif
  201. ifeq ($(CONFIG_AST2400), yes)
  202. UNSUPPORTED_FEATURES += CONFIG_AST2400=yes
  203. else
  204. override CONFIG_AST2400 = no
  205. endif
  206. ifeq ($(CONFIG_SATASII), yes)
  207. UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
  208. else
  209. override CONFIG_SATASII = no
  210. endif
  211. ifeq ($(CONFIG_ATAHPT), yes)
  212. UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
  213. else
  214. override CONFIG_ATAHPT = no
  215. endif
  216. ifeq ($(CONFIG_ATAVIA), yes)
  217. UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
  218. else
  219. override CONFIG_ATAVIA = no
  220. endif
  221. ifeq ($(CONFIG_ATAPROMISE), yes)
  222. UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
  223. else
  224. override CONFIG_ATAPROMISE = no
  225. endif
  226. ifeq ($(CONFIG_IT8212), yes)
  227. UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
  228. else
  229. override CONFIG_IT8212 = no
  230. endif
  231. ifeq ($(CONFIG_DRKAISER), yes)
  232. UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
  233. else
  234. override CONFIG_DRKAISER = no
  235. endif
  236. ifeq ($(CONFIG_NICREALTEK), yes)
  237. UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
  238. else
  239. override CONFIG_NICREALTEK = no
  240. endif
  241. ifeq ($(CONFIG_NICNATSEMI), yes)
  242. UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
  243. else
  244. override CONFIG_NICNATSEMI = no
  245. endif
  246. ifeq ($(CONFIG_NICINTEL), yes)
  247. UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
  248. else
  249. override CONFIG_NICINTEL = no
  250. endif
  251. ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
  252. UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
  253. else
  254. override CONFIG_NICINTEL_EEPROM = no
  255. endif
  256. ifeq ($(CONFIG_NICINTEL_SPI), yes)
  257. UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
  258. else
  259. override CONFIG_NICINTEL_SPI = no
  260. endif
  261. ifeq ($(CONFIG_OGP_SPI), yes)
  262. UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
  263. else
  264. override CONFIG_OGP_SPI = no
  265. endif
  266. ifeq ($(CONFIG_SATAMV), yes)
  267. UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
  268. else
  269. override CONFIG_SATAMV = no
  270. endif
  271. endif
  272. ifeq ($(TARGET_OS), libpayload)
  273. ifeq ($(MAKECMDGOALS),)
  274. .DEFAULT_GOAL := libflashrom.a
  275. $(info Setting default goal to libflashrom.a)
  276. endif
  277. FLASHROM_CFLAGS += -DSTANDALONE
  278. ifeq ($(CONFIG_DUMMY), yes)
  279. UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
  280. else
  281. override CONFIG_DUMMY = no
  282. endif
  283. # libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
  284. ifeq ($(CONFIG_ATAPROMISE), yes)
  285. UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
  286. else
  287. override CONFIG_ATAPROMISE = no
  288. endif
  289. # Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
  290. ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
  291. UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
  292. else
  293. override CONFIG_BUSPIRATE_SPI = no
  294. endif
  295. ifeq ($(CONFIG_SERPROG), yes)
  296. UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
  297. else
  298. override CONFIG_SERPROG = no
  299. endif
  300. ifeq ($(CONFIG_PONY_SPI), yes)
  301. UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
  302. else
  303. override CONFIG_PONY_SPI = no
  304. endif
  305. # Dediprog, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support).
  306. ifeq ($(CONFIG_DEDIPROG), yes)
  307. UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
  308. else
  309. override CONFIG_DEDIPROG = no
  310. endif
  311. ifeq ($(CONFIG_FT2232_SPI), yes)
  312. UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
  313. else
  314. override CONFIG_FT2232_SPI = no
  315. endif
  316. ifeq ($(CONFIG_USBBLASTER_SPI), yes)
  317. UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
  318. else
  319. override CONFIG_USBBLASTER_SPI = no
  320. endif
  321. ifeq ($(CONFIG_PICKIT2_SPI), yes)
  322. UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
  323. else
  324. override CONFIG_PICKIT2_SPI = no
  325. endif
  326. ifeq ($(CONFIG_CH341A_SPI), yes)
  327. UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
  328. else
  329. override CONFIG_CH341A_SPI = no
  330. endif
  331. endif
  332. ifneq ($(TARGET_OS), Linux)
  333. # Android is handled internally as separate OS, but it supports CONFIG_LINUX_SPI and CONFIG_MSTARDDC_SPI
  334. ifneq ($(TARGET_OS), Android)
  335. ifeq ($(CONFIG_LINUX_SPI), yes)
  336. UNSUPPORTED_FEATURES += CONFIG_LINUX_SPI=yes
  337. else
  338. override CONFIG_LINUX_SPI = no
  339. endif
  340. ifeq ($(CONFIG_MSTARDDC_SPI), yes)
  341. UNSUPPORTED_FEATURES += CONFIG_MSTARDDC_SPI=yes
  342. else
  343. override CONFIG_MSTARDDC_SPI = no
  344. endif
  345. endif
  346. endif
  347. ifeq ($(TARGET_OS), Android)
  348. # Android on x86 (currently) does not provide raw PCI port I/O operations
  349. ifeq ($(CONFIG_RAYER_SPI), yes)
  350. UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
  351. else
  352. override CONFIG_RAYER_SPI = no
  353. endif
  354. endif
  355. ###############################################################################
  356. # General architecture-specific settings.
  357. # Like above for the OS, below we verify user-supplied options depending on the target architecture.
  358. # Determine the destination processor architecture.
  359. # IMPORTANT: The following line must be placed before ARCH is ever used
  360. # (of course), but should come after any lines setting CC because the line
  361. # below uses CC itself.
  362. override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
  363. # PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
  364. # Right now this means the drivers below only work on x86.
  365. ifneq ($(ARCH), x86)
  366. ifeq ($(CONFIG_NIC3COM), yes)
  367. UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
  368. else
  369. override CONFIG_NIC3COM = no
  370. endif
  371. ifeq ($(CONFIG_NICREALTEK), yes)
  372. UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
  373. else
  374. override CONFIG_NICREALTEK = no
  375. endif
  376. ifeq ($(CONFIG_NICNATSEMI), yes)
  377. UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
  378. else
  379. override CONFIG_NICNATSEMI = no
  380. endif
  381. ifeq ($(CONFIG_RAYER_SPI), yes)
  382. UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
  383. else
  384. override CONFIG_RAYER_SPI = no
  385. endif
  386. ifeq ($(CONFIG_ATAHPT), yes)
  387. UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
  388. else
  389. override CONFIG_ATAHPT = no
  390. endif
  391. ifeq ($(CONFIG_ATAPROMISE), yes)
  392. UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
  393. else
  394. override CONFIG_ATAPROMISE = no
  395. endif
  396. ifeq ($(CONFIG_SATAMV), yes)
  397. UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
  398. else
  399. override CONFIG_SATAMV = no
  400. endif
  401. endif
  402. # Disable all drivers needing raw access (memory, PCI, port I/O) on
  403. # architectures with unknown raw access properties.
  404. # Right now those architectures are alpha hppa m68k sh s390
  405. ifneq ($(ARCH),$(filter $(ARCH),x86 mips ppc arm sparc))
  406. ifeq ($(CONFIG_INTERNAL), yes)
  407. UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
  408. else
  409. override CONFIG_INTERNAL = no
  410. endif
  411. ifeq ($(CONFIG_RAYER_SPI), yes)
  412. UNSUPPORTED_FEATURES += CONFIG_RAYER_SPI=yes
  413. else
  414. override CONFIG_RAYER_SPI = no
  415. endif
  416. ifeq ($(CONFIG_NIC3COM), yes)
  417. UNSUPPORTED_FEATURES += CONFIG_NIC3COM=yes
  418. else
  419. override CONFIG_NIC3COM = no
  420. endif
  421. ifeq ($(CONFIG_GFXNVIDIA), yes)
  422. UNSUPPORTED_FEATURES += CONFIG_GFXNVIDIA=yes
  423. else
  424. override CONFIG_GFXNVIDIA = no
  425. endif
  426. ifeq ($(CONFIG_AST1100), yes)
  427. UNSUPPORTED_FEATURES += CONFIG_AST1100=yes
  428. else
  429. override CONFIG_AST1100 = no
  430. endif
  431. ifeq ($(CONFIG_AST2400), yes)
  432. UNSUPPORTED_FEATURES += CONFIG_AST2400=yes
  433. else
  434. override CONFIG_AST2400 = no
  435. endif
  436. ifeq ($(CONFIG_SATASII), yes)
  437. UNSUPPORTED_FEATURES += CONFIG_SATASII=yes
  438. else
  439. override CONFIG_SATASII = no
  440. endif
  441. ifeq ($(CONFIG_ATAHPT), yes)
  442. UNSUPPORTED_FEATURES += CONFIG_ATAHPT=yes
  443. else
  444. override CONFIG_ATAHPT = no
  445. endif
  446. ifeq ($(CONFIG_ATAVIA), yes)
  447. UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
  448. else
  449. override CONFIG_ATAVIA = no
  450. endif
  451. ifeq ($(CONFIG_ATAPROMISE), yes)
  452. UNSUPPORTED_FEATURES += CONFIG_ATAPROMISE=yes
  453. else
  454. override CONFIG_ATAPROMISE = no
  455. endif
  456. ifeq ($(CONFIG_DRKAISER), yes)
  457. UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
  458. else
  459. override CONFIG_DRKAISER = no
  460. endif
  461. ifeq ($(CONFIG_NICREALTEK), yes)
  462. UNSUPPORTED_FEATURES += CONFIG_NICREALTEK=yes
  463. else
  464. override CONFIG_NICREALTEK = no
  465. endif
  466. ifeq ($(CONFIG_NICNATSEMI), yes)
  467. UNSUPPORTED_FEATURES += CONFIG_NICNATSEMI=yes
  468. else
  469. override CONFIG_NICNATSEMI = no
  470. endif
  471. ifeq ($(CONFIG_NICINTEL), yes)
  472. UNSUPPORTED_FEATURES += CONFIG_NICINTEL=yes
  473. else
  474. override CONFIG_NICINTEL = no
  475. endif
  476. ifeq ($(CONFIG_NICINTEL_SPI), yes)
  477. UNSUPPORTED_FEATURES += CONFIG_NICINTEL_SPI=yes
  478. else
  479. override CONFIG_NICINTEL_SPI = no
  480. endif
  481. ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
  482. UNSUPPORTED_FEATURES += CONFIG_NICINTEL_EEPROM=yes
  483. else
  484. override CONFIG_NICINTEL_EEPROM = no
  485. endif
  486. ifeq ($(CONFIG_OGP_SPI), yes)
  487. UNSUPPORTED_FEATURES += CONFIG_OGP_SPI=yes
  488. else
  489. override CONFIG_OGP_SPI = no
  490. endif
  491. ifeq ($(CONFIG_SATAMV), yes)
  492. UNSUPPORTED_FEATURES += CONFIG_SATAMV=yes
  493. else
  494. override CONFIG_SATAMV = no
  495. endif
  496. ifeq ($(CONFIG_IT8212), yes)
  497. UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
  498. else
  499. override CONFIG_IT8212 = no
  500. endif
  501. endif
  502. ###############################################################################
  503. # Flash chip drivers and bus support infrastructure.
  504. CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
  505. sst28sf040.o 82802ab.o \
  506. sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o spi25_statusreg.o \
  507. spi4ba.o opaque.o sfdp.o en29lv640b.o at45db.o
  508. ###############################################################################
  509. # Library code.
  510. LIB_OBJS = layout.o flashrom.o udelay.o programmer.o helpers.o
  511. ###############################################################################
  512. # Frontend related stuff.
  513. CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
  514. # Set the flashrom version string from the repository metadata (cf. util/getrevision.sh).
  515. # Note to packagers: Any tree exported with "make export" or "make tarball"
  516. # will not require git. The downloadable snapshots are already exported.
  517. VERSION := $(shell ./util/getrevision.sh --revision)
  518. # VERSION equals "offline" if online access is required but the respective git config variable is not set yet.
  519. ifeq ($(VERSION),offline)
  520. $(error Aborting)
  521. endif
  522. SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
  523. # No spaces in release names unless set explicitly
  524. RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/')
  525. # Inform user about the version string used. If there is no version information from a VCS then print
  526. # something anyway because $(info...) will print a line break in any case which would look suspicious.
  527. # The && between the echos is a workaround for old versions of GNU make that issue the error "unterminated
  528. # variable reference" if a semicolon is used instead.
  529. # Also, if a VCS is found then try to install hooks.
  530. $(info $(shell ./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh || \
  531. echo "Files don't seem to be under version control." && \
  532. echo "Replacing all version templates with $(VERSION)."))
  533. ###############################################################################
  534. # Default settings of CONFIG_* variables.
  535. # Always enable internal/onboard support for now.
  536. CONFIG_INTERNAL ?= yes
  537. # Always enable serprog for now.
  538. CONFIG_SERPROG ?= yes
  539. # RayeR SPIPGM hardware support
  540. CONFIG_RAYER_SPI ?= yes
  541. # PonyProg2000 SPI hardware support
  542. CONFIG_PONY_SPI ?= yes
  543. # Always enable 3Com NICs for now.
  544. CONFIG_NIC3COM ?= yes
  545. # Enable NVIDIA graphics cards. Note: write and erase do not work properly.
  546. CONFIG_GFXNVIDIA ?= yes
  547. # Enable AST1100 BMC SoCs.
  548. CONFIG_AST1100 ?= yes
  549. # Enable AST2400 BMC SoCs.
  550. CONFIG_AST2400 ?= yes
  551. # Always enable SiI SATA controllers for now.
  552. CONFIG_SATASII ?= yes
  553. # Highpoint (HPT) ATA/RAID controller support.
  554. # IMPORTANT: This code is not yet working!
  555. CONFIG_ATAHPT ?= no
  556. # VIA VT6421A LPC memory support
  557. CONFIG_ATAVIA ?= yes
  558. # Promise ATA controller support.
  559. CONFIG_ATAPROMISE ?= no
  560. # Always enable FT2232 SPI dongles for now.
  561. CONFIG_FT2232_SPI ?= yes
  562. # Always enable Altera USB-Blaster dongles for now.
  563. CONFIG_USBBLASTER_SPI ?= yes
  564. # MSTAR DDC support needs more tests/reviews/cleanups.
  565. CONFIG_MSTARDDC_SPI ?= no
  566. # Always enable PICkit2 SPI dongles for now.
  567. CONFIG_PICKIT2_SPI ?= yes
  568. # Always enable dummy tracing for now.
  569. CONFIG_DUMMY ?= yes
  570. # Always enable Dr. Kaiser for now.
  571. CONFIG_DRKAISER ?= yes
  572. # Always enable Realtek NICs for now.
  573. CONFIG_NICREALTEK ?= yes
  574. # Disable National Semiconductor NICs until support is complete and tested.
  575. CONFIG_NICNATSEMI ?= no
  576. # Always enable Intel NICs for now.
  577. CONFIG_NICINTEL ?= yes
  578. # Always enable SPI on Intel NICs for now.
  579. CONFIG_NICINTEL_SPI ?= yes
  580. # Always enable EEPROM on Intel NICs for now.
  581. CONFIG_NICINTEL_EEPROM ?= yes
  582. # Always enable SPI on OGP cards for now.
  583. CONFIG_OGP_SPI ?= yes
  584. # Always enable Bus Pirate SPI for now.
  585. CONFIG_BUSPIRATE_SPI ?= yes
  586. # Always enable Dediprog SF100 for now.
  587. CONFIG_DEDIPROG ?= yes
  588. # Always enable Marvell SATA controllers for now.
  589. CONFIG_SATAMV ?= yes
  590. # Enable Linux spidev interface by default. We disable it on non-Linux targets.
  591. CONFIG_LINUX_SPI ?= yes
  592. # Always enable ITE IT8212F PATA controllers for now.
  593. CONFIG_IT8212 ?= yes
  594. # Winchiphead CH341A
  595. CONFIG_CH341A_SPI ?= yes
  596. # Disable wiki printing by default. It is only useful if you have wiki access.
  597. CONFIG_PRINT_WIKI ?= no
  598. # Disable all features if CONFIG_NOTHING=yes is given unless CONFIG_EVERYTHING was also set
  599. ifeq ($(CONFIG_NOTHING), yes)
  600. ifeq ($(CONFIG_EVERYTHING), yes)
  601. $(error Setting CONFIG_NOTHING=yes and CONFIG_EVERYTHING=yes does not make sense)
  602. endif
  603. $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
  604. $(if $(filter yes, $($(var))),\
  605. $(eval $(var)=no)))
  606. endif
  607. # Enable all features if CONFIG_EVERYTHING=yes is given
  608. ifeq ($(CONFIG_EVERYTHING), yes)
  609. $(foreach var, $(filter CONFIG_%, $(.VARIABLES)),\
  610. $(if $(filter no, $($(var))),\
  611. $(eval $(var)=yes)))
  612. endif
  613. # Disable feature groups
  614. ifeq ($(CONFIG_ENABLE_LIBUSB0_PROGRAMMERS), no)
  615. override CONFIG_PICKIT2_SPI = no
  616. endif
  617. ifeq ($(CONFIG_ENABLE_LIBUSB1_PROGRAMMERS), no)
  618. override CONFIG_CH341A_SPI = no
  619. override CONFIG_DEDIPROG = no
  620. endif
  621. ifeq ($(CONFIG_ENABLE_LIBPCI_PROGRAMMERS), no)
  622. override CONFIG_INTERNAL = no
  623. override CONFIG_NIC3COM = no
  624. override CONFIG_GFXNVIDIA = no
  625. override CONFIG_AST1100 = no
  626. override CONFIG_AST2400 = no
  627. override CONFIG_SATASII = no
  628. override CONFIG_ATAHPT = no
  629. override CONFIG_ATAVIA = no
  630. override CONFIG_ATAPROMISE = no
  631. override CONFIG_IT8212 = no
  632. override CONFIG_DRKAISER = no
  633. override CONFIG_NICREALTEK = no
  634. override CONFIG_NICNATSEMI = no
  635. override CONFIG_NICINTEL = no
  636. override CONFIG_NICINTEL_SPI = no
  637. override CONFIG_NICINTEL_EEPROM = no
  638. override CONFIG_OGP_SPI = no
  639. override CONFIG_SATAMV = no
  640. endif
  641. # Bitbanging SPI infrastructure, default off unless needed.
  642. ifeq ($(CONFIG_RAYER_SPI), yes)
  643. override CONFIG_BITBANG_SPI = yes
  644. else
  645. ifeq ($(CONFIG_PONY_SPI), yes)
  646. override CONFIG_BITBANG_SPI = yes
  647. else
  648. ifeq ($(CONFIG_INTERNAL), yes)
  649. override CONFIG_BITBANG_SPI = yes
  650. else
  651. ifeq ($(CONFIG_NICINTEL_SPI), yes)
  652. override CONFIG_BITBANG_SPI = yes
  653. else
  654. ifeq ($(CONFIG_OGP_SPI), yes)
  655. override CONFIG_BITBANG_SPI = yes
  656. else
  657. CONFIG_BITBANG_SPI ?= no
  658. endif
  659. endif
  660. endif
  661. endif
  662. endif
  663. ###############################################################################
  664. # Handle CONFIG_* variables that depend on others set (and verified) above.
  665. # The external DMI decoder (dmidecode) does not work in libpayload. Bail out if the internal one got disabled.
  666. ifeq ($(TARGET_OS), libpayload)
  667. ifeq ($(CONFIG_INTERNAL), yes)
  668. ifeq ($(CONFIG_INTERNAL_DMI), no)
  669. UNSUPPORTED_FEATURES += CONFIG_INTERNAL_DMI=no
  670. else
  671. override CONFIG_INTERNAL_DMI = yes
  672. endif
  673. endif
  674. endif
  675. # Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
  676. CONFIG_INTERNAL_DMI ?= yes
  677. ###############################################################################
  678. # Programmer drivers and programmer support infrastructure.
  679. # Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
  680. FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
  681. FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
  682. ifeq ($(CONFIG_INTERNAL), yes)
  683. FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
  684. PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o internal.o
  685. ifeq ($(ARCH), x86)
  686. PROGRAMMER_OBJS += it87spi.o it85spi.o sb600spi.o amd_imc.o wbsio_spi.o mcp6x_spi.o
  687. PROGRAMMER_OBJS += ichspi.o ich_descriptors.o dmi.o
  688. ifeq ($(CONFIG_INTERNAL_DMI), yes)
  689. FEATURE_CFLAGS += -D'CONFIG_INTERNAL_DMI=1'
  690. endif
  691. else
  692. endif
  693. NEED_LIBPCI += CONFIG_INTERNAL
  694. endif
  695. ifeq ($(CONFIG_SERPROG), yes)
  696. FEATURE_CFLAGS += -D'CONFIG_SERPROG=1'
  697. PROGRAMMER_OBJS += serprog.o
  698. NEED_SERIAL += CONFIG_SERPROG
  699. NEED_POSIX_SOCKETS += CONFIG_SERPROG
  700. endif
  701. ifeq ($(CONFIG_RAYER_SPI), yes)
  702. FEATURE_CFLAGS += -D'CONFIG_RAYER_SPI=1'
  703. PROGRAMMER_OBJS += rayer_spi.o
  704. NEED_RAW_ACCESS += CONFIG_RAYER_SPI
  705. endif
  706. ifeq ($(CONFIG_PONY_SPI), yes)
  707. FEATURE_CFLAGS += -D'CONFIG_PONY_SPI=1'
  708. PROGRAMMER_OBJS += pony_spi.o
  709. NEED_SERIAL += CONFIG_PONY_SPI
  710. endif
  711. ifeq ($(CONFIG_BITBANG_SPI), yes)
  712. FEATURE_CFLAGS += -D'CONFIG_BITBANG_SPI=1'
  713. PROGRAMMER_OBJS += bitbang_spi.o
  714. endif
  715. ifeq ($(CONFIG_NIC3COM), yes)
  716. FEATURE_CFLAGS += -D'CONFIG_NIC3COM=1'
  717. PROGRAMMER_OBJS += nic3com.o
  718. NEED_LIBPCI += CONFIG_NIC3COM
  719. endif
  720. ifeq ($(CONFIG_GFXNVIDIA), yes)
  721. FEATURE_CFLAGS += -D'CONFIG_GFXNVIDIA=1'
  722. PROGRAMMER_OBJS += gfxnvidia.o
  723. NEED_LIBPCI += CONFIG_GFXNVIDIA
  724. endif
  725. ifeq ($(CONFIG_AST1100), yes)
  726. FEATURE_CFLAGS += -D'CONFIG_AST1100=1'
  727. PROGRAMMER_OBJS += ast1100.o
  728. NEED_LIBPCI += CONFIG_AST1100
  729. endif
  730. ifeq ($(CONFIG_AST2400), yes)
  731. FEATURE_CFLAGS += -D'CONFIG_AST2400=1'
  732. PROGRAMMER_OBJS += ast2400.o
  733. NEED_LIBPCI += CONFIG_AST2400
  734. endif
  735. ifeq ($(CONFIG_SATASII), yes)
  736. FEATURE_CFLAGS += -D'CONFIG_SATASII=1'
  737. PROGRAMMER_OBJS += satasii.o
  738. NEED_LIBPCI += CONFIG_SATASII
  739. endif
  740. ifeq ($(CONFIG_ATAHPT), yes)
  741. FEATURE_CFLAGS += -D'CONFIG_ATAHPT=1'
  742. PROGRAMMER_OBJS += atahpt.o
  743. NEED_LIBPCI += CONFIG_ATAHPT
  744. endif
  745. ifeq ($(CONFIG_ATAVIA), yes)
  746. FEATURE_CFLAGS += -D'CONFIG_ATAVIA=1'
  747. PROGRAMMER_OBJS += atavia.o
  748. NEED_LIBPCI += CONFIG_ATAVIA
  749. endif
  750. ifeq ($(CONFIG_ATAPROMISE), yes)
  751. FEATURE_CFLAGS += -D'CONFIG_ATAPROMISE=1'
  752. PROGRAMMER_OBJS += atapromise.o
  753. NEED_LIBPCI += CONFIG_ATAPROMISE
  754. endif
  755. ifeq ($(CONFIG_IT8212), yes)
  756. FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
  757. PROGRAMMER_OBJS += it8212.o
  758. NEED_LIBPCI += CONFIG_IT8212
  759. endif
  760. ifeq ($(CONFIG_FT2232_SPI), yes)
  761. # This is a totally ugly hack.
  762. FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")
  763. NEED_LIBFTDI += CONFIG_FT2232_SPI
  764. PROGRAMMER_OBJS += ft2232_spi.o
  765. endif
  766. ifeq ($(CONFIG_USBBLASTER_SPI), yes)
  767. # This is a totally ugly hack.
  768. FEATURE_CFLAGS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_USBBLASTER_SPI=1'")
  769. NEED_LIBFTDI += CONFIG_USBBLASTER_SPI
  770. PROGRAMMER_OBJS += usbblaster_spi.o
  771. endif
  772. ifeq ($(CONFIG_PICKIT2_SPI), yes)
  773. FEATURE_CFLAGS += -D'CONFIG_PICKIT2_SPI=1'
  774. PROGRAMMER_OBJS += pickit2_spi.o
  775. NEED_LIBUSB0 += CONFIG_PICKIT2_SPI
  776. endif
  777. ifneq ($(NEED_LIBFTDI), )
  778. FTDILIBS := $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; $(PKG_CONFIG) --libs libftdi1 || $(PKG_CONFIG) --libs libftdi || printf "%s" "-lftdi -lusb")
  779. FEATURE_CFLAGS += $(call debug_shell,grep -q "FT232H := yes" .features && printf "%s" "-D'HAVE_FT232H=1'")
  780. FTDI_INCLUDES := $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; $(PKG_CONFIG) --cflags-only-I libftdi1)
  781. FEATURE_CFLAGS += $(FTDI_INCLUDES)
  782. FEATURE_LIBS += $(call debug_shell,grep -q "FTDISUPPORT := yes" .features && printf "%s" "$(FTDILIBS)")
  783. # We can't set NEED_LIBUSB0 here because that would transform libftdi auto-enabling
  784. # into a hard requirement for libusb, defeating the purpose of auto-enabling.
  785. endif
  786. ifeq ($(CONFIG_DUMMY), yes)
  787. FEATURE_CFLAGS += -D'CONFIG_DUMMY=1'
  788. PROGRAMMER_OBJS += dummyflasher.o
  789. endif
  790. ifeq ($(CONFIG_DRKAISER), yes)
  791. FEATURE_CFLAGS += -D'CONFIG_DRKAISER=1'
  792. PROGRAMMER_OBJS += drkaiser.o
  793. NEED_LIBPCI += CONFIG_DRKAISER
  794. endif
  795. ifeq ($(CONFIG_NICREALTEK), yes)
  796. FEATURE_CFLAGS += -D'CONFIG_NICREALTEK=1'
  797. PROGRAMMER_OBJS += nicrealtek.o
  798. NEED_LIBPCI += CONFIG_NICREALTEK
  799. endif
  800. ifeq ($(CONFIG_NICNATSEMI), yes)
  801. FEATURE_CFLAGS += -D'CONFIG_NICNATSEMI=1'
  802. PROGRAMMER_OBJS += nicnatsemi.o
  803. NEED_LIBPCI += CONFIG_NICNATSEMI
  804. endif
  805. ifeq ($(CONFIG_NICINTEL), yes)
  806. FEATURE_CFLAGS += -D'CONFIG_NICINTEL=1'
  807. PROGRAMMER_OBJS += nicintel.o
  808. NEED_LIBPCI += CONFIG_NICINTEL
  809. endif
  810. ifeq ($(CONFIG_NICINTEL_SPI), yes)
  811. FEATURE_CFLAGS += -D'CONFIG_NICINTEL_SPI=1'
  812. PROGRAMMER_OBJS += nicintel_spi.o
  813. NEED_LIBPCI += CONFIG_NICINTEL_SPI
  814. endif
  815. ifeq ($(CONFIG_NICINTEL_EEPROM), yes)
  816. FEATURE_CFLAGS += -D'CONFIG_NICINTEL_EEPROM=1'
  817. PROGRAMMER_OBJS += nicintel_eeprom.o
  818. NEED_LIBPCI += CONFIG_NICINTEL_EEPROM
  819. endif
  820. ifeq ($(CONFIG_OGP_SPI), yes)
  821. FEATURE_CFLAGS += -D'CONFIG_OGP_SPI=1'
  822. PROGRAMMER_OBJS += ogp_spi.o
  823. NEED_LIBPCI += CONFIG_OGP_SPI
  824. endif
  825. ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
  826. FEATURE_CFLAGS += -D'CONFIG_BUSPIRATE_SPI=1'
  827. PROGRAMMER_OBJS += buspirate_spi.o
  828. NEED_SERIAL += CONFIG_BUSPIRATE_SPI
  829. endif
  830. ifeq ($(CONFIG_DEDIPROG), yes)
  831. FEATURE_CFLAGS += -D'CONFIG_DEDIPROG=1'
  832. PROGRAMMER_OBJS += dediprog.o
  833. NEED_LIBUSB1 += CONFIG_DEDIPROG
  834. endif
  835. ifeq ($(CONFIG_SATAMV), yes)
  836. FEATURE_CFLAGS += -D'CONFIG_SATAMV=1'
  837. PROGRAMMER_OBJS += satamv.o
  838. NEED_LIBPCI += CONFIG_SATAMV
  839. endif
  840. ifeq ($(CONFIG_LINUX_SPI), yes)
  841. # This is a totally ugly hack.
  842. FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_SPI_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_SPI=1'")
  843. PROGRAMMER_OBJS += linux_spi.o
  844. endif
  845. ifeq ($(CONFIG_MSTARDDC_SPI), yes)
  846. # This is a totally ugly hack.
  847. FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_I2C_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_MSTARDDC_SPI=1'")
  848. NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI
  849. PROGRAMMER_OBJS += mstarddc_spi.o
  850. endif
  851. ifeq ($(CONFIG_CH341A_SPI), yes)
  852. FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
  853. PROGRAMMER_OBJS += ch341a_spi.o
  854. NEED_LIBUSB1 += CONFIG_CH341A_SPI
  855. endif
  856. ifneq ($(NEED_SERIAL), )
  857. LIB_OBJS += serial.o
  858. endif
  859. ifneq ($(NEED_POSIX_SOCKETS), )
  860. ifeq ($(TARGET_OS), SunOS)
  861. LIBS += -lsocket -lnsl
  862. endif
  863. endif
  864. ifneq ($(NEED_LIBPCI), )
  865. CHECK_LIBPCI = yes
  866. # This is a dirty hack, but it saves us from checking all PCI drivers and all platforms manually.
  867. # libpci may need raw memory, MSR or PCI port I/O on some platforms.
  868. # Individual drivers might have the same needs as well.
  869. NEED_RAW_ACCESS += $(NEED_LIBPCI)
  870. FEATURE_CFLAGS += -D'NEED_PCI=1'
  871. FEATURE_CFLAGS += $(call debug_shell,grep -q "OLD_PCI_GET_DEV := yes" .libdeps && printf "%s" "-D'OLD_PCI_GET_DEV=1'")
  872. PROGRAMMER_OBJS += pcidev.o
  873. ifeq ($(TARGET_OS), NetBSD)
  874. # The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci.
  875. PCILIBS += -lpciutils -lpci
  876. else
  877. PCILIBS += -lpci
  878. endif
  879. endif
  880. ifneq ($(NEED_RAW_ACCESS), )
  881. # Raw memory, MSR or PCI port I/O access.
  882. FEATURE_CFLAGS += -D'NEED_RAW_ACCESS=1'
  883. PROGRAMMER_OBJS += physmap.o hwaccess.o
  884. ifeq ($(TARGET_OS), NetBSD)
  885. # For (i386|x86_64)_iopl(2).
  886. PCILIBS += -l$(shell uname -p)
  887. else
  888. ifeq ($(TARGET_OS), OpenBSD)
  889. # For (i386|amd64)_iopl(2).
  890. PCILIBS += -l$(shell uname -m)
  891. else
  892. ifeq ($(TARGET_OS), Darwin)
  893. # DirectHW framework can be found in the DirectHW library.
  894. PCILIBS += -framework IOKit -framework DirectHW
  895. endif
  896. endif
  897. endif
  898. endif
  899. ifneq ($(NEED_LIBUSB0), )
  900. CHECK_LIBUSB0 = yes
  901. FEATURE_CFLAGS += -D'NEED_LIBUSB0=1'
  902. USBLIBS := $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" ; $(PKG_CONFIG) --libs libusb || printf "%s" "-lusb")
  903. endif
  904. ifneq ($(NEED_LIBUSB1), )
  905. CHECK_LIBUSB1 = yes
  906. FEATURE_CFLAGS += -D'NEED_LIBUSB1=1'
  907. # FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
  908. ifeq ($(TARGET_OS),$(filter $(TARGET_OS),FreeBSD DragonFlyBSD))
  909. USB1LIBS += -lusb
  910. else
  911. ifeq ($(TARGET_OS),NetBSD)
  912. override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
  913. USB1LIBS += -lusb-1.0
  914. else
  915. USB1LIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libusb-1.0 || printf "%s" "-lusb-1.0")
  916. override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libusb-1.0 || printf "%s" "-I/usr/include/libusb-1.0")
  917. endif
  918. endif
  919. endif
  920. ifeq ($(CONFIG_PRINT_WIKI), yes)
  921. FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
  922. CLI_OBJS += print_wiki.o
  923. endif
  924. FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
  925. # We could use PULLED_IN_LIBS, but that would be ugly.
  926. FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
  927. LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
  928. OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
  929. all: hwlibs features $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
  930. ifeq ($(ARCH), x86)
  931. @+$(MAKE) -C util/ich_descriptors_tool/ TARGET_OS=$(TARGET_OS) EXEC_SUFFIX=$(EXEC_SUFFIX)
  932. endif
  933. $(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
  934. $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS)
  935. libflashrom.a: $(LIBFLASHROM_OBJS)
  936. $(AR) rcs $@ $^
  937. $(RANLIB) $@
  938. # TAROPTIONS reduces information leakage from the packager's system.
  939. # If other tar programs support command line arguments for setting uid/gid of
  940. # stored files, they can be handled here as well.
  941. TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
  942. %.o: %.c .features
  943. $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<
  944. # Make sure to add all names of generated binaries here.
  945. # This includes all frontends and libflashrom.
  946. # We don't use EXEC_SUFFIX here because we want to clean everything.
  947. clean:
  948. rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE)
  949. @+$(MAKE) -C util/ich_descriptors_tool/ clean
  950. distclean: clean
  951. rm -f .features .libdeps
  952. strip: $(PROGRAM)$(EXEC_SUFFIX)
  953. $(STRIP) $(STRIP_ARGS) $(PROGRAM)$(EXEC_SUFFIX)
  954. # to define test programs we use verbatim variables, which get exported
  955. # to environment variables and are referenced with $$<varname> later
  956. define COMPILER_TEST
  957. int main(int argc, char **argv)
  958. {
  959. (void) argc;
  960. (void) argv;
  961. return 0;
  962. }
  963. endef
  964. export COMPILER_TEST
  965. compiler: featuresavailable
  966. @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
  967. @echo "$$COMPILER_TEST" > .test.c
  968. @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
  969. @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
  970. echo "found." || { echo "not found."; \
  971. rm -f .test.c .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
  972. @rm -f .test.c .test$(EXEC_SUFFIX)
  973. @printf "Target arch is "
  974. @# FreeBSD wc will output extraneous whitespace.
  975. @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
  976. ( echo "unknown. Aborting."; exit 1)
  977. @printf "%s\n" '$(ARCH)'
  978. @printf "Target OS is "
  979. @# FreeBSD wc will output extraneous whitespace.
  980. @echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
  981. ( echo "unknown. Aborting."; exit 1)
  982. @printf "%s\n" '$(TARGET_OS)'
  983. ifeq ($(TARGET_OS), libpayload)
  984. @$(CC) --version 2>&1 | grep -q coreboot || \
  985. ( echo "Warning: It seems you are not using coreboot's reference compiler."; \
  986. echo "This might work but usually does not, please beware." )
  987. endif
  988. define LIBPCI_TEST
  989. /* Avoid a failing test due to libpci header symbol shadowing breakage */
  990. #define index shadow_workaround_index
  991. #if !defined __NetBSD__
  992. #include <pci/pci.h>
  993. #else
  994. #include <pciutils/pci.h>
  995. #endif
  996. struct pci_access *pacc;
  997. int main(int argc, char **argv)
  998. {
  999. (void) argc;
  1000. (void) argv;
  1001. pacc = pci_alloc();
  1002. return 0;
  1003. }
  1004. endef
  1005. export LIBPCI_TEST
  1006. define PCI_GET_DEV_TEST
  1007. /* Avoid a failing test due to libpci header symbol shadowing breakage */
  1008. #define index shadow_workaround_index
  1009. #if !defined __NetBSD__
  1010. #include <pci/pci.h>
  1011. #else
  1012. #include <pciutils/pci.h>
  1013. #endif
  1014. struct pci_access *pacc;
  1015. struct pci_dev *dev = {0};
  1016. int main(int argc, char **argv)
  1017. {
  1018. (void) argc;
  1019. (void) argv;
  1020. pacc = pci_alloc();
  1021. dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
  1022. return 0;
  1023. }
  1024. endef
  1025. export PCI_GET_DEV_TEST
  1026. define LIBUSB0_TEST
  1027. #include "platform.h"
  1028. #if IS_WINDOWS
  1029. #include <lusb0_usb.h>
  1030. #else
  1031. #include <usb.h>
  1032. #endif
  1033. int main(int argc, char **argv)
  1034. {
  1035. (void) argc;
  1036. (void) argv;
  1037. usb_init();
  1038. return 0;
  1039. }
  1040. endef
  1041. export LIBUSB0_TEST
  1042. define LIBUSB1_TEST
  1043. #include <stddef.h>
  1044. #include <libusb.h>
  1045. int main(int argc, char **argv)
  1046. {
  1047. (void)argc;
  1048. (void)argv;
  1049. libusb_init(NULL);
  1050. return 0;
  1051. }
  1052. endef
  1053. export LIBUSB1_TEST
  1054. hwlibs: compiler
  1055. @printf "" > .libdeps
  1056. ifeq ($(CHECK_LIBPCI), yes)
  1057. @printf "Checking for libpci headers... " | tee -a $(BUILD_DETAILS_FILE)
  1058. @echo "$$LIBPCI_TEST" > .test.c
  1059. @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
  1060. @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
  1061. echo "found." || { echo "not found."; echo; \
  1062. echo "The following features require libpci: $(NEED_LIBPCI)."; \
  1063. echo "Please install libpci headers or disable all features"; \
  1064. echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
  1065. echo "See README for more information."; echo; \
  1066. rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
  1067. @printf "Checking version of pci_get_dev... " | tee -a $(BUILD_DETAILS_FILE)
  1068. @echo "$$PCI_GET_DEV_TEST" > .test.c
  1069. @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
  1070. @ { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
  1071. ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \
  1072. ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
  1073. @printf "Checking if libpci is present and sufficient... " | tee -a $(BUILD_DETAILS_FILE)
  1074. @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS)" >>$(BUILD_DETAILS_FILE)
  1075. @{ { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) 2>>$(BUILD_DETAILS_FILE) >&2 && \
  1076. echo "yes." || { echo "no."; \
  1077. printf "Checking if libz+libpci are present and sufficient..." ; \
  1078. { printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz" >>$(BUILD_DETAILS_FILE) ; \
  1079. $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) -lz >&2 && \
  1080. echo "yes." && echo "NEEDLIBZ := yes" > .libdeps } || { echo "no."; echo; \
  1081. echo "The following features require libpci: $(NEED_LIBPCI)."; \
  1082. echo "Please install libpci (package pciutils) and/or libz or disable all features"; \
  1083. echo "mentioned above by specifying make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no"; \
  1084. echo "See README for more information."; echo; \
  1085. rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
  1086. @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
  1087. endif
  1088. ifeq ($(CHECK_LIBUSB0), yes)
  1089. @printf "Checking for libusb-0.1/libusb-compat headers... " | tee -a $(BUILD_DETAILS_FILE)
  1090. @echo "$$LIBUSB0_TEST" > .test.c
  1091. @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
  1092. @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
  1093. echo "found." || { echo "not found."; echo; \
  1094. echo "The following features require libusb-0.1/libusb-compat: $(NEED_LIBUSB0)."; \
  1095. echo "Please install libusb-0.1 headers or libusb-compat headers or disable all features"; \
  1096. echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB0_PROGRAMMERS=no"; \
  1097. echo "See README for more information."; echo; \
  1098. rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
  1099. @printf "Checking if libusb-0.1 is usable... " | tee -a $(BUILD_DETAILS_FILE)
  1100. @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS)" >>$(BUILD_DETAILS_FILE)
  1101. @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USBLIBS) >&2 && \
  1102. echo "yes." || { echo "no."; \
  1103. echo "The following features require libusb-0.1/libusb-compat: $(NEED_LIBUSB0)."; \
  1104. echo "Please install libusb-0.1 or libusb-compat or disable all features"; \
  1105. echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB0_PROGRAMMERS=no"; \
  1106. echo "See README for more information."; echo; \
  1107. rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
  1108. @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
  1109. endif
  1110. ifeq ($(CHECK_LIBUSB1), yes)
  1111. @printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
  1112. @echo "$$LIBUSB1_TEST" > .test.c
  1113. @printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
  1114. @{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
  1115. echo "found." || { echo "not found."; echo; \
  1116. echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
  1117. echo "Please install libusb-1.0 headers or disable all features"; \
  1118. echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
  1119. echo "See README for more information."; echo; \
  1120. rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
  1121. @printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
  1122. @printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
  1123. @{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
  1124. echo "yes." || { echo "no."; \
  1125. echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
  1126. echo "Please install libusb-1.0 or disable all features"; \
  1127. echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
  1128. echo "See README for more information."; echo; \
  1129. rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
  1130. @rm -f .test.c .test.o .test$(EXEC_SUFFIX)
  1131. endif
  1132. .features: features
  1133. # If a user does not explicitly request a non-working feature, we should
  1134. # silently disable it. However, if a non-working (does not compile) feature
  1135. # is explicitly requested, we should bail out with a descriptive error message.
  1136. # We also have to check that at least one programmer driver is enabled.
  1137. featuresavailable:
  1138. ifeq ($(PROGRAMMER_OBJS),)
  1139. @echo "You have to enable at least one programmer driver!"
  1140. @false
  1141. endif
  1142. ifneq ($(UNSUPPORTED_FEATURES), )
  1143. @echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)"
  1144. @false
  1145. endif
  1146. define FTDI_TEST
  1147. #include <stdlib.h>
  1148. #include <ftdi.h>
  1149. struct ftdi_context *ftdic = NULL;
  1150. int main(int argc, char **argv)
  1151. {
  1152. (void) argc;
  1153. (void) argv;
  1154. return ftdi_init(ftdic);
  1155. }
  1156. endef
  1157. export FTDI_TEST
  1158. define FTDI_232H_TEST
  1159. #include <ftdi.h>
  1160. enum ftdi_chip_type type = TYPE_232H;
  1161. endef
  1162. export FTDI_232H_TEST
  1163. define UTSNAME_TEST
  1164. #include <sys/utsname.h>
  1165. struct utsname osinfo;
  1166. int main(int argc, char **argv)
  1167. {
  1168. (void) argc;
  1169. (void) argv;
  1170. uname (&osinfo);
  1171. return 0;
  1172. }
  1173. endef
  1174. export UTSNAME_TEST
  1175. define LINUX_SPI_TEST
  1176. #include <linux/types.h>
  1177. #include <linux/spi/spidev.h>
  1178. int main(int argc, char **argv)
  1179. {
  1180. (void) argc;
  1181. (void) argv;
  1182. return 0;
  1183. }
  1184. endef
  1185. export LINUX_SPI_TEST
  1186. define LINUX_I2C_TEST
  1187. #include <linux/i2c-dev.h>
  1188. #include <linux/i2c.h>
  1189. int main(int argc, char **argv)
  1190. {
  1191. (void) argc;
  1192. (void) argv;
  1193. return 0;
  1194. }
  1195. endef
  1196. export LINUX_I2C_TEST
  1197. features: compiler
  1198. @echo "FEATURES := yes" > .features.tmp
  1199. ifneq ($(NEED_LIBFTDI), )
  1200. @printf "Checking for FTDI support... " | tee -a $(BUILD_DETAILS_FILE)
  1201. @echo "$$FTDI_TEST" > .featuretest.c
  1202. @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE)
  1203. @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
  1204. ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ; \
  1205. printf "Checking for FT232H support in libftdi... " ; \
  1206. echo "$$FTDI_232H_TEST" >> .featuretest.c ; \
  1207. printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS)" >>$(BUILD_DETAILS_FILE) ; \
  1208. { $(CC) $(CPPFLAGS) $(CFLAGS) $(FTDI_INCLUDES) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >&2 && \
  1209. ( echo "found."; echo "FT232H := yes" >> .features.tmp ) || \
  1210. ( echo "not found."; echo "FT232H := no" >> .features.tmp ) } \
  1211. ) || \
  1212. ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \
  1213. 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
  1214. endif
  1215. ifeq ($(CONFIG_LINUX_SPI), yes)
  1216. @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE)
  1217. @echo "$$LINUX_SPI_TEST" > .featuretest.c
  1218. @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
  1219. @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
  1220. ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \
  1221. ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \
  1222. 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
  1223. endif
  1224. ifneq ($(NEED_LINUX_I2C), )
  1225. @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE)
  1226. @echo "$$LINUX_I2C_TEST" > .featuretest.c
  1227. @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
  1228. @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
  1229. ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \
  1230. ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \
  1231. 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
  1232. endif
  1233. @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
  1234. @echo "$$UTSNAME_TEST" > .featuretest.c
  1235. @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
  1236. @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
  1237. ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
  1238. ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
  1239. @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
  1240. @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
  1241. $(PROGRAM).8.html: $(PROGRAM).8
  1242. @groff -mandoc -Thtml $< >$@
  1243. MAN_DATE := $(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)
  1244. $(PROGRAM).8: $(PROGRAM).8.tmpl
  1245. @# Add the man page change date and version to the man page
  1246. @sed -e 's#.TH FLASHROM 8 .*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)" "$(MAN_DATE)"#' <$< >$@
  1247. install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
  1248. mkdir -p $(DESTDIR)$(PREFIX)/sbin
  1249. mkdir -p $(DESTDIR)$(MANDIR)/man8
  1250. $(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
  1251. $(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
  1252. _export: $(PROGRAM).8
  1253. @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
  1254. @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
  1255. @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)"
  1256. @sed -e 's/^VERSION :=.*/VERSION := $(VERSION)/' \
  1257. -e 's/^MAN_DATE :=.*/MAN_DATE := $(MAN_DATE)/' \
  1258. -e 's#./util/getrevision.sh -c#false#' \
  1259. Makefile >"$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile"
  1260. # Restore modification date of all tracked files not marked 'export-ignore' in .gitattributes.
  1261. # sed is required to filter out file names having the attribute set.
  1262. @git ls-tree -r -z -t --full-name --name-only HEAD | \
  1263. git check-attr -z --stdin export-ignore | \
  1264. sed -zne 'x;n;n;s/^set$$//;t;x;p' | \
  1265. xargs -0 sh -c 'for f; do \
  1266. touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \
  1267. "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \
  1268. done'
  1269. export: _export
  1270. @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/"
  1271. tarball: _export
  1272. @tar -cz --format=ustar -f $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.gz -C $(EXPORTDIR)/ \
  1273. $(TAROPTIONS) flashrom-$(RELEASENAME)/
  1274. # Delete the exported directory again because it is most likely what's expected by the user.
  1275. @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
  1276. @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.gz
  1277. libpayload: clean
  1278. make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib
  1279. .PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload
  1280. # Disable implicit suffixes and built-in rules (for performance and profit)
  1281. .SUFFIXES:
  1282. -include $(OBJS:.o=.d)