diff --git a/repos/base/mk/generic.mk b/repos/base/mk/generic.mk index d1de60f98a..a1f3834674 100644 --- a/repos/base/mk/generic.mk +++ b/repos/base/mk/generic.mk @@ -7,7 +7,7 @@ # Collect object files and avoid duplicates (by using 'sort') # SRC_O += $(addprefix binary_,$(addsuffix .o,$(notdir $(SRC_BIN)))) -SRC = $(sort $(SRC_C) $(SRC_CC) $(SRC_ADA) $(SRC_RS) $(SRC_S) $(SRC_O)) +SRC = $(sort $(SRC_C) $(SRC_CC) $(SRC_ADB) $(SRC_ADS) $(SRC_RS) $(SRC_S) $(SRC_O)) OBJECTS = $(addsuffix .o,$(basename $(SRC))) # @@ -72,7 +72,11 @@ endif # %.o: %.adb $(MSG_COMP)$@ - $(VERBOSE)$(GNATMAKE) -q -c --GCC=$(CC) --RTS=$(PRG_DIR) $< -cargs $(CC_ADA_OPT) $(INCLUDES) + $(VERBOSE)$(GNATMAKE) -q -c --GCC=$(CC) --RTS=$(ADA_RTS) $< -cargs $(CC_ADA_OPT) $(INCLUDES) + +%.ali %.o: %.ads + $(MSG_COMP)$@ + $(VERBOSE)$(CC) -c -gnatg -gnatp -gnatpg -gnatn2 -I- -I$(ADA_RTS_SOURCE) $(CC_ADA_OPT) $< # # Compiling Rust sources diff --git a/repos/base/src/test/ada/README b/repos/base/src/test/ada/README deleted file mode 100644 index 8a14e3f8d4..0000000000 --- a/repos/base/src/test/ada/README +++ /dev/null @@ -1,13 +0,0 @@ -This directory contains a test for using freestanding Ada code with Genode. - -The program relies on the normal startup procedure of a Genode process. -Execution starts at the 'crt0' assembly entry provided by the startup library. -The 'crt0' code sets up the stack of the main thread and calls the '_main' -function implemented in the C++ portion of Genode's startup library. In turn, -the '_main' function calls 'main' of the actual program. The main function of -this example calls the Ada main procedure. The test further exercises the call -of C functions from Ada code. So the integration of Ada and C code is almost -seamless. - -Please note that the current version of this program does not use 'gnatbind'. -Therefore, package elaboration is not executed. diff --git a/repos/base/src/test/ada/adainclude/system.ads b/repos/base/src/test/ada/adainclude/system.ads deleted file mode 100644 index c63b1b0c02..0000000000 --- a/repos/base/src/test/ada/adainclude/system.ads +++ /dev/null @@ -1,2 +0,0 @@ -Package System is -end System; diff --git a/repos/base/src/test/ada/adalib/system.ali b/repos/base/src/test/ada/adalib/system.ali deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/repos/base/src/test/ada/target.mk b/repos/base/src/test/ada/target.mk deleted file mode 100644 index 975be192e2..0000000000 --- a/repos/base/src/test/ada/target.mk +++ /dev/null @@ -1,4 +0,0 @@ -TARGET = test-ada -SRC_ADA = main.adb add_package.adb -SRC_CC = add.cc startup.cc -LIBS = base diff --git a/repos/libports/lib/import/import-ada.mk b/repos/libports/lib/import/import-ada.mk new file mode 100644 index 0000000000..52fe6e4f51 --- /dev/null +++ b/repos/libports/lib/import/import-ada.mk @@ -0,0 +1 @@ +ADA_RTS = $(BUILD_BASE_DIR)/var/libcache/ada diff --git a/repos/libports/lib/import/import-test-ada.mk b/repos/libports/lib/import/import-test-ada.mk new file mode 100644 index 0000000000..0123bfe393 --- /dev/null +++ b/repos/libports/lib/import/import-test-ada.mk @@ -0,0 +1 @@ +INC_DIR += $(REP_DIR)/src/test/ada/lib diff --git a/repos/libports/lib/mk/ada.mk b/repos/libports/lib/mk/ada.mk new file mode 100644 index 0000000000..7376656759 --- /dev/null +++ b/repos/libports/lib/mk/ada.mk @@ -0,0 +1,22 @@ + +include $(REP_DIR)/lib/import/import-ada.mk +ADALIB = $(ADA_RTS)/adalib +ADAINCLUDE = $(ADA_RTS)/adainclude + +PACKAGES = system + +ADA_RTS_SOURCE = $(call select_from_ports,gcc)/src/noux-pkg/gcc/gcc/ada +SRC_ADS += $(foreach package, $(PACKAGES), $(package).ads) + +vpath %.ads $(ADA_RTS_SOURCE) + +SHARED_LIB = yes + +all: ada_source_path ada_object_path + +ada_source_path: ada_object_path + $(VERBOSE)$(shell echo $(CONTRIB_DIR)/gcc-$(shell echo $(call _hash_of_port,gcc) | cut -d" " -f1)/src/noux-pkg/gcc/gcc/ada > $(ADA_RTS)/ada_source_path) + +ada_object_path: + $(VERBOSE)$(shell mkdir -p $(ADA_RTS)) + $(VERBOSE)$(shell echo $(ADA_RTS) > $(ADA_RTS)/ada_object_path) diff --git a/repos/libports/lib/mk/test-ada.mk b/repos/libports/lib/mk/test-ada.mk new file mode 100644 index 0000000000..8b5285cd7c --- /dev/null +++ b/repos/libports/lib/mk/test-ada.mk @@ -0,0 +1,6 @@ +LIBS += base ada +SRC_ADB += add_package.adb + +include $(REP_DIR)/lib/import/import-test-ada.mk + +vpath %.adb $(REP_DIR)/src/test/ada/lib diff --git a/repos/base/run/ada.run b/repos/libports/run/ada.run similarity index 92% rename from repos/base/run/ada.run rename to repos/libports/run/ada.run index 5b36fba80e..34e9f02a89 100644 --- a/repos/base/run/ada.run +++ b/repos/libports/run/ada.run @@ -20,7 +20,7 @@ install_config { } -build_boot_image "core ld.lib.so init test-ada" +build_boot_image "core ld.lib.so ada.lib.so init test-ada" append qemu_args "-nographic " diff --git a/repos/libports/src/test/ada/README b/repos/libports/src/test/ada/README new file mode 100644 index 0000000000..7d2639108b --- /dev/null +++ b/repos/libports/src/test/ada/README @@ -0,0 +1,13 @@ +This directory contains an example Ada program on Genode. + +An Ada program relies on the normal startup procedure of Genode +components, which calls 'Component::construct()' in _startup.cc_. It +enters the Ada code by calling the Ada main procedure '_ada_main()' +from 'Component::construct()'. Additionally, the test exercises calls +of C functions from Ada code to demonstrate the almost seamless +integration of Ada and C code and illustrates the implementation of +Ada libraries in Genode. Ada programs require the _ada_ library as it +provides the needed runtime. + +Please note that the current version of this program does not use +'gnatbind'. Therefore, package elaboration is not executed. diff --git a/repos/base/src/test/ada/add_package.adb b/repos/libports/src/test/ada/lib/add_package.adb similarity index 100% rename from repos/base/src/test/ada/add_package.adb rename to repos/libports/src/test/ada/lib/add_package.adb diff --git a/repos/base/src/test/ada/add_package.ads b/repos/libports/src/test/ada/lib/add_package.ads similarity index 100% rename from repos/base/src/test/ada/add_package.ads rename to repos/libports/src/test/ada/lib/add_package.ads diff --git a/repos/base/src/test/ada/main.adb b/repos/libports/src/test/ada/main.adb similarity index 75% rename from repos/base/src/test/ada/main.adb rename to repos/libports/src/test/ada/main.adb index 2f2237d7ca..517ff81806 100644 --- a/repos/base/src/test/ada/main.adb +++ b/repos/libports/src/test/ada/main.adb @@ -1,5 +1,5 @@ -- --- \brief Ada test program that calls a external C functions +-- \brief Ada test program -- \author Norman Feske -- \date 2009-09-23 -- @@ -20,6 +20,6 @@ procedure main is pragma import(C, ext_c_print_int, "print_int"); begin - add_package.Add(13, 14, result); + add_package.Add(13, 14, result); ext_c_print_int(result); end main; diff --git a/repos/base/src/test/ada/add.cc b/repos/libports/src/test/ada/print.cc similarity index 100% rename from repos/base/src/test/ada/add.cc rename to repos/libports/src/test/ada/print.cc diff --git a/repos/base/src/test/ada/startup.cc b/repos/libports/src/test/ada/startup.cc similarity index 100% rename from repos/base/src/test/ada/startup.cc rename to repos/libports/src/test/ada/startup.cc diff --git a/repos/libports/src/test/ada/target.mk b/repos/libports/src/test/ada/target.mk new file mode 100644 index 0000000000..4d846a5113 --- /dev/null +++ b/repos/libports/src/test/ada/target.mk @@ -0,0 +1,4 @@ +TARGET = test-ada +SRC_ADB = main.adb +SRC_CC = print.cc startup.cc +LIBS = base ada test-ada