blob: c32e30be5bfc20252563da54f32bcca76ff46bc7 [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
29EXEC_SUFFIX := .exe
30# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
31# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */
32FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
33endif
34
Stefan Taunerf268d8b2017-10-26 18:45:00 +020035override TARGET_OS := $(shell $(CC) $(CPPFLAGS) -E $(SHAREDSRCDIR)/os.h | grep -v '^\#' | grep '"' | \
36 cut -f 2 -d'"')
37
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000038ifeq ($(TARGET_OS), DOS)
Stefan Taunerf268d8b2017-10-26 18:45:00 +020039EXEC_SUFFIX := .exe
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000040# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
41CFLAGS += -Wno-format
42endif
Stefan Taunerf268d8b2017-10-26 18:45:00 +020043
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000044ifeq ($(WARNERROR), yes)
45CFLAGS += -Werror
46endif
47
48
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000049FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
Carl-Daniel Hailfingerb7bce8a2012-08-14 21:36:11 +000050# enables functions that populate the descriptor structs from plain binary dumps
Nico Huberad186312016-05-02 15:15:29 +020051FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP_ONLY
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000052FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000053
Stefan Taunerb3850962011-12-24 00:00:32 +000054OBJ = $(OBJATH)/$(SRC:%.c=%.o)
55
56SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o))
57
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000058all:$(PROGRAM)$(EXEC_SUFFIX)
Stefan Taunerb3850962011-12-24 00:00:32 +000059
60$(OBJ): $(OBJATH)/%.o : %.c
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000061 $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
Stefan Taunerb3850962011-12-24 00:00:32 +000062
63# this enables us to share source files without simultaneously sharing .o files
64# with flashrom, which would lead to unexpected results (w/o running make clean)
65$(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000066 $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
Stefan Taunerb3850962011-12-24 00:00:32 +000067
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000068$(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ)
Carl-Daniel Hailfingera8da2242012-08-15 23:06:32 +000069 $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ)
Stefan Taunerb3850962011-12-24 00:00:32 +000070
71clean:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000072 rm -f $(PROGRAM) $(PROGRAM).exe
Stefan Taunerb3850962011-12-24 00:00:32 +000073 rm -rf $(DEPPATH) $(OBJATH)
74
75# Include the dependency files.
76-include $(shell mkdir -p $(DEPPATH) $(OBJATH) 2>/dev/null) $(wildcard $(DEPPATH)/*)
77
78.PHONY: all clean