Debian Codegraph @

config/common_make_rules

raw ◀ ▶
2 Debian patches touch this file
1 ########################################################-*-mode:Makefile-*-
2 ## ##
3 ## Language Technologies Institute ##
4 ## Carnegie Mellon University ##
5 ## Copyright (c) 1999 ##
6 ## All Rights Reserved. ##
7 ## ##
8 ## Permission is hereby granted, free of charge, to use and distribute ##
9 ## this software and its documentation without restriction, including ##
10 ## without limitation the rights to use, copy, modify, merge, publish, ##
11 ## distribute, sublicense, and/or sell copies of this work, and to ##
12 ## permit persons to whom this work is furnished to do so, subject to ##
13 ## the following conditions: ##
14 ## 1. The code must retain the above copyright notice, this list of ##
15 ## conditions and the following disclaimer. ##
16 ## 2. Any modifications must be clearly marked as such. ##
17 ## 3. Original authors' names are not deleted. ##
18 ## 4. The authors' names are not used to endorse or promote products ##
19 ## derived from this software without specific prior written ##
20 ## permission. ##
21 ## ##
22 ## CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ##
23 ## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
24 ## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
25 ## SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ##
26 ## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
27 ## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
28 ## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
29 ## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
30 ## THIS SOFTWARE. ##
31 ## ##
32 ###########################################################################
33 ## ##
34 ## Common make rules included in all Makefiles ##
35 ## ##
36 ###########################################################################
37
38 # System type
39 -include $(TOP)/config/system.mak
40
41 # Include project specific rules
42 -include $(TOP)/config/project.mak
43
44 ## User defined configuration options
45 include $(TOP)/config/config
46
47 INCLUDES = -I$(TOP)/include
48 ifeq ($(TARGET_OS),palmos)
49 INCLUDES += -I$(TOP)/palm/include
50 endif
51
52 CPPFLAGS += $(LOCAL_INCLUDES) $(INCLUDES)
53 CFLAGS += $(EXTRA_CC_FLAGS) $(OPT) $(DBG)
54 ## These'll become (target)arch dependent at some point
55 TARGET_PLATFORM=$(TARGET_CPU)-$(TARGET_OS)
56 HOST_PLATFORM=$(HOST_CPU)-$(HOST_OS)
57 ifndef BUILDDIR
58 BUILDDIR=$(TOP)/build/$(TARGET_PLATFORM)
59 endif
60 OBJDIR=$(BUILDDIR)/obj/$(DIRNAME)
61 BINDIR=$(BUILDDIR)/bin
62 ifeq ($(HOST_PLATFORM),$(TARGET_PLATFORM))
63 BINDIR=$(TOP)/bin
64 endif
65
66 LIBDIR=$(BUILDDIR)/lib
67 BUILDDIRS=$(OBJDIR) $(BINDIR) $(LIBDIR)
68
69 FLITELIBS = $(BUILDDIR)/lib/libflite.a
70 FLITELIBFLAGS = -L$(BUILDDIR)/lib -lflite
71 LDFLAGS += -lm $(AUDIOLIBS) $(OTHERLIBS)
72
73 FULLOBJS = $(OBJS:%=$(OBJDIR)/%)
74 ifdef SHFLAGS
75 SOOBJS = $(OBJS:.o=.os)
76 FULLSHOBJS = $(SOOBJS:%=$(OBJDIR)/%)
77 ifdef LIBNAME
78 ALL += $(OBJDIR)/.build_so
79 endif
80 endif
81 ifdef LIBNAME
82 ALL += $(OBJDIR)/.build_lib
83 endif
84 # Only do some directories when you are not cross compiling
85 ifeq ($(HOST_PLATFORM),$(TARGET_PLATFORM))
86 OTHER_BUILD_DIRS = $(HOST_ONLY_DIRS)
87 ALL += $(HOST_ONLY_BUILDS)
88 endif
89 # When target is palm add the palm directory at the top level
90 ifeq ($(DIRNAME),)
91 ifeq ($(TARGET_OS),palmos)
92 OTHER_BUILD_DIRS += palm
93 endif
94 endif
95
96 all: $(BUILDDIRS) $(OTHER_BUILD_DIRS) $(OBJDIR)/.make_build_dirs $(ALL) nothing
97
98 nothing:
99 @ echo > /dev/null
100
101 $(BUILDDIRS):
102 @ mkdir -p $@ 2>/dev/null || true
103
104 $(OBJDIR)/%.o : %.c
105 $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
106
107 $(OBJDIR)/%.os : %.c
108 $(CC) $(SHFLAGS) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
109
110 $(OBJDIR)/.build_lib: $(FULLOBJS)
•111 (cd $(OBJDIR) && $(AR) crv ../../../$(LIBDIR)/lib$(LIBNAME).a $(OBJS))
112 $(RANLIB) $(LIBDIR)/lib$(LIBNAME).a
113 @ touch $(OBJDIR)/.build_lib
114
115 $(OBJDIR)/.build_so: $(FULLSHOBJS)
•116 (cd $(OBJDIR) && $(AR) crv ../../../$(LIBDIR)/lib$(LIBNAME).shared.a $(SOOBJS))
117 $(RANLIB) $(LIBDIR)/lib$(LIBNAME).shared.a
118 @ touch $(OBJDIR)/.build_so
119
120 # Used in the lib/ directory and in building new voices
121 $(LIBDIR)/%.so: $(LIBDIR)/%.shared.a
122 @ echo making $@
•123 @ rm -rf $*-shared_os && mkdir $*-shared_os
124 @ rm -f $@ $@.${PROJECT_VERSION} $@.${PROJECT_SHLIB_VERSION}
•125 (cd $*-shared_os && ar x ../$<)
126 (cd $*-shared_os && $(CC) -shared -Wl,-soname,`basename $@`.${PROJECT_SHLIB_VERSION} -o ../$@.${PROJECT_VERSION} *.os $(LDFLAGS))
127 (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_VERSION}` `basename $@.${PROJECT_SHLIB_VERSION}` )
128 (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_SHLIB_VERSION}` `basename $@` )
•129 @ rm -rf $*-shared_os
130
131 $(OBJDIR)/.make_build_dirs:
132 @ echo making in $(DIRNAME) ...
133 ifdef BUILD_DIRS
134 @ set -e; for i in $(BUILD_DIRS) $(OTHER_BUILD_DIRS) ; \
135 do \
136 $(MAKE) -C $$i --no-print-directory; \
137 done
138 endif
139
140 clean:
141 @ echo make clean in $(DIRNAME) ...
142 @ rm -rf .build_lib .build_so *.o *.os *.a *~ $(LOCAL_CLEAN) $(OBJDIR)
143 ifdef ALL_DIRS
144 @ set -e; for i in $(ALL_DIRS) ; \
145 do \
146 $(MAKE) -C $$i --no-print-directory clean; \
147 done
148 endif
149
150 distclean:
151 @ echo make distclean in $(DIRNAME) ...
152 ifdef ALL_DIRS
153 @ set -e; for i in $(ALL_DIRS) ; \
154 do \
155 $(MAKE) -C $$i --no-print-directory distclean; \
156 done
157 endif
158 @ rm -rf .build_lib .build_shlib make.depend \
159 *.o *.os *.a *~ $(LOCAL_CLEAN) $(DIST_CLEAN) $(OBJDIR)
160
161 DEPEND=$(OBJDIR)/make.depend
162 MAKE_DEPEND=$(CC) -MM $(CPPFLAGS) $(CFLAGS)
163
164 depend:
165 @ echo make depend in $(DIRNAME) ...
166 @ rm -f $(DEPEND)
167 @ $(MAKE) nothing
168 ifdef ALL_DIRS
169 @ set -e; for i in $(ALL_DIRS) ; \
170 do \
171 $(MAKE) -C $$i --no-print-directory depend ; \
172 done
173 endif
174
175 $(DEPEND): $(SRCS) $(OBJDIR)
176 ifdef BUILD_DIRS
177 @ rm -f $(DEPEND)
178 @ for i in $(SRCS) ; \
179 do \
180 echo "# $$i" ; \
181 $(MAKE_DEPEND) $$i | sed -e 's,^\([^:][^:]*\):,$(OBJDIR)/\1:,'; \
182 echo ; \
183 done > $(DEPEND)
184 endif
185
186 file-list:
187 @ echo making file-list in $(DIRNAME) ...
188 ifeq ($(TOP),.)
189 @ for f in $(FILES) ; \
190 do \
191 echo $$f >>$(TOP)/FileList ; \
192 done
193 else
194 @ for f in $(FILES) ; \
195 do \
196 echo $(DIRNAME)/$$f >>$(TOP)/FileList ; \
197 done
198 endif
199 ifdef ALL_DIRS
200 @ for i in $(ALL_DIRS) ; \
201 do \
202 $(MAKE) -C $$i --no-print-directory file-list; \
203 done
204 endif
205
206 info:
207 @echo Project Name = $(PROJECT_NAME)
208 @echo Project Prefix = $(PROJECT_PREFIX)
209 @echo Project Version = $(PROJECT_VERSION)
210 @echo Project Date = $(PROJECT_DATE)
211 @echo Project State = $(PROJECT_STATE)
212 @echo
213 @echo Configuration Variables
214 @echo none at present
215
216 # If there are sources in this directory, load in the dependencies
217 ifdef SRCS
218 -include $(DEPEND)
219 endif