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 |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 24 | ifeq ($(TARGET_OS), DOS) |
| 25 | # DJGPP has odd uint*_t definitions which cause lots of format string warnings. |
| 26 | CFLAGS += -Wno-format |
| 27 | endif |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 28 | ifeq ($(WARNERROR), yes) |
| 29 | CFLAGS += -Werror |
| 30 | endif |
| 31 | |
| 32 | |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 33 | FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 34 | # enables functions that populate the descriptor structs from plain binary dumps |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 35 | FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP |
| 36 | FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 37 | |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 38 | OBJ = $(OBJATH)/$(SRC:%.c=%.o) |
| 39 | |
| 40 | SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o)) |
| 41 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 42 | all:$(PROGRAM)$(EXEC_SUFFIX) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 43 | |
| 44 | $(OBJ): $(OBJATH)/%.o : %.c |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 45 | $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $< |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 46 | |
| 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 Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 50 | $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $< |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 51 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 52 | $(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ) |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 53 | $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 54 | |
| 55 | clean: |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 56 | rm -f $(PROGRAM) $(PROGRAM).exe |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 57 | 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 |