-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
85 lines (66 loc) · 1.6 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# This is the Makefile for GCC compiler. Only you need to update outest.
.SUFFIXES:
.SUFFIXES: .o .a .so .c .h .s .cm
SRC := main.c print_set.c select_parameter.c convert.c
SHELL =/bin/bash
CC =gcc
# COVERAGE =-fprofile-arcs -ftest-coverage
COVERAGE =
OBJ =$(patsubst %.c, %.o, $(SRC))
INCH =./inc
INCS =./src
INC =-I$(INCH) -I$(INCS)
TARGET =cbfi.elf
FDPS =fdependent
OBJDIR =obj
ADIR =archive
RDIR =report
IDIR =inc
SDIR =src
CFLAG =-c -g -Wall -pg $(COVERAGE) -Werror
LFLAG =-pg $(COVERAGE)
EXRLIB =-lm
ALLDIR =$(OBJDIR) $(ADIR) $(IDIR) $(SDIR) $(RDIR)
vpath %.o $(OBJDIR)
vpath %.c $(SDIR)
.phony:link clean run show install
$(TARGET):$(OBJ)
$(MAKE) link
ifeq "$(MAKECMDGOALS)" ""
-include $(FDPS)
$(FDPS):$(SRC)
$(CC) $(INC) $(MFLAG) -MM $^ >$@
endif
ifneq ($(ALLDIR), $(wildcard $(ALLDIR)))
@echo "Directory dependency:[" $(ALLDIR) "]"
mkdir -vp $(filter-out $(wildcard $(ALLDIR)), $(ALLDIR))
endif
$(OBJ):%.o:%.c
$(CC) $(INC) $(CFLAG) -o $@ $<
mv $@ $(OBJDIR)
link:$(OBJ)
$(CC) $(INC) $(LFLAG) -o $(TARGET) $^ $(EXRLIB)
@echo $(shell date)
rm $(FDPS)
run:$(TARGET)
./$(TARGET)
$(SHELL) genCoverage.sh
clean:
$(cleanall)
show:
$(call symbol, $(OBJDIR)/main.o)
$(call dylink, $(TARGET))
install:
cp -v $(TARGET) /usr/bin/$(basename $(TARGET))
define cleanall
-rm -rf $(TARGET) $(OBJDIR)/*
-rm -rf $(RDIR)/* *.gcda *.gcno
-rm -rf $(ADIR)/*
-rm -rf core
endef
define symbol
nm -alp $1
endef
define dylink
ldd $1
endef