blob: 42b950adbffe25dbf894554b861194116048f386 [file] [log] [blame]
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +00001#
2# This file is part of the flashrom project.
3#
4# This Makefile works standalone, but it is usually called from the main
5# Makefile in the flashrom directory.
Stefan Taunerb3850962011-12-24 00:00:32 +00006
7PROGRAM=ich_descriptors_tool
8EXTRAINCDIRS = ../../ .
9DEPPATH = .dep
10OBJATH = .obj
11SHAREDSRC = ich_descriptors.c
12SHAREDSRCDIR = ../..
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000013# If your compiler spits out excessive warnings, run make WARNERROR=no
14# You shouldn't have to change this flag.
15WARNERROR ?= yes
Stefan Taunerb3850962011-12-24 00:00:32 +000016
17SRC = $(wildcard *.c)
18
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000019CC ?= gcc
Stefan Taunerb3850962011-12-24 00:00:32 +000020
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000021# If the user has specified custom CFLAGS, all CFLAGS settings below will be
22# completely ignored by gnumake.
23CFLAGS ?= -Os -Wall -Wshadow
Stefan Taunerf268d8b2017-10-26 18:45:00 +020024
Miklós Mártona75a2ed2018-01-30 20:25:00 +010025HOST_OS ?= $(shell uname)
26ifeq ($(findstring MINGW, $(HOST_OS)), MINGW)
27# Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found".
28CC = gcc
Miklós Mártona75a2ed2018-01-30 20:25:00 +010029endif
30
Stefan Taunerf268d8b2017-10-26 18:45:00 +020031override TARGET_OS := $(shell $(CC) $(CPPFLAGS) -E $(SHAREDSRCDIR)/os.h | grep -v '^\#' | grep '"' | \
32 cut -f 2 -d'"')
33
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000034ifeq ($(TARGET_OS), DOS)
Stefan Taunerf268d8b2017-10-26 18:45:00 +020035EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000036# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
Nico Huber8b1b3142023-01-08 13:46:05 +010037FLASHROM_CFLAGS += -Wno-format
38endif
39
40ifeq ($(TARGET_OS), MinGW)
41EXEC_SUFFIX := .exe
42# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
43# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */
44FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000045endif
Stefan Taunerf268d8b2017-10-26 18:45:00 +020046
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000047ifeq ($(WARNERROR), yes)
48CFLAGS += -Werror
49endif
50
51
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000052FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000053# enables functions that populate the descriptor structs from plain binary dumps
Nico Huberad186312016-05-02 15:15:29 +020054FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP_ONLY
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000055FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000056
Stefan Taunerb3850962011-12-24 00:00:32 +000057OBJ = $(OBJATH)/$(SRC:%.c=%.o)
58
59SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o))
60
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000061all:$(PROGRAM)$(EXEC_SUFFIX)
Stefan Taunerb3850962011-12-24 00:00:32 +000062
63$(OBJ): $(OBJATH)/%.o : %.c
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000064 $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
Stefan Taunerb3850962011-12-24 00:00:32 +000065
66# this enables us to share source files without simultaneously sharing .o files
67# with flashrom, which would lead to unexpected results (w/o running make clean)
68$(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000069 $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
Stefan Taunerb3850962011-12-24 00:00:32 +000070
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000071$(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000072 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ)
Stefan Taunerb3850962011-12-24 00:00:32 +000073
74clean:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000075 rm -f $(PROGRAM) $(PROGRAM).exe
Stefan Taunerb3850962011-12-24 00:00:32 +000076 rm -rf $(DEPPATH) $(OBJATH)
77
78# Include the dependency files.
79-include $(shell mkdir -p $(DEPPATH) $(OBJATH) 2>/dev/null) $(wildcard $(DEPPATH)/*)
80
81.PHONY: all clean