home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / mach / Machrules < prev    next >
Encoding:
Text File  |  1993-05-09  |  4.4 KB  |  127 lines

  1. # Rules for MiG interfaces that want to go into the C library.
  2.  
  3. # Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  4. # This file is part of the GNU C Library.
  5.  
  6. # The GNU C Library is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU Library General Public License
  8. # as published by the Free Software Foundation; either version 2 of
  9. # the License, or (at your option) any later version.
  10.  
  11. # The GNU C Library is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. # Library General Public License for more details.
  15.  
  16. # You should have received a copy of the GNU Library General Public
  17. # License along with the GNU C Library; see the file COPYING.LIB.  If
  18. # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  19. # Cambridge, MA 02139, USA.
  20.  
  21. # Makefiles define these variable before including this file:
  22. #    user-interfaces        Names of interfaces to put user stubs in for.
  23. #    server-interfaces    Names of interfaces to put server stubs in for.
  24. # This file sets:
  25. #    interface-headers    Names of generated interface header files.
  26. #    interface-routines    Names of generated interface routines.
  27. # All user stubs are put in individual files, prefixed with __, and a
  28. # symbol-alias to the un-__'d form generated; header for both is put in
  29. # foo.h.  If a server interface is listed as __foo, then its routines are
  30. # prefixed with __; server interfaces are written to foo_server.c and
  31. # foo_server.h (or __foo_server.c and __foo_server.h).
  32.  
  33. # Includers can also add to or modify `migdefines' to set MiG flags.
  34.  
  35. all:
  36.  
  37. include ../Makeconfig
  38.  
  39. ifndef MIG
  40. MIG = mig
  41. endif
  42. MIGFLAGS = -DMACH_IPC_COMPAT=0 -DSTANDALONE -DTypeCheck=0 \
  43.        $(+includes) $(migdefines) -subrprefix __
  44.  
  45. .SUFFIXES: .defs
  46.  
  47. define nl    # This is needed by *.ir.
  48.  
  49.  
  50. endef
  51. ifdef user-interfaces
  52. interface-includes := $(foreach if,$(user-interfaces),$(if).ir)
  53. ifndef no_deps
  54. include $(interface-includes)
  55. endif
  56. generated := $(generated) $(interface-includes)
  57. endif
  58.  
  59. # %.ir defines a variable `%-calls', which lists the RPCs defined by
  60. # %.defs, and a rule to build $(%-calls:%=__$(%-userprefix)%.c) from
  61. # %.defs, where $(%-userprefix) is the user prefix given in %.defs.  We use
  62. # the kludgificacious method of defining a pattern rule to build files
  63. # matching patterns we are pretty damn sure will only match the particular
  64. # files we have in mind.
  65. %.ir: %.uh
  66.     (echo 'define $*-calls'                    ;\
  67.      awk '/^kern_return_t/ { print $$2 }' $<        ;\
  68.      echo 'endef'                        ;\
  69.      echo '$*-calls := $$(subst $$(nl), ,$$($*-calls))'    ;\
  70.      echo '$$($*-calls:%=_\%%.c): $*.defs'            ;\
  71.      echo '    $$(generate-user-calls)'             \
  72.     ) > $@-new
  73.     mv $@-new $@
  74. vpath Machrules ../mach    # Find ourselves.
  75.  
  76. define generate-user-calls
  77. $(MIG) $< $(MIGFLAGS) \
  78.        -prefix __ -i ./__ -server /dev/null -user /dev/null -header /dev/null
  79. endef
  80.  
  81. __%_server.c __%_server.h: %.defs
  82.     $(MIG) $< $(MIGFLAGS) -prefix __ \
  83.            -user /dev/null -header /dev/null \
  84.            -server $(@:.h=.c) -sheader $(@:.c=.h)
  85. %_server.c %_server.h: %.defs
  86.     $(MIG) $< $(MIGFLAGS) \
  87.            -user /dev/null -header /dev/null \
  88.            -server $(@:.h=.c) -sheader $(@:.c=.h)
  89.  
  90. # To get header files that declare both the straight and __ functions,
  91. # we generate two files and paste them together.
  92. %.uh: %.defs
  93.     $(MIG) $< $(MIGFLAGS) \
  94.            -header $@ -server /dev/null -user /dev/null
  95. %.__h: %.defs
  96.     $(MIG) $< $(MIGFLAGS) -prefix __ \
  97.            -header $@ -server /dev/null -user /dev/null
  98.  
  99. %.h: %.__h %.uh
  100. # The last line of foo.__h is "#endif _foo_user_".
  101. # The first two lines of foo.uh are "#ifndef _foo_user_"/"#define _foo_user_".
  102.     (sed -e '$$d' $<; sed -e '1,2d' $(word 2,$^)) > $@-new
  103.     mv $@-new $@
  104.  
  105. if-calls.c := $(strip $(foreach if,$(user-interfaces),$($(if)-calls:%=%.c)))
  106. ifdef if-calls.c
  107. $(if-calls.c):
  108.     (echo '#include <gnu-stabs.h>'; \
  109.      echo 'symbol_alias (__$*, $*)') > $@-new
  110.     mv $@-new $@
  111. endif
  112.  
  113. interface-routines := $(foreach if,$(user-interfaces),        \
  114.                 $($(if)-calls)            \
  115.                 $(addprefix __,$($(if)-calls)))    \
  116.               $(server-interfaces:%=%_server)
  117. interface-headers := $(user-interfaces:%=%.h) $(server-interfaces:%=%_server.h)
  118.  
  119. # Remove the generated user stub source and header files,
  120. # and don't distribute them.
  121. mach-generated := $(interface-routines:%=%.c) \
  122.           $(interface-headers:%=%.h %.uh %.__h)
  123. generated := $(generated) $(mach-generated)
  124.  
  125. # These are needed to generate the dependencies.
  126. before-compile := $(before-compile) $(interface-headers)
  127.