Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 1 | # |
| 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 Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 6 | |
| 7 | PROGRAM=ich_descriptors_tool |
| 8 | EXTRAINCDIRS = ../../ . |
| 9 | DEPPATH = .dep |
| 10 | OBJATH = .obj |
| 11 | SHAREDSRC = ich_descriptors.c |
| 12 | SHAREDSRCDIR = ../.. |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 13 | # If your compiler spits out excessive warnings, run make WARNERROR=no |
| 14 | # You shouldn't have to change this flag. |
| 15 | WARNERROR ?= yes |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 16 | |
| 17 | SRC = $(wildcard *.c) |
| 18 | |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 19 | CC ?= gcc |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 20 | |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 21 | # If the user has specified custom CFLAGS, all CFLAGS settings below will be |
| 22 | # completely ignored by gnumake. |
| 23 | CFLAGS ?= -Os -Wall -Wshadow |
Stefan Tauner | f268d8b | 2017-10-26 18:45:00 +0200 | [diff] [blame] | 24 | |
| 25 | override TARGET_OS := $(shell $(CC) $(CPPFLAGS) -E $(SHAREDSRCDIR)/os.h | grep -v '^\#' | grep '"' | \ |
| 26 | cut -f 2 -d'"') |
| 27 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 28 | ifeq ($(TARGET_OS), DOS) |
Stefan Tauner | f268d8b | 2017-10-26 18:45:00 +0200 | [diff] [blame] | 29 | EXEC_SUFFIX := .exe |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 30 | # DJGPP has odd uint*_t definitions which cause lots of format string warnings. |
| 31 | CFLAGS += -Wno-format |
| 32 | endif |
Stefan Tauner | f268d8b | 2017-10-26 18:45:00 +0200 | [diff] [blame] | 33 | |
| 34 | ifeq ($(TARGET_OS), MinGW) |
| 35 | EXEC_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/ */ |
| 38 | FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 |
| 39 | endif |
| 40 | |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 41 | ifeq ($(WARNERROR), yes) |
| 42 | CFLAGS += -Werror |
| 43 | endif |
| 44 | |
| 45 | |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 46 | FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 47 | # enables functions that populate the descriptor structs from plain binary dumps |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 48 | FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP_ONLY |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 49 | FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 50 | |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 51 | OBJ = $(OBJATH)/$(SRC:%.c=%.o) |
| 52 | |
| 53 | SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o)) |
| 54 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 55 | all:$(PROGRAM)$(EXEC_SUFFIX) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 56 | |
| 57 | $(OBJ): $(OBJATH)/%.o : %.c |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 58 | $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $< |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 59 | |
| 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 Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 63 | $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $< |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 64 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 65 | $(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ) |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 66 | $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 67 | |
| 68 | clean: |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 69 | rm -f $(PROGRAM) $(PROGRAM).exe |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 70 | 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 |