Makefile 1.77 KB
Newer Older
1 2 3 4 5
#
# This file is part of the flashrom project.
#
# This Makefile works standalone, but it is usually called from the main
# Makefile in the flashrom directory.
6 7 8 9 10 11 12

PROGRAM=ich_descriptors_tool
EXTRAINCDIRS = ../../ .
DEPPATH = .dep
OBJATH = .obj
SHAREDSRC = ich_descriptors.c
SHAREDSRCDIR = ../..
13 14 15
# If your compiler spits out excessive warnings, run make WARNERROR=no
# You shouldn't have to change this flag.
WARNERROR ?= yes
16 17 18

SRC = $(wildcard *.c)

19
CC ?= gcc
20

21 22 23
# If the user has specified custom CFLAGS, all CFLAGS settings below will be
# completely ignored by gnumake.
CFLAGS ?= -Os -Wall -Wshadow
24 25 26 27
ifeq ($(TARGET_OS), DOS)
# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
CFLAGS += -Wno-format
endif
28 29 30 31 32
ifeq ($(WARNERROR), yes)
CFLAGS += -Werror
endif


33
FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
34
# enables functions that populate the descriptor structs from plain binary dumps
35 36
FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP
FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
37

38 39 40 41
OBJ = $(OBJATH)/$(SRC:%.c=%.o)

SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o))

42
all:$(PROGRAM)$(EXEC_SUFFIX)
43 44

$(OBJ): $(OBJATH)/%.o : %.c
45
	$(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
46 47 48 49

# this enables us to share source files without simultaneously sharing .o files
# with flashrom, which would lead to unexpected results (w/o running make clean)
$(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c
50
	$(CC) $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) -o $@ -c $<
51

52
$(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ)
53
	$(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ)
54 55

clean:
56
	rm -f $(PROGRAM) $(PROGRAM).exe
57 58 59 60 61 62
	rm -rf $(DEPPATH) $(OBJATH)

# Include the dependency files.
-include $(shell mkdir -p $(DEPPATH) $(OBJATH) 2>/dev/null) $(wildcard $(DEPPATH)/*)

.PHONY: all clean