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 | # If the user has specified custom CFLAGS, all CFLAGS settings below will be |
| 22 | # completely ignored by gnumake. |
| 23 | CFLAGS ?= -Os -Wall -Wshadow |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 24 | CFLAGS += -I$(SHAREDSRCDIR)/include |
Stefan Tauner | f268d8b | 2017-10-26 18:45:00 +0200 | [diff] [blame] | 25 | |
Thomas Heijligen | 3976b7e | 2021-10-20 15:55:35 +0200 | [diff] [blame] | 26 | # Auto determine HOST_OS and TARGET_OS if they are not set as argument |
Miklós Márton | a75a2ed | 2018-01-30 20:25:00 +0100 | [diff] [blame] | 27 | HOST_OS ?= $(shell uname) |
Thomas Heijligen | 3976b7e | 2021-10-20 15:55:35 +0200 | [diff] [blame] | 28 | TARGET_OS := $(call c_macro_test, ../../Makefile.d/os_test.h) |
| 29 | |
Miklós Márton | a75a2ed | 2018-01-30 20:25:00 +0100 | [diff] [blame] | 30 | ifeq ($(findstring MINGW, $(HOST_OS)), MINGW) |
| 31 | # Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found". |
| 32 | CC = gcc |
Miklós Márton | a75a2ed | 2018-01-30 20:25:00 +0100 | [diff] [blame] | 33 | endif |
| 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 |
Thomas Heijligen | 3976b7e | 2021-10-20 15:55:35 +0200 | [diff] [blame] | 44 | # for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ |
Nico Huber | 8b1b314 | 2023-01-08 13:46:05 +0100 | [diff] [blame] | 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 | |
Thomas Heijligen | 3976b7e | 2021-10-20 15:55:35 +0200 | [diff] [blame] | 75 | # We don't use EXEC_SUFFIX here because we want to clean everything. |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 76 | clean: |
Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 77 | rm -f $(PROGRAM) $(PROGRAM).exe |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 78 | rm -rf $(DEPPATH) $(OBJATH) |
| 79 | |
| 80 | # Include the dependency files. |
| 81 | -include $(shell mkdir -p $(DEPPATH) $(OBJATH) 2>/dev/null) $(wildcard $(DEPPATH)/*) |
| 82 | |
| 83 | .PHONY: all clean |