summaryrefslogtreecommitdiff
path: root/Makerules
diff options
context:
space:
mode:
Diffstat (limited to 'Makerules')
-rw-r--r--Makerules63
1 files changed, 63 insertions, 0 deletions
diff --git a/Makerules b/Makerules
index 12d01eed7c..3951bb185b 100644
--- a/Makerules
+++ b/Makerules
@@ -1324,6 +1324,69 @@ ifndef no_deps
-include $(stdio_lim:h=d)
endif
common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
+
+ifeq (yes,$(build-shared))
+# Generate the header containing the names of all shared libraries.
+# We use a stamp file to avoid unnecessary recompilations.
+before-compile += $(common-objpfx)gnu/lib-names.h
+ifeq ($(soversions.mk-done),t)
+ifndef abi-variants
+lib-names-h-abi = gnu/lib-names.h
+lib-names-stmp-abi = gnu/lib-names.stmp
+else
+lib-names-h-abi = gnu/lib-names-$(default-abi).h
+lib-names-stmp-abi = gnu/lib-names-$(default-abi).stmp
+before-compile += $(common-objpfx)$(lib-names-h-abi)
+common-generated += gnu/lib-names.h
+install-others-nosubdir: $(inst_includedir)/$(lib-names-h-abi)
+$(common-objpfx)gnu/lib-names.h:
+ $(make-target-directory)
+ { \
+ echo '/* This file is automatically generated.';\
+ echo ' It defines macros to allow user program to find the shared'; \
+ echo ' library files which come as part of GNU libc. */'; \
+ echo '#ifndef __GNU_LIB_NAMES_H'; \
+ echo '#define __GNU_LIB_NAMES_H 1'; \
+ echo ''; \
+ $(if $(abi-includes), \
+ $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
+ echo '';) \
+ $(foreach v,$(abi-variants),\
+ $(if $(abi-$(v)-condition),\
+ echo '#if $(abi-$(v)-condition)'; \
+ echo '# include <gnu/lib-names-$(v).h>'); \
+ $(if $(abi-$(v)-condition),echo '#endif';)) \
+ echo ''; \
+ echo '#endif /* gnu/lib-names.h */'; \
+ } > $@
+endif
+$(common-objpfx)$(lib-names-h-abi): $(common-objpfx)$(lib-names-stmp-abi); @:
+$(common-objpfx)$(lib-names-stmp-abi): $(..)scripts/lib-names.awk \
+ $(common-objpfx)soversions.i
+ $(make-target-directory)
+ { \
+ $(if $(abi-variants), \
+ echo '/* This file is automatically generated. */';\
+ echo '#ifndef __GNU_LIB_NAMES_H'; \
+ echo '# error "Never use <$(lib-names-h-abi)> directly; include <gnu/lib-names.h> instead."'; \
+ echo '#endif';, \
+ echo '/* This file is automatically generated.';\
+ echo ' It defines macros to allow user program to find the shared'; \
+ echo ' library files which come as part of GNU libc. */'; \
+ echo '#ifndef __GNU_LIB_NAMES_H'; \
+ echo '#define __GNU_LIB_NAMES_H 1';) \
+ echo ''; \
+ ($(foreach s,$(all-sonames), echo $(s);)) \
+ | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort; \
+ $(if $(abi-variants),, \
+ echo ''; \
+ echo '#endif /* gnu/lib-names.h */';) \
+ } > ${@:stmp=T}
+ $(move-if-change) ${@:stmp=T} ${@:stmp=h}
+ touch $@
+endif
+common-generated += $(lib-names-h-abi) $(lib-names-stmp-abi)
+endif
FORCE: