(linenum→info "unix/slp.c:2238")

glibc/2.7/mach/Machrules

    1: # Rules for MiG interfaces that want to go into the C library.
    2: # Copyright (C) 1991,1992,1993,1994,1995,1996,1998,1999,2001,2002,2006
    3: #       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 Lesser General Public
    8: # License as published by the Free Software Foundation; either
    9: # version 2.1 of 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: # Lesser General Public License for more details.
   15: 
   16: # You should have received a copy of the GNU Lesser General Public
   17: # License along with the GNU C Library; if not, write to the Free
   18: # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   19: # 02111-1307 USA.
   20: 
   21: # Makefiles may 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: #       interface-library     Name of interface library to build and install.
   25: # This file sets:
   26: #       interface-headers     Names of generated interface header files.
   27: #       interface-routines    Names of generated interface routines.
   28: # All user stubs are put in individual files, prefixed with RPC_; header
   29: # for both __ and non-__ names is put in foo.h.  Server interfaces are
   30: # written to foo_server.c and foo_server.h; the server functions are called
   31: # _S_rpcname.
   32: 
   33: # Includers can also add to or modify `migdefines' to set MiG flags.
   34: 
   35: all:
   36: 
   37: # Make sure no value comes from the environment, since we append to it.
   38: # This is done also in ../Rules, but we append to the value before
   39: # including Rules, which changes the origin.
   40: ifneq   "$(findstring env,$(origin generated))" ""
   41: generated :=
   42: endif
   43: 
   44: 
   45: include ../Makeconfig
   46: 
   47: # This makefile contains a lot of implicit rules that get optimized
   48: # away if the target directory does not exist.
   49: ifndef no_deps
   50: -include $(objpfx)dummy.mk
   51: endif
   52: $(objpfx)dummy.mk:
   53:         $(make-target-directory)
   54:         echo '# Empty' > $@
   55: 
   56: MIGFLAGS = -DMACH_IPC_COMPAT=0 -DSTANDALONE -DTypeCheck=0 \
   57:            $(+includes) $(migdefines) -subrprefix __
   58: # Putting CC in the enivronment makes the mig wrapper script
   59: # use the same compiler setup we are using to run cpp.
   60: MIG := CC='${CC}' CPP='${CPP} -x c' $(MIG)
   61: 
   62: .SUFFIXES: .defs        # Just to set specified_rule_matched.
   63: 
   64: define nl       # This is needed by *.ir.
   65: 
   66: 
   67: endef
   68: ifdef user-interfaces
   69: *.ir := $(addprefix $(objpfx),$(foreach if,$(user-interfaces),$(if).ir))
   70: ifndef no_deps
   71: ifndef inhibit_interface_rules
   72: -include $(*.ir)
   73: endif
   74: endif
   75: ifneq "$(*.ir)" "$(wildcard $(*.ir))"
   76: # If any .ir file is missing, we will be unable to make all the deps.
   77: no_deps=t
   78: endif
   79: generated += $(*.ir:$(objpfx)%=%)
   80: endif
   81: 
   82: 
   83: # %.ir defines a variable `%-calls', which lists the RPCs defined by
   84: # %.defs, and a rule to build $(%-calls:%=RPC_$(%-userprefix)%.c) from
   85: # %.defs, where $(%-userprefix) is the user prefix given in %.defs.  We use
   86: # the kludgificacious method of defining a pattern rule to build files
   87: # matching patterns we are pretty damn sure will only match the particular
   88: # files we have in mind.  To be so damn sure, we use the silly names
   89: # RPC_*.c and the pattern R%C_*.c because using __*.c and _%*.c (or any
   90: # other useful pattern) causes the rule for `host_info' to also match
   91: # `xxx_host_info', and analogous lossage.
   92: #
   93: # Depend on %.h just so they will be built from %.uh in the
   94: # makefile-rebuilding run which builds %.ir; otherwise, %.uh is built as an
   95: # intermediate in order to make %.ir and then removed before re-exec, when
   96: # %.uh is built all over again to build %.h.
   97: $(objpfx)%.ir: $(objpfx)%.uh $(objpfx)%.h
   98:         ($(AWK) "NF == 4 && (\$$2 == \"Routine\" || \$$2 == \"SimpleRoutine\")\
   99:                 { printf \"$*-calls += %s\\n\", \$$3 }" $<     ;\
  100:          echo '$$($*-calls:%=$$(objpfx)R\%C_%.c): $$(objpfx)$*.ustamp ;';\
  101:         ) > $@-new
  102:         mv -f $@-new $@
  103: vpath Machrules ../mach # Find ourselves.
  104: 
  105: ifndef transform-user-stub-output
  106: transform-user-stub-output = tmp
  107: define transform-user-stub
  108: echo "weak_alias (__$$call, $$call)" >> $(objpfx)tmp_$${call}.c;
  109: endef
  110: endif
  111: 
  112: 
  113: # Generate `#include <NAME.defs>', taking $* for NAME.
  114: # If $(NAME.defs) is defined use its value in place of `NAME.defs'.
  115: define include-%.defs
  116: echo '#include <$(firstword $($*.defs) $*.defs)>'
  117: endef
  118: 
  119: ifndef no_deps
  120: # Not an implicit rule so the stamps are never removed as intermediates!
  121: $(patsubst %,$(objpfx)%.ustamp,$(user-interfaces)): $(objpfx)%.ustamp:
  122:         rm -f $@
  123:         $(include-%.defs) | \
  124:         $(MIG) - /dev/null -prefix __ \
  125:                $(MIGFLAGS) $(user-MIGFLAGS) $(MIGFLAGS-$*) \
  126:                -i $(objpfx)tmp_ \
  127:                -server /dev/null -user /dev/null -header /dev/null
  128:         for call in $($*-calls); do \
  129:           $(transform-user-stub) \
  130:           $(move-if-change) $(objpfx)$(transform-user-stub-output)_$${call}.c \
  131:                             $(objpfx)RPC_$${call}.c; \
  132:         done
  133:         touch $@
  134: -include $(patsubst %,$(objpfx)%.udeps,$(user-interfaces))
  135: $(patsubst %,$(objpfx)%.udeps,$(user-interfaces)):
  136:   $(objpfx)%.udeps: $(..)mach/Machrules
  137:         $(make-target-directory)
  138: # We must use $(CFLAGS) to get -O flags that affect #if's in header files.
  139:         $(include-%.defs) | \
  140:         $(CC) $(CFLAGS) $(CPPFLAGS) -M -x c - | \
  141:         sed -e 's,- *:,$(.udeps-targets):,' \
  142:             $(sed-remove-objpfx) > $@.new
  143:         mv -f $@.new $@
  144: .udeps-targets = $@ $(@:.udeps=.ustamp) $(@:.udeps=.uh) $(@:.udeps=.__h) \
  145:                  $(@:.udeps=_server.c) $(@:.udeps=_server.h)
  146: endif
  147: 
  148: # Look for the server stub files where they will be written.
  149: vpath %_server.c $(addprefix $(objpfx),$(sort $(dir $(server-interfaces))))
  150: 
  151: # Build the server stubs in $(objdir).
  152: $(objpfx)%_server.c $(objpfx)%_server.h:
  153:         $(make-target-directory)
  154:         $(include-%.defs) | \
  155:         $(MIG) - /dev/null -prefix _S_ \
  156:                $(MIGFLAGS) $(server-MIGFLAGS) $(MIGFLAGS-$*) \
  157:                -user /dev/null -header /dev/null \
  158:                -server $(@:.h=.c) -sheader $(@:.c=.h)
  159: 
  160: # To get header files that declare both the straight and __ functions,
  161: # we generate two files and paste them together.
  162: $(patsubst %,$(objpfx)%.uh,$(user-interfaces)): $(objpfx)%.uh:; $(mig.uh)
  163: define mig.uh
  164: $(make-target-directory)
  165: $(include-%.defs) | \
  166: $(MIG) - /dev/null $(MIGFLAGS) $(MIGFLAGS-$*) \
  167:        -header $@ -server /dev/null -user /dev/null
  168: endef
  169: $(patsubst %,$(objpfx)%.__h,$(user-interfaces)): $(objpfx)%.__h:; $(mig.__h)
  170: define mig.__h
  171: $(make-target-directory)
  172: $(include-%.defs) | \
  173: $(MIG) - /dev/null $(MIGFLAGS) $(MIGFLAGS-$*) -prefix __ \
  174:        -header $@ -server /dev/null -user /dev/null
  175: endef
  176: 
  177: $(patsubst %,$(objpfx)%.h,$(user-interfaces)): $(objpfx)%.h: $(objpfx)%.__h \
  178:                                                              $(objpfx)%.uh
  179: # The last line of foo.__h is "#endif _foo_user_".
  180: # The first two lines of foo.uh are "#ifndef _foo_user_"/"#define _foo_user_".
  181:         (sed -e '$$d' $<; sed -e '1,2d' $(word 2,$^)) > $@-new
  182:         mv -f $@-new $@
  183: 
  184: interface-routines := $(foreach if,$(user-interfaces),                  \
  185:                                 $(addprefix RPC_,$($(if)-calls)))   \
  186:                       $(server-interfaces:%=%_server)
  187: interface-headers := $(user-interfaces:%=%.h) \
  188:                      $(server-interfaces:%=%_server.h)
  189: 
  190: # Remove the generated user stub source and header files,
  191: # and don't distribute them.
  192: mach-generated = $(interface-routines:%=%.c) $(interface-headers) \
  193:                  $(foreach h,$(user-interfaces),$h.uh $h.__h)
  194: generated += $(mach-generated)
  195: 
  196: # These are needed to generate the dependencies.
  197: before-compile += $(interface-headers:%=$(objpfx)%)
  198: 
  199: # Don't let these be intermediate files and get removed.
  200: $(foreach h,$(interface-headers:%.h=$(objpfx)%),$h.h $h.__h $h.uh) :
  201: $(interface-routines:%=$(objpfx)%.c) :
  202: 
  203: # Convenient target to generate all the headers.
  204: .PHONY: interface-headers
  205: interface-headers: $(interface-headers)
  206: 
  207: # Don't automatically generate dependencies for the sources we generate.
  208: # There are likely to be a whole lot of them, and we know their
  209: # dependencies ahead of time anyway because they're boilerplate.
  210: omit-deps += $(interface-routines)
  211: 
  212: # Choose any single module generated by MiG.  We will compute this module's
  213: # dependencies and then assume all other MiG-generated modules depend on the
  214: # same headers.
  215: some-if-rtn := $(firstword $(interface-routines))
  216: ifdef some-if-rtn
  217: $(foreach o,$(object-suffixes),$(interfaces-routines:%=%$o)): $(some-if-rtn).d
  218: generated += $(some-if-rtn).d
  219: endif
  220: ^L
  221: # If defined, $(interface-library) is `libNAME'.  It is to be a library
  222: # containing all the MiG-generated functions for the specified interfaces.
  223: 
  224: ifdef interface-library
  225: 
  226: $(interface-library)-routines = $(interface-routines)
  227: extra-libs += $(interface-library)
  228: extra-libs-others += $(interface-library)
  229: 
  230: ifeq (yes,$(build-shared))
  231: interface.so = $(interface-library:=.so)
  232: 
  233: # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
  234: $(objpfx)$(interface.so): $(common-objpfx)libc.so
  235: endif
  236: 
  237: endif
Syntax (Markdown)