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