blob: e312996f95e2576c7a367cc0fcffa2dba43b0618 [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
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000024ifeq ($(TARGET_OS), DOS)
25# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
26CFLAGS += -Wno-format
27endif
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000028ifeq ($(WARNERROR), yes)
29CFLAGS += -Werror
30endif
31
32
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000033FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000034# enables functions that populate the descriptor structs from plain binary dumps
Nico Huberad186312016-05-02 15:15:29 +020035FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP_ONLY
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000036FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000037
Stefan Taunerb3850962011-12-24 00:00:32 +000038OBJ = $(OBJATH)/$(SRC:%.c=%.o)
39
40SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o))
41
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000042all:$(PROGRAM)$(EXEC_SUFFIX)
Stefan Taunerb3850962011-12-24 00:00:32 +000043
44$(OBJ): $(OBJATH)/%.o : %.c
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000045 $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
Stefan Taunerb3850962011-12-24 00:00:32 +000046
47# this enables us to share source files without simultaneously sharing .o files
48# with flashrom, which would lead to unexpected results (w/o running make clean)
49$(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000050 $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
Stefan Taunerb3850962011-12-24 00:00:32 +000051
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000052$(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000053 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ)
Stefan Taunerb3850962011-12-24 00:00:32 +000054
55clean:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000056 rm -f $(PROGRAM) $(PROGRAM).exe
Stefan Taunerb3850962011-12-24 00:00:32 +000057 rm -rf $(DEPPATH) $(OBJATH)
58
59# Include the dependency files.
60-include $(shell mkdir -p $(DEPPATH) $(OBJATH) 2>/dev/null) $(wildcard $(DEPPATH)/*)
61
62.PHONY: all clean