common_make_rules 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. # System type
  38. -include $(TOP)/config/system.mak
  39. # Include project specific rules
  40. -include $(TOP)/config/project.mak
  41. ## User defined configuration options
  42. include $(TOP)/config/config
  43. INCLUDES = -I$(TOP)/include
  44. ifeq ($(TARGET_OS),palmos)
  45. INCLUDES += -I$(TOP)/palm/include
  46. endif
  47. CPPFLAGS += $(LOCAL_INCLUDES) $(INCLUDES)
  48. CFLAGS += $(EXTRA_CC_FLAGS) $(OPT) $(DBG)
  49. ## These'll become (target)arch dependent at some point
  50. TARGET_PLATFORM=$(TARGET_CPU)-$(TARGET_OS)
  51. HOST_PLATFORM=$(HOST_CPU)-$(HOST_OS)
  52. ifndef BUILDDIR
  53. BUILDDIR=$(TOP)/build/$(TARGET_PLATFORM)
  54. endif
  55. OBJDIR=$(BUILDDIR)/obj/$(DIRNAME)
  56. BINDIR=$(BUILDDIR)/bin
  57. ifeq ($(HOST_PLATFORM),$(TARGET_PLATFORM))
  58. BINDIR=$(TOP)/bin
  59. endif
  60. LIBDIR=$(BUILDDIR)/lib
  61. BUILDDIRS=$(OBJDIR) $(BINDIR) $(LIBDIR)
  62. FLITELIBS = $(BUILDDIR)/lib/libflite.a
  63. FLITELIBFLAGS = -L$(BUILDDIR)/lib -lflite
  64. LDFLAGS += -lm $(AUDIOLIBS) $(OTHERLIBS)
  65. FULLOBJS = $(OBJS:%=$(OBJDIR)/%)
  66. ifdef SHFLAGS
  67. SOOBJS = $(OBJS:.o=.os)
  68. FULLSHOBJS = $(SOOBJS:%=$(OBJDIR)/%)
  69. ifdef LIBNAME
  70. ALL += $(OBJDIR)/.build_so
  71. endif
  72. endif
  73. ifdef LIBNAME
  74. ALL += $(OBJDIR)/.build_lib
  75. endif
  76. # Only do some directories when you are not cross compiling
  77. ifeq ($(HOST_PLATFORM),$(TARGET_PLATFORM))
  78. OTHER_BUILD_DIRS = $(HOST_ONLY_DIRS)
  79. ALL += $(HOST_ONLY_BUILDS)
  80. endif
  81. # When target is palm add the palm directory at the top level
  82. ifeq ($(DIRNAME),)
  83. ifeq ($(TARGET_OS),palmos)
  84. OTHER_BUILD_DIRS += palm
  85. endif
  86. endif
  87. all: $(BUILDDIRS) $(OTHER_BUILD_DIRS) $(OBJDIR)/.make_build_dirs $(ALL) nothing
  88. nothing:
  89. @ echo > /dev/null
  90. $(BUILDDIRS):
  91. @ mkdir -p $@ 2>/dev/null || true
  92. $(OBJDIR)/%.o : %.c
  93. $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
  94. $(OBJDIR)/%.os : %.c
  95. $(CC) $(SHFLAGS) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
  96. $(OBJDIR)/.build_lib: $(FULLOBJS)
  97. @ (cd $(OBJDIR) && $(AR) cruv ../../../$(LIBDIR)/lib$(LIBNAME).a $(OBJS))
  98. @ $(RANLIB) $(LIBDIR)/lib$(LIBNAME).a
  99. @ touch $(OBJDIR)/.build_lib
  100. $(OBJDIR)/.build_so: $(FULLSHOBJS)
  101. @ (cd $(OBJDIR) && $(AR) cruv ../../../$(LIBDIR)/lib$(LIBNAME).shared.a $(SOOBJS))
  102. @ $(RANLIB) $(LIBDIR)/lib$(LIBNAME).shared.a
  103. @ touch $(OBJDIR)/.build_so
  104. # Used in the lib/ directory and in building new voices
  105. $(LIBDIR)/%.so: $(LIBDIR)/%.shared.a
  106. @ echo making $@
  107. @ rm -rf shared_os && mkdir shared_os
  108. @ rm -f $@ $@.${PROJECT_VERSION} $@.${PROJECT_SHLIB_VERSION}
  109. @ (cd shared_os && ar x ../$<)
  110. @ (cd shared_os && $(CC) -shared -Wl,-soname,`basename $@`.${PROJECT_SHLIB_VERSION} -o ../$@.${PROJECT_VERSION} *.os)
  111. @ (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_VERSION}` `basename $@.${PROJECT_SHLIB_VERSION}` )
  112. @ (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_SHLIB_VERSION}` `basename $@` )
  113. @ rm -rf shared_os
  114. $(OBJDIR)/.make_build_dirs:
  115. @ echo making in $(DIRNAME) ...
  116. ifdef BUILD_DIRS
  117. @ set -e; for i in $(BUILD_DIRS) $(OTHER_BUILD_DIRS) ; \
  118. do \
  119. $(MAKE) -C $$i --no-print-directory; \
  120. done
  121. endif
  122. clean:
  123. @ echo make clean in $(DIRNAME) ...
  124. @ rm -rf .build_lib .build_so *.o *.os *.a *~ $(LOCAL_CLEAN) $(OBJDIR)
  125. ifdef ALL_DIRS
  126. @ set -e; for i in $(ALL_DIRS) ; \
  127. do \
  128. $(MAKE) -C $$i --no-print-directory clean; \
  129. done
  130. endif
  131. distclean:
  132. @ echo make distclean in $(DIRNAME) ...
  133. ifdef ALL_DIRS
  134. @ set -e; for i in $(ALL_DIRS) ; \
  135. do \
  136. $(MAKE) -C $$i --no-print-directory distclean; \
  137. done
  138. endif
  139. @ rm -rf .build_lib .build_shlib make.depend \
  140. *.o *.os *.a *~ $(LOCAL_CLEAN) $(DIST_CLEAN) $(OBJDIR)
  141. DEPEND=$(OBJDIR)/make.depend
  142. MAKE_DEPEND=$(CC) -MM $(CPPFLAGS) $(CFLAGS)
  143. depend:
  144. @ echo make depend in $(DIRNAME) ...
  145. @ rm -f $(DEPEND)
  146. @ $(MAKE) nothing
  147. ifdef ALL_DIRS
  148. @ set -e; for i in $(ALL_DIRS) ; \
  149. do \
  150. $(MAKE) -C $$i --no-print-directory depend ; \
  151. done
  152. endif
  153. $(DEPEND): $(SRCS) $(OBJDIR)
  154. ifdef BUILD_DIRS
  155. @ rm -f $(DEPEND)
  156. @ for i in $(SRCS) ; \
  157. do \
  158. echo "# $$i" ; \
  159. $(MAKE_DEPEND) $$i | sed -e 's,^\([^:][^:]*\):,$(OBJDIR)/\1:,'; \
  160. echo ; \
  161. done > $(DEPEND)
  162. endif
  163. file-list:
  164. @ echo making file-list in $(DIRNAME) ...
  165. ifeq ($(TOP),.)
  166. @ for f in $(FILES) ; \
  167. do \
  168. echo $$f >>$(TOP)/FileList ; \
  169. done
  170. else
  171. @ for f in $(FILES) ; \
  172. do \
  173. echo $(DIRNAME)/$$f >>$(TOP)/FileList ; \
  174. done
  175. endif
  176. ifdef ALL_DIRS
  177. @ for i in $(ALL_DIRS) ; \
  178. do \
  179. $(MAKE) -C $$i --no-print-directory file-list; \
  180. done
  181. endif
  182. info:
  183. @echo Project Name = $(PROJECT_NAME)
  184. @echo Project Prefix = $(PROJECT_PREFIX)
  185. @echo Project Version = $(PROJECT_VERSION)
  186. @echo Project Date = $(PROJECT_DATE)
  187. @echo Project State = $(PROJECT_STATE)
  188. @echo
  189. @echo Configuration Variables
  190. @echo none at present
  191. # If there are sources in this directory, load in the dependencies
  192. ifdef SRCS
  193. -include $(DEPEND)
  194. endif