Blame sysdeps/mach/hurd/Makefile

Packit 6c4009
# Copyright (C) 1993-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
ifdef in-Makerules
Packit 6c4009
Packit 6c4009
# Look for header files in hurd/ under the top-level library source directory.
Packit 6c4009
# Look for generated header files where they get created.
Packit 6c4009
includes += -I$(..)hurd -I$(common-objpfx)hurd/
Packit 6c4009
Packit 6c4009
# We use the style `if (err = call(...))' a lot in the Hurd code,
Packit 6c4009
# where we have a lot of functions that return zero or an errno code.
Packit 6c4009
+cflags += -Wno-parentheses
Packit 6c4009
Packit 6c4009
# Do not use any assembly code from sysdeps/unix (and subdirectories).
Packit 6c4009
# This bypasses all the system call stubs and uses any existing posix or
Packit 6c4009
# generic C files instead.
Packit 6c4009
inhibit-sysdep-asm += unix.*
Packit 6c4009
inhibit-unix-syscalls = yes
Packit 6c4009
Packit 6c4009
# Don't try to generate anything from the installed Unix system and its
Packit 6c4009
# libraries.  That is only of use when building for a Unix system, so as to
Packit 6c4009
# be compatible with some existing binaries for that system.
Packit 6c4009
inhibit-glue = yes
Packit 6c4009
Packit 6c4009
ifeq (,$(filter mach hurd,$(subdir)))
Packit 6c4009
# Subdirectories other than hurd/ might use the generated Hurd headers.
Packit 6c4009
# So make sure we get a chance to run in hurd/ to make them before all else.
Packit 6c4009
# (But we don't want to do this in mach/, because hurd/ needs some things
Packit 6c4009
# there, and we know mach/ doesn't need anything from hurd/.)
Packit 6c4009
Packit 6c4009
hurd-objpfx = $(common-objpfx)hurd/
Packit 6c4009
Packit 6c4009
# These are all the generated headers that <hurd.h> includes.
Packit 6c4009
before-compile += $(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process)
Packit 6c4009
$(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process): hurd-before-compile
Packit 6c4009
.PHONY: hurd-before-compile
Packit 6c4009
hurd-before-compile: $(common-objpfx)mach/mach-shortcuts.h
Packit 6c4009
	$(MAKE) -C $(..)hurd subdir=hurd before-compile no_deps=t
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
# Hurd profil.c includes this file, so give a rule to make it.
Packit 6c4009
ifeq ($(subdir),gmon)
Packit 6c4009
$(common-objpfx)hurd/../mach/RPC_task_get_sampled_pcs.c:
Packit 6c4009
	$(MAKE) -C $(..)mach subdir=mach before-compile no_deps=t
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009

Packit 6c4009
# Generate bits/errno.h from the section of the manual that lists all the errno
Packit 6c4009
# codes.
Packit 6c4009
Packit 6c4009
errno.texinfo = $(..)manual/errno.texi
Packit 6c4009
Packit 6c4009
hurd = $(..)sysdeps/mach/hurd
Packit 6c4009
Packit 6c4009
define mach-errno-h
Packit 6c4009
($(foreach h,mach/message.h \
Packit 6c4009
	     mach/kern_return.h \
Packit 6c4009
	     mach/mig_errors.h \
Packit 6c4009
	     device/device_types.h,\
Packit 6c4009
 echo '#include <$h>';\
Packit 6c4009
 ))
Packit 6c4009
endef
Packit 6c4009
Packit 6c4009
# We use the compiler to generate a list of absolute file names for
Packit 6c4009
# the headers we want to search for Mach error codes, listed above (and
Packit 6c4009
# incidentally, all other headers those include).
Packit 6c4009
-include $(common-objpfx)errnos.d
Packit 6c4009
$(common-objpfx)errnos.d: $(mach-errnos-deps)
Packit 6c4009
	$(mach-errno-h) | \
