The file is used to:

  1. Register the library to Unikraft’s build system:

    $(eval $(call addlib_s,libhogweed,$(CONFIG_LIBHOGWEED)))

    As you can see, we are registering the library to Unikraft’s build system only if the main library’s config variable, LIBHOGWEED, is set.

  2. Set the URL from where the library will be automatically downloaded at build time:

  3. Declare helper variables for the most used paths:


    There are some useful default variables, for example:

    • $LIBNAME_ORIGIN: represents the path where the original library is downloaded and extracted during the build process;
    • $LIBNAME_BASE: represents the path of the ported library sources(the path appended to the $LIBS variable).
  4. Set the locations where the headers are searched:

    // including the path of the glue header added by us

    You should include the directories with the default library’s headers as well as the directories with the glue headers created by you, if it’s the case.

  5. Add compile flags, used in general for suppressing some compile warnings and making the build process neater:

    LIBHOGWEED_SUPPRESS_FLAGS += -Wno-unused-parameter \
            -Wno-unused-variable -Wno-unused-value -Wno-unused-function \
            -Wno-missing-field-initializers -Wno-implicit-fallthrough \
            -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
  6. Register the library’s sources:

  7. Register the library’s tests:

    LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa-compute-root-test.c
    LIBHOGWEED_RSA-COMPUTE-ROOT-TEST_FLAGS-y += -Dtest_main=rsa_compute_root_test

    There are situations when the test cases have each a main() function. In order to wrap all the tests into one single main function, we have to modify their main function name by using preprocessing symbols.

    Note: A good practice is to include a test only if the config variable corresponding to that test is set.

  8. This step is very customizable, being like a script executed before starting to compile the unikernel.

    In most cases, and in this case too, the libraries build their own config file through a provided executable, usually named configure:

    	$(call verbose_cmd,CONFIG,libhogweed: $(notdir $@), \
            cd $(LIBHOGWEED_EXTRACTED) && ./configure --enable-mini-gmp \

    We can also do things like generating headers using the original building system, modify sources, etc.