home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / sysdeps / unix / Makefile < prev    next >
Encoding:
Makefile  |  1993-05-21  |  8.0 KB  |  241 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. ifneq (,$(wildcard $(sysincludedir)/sys/param.h))
  20. local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_SYS_PARAM_H
  21. endif
  22. ifneq (,$(wildcard $(sysincludedir)/sys/limits.h))
  23. local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_SYS_LIMITS_H
  24. endif
  25. ifneq (,$(wildcard $(sysincludedir)/limits.h))
  26. local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_LIMITS_H
  27. endif
  28.  
  29. $(common-objpfx)local_lim.h: $(common-objpfx)mk-local_lim
  30.     if $(dir $<)$(notdir $<) > $@-t; then mv $@-t $@; else XXX; fi
  31. $(common-objpfx)mk-local_lim: $(sysdep_dir)/unix/mk-local_lim.c
  32.     cwd=`pwd`; cd $(@D); \
  33.     $(CC) $(native-CFLAGS) $(local_lim-CFLAGS) $$cwd/$< -o $(@F)
  34.  
  35. before-compile := $(before-compile) $(common-objpfx)local_lim.h
  36. generated := $(generated) \
  37.          $(common-objpfx)local_lim.h $(common-objpfx)mk-local_lim
  38.  
  39. before-compile := $(before-compile) $(common-objpfx)sys/param.h
  40.  
  41. $(common-objpfx)sys/param.h: $(sysincludedir)/sys/param.h
  42.     -mkdir $(@D:%/=%)
  43.     (echo '#ifndef _GNU_SYS_PARAM_H';    \
  44.      echo '#define _GNU_SYS_PARAM_H 1';    \
  45.      echo '#include <endian.h>';        \
  46.      awk < $<            \
  47.        '/^#define[     ]*NULL/ { print "#ifndef NULL";    \
  48.                   print $$0;        \
  49.                   print "#endif";    \
  50.                   was_null = 1 }    \
  51.         { if (!was_null) print $$0;            \
  52.           was_null = 0 }';        \
  53.      echo '#ifndef MAXHOSTNAMELEN'; \
  54.      echo '#define MAXHOSTNAMELEN 64 /* XXX */'; \
  55.      echo '#endif /* No MAXHOSTNAMELEN.  */'; \
  56.      echo '#endif    /* sys/param.h */') > $@-tmp
  57.     mv $@-tmp $@
  58.  
  59. $(common-objpfx)param.h.c: $(sysincludedir)/sys/param.h
  60.     rm -f $@
  61.     cp $< $@
  62. $(common-objpfx)param.h.dep: $(common-objpfx)param.h.c \
  63.                  $(sysdep_dir)/unix/Makefile
  64.     $(+mkdep) -I$(sysincludedir) $<        \
  65.     | sed > $@                \
  66.           -e 's@^.*:@@'            \
  67.           -e 's@$<@@g'            \
  68.           -e 's@$(sysincludedir)/*@@g'    \
  69.           -e 's@\\$$@@'            \
  70.           -e 's@^@sys/param.h-includes := $$(sys/param.h-includes) @'
  71.  
  72. # Get the generated definition of sys/param.h-includes.
  73. include $(common-objpfx)param.h.dep
  74.  
  75. # Don't preempt our own headers. 
  76. sys/param.h-includes := \
  77.   $(filter-out $(patsubst $(..)%,%,\
  78.               $(wildcard $(addprefix $(..),\
  79.                      $(sys/param.h-includes)))),\
  80.            $(sys/param.h-includes))
  81.  
  82.  
  83. .PHONY: sys/param.h-includes
  84. sys/param.h-includes: $(addprefix $(common-objpfx),$(sys/param.h-includes))
  85.  
  86. ifdef sys/param.h-includes
  87. # Copy the system files to $(common-objdir).
  88. $(addprefix $(common-objpfx),$(sys/param.h-includes)): $(common-objpfx)%: \
  89.                                $(sysincludedir)/%
  90.     -mkdir $(@D:%/=%)
  91. # Some of these files sometimes contain conflicting declarations for htons,
  92. # ntohs, etc.  They also often contain definitions of *_ENDIAN and
  93. # BYTE_ORDER, which we define ourselves in <endian.h>.
  94.     sed -e '/[     ]*[hn]to[nh][sl][     (]*/d' \
  95.         -e '/^#define[     ]*[A-Z]*_ENDIAN/d' \
  96.         -e '/^#define[     ]*BYTE_ORDER/d' \
  97.         $< > $@-t
  98.     mv $@-t $@
  99. endif
  100.  
  101. generated := $(generated) $(addprefix $(common-objpfx),\
  102.          sys/param.h $(sys/param.h-includes) param.h.c param.h.dep)
  103.  
  104.  
  105. ifeq ($(subdir),misc)
  106.  
  107. # Install system headers the system sys/param.h uses.
  108.  
  109. sysdep_headers := $(sysdep_headers) sys/param.h $(sys/param.h-includes)
  110.  
  111. endif # misc
  112.  
  113. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  114.     $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/errnos.h))))))
  115.  
  116. # These need to exist before any compiling is done,
  117. # so cpp doesn't instead find the stub versions.
  118. before-compile := $(before-compile) $(common-objpfx)errnos.h 
  119.  
  120. $(common-objpfx)errnos.h: $(common-objpfx)make-errnos
  121.     $(dir $<)$(notdir $<) > $@-tmp
  122.     mv $@-tmp $@
  123.  
  124. $(common-objpfx)make-errnos: $(common-objpfx)make-errnos.c
  125.     $(common-objdir-compile)
  126.  
  127. $(common-objpfx)make-errnos.c: $(sysdep_dir)/unix/errnos-tmpl.c \
  128.             $(sysdep_dir)/unix/errnos.awk $(common-objpfx)errnos
  129.     awk -f $(word 2,$^) errnos="`tr '\012' ' ' < $(word 3,$^)`" $< > $@T
  130.     mv $@T $@
  131.  
  132. $(common-objpfx)errnos: $(wildcard $(sysincludedir)/errno.h    \
  133.                    $(sysincludedir)/sys/errno.h)
  134.     cat $^ | sed -n 's/^#define[     ]*\(E[A-Z0-9][A-Z0-9]*\)[     ].*$$/\1/p' > $@-tmp
  135.     mv $@-tmp $@
  136.  
  137. generated := $(generated) $(addprefix $(common-objpfx),\
  138.          errnos.h errnos make-errnos make-errnos.c)
  139. endif
  140.  
  141. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  142.     $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/ioctls.h))))))
  143.  
  144. before-compile := $(before-compile) $(common-objpfx)ioctls.h
  145.  
  146. $(common-objpfx)ioctls.h: $(common-objpfx)make-ioctls
  147.     $(dir $<)$(notdir $<) > $@-tmp
  148.     mv $@-tmp $@
  149.  
  150. sys/termios.h := $(wildcard $(sysincludedir)/sys/termios.h)
  151. ifneq (,$(strip $(sys/termios.h)))
  152. make-ioctls-CFLAGS := -DHAVE_SYS_TERMIOS_H
  153. endif
  154. $(common-objpfx)make-ioctls: $(common-objpfx)make-ioctls.c
  155.     cd $(@D); $(CC) $(native-CFLAGS) $(make-ioctls-CFLAGS) \
  156.             $(<:$(common-objpfx)%=%) -o $(@F)
  157.  
  158. $(common-objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \
  159.                    $(sysdep_dir)/unix/ioctls.awk \
  160.                    $(common-objpfx)ioctls
  161.     awk -f $(word 2,$^) requests="`cat $(word 3,$^)`" $< > $@T
  162.     mv $@T $@
  163.  
  164.  
  165. termbits.h := $(firstword $(wildcard $(+sysdep_dirs:%=%/termbits.h)))
  166. ifeq ($(termbits.h),$(sysdep_dir)/generic/termbits.h)
  167. termbits.h := # Ignore the generic version.
  168. endif
  169.  
  170. # If there is a system-specific <termbits.h> file, we want to omit all the
  171. # symbols it defines from ioctls.  Otherwise, both ioctls.h and termbits.h
  172. # would define them.  The system-specific <termbits.h> file presumably
  173. # defines them with the same values as we find from the system's headers.
  174. # We also want to omit from ioctls the symbols defined in our own
  175. # <sys/ttydefaults.h>, to avoid multiple definition conflicts.
  176. # We use snarf-ioctls on these files to find what symbols we want to omit.
  177. # Then we turn this into a big alternation for egrep.  
  178.  
  179. $(common-objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls \
  180.             $(sysincludedir)/sys/ioctl.h $(sys/termios.h)
  181.     $(dir $<)$(notdir $<) $(filter-out $<,$^) \
  182.     | egrep -v "^(`$(dir $<)$(notdir $<) \
  183.                $(termbits.h) $(..)termios/sys/ttydefaults.h \
  184.             | tr '\012' '|'`nevermatch)$$" \
  185.     | sort | uniq | tr '\012' ' ' > $@-tmp
  186.     mv $@-tmp $@
  187.  
  188. generated := $(generated) $(addprefix $(common-objpfx),\
  189.          ioctls.h ioctls make-ioctls make-ioctls.c)
  190. endif
  191.  
  192. ifeq ($(subdir),stdio)
  193.  
  194. before-compile: $(objpfx)errlist.c
  195. $(objpfx)errlist.c: $(objpfx)make_errlist
  196.     @rm -f $@
  197.     $< > $@-tmp
  198.     mv $@-tmp $@
  199.  
  200. $(objpfx)make_errlist: $(sysdep_dir)/unix/make_errlist.c
  201.     $(native-compile)
  202.  
  203. generated := $(generated) $(addprefix $(objpfx),make_errlist errlist.c)
  204.  
  205. endif
  206.  
  207. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  208.     $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/syscall.h))))))
  209.  
  210. # The syscall code assumes a file <syscall.h> that defines macros
  211. # `SYS_call' for syscall `call'.  Variations on this I have seen include:
  212. # it's in <sys/syscall.h>;
  213. # it's in <sys.s>;
  214. # it defines `CALL' instead of `SYS_call'.
  215.  
  216. # Find a file that might have these.
  217. syscall.h := $(firstword $(wildcard $(addprefix $(sysincludedir)/, \
  218.                         syscall.h sys/syscall.h \
  219.                         sys.s sys/sys.s \
  220.                         sys.S sys/sys.S)))
  221. ifdef syscall.h
  222.  
  223. # Transmogrify any of several formats of the file into the one we want.
  224. $(common-objpfx)syscall.h: $(syscall.h)
  225.     tr '[A-Z]' '[a-z]' < $< | \
  226.     sed -e 's/[     ]sys_/ /' \
  227.         -e 's/^#define[     ]*\([a-z0-9_]*\)[     ]*/#define SYS_\1 /' \
  228.         -e 's/[     ]sys_/ SYS_/' \
  229.         -e '/^#/!d' \
  230.         -e '/^#ident/d' \
  231.         -e 's-\(/\*[^*]*\)$$-\1\*/-' \
  232.     > $@-tmp
  233.     mv $@-tmp $@
  234.  
  235. before-compile := $(before-compile) $(common-objpfx)syscall.h
  236. generated := $(generated) $(common-objpfx)syscall.h
  237.  
  238. endif
  239.  
  240. endif
  241.