-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
57 lines (46 loc) · 1.37 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
TARGET := ipmi-fru-it
SRC = ipmi-fru-it.c
OBJ = $(SRC:.c=.o)
DEP = $(OBJ:.o=.d)
INIPARSER := iniparser
PARSER_DIR := lib/$(INIPARSER)
PARSER_HEADERS := $(PARSER_DIR)/src
HIDE := @
CC := gcc
CFLAGS := -g -Wall
INCLUDES := -I $(PARSER_HEADERS)
LDFLAGS := -L $(PARSER_DIR) -liniparser -lz
ifeq (,$(strip $(filter $(MAKECMDGOALS),clean)))
MAKEFLAGS+=--output-sync=target
ifneq (,$(strip $(DEP)))
-include $(DEP)
endif
endif
%.d : %.c
@printf "%b[1;36m%s%b[0m\n" "\0033" "Dependency: $< -> $@" "\0033"
$(CC) -MM -MG -MT '$@ $(@:.d=.o)' $(CFLAGS) $(INCLUDES) -o $@ $<
@printf "\n"
%.o : %.c
@printf "%b[1;36m%s%b[0m\n" "\0033" "Compiling: $< -> $@" "\0033"
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
@printf "\n"
.PHONY: all clean
.DEFAULT_GOAL := all
all: $(TARGET)
$(INIPARSER):
@printf "%b[1;36m%s%b[0m\n" "\0033" "Buidling: $@" "\0033"
make -C $(PARSER_DIR)
@printf "%b[1;32m%s%b[0m\n\n" "\0033" "$@ Done!" "\0033"
$(TARGET): $(OBJ) $(DEP) $(INIPARSER) Makefile
@printf "%b[1;36m%s%b[0m\n" "\0033" "Buidling: $(OBJ) -> $@" "\0033"
$(CC) -o $@ $(OBJ) $(LDFLAGS)
@printf "%b[1;32m%s%b[0m\n\n" "\0033" "$@ Done!" "\0033"
RM_LIST = $(wildcard $(TARGET) *.o *.d)
clean:
@printf "%b[1;36m%s%b[0m\n" "\0033" "Cleaning" "\0033"
ifneq (,$(RM_LIST))
rm -rf $(RM_LIST)
@printf "\n"
endif
make -C $(PARSER_DIR) $@
@printf "%b[1;32m%s%b[0m\n\n" "\0033" "Done!" "\0033"