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 45include $(TOP)/config/config 46 47INCLUDES = -I$(TOP)/include 48ifeq ($(TARGET_OS),palmos) 49INCLUDES += -I$(TOP)/palm/include 50endif 51 52CPPFLAGS += $(LOCAL_INCLUDES) $(INCLUDES) 53CFLAGS += $(EXTRA_CC_FLAGS) $(OPT) $(DBG) 54## These'll become (target)arch dependent at some point 55TARGET_PLATFORM=$(TARGET_CPU)-$(TARGET_OS) 56HOST_PLATFORM=$(HOST_CPU)-$(HOST_OS) 57ifndef BUILDDIR 58BUILDDIR=$(TOP)/build/$(TARGET_PLATFORM) 59endif 60OBJDIR=$(BUILDDIR)/obj/$(DIRNAME) 61BINDIR=$(BUILDDIR)/bin 62ifeq ($(HOST_PLATFORM),$(TARGET_PLATFORM)) 63BINDIR=$(TOP)/bin 64endif 65 66LIBDIR=$(BUILDDIR)/lib 67BUILDDIRS=$(OBJDIR) $(BINDIR) $(LIBDIR) 68 69FLITELIBS = $(BUILDDIR)/lib/libflite.a 70FLITELIBFLAGS = -L$(BUILDDIR)/lib -lflite 71LDFLAGS += -lm $(AUDIOLIBS) $(OTHERLIBS) 72 73FULLOBJS = $(OBJS:%=$(OBJDIR)/%) 74ifdef SHFLAGS 75SOOBJS = $(OBJS:.o=.os) 76FULLSHOBJS = $(SOOBJS:%=$(OBJDIR)/%) 77ifdef LIBNAME 78ALL += $(OBJDIR)/.build_so 79endif 80endif 81ifdef LIBNAME 82ALL += $(OBJDIR)/.build_lib 83endif 84# Only do some directories when you are not cross compiling 85ifeq ($(HOST_PLATFORM),$(TARGET_PLATFORM)) 86OTHER_BUILD_DIRS = $(HOST_ONLY_DIRS) 87ALL += $(HOST_ONLY_BUILDS) 88endif 89# When target is palm add the palm directory at the top level 90ifeq ($(DIRNAME),) 91ifeq ($(TARGET_OS),palmos) 92OTHER_BUILD_DIRS += palm 93endif 94endif 95 96all: $(BUILDDIRS) $(OTHER_BUILD_DIRS) $(OBJDIR)/.make_build_dirs $(ALL) nothing 97 98nothing: 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) cruv ../../../$(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) cruv ../../../$(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) -lm) 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) ... 133ifdef BUILD_DIRS 134 @ set -e; for i in $(BUILD_DIRS) $(OTHER_BUILD_DIRS) ; \ 135 do \ 136 $(MAKE) -C $$i --no-print-directory; \ 137 done 138endif 139 140clean: 141 @ echo make clean in $(DIRNAME) ... 142 @ rm -rf .build_lib .build_so *.o *.os *.a *~ $(LOCAL_CLEAN) $(OBJDIR) 143ifdef ALL_DIRS 144 @ set -e; for i in $(ALL_DIRS) ; \ 145 do \ 146 $(MAKE) -C $$i --no-print-directory clean; \ 147 done 148endif 149 150distclean: 151 @ echo make distclean in $(DIRNAME) ... 152ifdef ALL_DIRS 153 @ set -e; for i in $(ALL_DIRS) ; \ 154 do \ 155 $(MAKE) -C $$i --no-print-directory distclean; \ 156 done 157endif 158 @ rm -rf .build_lib .build_shlib make.depend \ 159 *.o *.os *.a *~ $(LOCAL_CLEAN) $(DIST_CLEAN) $(OBJDIR) 160 161DEPEND=$(OBJDIR)/make.depend 162MAKE_DEPEND=$(CC) -MM $(CPPFLAGS) $(CFLAGS) 163 164depend: 165 @ echo make depend in $(DIRNAME) ... 166 @ rm -f $(DEPEND) 167 @ $(MAKE) nothing 168ifdef ALL_DIRS 169 @ set -e; for i in $(ALL_DIRS) ; \ 170 do \ 171 $(MAKE) -C $$i --no-print-directory depend ; \ 172 done 173endif 174 175$(DEPEND): $(SRCS) $(OBJDIR) 176ifdef 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) 184endif 185 186file-list: 187 @ echo making file-list in $(DIRNAME) ... 188ifeq ($(TOP),.) 189 @ for f in $(FILES) ; \ 190 do \ 191 echo $$f >>$(TOP)/FileList ; \ 192 done 193else 194 @ for f in $(FILES) ; \ 195 do \ 196 echo $(DIRNAME)/$$f >>$(TOP)/FileList ; \ 197 done 198endif 199ifdef ALL_DIRS 200 @ for i in $(ALL_DIRS) ; \ 201 do \ 202 $(MAKE) -C $$i --no-print-directory file-list; \ 203 done 204endif 205 206info: 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 217ifdef SRCS 218-include $(DEPEND) 219endif 220