/
common_make_rules
224 lines (197 loc) · 7.19 KB
/
common_make_rules
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
########################################################-*-mode:Makefile-*-
## ##
## Language Technologies Institute ##
## Carnegie Mellon University ##
## Copyright (c) 1999 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
## ##
## Common make rules included in all Makefiles ##
## ##
###########################################################################
# System type
-include $(TOP)/config/system.mak
# Include project specific rules
-include $(TOP)/config/project.mak
## User defined configuration options
include $(TOP)/config/config
INCLUDES = -I$(TOP)/include
CPPFLAGS += $(LOCAL_INCLUDES) $(INCLUDES)
CFLAGS += $(EXTRA_CC_FLAGS) $(OPT) $(DBG)
## These'll become (target)arch dependent at some point
TARGET_PLATFORM=$(TARGET_CPU)-$(TARGET_OS)
HOST_PLATFORM=$(HOST_CPU)-$(HOST_OS)
ifeq ($(BUILDDIR), default)
BUILDDIR = $(ABS_TOP_SRCDIR)/build/$(TARGET_PLATFORM)
endif
OBJDIR=$(BUILDDIR)/$(OBJSUBDIR)/$(DIRNAME)
BINDIR=$(BUILDDIR)/bin
ifeq ($(HOST_PLATFORM),$(TARGET_PLATFORM))
BINDIR=$(TOP)/bin
endif
LIBDIR=$(BUILDDIR)/lib
BUILDDIRS=$(OBJDIR) $(BINDIR) $(LIBDIR)
MIMICLIBS = $(LIBDIR)/libmimic.a
MIMICLIBFLAGS = -L$(LIBDIR) -lmimic
LDFLAGS += -lm $(AUDIOLIBS) $(OTHERLIBS)
FULLOBJS = $(OBJS:%=$(OBJDIR)/%)
ifdef SHFLAGS
SOOBJS = $(OBJS:.o=.os)
FULLSHOBJS = $(SOOBJS:%=$(OBJDIR)/%)
ifdef LIBNAME
ALL += $(OBJDIR)/.build_so
endif
endif
ifdef LIBNAME
ALL += $(OBJDIR)/.build_lib
endif
# Only do some directories when you are not cross compiling
ifeq ($(HOST_PLATFORM),$(TARGET_PLATFORM))
OTHER_BUILD_DIRS = $(HOST_ONLY_DIRS)
ALL += $(HOST_ONLY_BUILDS)
endif
all: $(BUILDDIRS) $(OTHER_BUILD_DIRS) $(OBJDIR)/.make_build_dirs $(ALL) nothing
nothing:
@ echo > /dev/null
$(BUILDDIRS):
@ mkdir -p $@ 2>/dev/null || true
$(OBJDIR)/%.o : %.c
$(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.os : %.c
$(CC) $(SHFLAGS) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJDIR)/.build_lib: $(FULLOBJS)
@ (cd $(OBJDIR) && $(AR) cruv $(LIBDIR)/lib$(LIBNAME).a $(OBJS))
@ $(RANLIB) $(LIBDIR)/lib$(LIBNAME).a
@ touch $(OBJDIR)/.build_lib
$(OBJDIR)/.build_so: $(FULLSHOBJS)
@ (cd $(OBJDIR) && $(AR) cruv $(LIBDIR)/lib$(LIBNAME).shared.a $(SOOBJS))
@ $(RANLIB) $(LIBDIR)/lib$(LIBNAME).shared.a
@ touch $(OBJDIR)/.build_so
# Used in the lib/ directory and in building new voices
$(LIBDIR)/%.so: $(LIBDIR)/%.shared.a
@ echo making $@
@ rm -rf shared_os && mkdir shared_os
@ rm -f $@ $@.${PROJECT_VERSION} $@.${PROJECT_SHLIB_VERSION}
@ (cd shared_os && ar x ../$<)
@ (cd shared_os && $(CC) -shared -Wl,-soname,`basename $@`.${PROJECT_SHLIB_VERSION} -o ../$@.${PROJECT_VERSION} *.os)
@ (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_VERSION}` `basename $@.${PROJECT_SHLIB_VERSION}` )
@ (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_SHLIB_VERSION}` `basename $@` )
@ rm -rf shared_os
$(OBJDIR)/.make_build_dirs:
@ echo making in $(DIRNAME) ...
ifdef BUILD_DIRS
@ set -e; for i in $(BUILD_DIRS) $(OTHER_BUILD_DIRS) ; \
do \
$(MAKE) -C $$i --no-print-directory; \
done
endif
clean:
@ echo make clean in $(DIRNAME) ...
@ rm -rf .build_lib .build_so *.gcda *.gcno *.gcov *.o *.os *.a *~ $(LOCAL_CLEAN)
ifdef ALL_DIRS
@ set -e; for i in $(ALL_DIRS) ; \
do \
$(MAKE) -C $$i --no-print-directory clean; \
done
endif
distclean:
@ echo make distclean in $(DIRNAME) ...
ifdef ALL_DIRS
@ set -e; for i in $(ALL_DIRS) ; \
do \
$(MAKE) -C $$i --no-print-directory distclean; \
done
endif
@ rm -rf .build_lib .build_shlib make.depend \
*.o *.os *.a *~ $(LOCAL_CLEAN) $(DIST_CLEAN)
DEPEND=$(OBJDIR)/make.depend
MAKE_DEPEND=$(CC) -MM $(CPPFLAGS) $(CFLAGS)
depend:
@ echo make depend in $(DIRNAME) ...
@ rm -f $(DEPEND)
@ $(MAKE) nothing
ifdef ALL_DIRS
@ set -e; for i in $(ALL_DIRS) ; \
do \
$(MAKE) -C $$i --no-print-directory depend ; \
done
endif
$(DEPEND): $(SRCS) $(OBJDIR)
ifdef BUILD_DIRS
@ rm -f $(DEPEND)
@ for i in $(SRCS) ; \
do \
echo "# $$i" ; \
$(MAKE_DEPEND) $$i | sed -e 's,^\([^:][^:]*\):,$(OBJDIR)/\1:,'; \
echo ; \
done > $(DEPEND)
endif
file-list:
@ echo making file-list in $(DIRNAME) ...
ifeq ($(TOP),.)
@ for f in $(FILES) ; \
do \
echo $$f >>$(TOP)/FileList ; \
done
else
@ for f in $(FILES) ; \
do \
echo $(DIRNAME)/$$f >>$(TOP)/FileList ; \
done
endif
ifdef ALL_DIRS
@ for i in $(ALL_DIRS) ; \
do \
$(MAKE) -C $$i --no-print-directory file-list; \
done
endif
info:
@echo Project Name = $(PROJECT_NAME)
@echo Project Prefix = $(PROJECT_PREFIX)
@echo Project Version = $(PROJECT_VERSION)
@echo Project Date = $(PROJECT_DATE)
@echo Project State = $(PROJECT_STATE)
@echo
@echo Configuration Variables
@echo none at present
gcov:
@ echo making gcov in $(DIRNAME) ...
@ for f in $(SRCS) ; \
do \
gcov $$f ; \
done
ifdef ALL_DIRS
@ for i in $(ALL_DIRS) ; \
do \
$(MAKE) -C $$i --no-print-directory gcov; \
done
endif
# If there are sources in this directory, load in the dependencies
ifdef SRCS
-include $(DEPEND)
endif