blob: d1b5eae927131ff3e93c0df23fac95a03a5a11e8 [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
25override TARGET_OS := $(shell $(CC) $(CPPFLAGS) -E $(SHAREDSRCDIR)/os.h | grep -v '^\#' | grep '"' | \
26 cut -f 2 -d'"')
27
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000028ifeq ($(TARGET_OS), DOS)
Stefan Taunerf268d8b2017-10-26 18:45:00 +020029EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000030# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
31CFLAGS += -Wno-format
32endif
Stefan Taunerf268d8b2017-10-26 18:45:00 +020033
34ifeq ($(TARGET_OS), MinGW)
35EXEC_SUFFIX := .exe
36# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
37# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */
38FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
39endif
40
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000041ifeq ($(WARNERROR), yes)
42CFLAGS += -Werror
43endif
44
45
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000046FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000047# enables functions that populate the descriptor structs from plain binary dumps
Nico Huberad186312016-05-02 15:15:29 +020048FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP_ONLY
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000049FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000050
Stefan Taunerb3850962011-12-24 00:00:32 +000051OBJ = $(OBJATH)/$(SRC:%.c=%.o)
52
53SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o))
54
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000055all:$(PROGRAM)$(EXEC_SUFFIX)
Stefan Taunerb3850962011-12-24 00:00:32 +000056
57$(OBJ): $(OBJATH)/%.o : %.c
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000058 $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
Stefan Taunerb3850962011-12-24 00:00:32 +000059
60# this enables us to share source files without simultaneously sharing .o files
61# with flashrom, which would lead to unexpected results (w/o running make clean)
62$(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000063 $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
Stefan Taunerb3850962011-12-24 00:00:32 +000064
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000065$(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000066 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ)
Stefan Taunerb3850962011-12-24 00:00:32 +000067
68clean:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000069 rm -f $(PROGRAM) $(PROGRAM).exe
Stefan Taunerb3850962011-12-24 00:00:32 +000070 rm -rf $(DEPPATH) $(OBJATH)
71
72# Include the dependency files.
73-include $(shell mkdir -p $(DEPPATH) $(OBJATH) 2>/dev/null) $(wildcard $(DEPPATH)/*)
74
75.PHONY: all clean