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 | |
Miklós Márton | a75a2ed | 2018-01-30 20:25:00 +0100 | [diff] [blame] | 25 | HOST_OS ?= $(shell uname) |
| 26 | ifeq ($(findstring MINGW, $(HOST_OS)), MINGW) |
| 27 | # Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found". |
| 28 | CC = gcc |
Miklós Márton | a75a2ed | 2018-01-30 20:25:00 +0100 | [diff] [blame] | 29 | endif |
| 30 | |
Stefan Tauner | f268d8b | 2017-10-26 18:45:00 +0200 | [diff] [blame] | 31 | override TARGET_OS := $(shell $(CC) $(CPPFLAGS) -E $(SHAREDSRCDIR)/os.h | grep -v '^\#' | grep '"' | \ |
| 32 | cut -f 2 -d'"') |
| 33 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 34 | ifeq ($(TARGET_OS), DOS) |
Stefan Tauner | f268d8b | 2017-10-26 18:45:00 +0200 | [diff] [blame] | 35 | EXEC_SUFFIX := .exe |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 36 | # DJGPP has odd uint*_t definitions which cause lots of format string warnings. |
Nico Huber | 8b1b314 | 2023-01-08 13:46:05 +0100 | [diff] [blame^] | 37 | FLASHROM_CFLAGS += -Wno-format |
| 38 | endif |
| 39 | |
| 40 | ifeq ($(TARGET_OS), MinGW) |
| 41 | EXEC_SUFFIX := .exe |
| 42 | # Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that |
| 43 | # for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */ |
| 44 | FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 45 | endif |
Stefan Tauner | f268d8b | 2017-10-26 18:45:00 +0200 | [diff] [blame] | 46 | |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 47 | ifeq ($(WARNERROR), yes) |
| 48 | CFLAGS += -Werror |
| 49 | endif |
| 50 | |
| 51 | |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 52 | FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d |
Carl-Daniel Hailfinger | b7bce8a | 2012-08-14 21:36:11 +0000 | [diff] [blame] | 53 | # enables functions that populate the descriptor structs from plain binary dumps |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 54 | FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP_ONLY |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 55 | FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 56 | |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 57 | OBJ = $(OBJATH)/$(SRC:%.c=%.o) |
| 58 | |
| 59 | SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o)) |
| 60 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 61 | all:$(PROGRAM)$(EXEC_SUFFIX) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 62 | |
| 63 | $(OBJ): $(OBJATH)/%.o : %.c |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 64 | $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $< |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 65 | |
| 66 | # this enables us to share source files without simultaneously sharing .o files |
| 67 | # with flashrom, which would lead to unexpected results (w/o running make clean) |
| 68 | $(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 69 | $(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $< |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 70 | |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 71 | $(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ) |
Carl-Daniel Hailfinger | a8da224 | 2012-08-15 23:06:32 +0000 | [diff] [blame] | 72 | $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 73 | |
| 74 | clean: |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 75 | rm -f $(PROGRAM) $(PROGRAM).exe |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 76 | rm -rf $(DEPPATH) $(OBJATH) |
| 77 | |
| 78 | # Include the dependency files. |
| 79 | -include $(shell mkdir -p $(DEPPATH) $(OBJATH) 2>/dev/null) $(wildcard $(DEPPATH)/*) |
| 80 | |
| 81 | .PHONY: all clean |