From f866f3f98719510c83eb7d9f9969176886cf8f9a Mon Sep 17 00:00:00 2001 From: Simon Kuenzer Date: Fri, 2 Jun 2023 02:21:25 +0200 Subject: [PATCH] lib/ukstore: Re-use `libraries.in` from `lib/uklibid` Instead of generating own library identifiers, this commit adopts `lib/ukstore` to use the same library catalog from `lib/uklibid`. At the same time, this commit adopt `Makefile.uk` to make use of the `SUBBUILD` feature of the build system. This is done for simplifying Makefile.uk and to let the build system natively generate each dynamic headers of `lib/ukstore`. Signed-off-by: Simon Kuenzer Reviewed-by: Michalis Pappas Reviewed-by: Robert Kuban Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #938 --- lib/ukstore/Config.uk | 1 + lib/ukstore/Makefile.uk | 66 +++++-------------- .../{gen_array.h.awk => store_array.awk} | 0 lib/ukstore/{gen_libs.ld.awk => store_ld.awk} | 0 .../{gen_libs.h.awk => store_libs.awk} | 0 5 files changed, 19 insertions(+), 48 deletions(-) rename lib/ukstore/{gen_array.h.awk => store_array.awk} (100%) rename lib/ukstore/{gen_libs.ld.awk => store_ld.awk} (100%) rename lib/ukstore/{gen_libs.h.awk => store_libs.awk} (100%) diff --git a/lib/ukstore/Config.uk b/lib/ukstore/Config.uk index 178644199..d3560b5c9 100644 --- a/lib/ukstore/Config.uk +++ b/lib/ukstore/Config.uk @@ -2,4 +2,5 @@ config LIBUKSTORE bool "ukstore: Run-time configuring and monitoring" select LIBNOLIBC if !HAVE_LIBC select LIBUKDEBUG + select LIBUKLIBID default n diff --git a/lib/ukstore/Makefile.uk b/lib/ukstore/Makefile.uk index a0e752a2d..772992082 100644 --- a/lib/ukstore/Makefile.uk +++ b/lib/ukstore/Makefile.uk @@ -1,53 +1,23 @@ $(eval $(call addlib_s,libukstore,$(CONFIG_LIBUKSTORE))) -$(call mk_sub_libbuild_dir,libukstore,include/uk/bits) - -LIBUKSTORE_GEN_INCLUDES_PATH := $(call sub_libbuild_dir,libukstore,include) - CINCLUDES-y += -I$(LIBUKSTORE_BASE)/include -CINCLUDES-$(CONFIG_LIBUKSTORE) += -I$(LIBUKSTORE_GEN_INCLUDES_PATH) +CINCLUDES-$(CONFIG_LIBUKSTORE) += -I$(LIBUKSTORE_BUILD)/include CXXINCLUDES-y += -I$(LIBUKSTORE_BASE)/include -CXXINCLUDES-$(CONFIG_LIBUKSTORE) += -I$(LIBUKSTORE_GEN_INCLUDES_PATH) - -LIBUKSTORE_PHONY_SRC := $(LIBUKSTORE_BUILD)/uk_libs.in -LIBUKSTORE_PHONY_SRC_NEW := $(addsuffix .new, $(LIBUKSTORE_PHONY_SRC)) - -LIBUKSTORE_GEN_SRC := $(LIBUKSTORE_GEN_INCLUDES_PATH)/uk/bits/store_libs.h -LIBUKSTORE_GEN_ARR := $(LIBUKSTORE_GEN_INCLUDES_PATH)/uk/bits/store_array.h -LIBUKSTORE_GEN_LD := $(LIBUKSTORE_BUILD)/store_libs.lds.S - -UK_PREPROCESS-$(CONFIG_LIBUKSTORE) += $(LIBUKSTORE_PHONY_SRC) $(LIBUKSTORE_GEN_SRC) $(LIBUKSTORE_GEN_LD) $(LIBUKSTORE_GEN_ARR) - -$(LIBUKSTORE_PHONY_SRC): %: %.new - @cmp -s $^ $@; if [ $$? -ne 0 ]; then cp $^ $@; fi - -$(LIBUKSTORE_BUILD)/uk_libs.in.new: - $(call build_cmd,GEN,libukstore,$(notdir $@), \ - echo $(foreach P,$(UK_PLATS) $(UK_PLATS-y),\ - $(if $(call qstrip,$($(call uc,$(P))_LIBS) $($(call uc,$(P))_LIBS-y)),\ - $(foreach L,$($(call uc,$(P))_LIBS) $($(call uc,$(P))_LIBS-y), \ - $(if $(call qstrip,$($(call vprefix_lib,$(L),SRCS)) $($(call vprefix_lib,$(L),SRCS-y))), \ - $(L) \ - )))) \ - $(UK_LIBS) $(UK_LIBS-y) \ - | tr ' ' '\n' > $@) - -$(LIBUKSTORE_GEN_INCLUDES_PATH)/uk/bits/store_libs.h: $(LIBUKSTORE_BASE)/gen_libs.h.awk $(LIBUKSTORE_BUILD)/uk_libs.in - $(call build_cmd,AWK,libukstore,$(notdir $@), \ - $(AWK) -F '-' -f $(LIBUKSTORE_BASE)/gen_libs.h.awk \ - $(LIBUKSTORE_BUILD)/uk_libs.in > $@) - -$(LIBUKSTORE_BUILD)/store_libs.lds.S: $(LIBUKSTORE_BASE)/gen_libs.ld.awk $(LIBUKSTORE_BUILD)/uk_libs.in - $(call build_cmd,AWK,libukstore,$(notdir $@), \ - $(AWK) -F '-' -f $(LIBUKSTORE_BASE)/gen_libs.ld.awk \ - $(LIBUKSTORE_BUILD)/uk_libs.in > $@) - -$(LIBUKSTORE_GEN_INCLUDES_PATH)/uk/bits/store_array.h: $(LIBUKSTORE_BASE)/gen_array.h.awk $(LIBUKSTORE_BUILD)/uk_libs.in - $(call build_cmd,AWK,libukstore,$(notdir $@), \ - $(AWK) -F '-' -f $(LIBUKSTORE_BASE)/gen_array.h.awk \ - $(LIBUKSTORE_BUILD)/uk_libs.in > $@) - +CXXINCLUDES-$(CONFIG_LIBUKSTORE) += -I$(LIBUKSTORE_BUILD)/include + +# Cross-reference libraries catalog generated by lib/uklibid +# NOTE: Normally, we do not consider such cross-referencing a good practice, +# since libraries.in is in a way internal to lib/uklibid. +# On the other hand, it somehow doesn't make sense to create the same file +# again for this library, so we opt for deduplication here. +LIBUKSTORE_LIBRARIES_IN = $(call sub_build_dir,libuklibid)/libraries.in + +LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BASE)/store_libs.awk>.h +LIBUKSTORE_STORE_LIBS_SUBBUILD = include/uk/bits +LIBUKSTORE_STORE_LIBS_AWKINCLUDES-y += $(LIBUKSTORE_LIBRARIES_IN) +LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BASE)/store_array.awk>.h +LIBUKSTORE_STORE_ARRAY_SUBBUILD = include/uk/bits +LIBUKSTORE_STORE_ARRAY_AWKINCLUDES-y += $(LIBUKSTORE_LIBRARIES_IN) +LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BASE)/store_ld.awk>.lds.S +LIBUKSTORE_STORE_LD_AWKINCLUDES-y += $(LIBUKSTORE_LIBRARIES_IN) LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BASE)/store.c -LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BUILD)/store_libs.lds.S - -LIBUKSTORE_CLEAN = $(LIBUKSTORE_PHONY_SRC) $(LIBUKSTORE_PHONY_SRC_NEW) diff --git a/lib/ukstore/gen_array.h.awk b/lib/ukstore/store_array.awk similarity index 100% rename from lib/ukstore/gen_array.h.awk rename to lib/ukstore/store_array.awk diff --git a/lib/ukstore/gen_libs.ld.awk b/lib/ukstore/store_ld.awk similarity index 100% rename from lib/ukstore/gen_libs.ld.awk rename to lib/ukstore/store_ld.awk diff --git a/lib/ukstore/gen_libs.h.awk b/lib/ukstore/store_libs.awk similarity index 100% rename from lib/ukstore/gen_libs.h.awk rename to lib/ukstore/store_libs.awk -- 2.39.5