-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
149 lines (100 loc) · 3.3 KB
/
makefile
File metadata and controls
149 lines (100 loc) · 3.3 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#
# 'make depend' uses makedepend to automatically generate dependencies
# (dependencies are added to end of Makefile)
# 'make' build static lib 'libinireader.a'
# 'make clean' removes all .o and static lib files
#
# define the C compiler to use
#CC = gcc
CC = @echo
# define any compile-time flags
#CFLAGS = -c
# define any archive (static lib) flags
#ARFLAGS=rv
# define any directories containing header files other than /usr/include
#INCLUDES =-ICore/include -I../Utils/include
# define library paths in addition to /usr/lib
# specify path using -Lpath, something like:
#LFLAGS = -L/home/newhall/lib -L../lib
# define the CPP source files
SRCS = \
x.cpp \
y.cpp \
X/a.cpp \
X/b.cpp
# define the CPP object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
# Below we are replacing the suffix .cpp of all words in the macro SRCS
# with the .o suffix
OBJS = $(SRCS:.cpp=.o)
# generate object names without compile
OBJNAMES = $(SRCS:.cpp=.o)
#folder for lib file.
LIBDIR = lib
MAC2= mac2
# define the static lib file
ST_LIB = $(LIBDIR)/libMRTest.a
# The following part of the makefile is generic; it can be used to
# build any static lib just by changing the definitions above and by
# deleting dependencies appended to the file from 'make depend'
.PHONY: depend clean
#all:
all: $(ST_LIB)
@echo Simple compiler named libutils.a has been compiled
# rule to archive all of the object files into the static lib
# chains to the OBJS macro which calls the .cpp.o to do the compilation first.
$(ST_LIB): $(MAC2)
@echo $(ST_LIB) target rules
# @echo $(SRCS)
# @echo $(SRCS:.cpp=.o)
# @echo $< -o $@
#$(MAC2): $(SRCS:.cpp=.o)
# @echo $(MAC2) target rules
# @echo vars less=$< at=$@ Question=$? percent=$% carret=$^ asterix=$*
# @echo $@ $?
#$(MAC2):
# @echo $(MAC2) target rules - for each loop
# $(foreach i,$(SRCS:.cpp=), \
# @echo compile $i.cpp to $i.o \n \
# )
$(MAC2):
@echo $(MAC2) target rules - for each loop
$(foreach i,$(SRCS:.cpp=), \
$(shell echo $i.cpp to $i.o > /dev/stderr) \
)
#$(MAC2):
# @echo $(MAC2) target rules - for each loop
# $(foreach i,$(SRCS:.cpp=), \
# $(if $($i) \
# ,$(shell echo $i.cpp to $i.o > /dev/stderr) \
# ,$(shell echo No value in i=$(i) > /dev/stderr) \
# ) \
# )
# @echo Prerequisite=$< Target=$@ Whatever=$?
# @echo vars less=$< at=$@ Question=$? percent=$% carret=$^ asterix=$*
# @echo $@ $?
# @echo $(ST_LIB) target rules
# @echo $@ $?
#$(ST_LIB): $(OBJS)
# mkdir -p $(LIBDIR)
# $(AR) $(ARFLAGS) $@ $?
# this is a suffix replacement rule for building .o's from .cpp's
# it uses automatic variables $<: the name of the prerequisite of
# the rule(a .cpp file) and $@: the name of the target of the rule (a .o file)
# (see the gnu make manual section about automatic variables)
#.cpp.o:
# @echo cpp o replacement rules
# @echo $< -o $@
# @echo Prerequisite=$< Target=$@ Whatever=$?
# @echo vars less=$< at=$@ Question=$? percent=$% carret=$^ asterix=$*
# $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
@echo $(ST_LIB) clean rules
$(RM) $(OBJNAMES)
$(RM) *~ $(ST_LIB)
depend: $(SRCS)
makedepend $(INCLUDES) $^
# DO NOT DELETE THIS LINE -- make depend needs it