-#ifndef GREETER_LIB_C
-#define GREETER_LIB_C
-#ifndef FACE
- #define GREETER_IMPL
+#ifndef ExampleGreet·Greeter·ONCE
+#define ExampleGreet·Greeter·ONCE
+
+#ifndef ExampleGreet·Greeter
+ #define ExampleGreet·Greeter
#endif
-#define FACE
-#include "math.lib.c"
-#undef FACE
+#include "Math.lib.c"
-void Greet·hello_loop(int count);
+void ExampleGreet·Greeter·hello_loop(int count);
-#ifdef GREETER_IMPL
+#ifdef ExampleGreet·Greeter
#include <stdio.h>
-void Greet·hello_loop(int count){
+void ExampleGreet·Greeter·hello_loop(int count){
for(int TM = 0; TM < count; ++TM){
- int current_count = Math·add(TM ,1);
+ int current_count = ExampleGreet·Math·add(TM ,1);
printf("Hello iteration: %d\n" ,current_count);
}
}
-#endif // GREETER_IMPL
-#endif // GREETER_LIB_C
-
+#endif // ExampleGreet·Greeter
+#endif // ExampleGreet·Greeter·ONCE
-#ifndef ExampleGreet·math·ONCE
-#define ExampleGreet·math·ONCE
+#ifndef ExampleGreet·Math·ONCE
+#define ExampleGreet·Math·ONCE
-#ifndef ExampleGreet·math
- #define ExampleGreet·math
+#ifndef ExampleGreet·Math
+ #define ExampleGreet·Math
#endif
int ExampleGreet·Math·add(int a ,int b);
-#ifdef ExampleGreet·math
+#ifdef ExampleGreet·Math
int ExampleGreet·Math·add(int a ,int b){
return a + b;
}
-#endif // ExampleGreet·math
-#endif // ExampleGreet·math·ONCE
+#endif // ExampleGreet·Math
+#endif // ExampleGreet·Math·ONCE
#include <stdlib.h>
#include <stdio.h>
-#define FACE
-#include "math.lib.c"
-#include "greeter.lib.c"
-#undef FACE
+#include "Math.lib.c"
+#include "Greeter.lib.c"
void CLI(void){
- int base_count = Math·add(1 ,2);
+ int base_count = ExampleGreet·Math·add(1 ,2);
printf("Calculated base loop count: %d\n" ,base_count);
- Greet·hello_loop(base_count);
+ ExampleGreet·Greeter·hello_loop(base_count);
}
int main(int argc ,char **argv){
#!/usr/bin/env bash
script_afp=$(realpath "${BASH_SOURCE[0]}")
-# input guards
+setup_must_be="developer/tool/setup"
+if [ "$SETUP" != "$setup_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $setup_must_be environment"
+ exit 1
+fi
- setup_must_be="developer/tool/setup"
- if [ "$SETUP" != "$setup_must_be" ]; then
- echo "$(script_fp):: error: must be run in the $setup_must_be environment"
- exit 1
- fi
-
-set -e
+set -euo pipefail # RT-style shell safety
set -x
+ # Command is first, Namespace is second
+ CMD="${1:-usage}"
+ NAMESPACE_ARG="${2:-}"
+
cd "$REPO_HOME/developer" || exit 1
- /bin/make -f tool/makefile $@
+
+ # Pass both to the orchestrator
+ NAMESPACE="$NAMESPACE_ARG" /bin/make -f tool/makefile "$CMD"
set +x
echo "$(script_fn) done."
+
RT_MAKEFILE_DP := $(REPO_HOME)/shared/tool/makefile
include $(RT_MAKEFILE_DP)/Harmony.mk
+# If a namespace is provided, update the source directory
+ifneq ($(NAMESPACE),)
+ C_SOURCE_DIR := authored/$(NAMESPACE)
+ export C_SOURCE_DIR
+endif
+
.PHONY: usage
usage:
@printf "Usage: make [usage|version|information|all|lib|CLI|kmod|clean]\n"
@printf "local ----------------------------------------\n"
-@echo CURDIR='$(CURDIR)'
@echo REPO_HOME="$(REPO_HOME)"
+ @echo NAMESPACE="$(NAMESPACE)"
+ @echo C_SOURCE_DIR="$(C_SOURCE_DIR)"
@echo KMOD_BUILD_DIR="/lib/modules/$(shell uname -r)/build"
@echo CURDIR="$(CURDIR)"
@printf "target_library_CLI.mk ----------------------------------------\n"
CFLAGS += -include "$(REPO_HOME)/shared/tool/makefile/RT_global.h"
CFLAGS += -I $(C_SOURCE_DIR)
-
# Project administrators can override this in their local makefile
LIBRARY_NAME ?= $(PROJECT)
LIBRARY_NAME := $(subst -,_,$(LIBRARY_NAME))
# Pass the global header to Kbuild exactly as done for user-space
KMOD_CCFLAGS += -include $(REPO_HOME)/shared/tool/makefile/RT_global.h
KMOD_OUTPUT_DIR ?= scratchpad/kmod
+
# recipes
+#$(OBJECT_DIR)/%.o: $(C_SOURCE_DIR)/%.c
+# @mkdir -p $(OBJECT_DIR)
+# $(C) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
+
+# The local logic checks if NAMESPACE is defined, and if the target is a .lib.o file
$(OBJECT_DIR)/%.o: $(C_SOURCE_DIR)/%.c
@mkdir -p $(OBJECT_DIR)
- $(C) $(CFLAGS) -o $@ -c $<
+ $(C) $(CFLAGS) $(if $(and $(NAMESPACE),$(findstring .lib,$@)),-D$(NAMESPACE)·$(basename $*),) -o $@ -c $<
+
$(MACHINE_DIR)/%: $(OBJECT_DIR)/%.CLI.o
@mkdir -p $(MACHINE_DIR)