home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / Make-dist < prev    next >
Encoding:
Text File  |  1993-05-16  |  6.5 KB  |  212 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. dist:
  20.  
  21. ifdef subdir
  22. .. := ../
  23. else
  24. .. :=
  25. endif
  26.  
  27. include $(..)Makeconfig
  28.  
  29. foo:=$(shell echo first generated='$(generated)' >&2)
  30. ifdef objpfx
  31. generated := $(foreach file,$(filter $(objpfx)%,$(generated)),\
  32.                $(file:$(objpfx)%=%) $(file)) \
  33.          $(filter-out $(objpfx)%,$(generated))
  34. foo:=$(shell echo generated='$(generated)' >&2)
  35. endif
  36.  
  37. foo:=$(shell echo 'distribute=$(distribute)'>&2)
  38. foo:=$(shell echo 'foobar=$(filter %.c %.S %.s %.h,$(distribute))'>&2)
  39.  
  40. ifndef sysdep_dirs
  41. # Find all sysdep directories.
  42. export sysdep_dirs := $(shell find $(..)sysdeps -type d -print)
  43. else
  44. # Defined by the parent.
  45. sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
  46. endif
  47.  
  48. # Makefiles can define `source_dirs' to list nonstandard directories
  49. # where source files might be found.
  50.  
  51. ifdef    subdir
  52. all-headers = $(headers)
  53. else
  54. +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t echo-distinfo \
  55.              | grep -v '^make')
  56. all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
  57. +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
  58. +subdir-headers := $(filter-out $(headers),$(all-headers))
  59. endif
  60. foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
  61.  
  62. # Find all sysdep sources and headers.
  63. +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
  64.           $(filter %.c %.S %.s %.h,$(distribute))
  65. foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
  66. # Find all the files that have a stub or generic version.
  67. try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic,\
  68.                  $(addprefix $(dir)/,$(+maybe-sysdeps)))
  69. foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
  70. +sysdeps := $(wildcard $(try-sysdeps))
  71. foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
  72. +sysdep-names := $(sort $(notdir $(+sysdeps)))
  73. foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
  74.  
  75. # Now find all the sysdep versions of those files.
  76. +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
  77.                  $(addprefix $(dir)/, \
  78.                          $(+sysdep-names) \
  79.                          $(+sysdep-names:.c=.s) \
  80.                          $(+sysdep-names:.c=.S) \
  81.                   )))
  82.  
  83.  
  84. # Source and header files to go in the distribution tar file.
  85.  
  86. .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
  87. sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
  88.  
  89. +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
  90.     $(addsuffix .c,$(sysdep_routines)) \
  91.     $(+subdir-nodist)
  92. #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
  93. +tsrcs    := $(filter-out $(+out) $(addprefix %/,$(+out)), \
  94.             $(sources) $(all-headers) $(distribute)) \
  95.        $(+sysdeps)
  96. foo:=$(shell echo made +tsrcs >&2)
  97. foo:=$(shell echo generated='$(generated)' >&2)
  98. +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
  99. foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
  100. foo:=$(shell echo foobie, dammit! >&2)
  101.  
  102. ifndef tardir
  103. rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
  104.                -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
  105.             < $(..)version.c)
  106. release := $(word 1,$(rel+vers))
  107. version := $(word 2,$(rel+vers))
  108. export tardir := glibc-$(version)
  109. endif
  110.  
  111. $(..)$(tardir):
  112.     ln -s . $@
  113.  
  114. +tsrcs := $(+tsrcs) \
  115.       TAGS
  116. .PHONY: TAGS
  117. TAGS: $(..)MakeTAGS
  118.     $(MAKE) -f $< $@ -o subdir_TAGS
  119.  
  120. ifdef       subdir
  121.  
  122. foo:=$(shell echo subdir foo >&2)
  123.  
  124. +tsrcs := Makefile $(+tsrcs)                \
  125.       $(addsuffix .c,$(others) $(tests))        \
  126.       $(wildcard $(addsuffix .input,$(tests))    \
  127.       $(addsuffix .args,$(tests)))
  128. +tardeps := $(strip $(+tsrcs))
  129. +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
  130.  
  131. verbose = v
  132.  
  133. .PHONY: dist
  134. dist: $(..)$(tardir) $(+tardeps)
  135.     @cd ..; if test -f dist.tar; then c=u; else c=c; fi;    \
  136.     $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ...";    \
  137.     tar $${c}h$(verbose)f dist.tar $(+tsrcs)
  138.  
  139. else    # Parent makefile.
  140.  
  141. # Find what other things sysdep directories want to distribute.
  142.  
  143. foo:=$(shell echo parent foobie>&2)
  144. +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
  145. foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
  146. sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
  147. ifdef sysdep-Subdir-files
  148. subdirs := $(sort $(subdirs) $(shell cat $(sysdep-Subdir-files)))
  149. endif
  150. +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
  151.               $(addprefix $(dir $(file)),$(shell cat $(file)))) \
  152.         $(+sysdep-distfiles) \
  153.         $(sysdep-Subdir-files)
  154. foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
  155.  
  156. subdirs := $(filter-out crypt,$(subdirs))
  157.  
  158. +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies \
  159.                            configure configure.in,\
  160.                       $(addsuffix /$(file),$(sysdep_dirs)))) \
  161.          $(+sysdep-dist)
  162.  
  163. +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
  164.  
  165. %/configure: %/configure.in
  166.     autoconf $(ACFLAGS) $< > $@.new
  167.     mv $@.new $@
  168.  
  169. .PHONY: dist
  170. dist: $(tardir).tar.z $(tardir)-crypt.tar.z
  171.  
  172. $(tardir)-crypt.tar.z: crypt/crypt.tar.z
  173.     ln $< $@
  174. crypt/%: FORCE
  175.     $(MAKE) -C $(@D) $(@F)
  176. FORCE:
  177.  
  178. subdir_dist: dist.tar
  179. dist.tar: $(tardir) $(+tsrcs)
  180.     tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
  181.  
  182. $(tardir).tar: dist.tar subdir_dist
  183.     tar xf $< -C /tmp
  184.     tar covf $@ -C /tmp $(tardir)
  185.     -rm -fr /tmp/$(tardir) &
  186.  
  187. %.Z: %
  188.     compress -c $< > $@
  189.  
  190. %.z: %
  191.     gzip -9 -c $< > $@
  192.  
  193. foo:=$(shell echo 'subdirs=$(subdirs)' >&2)
  194. dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
  195. .PHONY: subdir_dist $(dist-subdirs)
  196. subdir_dist: $(dist-subdirs)
  197. $(dist-subdirs):
  198.     $(MAKE) -C $(patsubst dist-%,%,$@) dist
  199.  
  200. # This is here instead of in Makefile so it can use $(release) and $(version).
  201. README: README.template version.c
  202.     -rm -f $@
  203.     sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
  204. # Make it unwritable so I won't change it by mistake.
  205.     chmod 444 $@
  206.  
  207.  
  208. endif    # Subdirectory vs. parent makefile
  209.  
  210. # Get these things out of the environment because they take up lots of space.
  211. unexport distribute generated
  212.