home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / Makefile < prev    next >
Encoding:
Makefile  |  1993-05-22  |  6.3 KB  |  202 lines

  1. # Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3.  
  4. # The GNU C Library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public License as
  6. # published by the Free Software Foundation; either version 2 of the
  7. # License, or (at your option) any later version.
  8.  
  9. # The GNU C Library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. # Library General Public License for more details.
  13.  
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with the GNU C Library; see the file COPYING.LIB.  If
  16. # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. # Cambridge, MA 02139, USA.
  18.  
  19. #
  20. #    Master Makefile for the GNU C library
  21. #
  22. ifneq (,)
  23. This makefile requires GNU Make.
  24. endif
  25.  
  26.  
  27. # This is the default target; it makes everything except the tests.
  28. .PHONY: all
  29. all: lib others
  30.  
  31. configure: configure.in
  32.     autoconf $(ACFLAGS)
  33.  
  34. include Makeconfig
  35.  
  36. include $(objpfx)sysd-dirs
  37. define \n
  38.  
  39.  
  40. endef
  41. sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
  42.  
  43. # These are the subdirectories containing the library source.
  44. +ansi_dirs    := assert ctype locale math setjmp \
  45.            signal stdio stdlib malloc string time
  46. +posix_dirs    := dirent grp pwd posix io termios
  47. +other_dirs    := resource socket misc gnulib $(wildcard crypt) manual
  48. subdirs        := $(strip $(+ansi_dirs) $(+posix_dirs) $(+other_dirs) \
  49.                $(sysdep-subdirs))
  50. export subdirs := $(subdirs)    # Benign, useless in GNU make before 3.63.
  51.  
  52.  
  53. # All initialization source files.
  54. +subdir_inits    := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
  55. # All subdirectories containing initialization source files.
  56. +init_subdirs    := $(patsubst %/,%,$(dir $(+subdir_inits)))
  57.  
  58.  
  59. # These are the targets that are made by making them in each subdirectory.
  60. +subdir_targets    := subdir_lib objects objs others mostlyclean subdir_clean\
  61.            tests subdir_lint.out     \
  62.            subdir_echo-headers subdir_echo-distinfo subdir_install
  63.  
  64. headers := features.h stubs.h errno.h sys/errno.h errnos.h limits.h \
  65.        $(stddef.h) $(stdarg.h)
  66.  
  67. echo-headers: subdir_echo-headers
  68.  
  69. ifdef +gnu-stabs
  70. # We're using the GNU linker, so we use the set-element init function.
  71. +init := set-init
  72. else
  73. # We're not using the GNU linker, so we use the munch init function.
  74. +init := munch-init
  75.  
  76. $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
  77.     awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
  78.     mv $@-t $@
  79. endif
  80.  
  81. aux    := sysdep $(+init) version start
  82.  
  83.  
  84. # What to install.
  85. install-lib = crt0.o Mcrt1.o    # libc.a is done by Makerules.
  86.  
  87.  
  88. include Makerules
  89.  
  90. # Install from subdirectories too.
  91. install: subdir_install
  92.  
  93. # `crt0' is the traditional name for the startup code,
  94. # so that's what we install start.o as.
  95. $(objpfx)crt0.o: $(objpfx)start.o
  96.     -rm -f $@
  97.     ln $< $@
  98.  
  99. $(objpfx)Mcrt1.o:
  100.     cp /dev/null $(objpfx)Mcrt1.c
  101.     $(COMPILE.c) $(objpfx)Mcrt1.c $(OUTPUT_OPTION)
  102.     rm -f $(objpfx)Mcrt1.c
  103.  
  104. $(libc.a): subdir_lib
  105.  
  106.  
  107. $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make
  108.     (echo define sysdep-subdirs;                          \
  109.      for dir in $(sysdirs); do                          \
  110.        if [ -r $(sysdep_dir)/$$dir/Subdirs ]; then                  \
  111.          cat $(sysdep_dir)/$$dir/Subdirs;                      \
  112.        else true;                                  \
  113.        fi;                                      \
  114.      done;                                      \
  115.      echo endef) > $@-tmp
  116.      mv $@-tmp $@
  117.  
  118. # Makerules creates a file `stub-$(subdir)' for each subdirectory, which
  119. # contains `#define __stub_FUNCTION' for each function which is a stub.
  120. # Here we paste all of these together into <stubs.h>.
  121.  
  122. subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
  123.  
  124. # Call the subdirs to make their stub-SUBDIR files.
  125. $(subdir-stubs): $(common-objpfx)stub-%: FORCE
  126.     $(MAKE) -C $* stubs
  127. FORCE:
  128.  
  129. $(objpfx)stubs.h: $(common-objpfx)stub- $(subdir-stubs)
  130.     (echo '/* This file is automatically generated.';\
  131.      echo '   It defines a symbol `__stub_FUNCTION'\'' for each function';\
  132.      echo '   in the C library which is a stub, meaning it will fail';\
  133.      echo '   every time called, usually setting errno to ENOSYS.  */';\
  134.      sort $^) > $@.new
  135.     mv $@.new $@
  136.  
  137. # This makes the Info or DVI file of the documentation from the Texinfo source.
  138. .PHONY: info dvi
  139. info dvi:
  140.     $(MAKE) -C manual $@
  141.  
  142. # This makes all the subdirectory targets.
  143.  
  144. # For each target, make it depend on DIR/target for each subdirectory DIR.
  145. $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
  146.  
  147. # Compute a list of all those targets.
  148. all-subdirs-targets := $(foreach dir,$(subdirs),\
  149.                  $(addprefix $(dir)/,$(+subdir_targets)))
  150.  
  151. # The action for each of those is to cd into the directory and make the
  152. # target there.
  153. $(all-subdirs-targets):
  154.     $(MAKE) -C $(@D) $(@F)
  155.  
  156. .PHONY: $(+subdir_targets) $(all-subdirs-targets)
  157.  
  158. # This clobbers everything that can be regenerated.
  159. .PHONY: clean realclean distclean
  160. realclean: distclean
  161. clean:
  162.     -rm -f $(objects) $(+depfiles) munch-init.c $(objpfx)depend-
  163.     -rm -f $(libc.a) $(addprefix $(objpfx),$(install-lib)) core TAGS
  164.     -rm -f $(addprefix $(+sysdir_pfx),sysd-Makefile sysd-dirs sysdirs)
  165. # This is done this way rather than having `subdir_clean' be a
  166. # dependency of this target so that libc.a will be removed before the
  167. # subdirectories are dealt with and so they won't try to remove object
  168. # files from it when it's going to be removed anyway.
  169.     @$(MAKE) subdir_clean
  170.  
  171. distclean: clean
  172.     -rm -f $(addprefix $(objpfx),config.status config.make)
  173.  
  174. .PHONY: echo_subdirs
  175. echo_subdirs:;@echo '$(subdirs)'
  176.  
  177. .PHONY: echo-distinfo parent_echo-distinfo
  178. echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
  179. parent_echo-distinfo:
  180.     @echo $(addprefix +header+,$(headers)) \
  181.           $(addprefix +nodist+,$(generated))
  182.  
  183. # Make the distribution tarfile.
  184.  
  185. distribute  := README INSTALL NOTES COPYING.LIB COPYING ChangeLog NEWS    \
  186.            Makefile Makeconfig Makerules Rules Make-dist MakeTAGS    \
  187.            ansidecl.h mkinstalldirs                         \
  188.            configure configure.in aclocal.m4 config.sub config.guess\
  189.            munch-tmpl.c munch.awk gnu-stabs.h sysdep.h
  190.  
  191. export distribute := $(strip $(distribute))
  192. export generated := $(generated) $(objpfx)stubs.h
  193.  
  194. .PHONY: dist
  195. dist: Make-dist $(distribute)
  196.     $(MAKE) -f $< no_deps=t $(Make-dist-args)
  197.  
  198. README: README.template version.c ; # Make-dist should update README.
  199.  
  200. INSTALL: manual/maint.texi
  201.     makeinfo --no-validate --no-warn --no-headers $< -o $@
  202.