using simplified C gating for new Example
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Mon, 9 Mar 2026 14:41:30 +0000 (14:41 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Mon, 9 Mar 2026 14:41:30 +0000 (14:41 +0000)
developer/authored/greeter.lib.c [new file with mode: 0644]
developer/authored/hello.CLI.c
developer/authored/math.lib.c [new file with mode: 0644]
developer/tool/make
developer/tool/makefile
shared/tool/makefile/Harmony.mk [new file with mode: 0644]
shared/tool/makefile/RT_0.h [deleted file]
shared/tool/makefile/RT_global.h [new file with mode: 0644]
shared/tool/makefile/environment_RT_1.mk [deleted file]
shared/tool/makefile/target_library_CLI.mk

diff --git a/developer/authored/greeter.lib.c b/developer/authored/greeter.lib.c
new file mode 100644 (file)
index 0000000..b7be528
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef GREETER_LIB_C
+#define GREETER_LIB_C
+#ifndef FACE
+  #define GREETER_IMPL
+#endif
+
+#define FACE
+#include "math.lib.c"
+#undef FACE
+
+void Greet·hello_loop(int count);
+
+#ifdef GREETER_IMPL
+
+#include <stdio.h>
+
+void Greet·hello_loop(int count){
+  for(int TM = 0; TM < count; ++TM){
+    int current_count = Math·add(TM ,1);
+    printf("Hello iteration: %d\n" ,current_count);
+  }
+}
+
+#endif // GREETER_IMPL
+#endif // GREETER_LIB_C
+
index a626cac..d498dbf 100644 (file)
@@ -1,2 +1,22 @@
+#include <stdlib.h>
 #include <stdio.h>
-int main(void){ puts("hello from Rabbit CLI"); return 0; }
+
+#define FACE
+#include "math.lib.c"
+#include "greeter.lib.c"
+#undef FACE
+
+void CLI(void){
+  int base_count = Math·add(1 ,2);
+  printf("Calculated base loop count: %d\n" ,base_count);
+  Greet·hello_loop(base_count);
+}
+
+int main(int argc ,char **argv){
+  (void)argc;
+  (void)argv;
+  
+  CLI();
+  
+  return EXIT_SUCCESS;
+}
diff --git a/developer/authored/math.lib.c b/developer/authored/math.lib.c
new file mode 100644 (file)
index 0000000..6256c7c
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef MATH_LIB_C
+#define MATH_LIB_C
+
+#ifndef FACE
+  #define MATH_IMPL
+#endif
+
+int Math·add(int a ,int b);
+
+#ifdef MATH_IMPL
+
+int Math·add(int a ,int b){
+  return a + b;
+}
+
+#endif // MATH_IMPL
+#endif // MATH_LIB_C
index 853149a..740321f 100755 (executable)
@@ -12,7 +12,7 @@ script_afp=$(realpath "${BASH_SOURCE[0]}")
 set -e
 set -x
 
-  cd "$REPO_HOME"/developer || exit 1
+  cd "$REPO_HOME/developer" || exit 1
   /bin/make -f tool/makefile $@
 
 set +x
index 8eaf73c..2d5d057 100644 (file)
@@ -3,7 +3,7 @@
 .EXPORT_ALL_VARIABLES:
 
 RT_MAKEFILE_DP := $(REPO_HOME)/shared/tool/makefile
-include $(RT_MAKEFILE_DP)/environment_RT_1.mk
+include $(RT_MAKEFILE_DP)/Harmony.mk
 
 .PHONY: usage 
 usage:
diff --git a/shared/tool/makefile/Harmony.mk b/shared/tool/makefile/Harmony.mk
new file mode 100644 (file)
index 0000000..da5efc6
--- /dev/null
@@ -0,0 +1,35 @@
+# tool/shared/Harmony.mk
+# makefile environment variable defaults.
+# cc is the name of the C compiler, a file called <name>.c is C source code.
+# RT uses header integrated C source files, i.e. the source and the header are the same file
+
+SHELL=/bin/bash
+
+ECHO := printf "%b\n"
+
+C_SOURCE_DIR     ?= authored
+C                ?= gcc
+CFLAGS           ?= -std=gnu11 -Wall -Wextra -Wpedantic -finput-charset=UTF-8
+CFLAGS           += -MMD -MP
+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))
+
+BUILD_DIR        ?= scratchpad/build
+OBJECT_DIR       ?= $(BUILD_DIR)/object
+LIBRARY_DIR      ?= scratchpad/made
+MACHINE_DIR      ?= scratchpad/made
+
+LIBRARY_FILE     ?= $(LIBRARY_DIR)/lib$(LIBRARY_NAME).a
+
+LN_FLAGS         ?= -L$(LIBRARY_DIR) -L/lib64 -L/lib -l$(LIBRARY_NAME)
+
+KMOD_SOURCE_DIR  ?= authored
+KMOD_CCFLAGS     ?= -I $(KMOD_SOURCE_DIR)
+# 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
diff --git a/shared/tool/makefile/RT_0.h b/shared/tool/makefile/RT_0.h
deleted file mode 100644 (file)
index e102a5c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef RT·ENVIRONMENT_H
-#define RT·ENVIRONMENT_H
-  #include <stdint.h>
-  #include <stdbool.h>
-
-  typedef unsigned int uint;
-
-  #define Local static
-  #define Free(pt) free(pt); (pt) = NULL;
-
-#endif
diff --git a/shared/tool/makefile/RT_global.h b/shared/tool/makefile/RT_global.h
new file mode 100644 (file)
index 0000000..29f2e63
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef RT_global_H
+#define RT_global_H
+  #include <stdint.h>
+  #include <stdbool.h>
+
+  typedef unsigned int uint;
+
+  #define Local static
+  #define Free(pt) free(pt); (pt) = NULL;
+
+#endif
diff --git a/shared/tool/makefile/environment_RT_1.mk b/shared/tool/makefile/environment_RT_1.mk
deleted file mode 100644 (file)
index 0f23127..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-# enviroment_RT_1.mk
-# makefile environment variable defaults.
-# cc is the name of the C compiler, a file called <name>.c is C source code.
-# RT uses header integrated C source files, i.e. the source and the header are the same file
-
-SHELL=/bin/bash
-
-# environment_RT_1.mk
-
-ECHO := printf "%b\n"
-
-C_SOURCE_DIR     := authored
-C                := gcc
-CFLAGS           := -std=gnu11 -Wall -Wextra -Wpedantic -finput-charset=UTF-8
-CFLAGS           += -MMD -MP
-CFLAGS           += -I $(C_SOURCE_DIR)
-
-LIBRARY_NAME    := $(PROJECT)
-LIBRARY_NAME    := $(subst -,_,$(LIBRARY_NAME))
-
-LIBRARY_DIR     := scratchpad
-LIBRARY_FILE    := $(LIBRARY_DIR)/lib$(LIBRARY_NAME).a
-
-LN_FLAGS        := -L$(LIBRARY_DIR) -L/lib64 -L/lib
-
-MACHINE_DIR     := scratchpad/made
-
-KMOD_SOURCE_DIR  := cc
-KMOD_CCFLAGS    := -I $(KMOD_SOURCE_DIR)
-KMOD_OUTPUT_DIR := scratchpad/kmod
index 8cf8346..2d28b76 100644 (file)
@@ -8,14 +8,13 @@
 #--------------------------------------------------------------------------------
 # defaults for environment variables
 
-C              ?= gcc
-CFLAGS         ?=
-C_SOURCE_DIR   ?= cc
-BUILD_DIR      ?= scratchpad/build
-LIBRARY_FILE   ?= $(BUILD_DIR)/made/lib$(PROJECT).a
-MACHINE_DIR    ?= $(BUILD_DIR)/made
-OBJECT_DIR     ?= $(BUILD_DIR)/object
-LN_FLAGS       ?=
+C              ?= cc
+CFLAGS         ?= -O2 -Wall -Wextra -pedantic
+C_SOURCE_DIR   ?= src
+OBJECT_DIR     ?= obj
+LIBRARY_DIR    ?= lib
+MACHINE_DIR    ?= bin
+LN_FLAGS       ?= -L$(LIBRARY_DIR) -L/usr/local/lib -L/usr/lib
 
 #--------------------------------------------------------------------------------
 # derived variables