Packit 6c4009
	$(CC) $(CFLAGS) \
Packit 6c4009
	    $(subst -include $(common-objpfx)libc-modules.h,,$(CPPFLAGS)) \
Packit 6c4009
	    -M -x c - | \
Packit 6c4009
	sed $(sed-remove-objpfx) -e 's,- *:,mach-errnos-deps :=,' \
Packit 6c4009
	    -e 's, \.\./, $(..),g' > $@t
Packit 6c4009
	mv -f $@t $@
Packit 6c4009
Packit 6c4009
$(hurd)/bits/errno.h: $(common-objpfx)stamp-errnos ;
Packit 6c4009
$(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \
Packit 6c4009
			      $(mach-errnos-deps) $(common-objpfx)errnos.d
Packit 6c4009
	$(AWK) -f $^ > $(hurd)/bits/errno.h-tmp
Packit 6c4009
# Make it unwritable so noone will edit it by mistake.
Packit 6c4009
	-chmod a-w $(hurd)/bits/errno.h-tmp
Packit 6c4009
	$(move-if-change) $(hurd)/bits/errno.h-tmp $(hurd)/bits/errno.h
Packit 6c4009
	touch $@
Packit 6c4009
Packit 6c4009
common-generated += errnos.d stamp-errnos
Packit 6c4009

Packit 6c4009
# We install the real libc.a as libcrt.a and as libc.a we install a linker
Packit 6c4009
# script which does -( -lcrt -lmachuser -lhurduser -).
Packit 6c4009
Packit 6c4009
libc-name = crt
Packit 6c4009
Packit 6c4009
ifeq (,$(subdir))
Packit 6c4009
install-others += $(inst_libdir)/libc.a
Packit 6c4009
$(inst_libdir)/libc.a: $(hurd)/libc-ldscript $(+force); $(do-install)
Packit 6c4009
ifeq (yes,$(build-profile))
Packit 6c4009
install-others += $(inst_libdir)/libc_p.a
Packit 6c4009
$(inst_libdir)/libc_p.a: $(hurd)/libc_p-ldscript $(+force); $(do-install)
Packit 6c4009
endif
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
# Make sure these are used to build the libc.so shared object too.  There
Packit 6c4009
# is a circular dependency between each of these shared objects and libc
Packit 6c4009
# (many high-level libc functions call stubs, stubs call low-level libc
Packit 6c4009
# functions like memcpy and mach_msg).  This works out fine at run time
Packit 6c4009
# (all the objects are loaded before resolving their symbols, so these
Packit 6c4009
# interdependencies are fine).  But to create the shared objects we must
Packit 6c4009
# link them one at a time; since each needs one or both of the others to
Packit 6c4009
# produce its DT_NEEDED entries and to assign its undefined symbols the
Packit 6c4009
# right symbol versions, we can't do any of them before the others!  To
Packit 6c4009
# get around this, we link each lib*user.so shared object twice.  First,
Packit 6c4009
# we link an object without reference to libc.so (since we haven't linked
Packit 6c4009
# libc.so yet), so it lacks a DT_NEEDED record for the libc soname it
Packit 6c4009
# depends on, and its undefined symbol references lack the symbol version
Packit 6c4009
# assignments they should have.  We will use this shared object solely to
Packit 6c4009
# link libc.so against it; that gives libc.so the proper DT_NEEDED record,
Packit 6c4009
# and symbol versions assignments (if the lib*user.so object is using them).
Packit 6c4009
# Finally we link a second version of the same lib*user.so shared object,
Packit 6c4009
# this time linked normally against libc so it gets a proper DT_NEEDED
Packit 6c4009
# record and symbol version set; this one can be installed for run-time use.
Packit 6c4009
rpcuserlibs := $(common-objpfx)mach/libmachuser.so \
Packit 6c4009
	       $(common-objpfx)hurd/libhurduser.so
Packit 6c4009
link-rpcuserlibs := $(rpcuserlibs:%user.so=%user-link.so)
Packit 6c4009
$(common-objpfx)libc.so: $(link-rpcuserlibs)
Packit 6c4009
$(common-objpfx)linkobj/libc.so: $(link-rpcuserlibs)
Packit 6c4009
rpath-dirs += mach hurd
Packit 6c4009
Packit 6c4009
# Make sure the `lib' pass builds the dummy shared objects so
Packit 6c4009
# we can link libc against them.
Packit 6c4009
ifeq (mach,$(subdir))
Packit 6c4009
lib-noranlib: $(common-objpfx)mach/libmachuser-link.so
Packit 6c4009
endif
Packit 6c4009
ifeq (hurd,$(subdir))
Packit 6c4009
lib-noranlib: $(common-objpfx)hurd/libhurduser-link.so
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
$(link-rpcuserlibs): %-link.so: %_pic.a
Packit 6c4009
# These shared objects are just for the purpose of linking libc,
Packit 6c4009
# so they don't need abi-note.o linked into them.
Packit 6c4009
	$(build-shlib-helper) \
Packit 6c4009
		-nostdlib -o $@ \
Packit 6c4009
		-Wl,-soname=$(*F).so$($(*F).so-version) \
Packit 6c4009
		$(build-shlib-objlist)
Packit 6c4009
libmachuser-link.so-no-z-defs = yes
Packit 6c4009
libhurduser-link.so-no-z-defs = yes
Packit 6c4009
Packit 6c4009
# And get them into the libc.so ldscript.
Packit 6c4009
$(inst_libdir)/libc.so: $(rpcuserlibs)
Packit 6c4009
Packit 6c4009
# The RPC stubs from these libraries are needed in building the dynamic
Packit 6c4009
# linker, too.  It must be self-contained, so we link the needed PIC
Packit 6c4009
# objects directly into the shared object.
Packit 6c4009
ifeq (elf,$(subdir))
Packit 6c4009
$(objpfx)librtld.map: $(rpcuserlibs:.so=_pic.a)
Packit 6c4009
Packit 6c4009
CFLAGS-dl-load.c = -DEXTERNAL_MAP_FROM_FD
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
# Override the generic Makeconfig values so we link against the RPC libs.
Packit 6c4009
link-libc-static := -Wl,--start-group \
Packit 6c4009
		    $(patsubst %,$(common-objpfx)%.a,\
Packit 6c4009
			       libc mach/libmachuser hurd/libhurduser) \
Packit 6c4009
		    $(static-gnulib) -Wl,--end-group
Packit 6c4009
link-libc-static-tests := -Wl,--start-group \
Packit 6c4009
		    $(patsubst %,$(common-objpfx)%.a,\
Packit 6c4009
			       libc mach/libmachuser hurd/libhurduser) \
Packit 6c4009
		    $(static-gnulib-tests) -Wl,--end-group
Packit 6c4009

Packit 6c4009
ifeq ($(subdir),csu)
Packit 6c4009
Packit 6c4009
extra-objs += static-start.o
Packit 6c4009
Packit 6c4009
# We need special startup code for statically linked binaries.
Packit 6c4009
$(objpfx)crt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o
Packit 6c4009
	$(link-relocatable)
Packit 6c4009
Packit 6c4009
endif
Packit 6c4009

Packit 6c4009
ifeq (hurd, $(subdir))
Packit 6c4009
sysdep_routines += cthreads
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq ($(subdir),sunrpc)
Packit 6c4009
sysdep_headers += nfs/nfs.h
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq ($(subdir),socket)
Packit 6c4009
sysdep_headers += net/ethernet.h net/if_arp.h net/if_ether.h net/route.h
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq ($(subdir),nis)
Packit 6c4009
CFLAGS-ypclnt.c += -DUSE_BINDINGDIR=1
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
endif	# in-Makerules