Blame mach/Makefile

Packit 6c4009
# Copyright (C) 1991-2018 Free Software Foundation, Inc.
Packit 6c4009
# This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
# The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
# modify it under the terms of the GNU Lesser General Public
Packit 6c4009
# License as published by the Free Software Foundation; either
Packit 6c4009
# version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
# The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
# Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
# You should have received a copy of the GNU Lesser General Public
Packit 6c4009
# License along with the GNU C Library; if not, see
Packit 6c4009
# <http://www.gnu.org/licenses/>.
Packit 6c4009
Packit 6c4009
subdir := mach
Packit 6c4009
Packit 6c4009
include ../Makeconfig
Packit 6c4009
Packit 6c4009
headers = mach_init.h mach.h mach_error.h mach-shortcuts.h mach/mach_traps.h \
Packit 6c4009
	  $(interface-headers) mach/mach.h mach/mig_support.h mach/error.h \
Packit 6c4009
	  $(lock-headers) machine-sp.h bits/mach/param.h
Packit 6c4009
lock = spin-solid spin-lock mutex-init mutex-solid
Packit 6c4009
lock-headers = lock-intern.h spin-lock.h
Packit 6c4009
routines = $(mach-syscalls) $(mach-shortcuts) \
Packit 6c4009
	   mach_init mig_strncpy msg \
Packit 6c4009
	   mig-alloc mig-dealloc mig-reply \
Packit 6c4009
	   msg-destroy msgserver \
Packit 6c4009
	   mach_error errstring error_compat errsystems \
Packit 6c4009
	   devstream setup-thread $(lock)
Packit 6c4009
Packit 6c4009
# The RPC interfaces go in a separate library.
Packit 6c4009
interface-library := libmachuser
Packit 6c4009
Packit 6c4009
# We produce mach_interface.h from mach.defs because there is already a
Packit 6c4009
# <mach/mach.h> that is not the interface header (thanks CMU).
Packit 6c4009
mach-interface-list := $(patsubst mach,mach_interface,$(mach-interface-list))
Packit 6c4009
mach/mach_interface.defs = mach/mach.defs
Packit 6c4009
Packit 6c4009
# Similarly for memory_object_user vs. memory_object
Packit 6c4009
mach-interface-list := $(patsubst memory_object,memory_object_user,\
Packit 6c4009
				  $(mach-interface-list))
Packit 6c4009
mach/memory_object_user.defs = mach/memory_object.defs
Packit 6c4009
Packit 6c4009
user-interfaces := $(addprefix mach/,$(mach-interface-list)	\
Packit 6c4009
			       	     mach_port mach_host exc	\
Packit 6c4009
		    )\
Packit 6c4009
		   $(addprefix device/,device device_request)
Packit 6c4009
Packit 6c4009
server-interfaces := mach/exc
Packit 6c4009
Packit 6c4009
# Clear any environment	value.
Packit 6c4009
generated =
Packit 6c4009
Packit 6c4009
# Avoid ssp before TLS is initialized.
Packit 6c4009
CFLAGS-mach_init.o = $(no-stack-protector)
Packit 6c4009
CFLAGS-RPC_vm_statistics.o = $(no-stack-protector)
Packit 6c4009
CFLAGS-RPC_vm_map.o = $(no-stack-protector)
Packit 6c4009
CFLAGS-RPC_vm_protect.o = $(no-stack-protector)
Packit 6c4009
CFLAGS-RPC_i386_set_gdt.o = $(no-stack-protector)
Packit 6c4009
CFLAGS-RPC_i386_set_ldt.o = $(no-stack-protector)
Packit 6c4009
CFLAGS-RPC_task_get_special_port.o = $(no-stack-protector)
Packit 6c4009

Packit 6c4009
# Translate GNU names for CPUs into the names used in Mach header files.
Packit 6c4009
mach-machine = $(patsubst powerpc,ppc,$(base-machine))
Packit 6c4009
Packit 6c4009
# Define mach-syscalls and sysno-*.
Packit 6c4009
ifndef inhibit_mach_syscalls
Packit 6c4009
-include $(objpfx)mach-syscalls.mk
Packit 6c4009
endif
Packit 6c4009
$(objpfx)mach-syscalls.mk: syscalls.awk Makefile libc-modules.h
Packit 6c4009
# Go kludges!!!
Packit 6c4009
	$(make-target-directory)
Packit 6c4009
# We must use $(CFLAGS) to get -O flags that affect #if's in header files.
Packit 6c4009
	echo '#include <mach/syscall_sw.h>' | \
Packit 6c4009
	$(CC) $(CFLAGS) $(CPPFLAGS) -E -MD -MP -MF $@-dep -MT $@ \
Packit 6c4009
	      -x c-header - \
Packit 6c4009
	      -D_MACH_`echo $(mach-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \
Packit 6c4009
	sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
Packit 6c4009
	| $(AWK) -f $< > $@-new
Packit 6c4009
ifneq (,$(objpfx))
Packit 6c4009
	sed $(sed-remove-objpfx) $@-dep >> $@-new
Packit 6c4009
else
Packit 6c4009
	cat $@-dep >> $@-new
Packit 6c4009
endif
Packit 6c4009
	rm -f $@-dep
Packit 6c4009
	mv -f $@-new $@
Packit 6c4009
generated += mach-syscalls.mk
Packit 6c4009
Packit 6c4009
ifndef mach-syscalls
Packit 6c4009
# We cannot make the deps properly until we know how to make the system
Packit 6c4009
# call functions, and for that we must know what they all are.
Packit 6c4009
no_deps=t
Packit 6c4009
else
Packit 6c4009
$(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
Packit 6c4009
	(echo '#include <sysdep.h>'; \
Packit 6c4009
	 echo 'kernel_trap (__$*,$(sysno-$*),$(nargs-$*))'; \
Packit 6c4009
	 echo 'weak_alias (__$*, $*)'; \
Packit 6c4009
	 echo 'libc_hidden_def (__$*)') > $@-new
Packit 6c4009
	 mv -f $@-new $@
Packit 6c4009
generated += $(mach-syscalls:=.S)
Packit 6c4009
endif	# mach-syscalls
Packit 6c4009
Packit 6c4009
# These syscalls that look like RPCs actually have no RPC equivalents.
Packit 6c4009
mach-shortcuts := $(filter-out device_writev_request \
Packit 6c4009
			       device_read_overwrite_request \
Packit 6c4009
			       device_read_overwrite \
Packit 6c4009
			       vm_read_overwrite \
Packit 6c4009
			       thread_switch \
Packit 6c4009
			       ,\
Packit 6c4009
		  $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))))
Packit 6c4009
Packit 6c4009
ifndef mach-shortcuts
Packit 6c4009
# Forget about mach_interface.defs for this run.  On the next run,
Packit 6c4009
# $(mach-shortcuts) will be set, and that will change how
Packit 6c4009
# mach_interface.defs is processed: it will get the -D flags below.
Packit 6c4009
user-interfaces := $(filter-out $(mach-interface-list:%=mach/%) \
Packit 6c4009
				mach/mach_port mach/mach_host mach/mach4 mach/gnumach \
Packit 6c4009
				device/device_request,\
Packit 6c4009
				$(user-interfaces))
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
# For some reason, the calls in this file are `protected' by an ifdef.
Packit 6c4009
MIGFLAGS-mach/mach4=-DMACH_PCSAMPLE
Packit 6c4009
Packit 6c4009
# Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
Packit 6c4009
migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
Packit 6c4009
$(mach-interface-list:%=mach/%.uh) \
Packit 6c4009
  mach/mach_host.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
Packit 6c4009
Packit 6c4009
ifdef mach-shortcuts
Packit 6c4009
$(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
Packit 6c4009
						$(objpfx)RPC_%_rpc.c
Packit 6c4009
	$(AWK)	-v alias=$* -v call=__$* -v rpc=__$*_rpc \
Packit 6c4009
		-v syscall=__syscall_$* -f $^ > $@-new
Packit 6c4009
	mv -f $@-new $@
Packit 6c4009
generated += $(mach-shortcuts:%=%.c)
Packit 6c4009
endif	# mach-shortcuts
Packit 6c4009
Packit 6c4009
# Generate mach-shortcuts.h, which will contain the prototypes for the
Packit 6c4009
# shortcutted kernel RPC functions.
Packit 6c4009
$(objpfx)mach-shortcuts.h: $(mach-interface-list:%=$(objpfx)mach/%.h) \
Packit 6c4009
			   $(objpfx)mach/mach_host.h \
Packit 6c4009
			   $(objpfx)mach/mach_port.h
Packit 6c4009
# The first line gets us one paragraph per line, with @s separating real lines.
Packit 6c4009
# The second line selects paragraphs for the shortcutted functions.
Packit 6c4009
# The third line removes `_rpc' from the names and reconstitutes the lines.
Packit 6c4009
	( echo "#include <mach/mach_types.h>" ; \
Packit 6c4009
	  echo "#include <mach/message.h>" ; \
Packit 6c4009
	  echo ; \
Packit 6c4009
	  cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
Packit 6c4009
	  | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
Packit 6c4009
	  | sed 's/_rpc//g' | tr @ \\012 ) > $@-new
Packit 6c4009
	mv -f $@-new $@
Packit 6c4009
generated += mach-shortcuts.h
Packit 6c4009
Packit 6c4009
before-compile += $(objpfx)mach-shortcuts.h
Packit 6c4009

Packit 6c4009
include Machrules
Packit 6c4009
include ../Rules
Packit 6c4009
Packit 6c4009
Packit 6c4009
# A gcc bug prevents the generated file from working properly,
Packit 6c4009
# so we have one in the distribution for the time being.
Packit 6c4009
generated += errsystems.c
Packit 6c4009
$(objpfx)errsystems.c: errsystems.awk err_*.sub \
Packit 6c4009
		       $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
Packit 6c4009
	$(AWK) -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
Packit 6c4009
	mv -f $@.n $@
Packit 6c4009
Packit 6c4009
Packit 6c4009
# Convenient target to update all the generated source files.
Packit 6c4009
.PHONY: generated
Packit 6c4009
generated: $(addprefix $(common-objpfx),$(common-generated)) \
Packit 6c4009
	   $(addprefix $(objpfx),$(generated))
Packit 6c4009
Packit 6c4009
.PHONY: mach-before-compile
Packit 6c4009
mach-before-compile: $(mach-before-compile)