misc build
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Thu, 16 Oct 2025 05:33:03 +0000 (05:33 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Thu, 16 Oct 2025 05:33:03 +0000 (05:33 +0000)
developer/cc/hello.cli.c [new file with mode: 0644]
developer/cc/noop.lib.c [deleted file]
developer/cc/rabbit_module_no-op.mod.c [new file with mode: 0644]
developer/scratchpad/makefile-cc.deps
developer/tool/clean [deleted file]
developer/tool/makefile
developer/tool/makefile_mod [new file with mode: 0644]
rabit_kmod_seed.tar.gz [deleted file]

diff --git a/developer/cc/hello.cli.c b/developer/cc/hello.cli.c
new file mode 100644 (file)
index 0000000..a626cac
--- /dev/null
@@ -0,0 +1,2 @@
+#include <stdio.h>
+int main(void){ puts("hello from Rabbit CLI"); return 0; }
diff --git a/developer/cc/noop.lib.c b/developer/cc/noop.lib.c
deleted file mode 100644 (file)
index f6c5586..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-// rabit_noop.c — Rabit no-op netfilter interposer (Debian 12/Bookworm)
-// Build: out-of-tree module. Load/unload to verify hook coverage.
-// Behavior: increments counters, returns NF_ACCEPT. No packet mutation.
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/version.h>
-#include <linux/skbuff.h>
-#include <linux/atomic.h>
-#include <linux/netdevice.h>
-#include <linux/netfilter.h>
-#include <linux/netfilter_ipv4.h>
-#include <linux/netfilter_ipv6.h>
-
-static atomic64_t cnt_v4_local_out  = ATOMIC_LONG_INIT(0);
-static atomic64_t cnt_v4_postroute  = ATOMIC_LONG_INIT(0);
-static atomic64_t cnt_v6_local_out  = ATOMIC_LONG_INIT(0);
-static atomic64_t cnt_v6_postroute  = ATOMIC_LONG_INIT(0);
-
-static unsigned int rabit_v4_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *st) {
-  if (st->hook == NF_INET_LOCAL_OUT)     atomic64_inc(&cnt_v4_local_out);
-  else if (st->hook == NF_INET_POST_ROUTING) atomic64_inc(&cnt_v4_postroute);
-  return NF_ACCEPT;
-}
-
-static unsigned int rabit_v6_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *st) {
-  if (st->hook == NF_INET_LOCAL_OUT)     atomic64_inc(&cnt_v6_local_out);
-  else if (st->hook == NF_INET_POST_ROUTING) atomic64_inc(&cnt_v6_postroute);
-  return NF_ACCEPT;
-}
-
-static struct nf_hook_ops rabit_ops[] = {
-  { .hook = rabit_v4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_LOCAL_OUT,   .priority = NF_IP_PRI_FIRST },
-  { .hook = rabit_v4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_POST_ROUTING,.priority = NF_IP_PRI_FIRST },
-  { .hook = rabit_v6_hook, .pf = NFPROTO_IPV6, .hooknum = NF_INET_LOCAL_OUT,   .priority = NF_IP6_PRI_FIRST },
-  { .hook = rabit_v6_hook, .pf = NFPROTO_IPV6, .hooknum = NF_INET_POST_ROUTING,.priority = NF_IP6_PRI_FIRST },
-};
-
-static int __init rabit_init(void) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)
-  int ret = nf_register_net_hooks(&init_net, rabit_ops, ARRAY_SIZE(rabit_ops));
-#else
-  int ret = nf_register_hooks(rabit_ops, ARRAY_SIZE(rabit_ops));
-#endif
-  if (ret)
-    pr_err("rabit_noop: nf_register_* failed: %d\n", ret);
-  else
-    pr_info("rabit_noop: loaded (no-op)\n");
-  return ret;
-}
-
-static void __exit rabit_exit(void) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)
-  nf_unregister_net_hooks(&init_net, rabit_ops, ARRAY_SIZE(rabit_ops));
-#else
-  nf_unregister_hooks(rabit_ops, ARRAY_SIZE(rabit_ops));
-#endif
-  pr_info("rabit_noop: unload stats v4(lo=%lld,po=%lld) v6(lo=%lld,po=%lld)\n",
-          (long long)atomic64_read(&cnt_v4_local_out),
-          (long long)atomic64_read(&cnt_v4_postroute),
-          (long long)atomic64_read(&cnt_v6_local_out),
-          (long long)atomic64_read(&cnt_v6_postroute));
-}
-
-module_init(rabit_init);
-module_exit(rabit_exit);
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Rabit");
-MODULE_DESCRIPTION("Rabit no-op netfilter interposer");
diff --git a/developer/cc/rabbit_module_no-op.mod.c b/developer/cc/rabbit_module_no-op.mod.c
new file mode 100644 (file)
index 0000000..f6c5586
--- /dev/null
@@ -0,0 +1,69 @@
+// rabit_noop.c — Rabit no-op netfilter interposer (Debian 12/Bookworm)
+// Build: out-of-tree module. Load/unload to verify hook coverage.
+// Behavior: increments counters, returns NF_ACCEPT. No packet mutation.
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/skbuff.h>
+#include <linux/atomic.h>
+#include <linux/netdevice.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter_ipv4.h>
+#include <linux/netfilter_ipv6.h>
+
+static atomic64_t cnt_v4_local_out  = ATOMIC_LONG_INIT(0);
+static atomic64_t cnt_v4_postroute  = ATOMIC_LONG_INIT(0);
+static atomic64_t cnt_v6_local_out  = ATOMIC_LONG_INIT(0);
+static atomic64_t cnt_v6_postroute  = ATOMIC_LONG_INIT(0);
+
+static unsigned int rabit_v4_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *st) {
+  if (st->hook == NF_INET_LOCAL_OUT)     atomic64_inc(&cnt_v4_local_out);
+  else if (st->hook == NF_INET_POST_ROUTING) atomic64_inc(&cnt_v4_postroute);
+  return NF_ACCEPT;
+}
+
+static unsigned int rabit_v6_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *st) {
+  if (st->hook == NF_INET_LOCAL_OUT)     atomic64_inc(&cnt_v6_local_out);
+  else if (st->hook == NF_INET_POST_ROUTING) atomic64_inc(&cnt_v6_postroute);
+  return NF_ACCEPT;
+}
+
+static struct nf_hook_ops rabit_ops[] = {
+  { .hook = rabit_v4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_LOCAL_OUT,   .priority = NF_IP_PRI_FIRST },
+  { .hook = rabit_v4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_POST_ROUTING,.priority = NF_IP_PRI_FIRST },
+  { .hook = rabit_v6_hook, .pf = NFPROTO_IPV6, .hooknum = NF_INET_LOCAL_OUT,   .priority = NF_IP6_PRI_FIRST },
+  { .hook = rabit_v6_hook, .pf = NFPROTO_IPV6, .hooknum = NF_INET_POST_ROUTING,.priority = NF_IP6_PRI_FIRST },
+};
+
+static int __init rabit_init(void) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)
+  int ret = nf_register_net_hooks(&init_net, rabit_ops, ARRAY_SIZE(rabit_ops));
+#else
+  int ret = nf_register_hooks(rabit_ops, ARRAY_SIZE(rabit_ops));
+#endif
+  if (ret)
+    pr_err("rabit_noop: nf_register_* failed: %d\n", ret);
+  else
+    pr_info("rabit_noop: loaded (no-op)\n");
+  return ret;
+}
+
+static void __exit rabit_exit(void) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)
+  nf_unregister_net_hooks(&init_net, rabit_ops, ARRAY_SIZE(rabit_ops));
+#else
+  nf_unregister_hooks(rabit_ops, ARRAY_SIZE(rabit_ops));
+#endif
+  pr_info("rabit_noop: unload stats v4(lo=%lld,po=%lld) v6(lo=%lld,po=%lld)\n",
+          (long long)atomic64_read(&cnt_v4_local_out),
+          (long long)atomic64_read(&cnt_v4_postroute),
+          (long long)atomic64_read(&cnt_v6_local_out),
+          (long long)atomic64_read(&cnt_v6_postroute));
+}
+
+module_init(rabit_init);
+module_exit(rabit_exit);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Rabit");
+MODULE_DESCRIPTION("Rabit no-op netfilter interposer");
index b485e73..bbb727e 100644 (file)
@@ -1,2 +1,7 @@
-scratchpad/noop.lib.o: cc/noop.lib.c \
+scratchpad/no-op.lib.o: cc/no-op.lib.c \
  /home/Thomas/subu_data/developer/project/Linux/Rabbit/tool_shared/third_party/RT-project-share/release/make/RT_0.h
+scratchpad/hello.cli.o: cc/hello.cli.c \
+ /home/Thomas/subu_data/developer/project/Linux/Rabbit/tool_shared/third_party/RT-project-share/release/make/RT_0.h
+
+machine/hello : scratchpad/hello.cli.o scratchpad/libRabbit.a
+       gcc -o machine/hello scratchpad/hello.cli.o -Lscratchpad -L/lib64 -L/lib -lRabbit
diff --git a/developer/tool/clean b/developer/tool/clean
deleted file mode 100755 (executable)
index 12aee9b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env bash
-script_afp=$(realpath "${BASH_SOURCE[0]}")
-
-# input guards
-
-  env_must_be="developer/tool🖉/env"
-  if [ "$ENV" != "$env_must_be" ]; then
-    echo "$(script_fp):: error: must be run in the $env_must_be environment"
-    exit 1
-  fi
-
-set -e
-set -x
-
-
-cd "$REPO_HOME"/developer || exit 1
-
-# remove object files, deps file, library, and whatever else is on the scratchpad if anything
-  rm scratchpad/*.o $DEPFILE scratchpad/lib*.a   || true
-
-# remove built executables
-  rm -f machine/* || true
-
-set +x
-echo "$(script_fn) done."
index bc55904..72832a4 100644 (file)
@@ -1,16 +1,11 @@
 
-RT-INCOMMON:=$(REPO_HOME)/tool_shared/third_party/RT-project-share/release
+RT-INCOMMON:=$(REPO_HOME)/release
 
 include $(RT-INCOMMON)/make/environment_RT_0
 
-# To compile the example directory uncomment the following assignments:
-SRCDIR_List=cc
-CFLAGS+=-Icc
-
-CFLAGS+= -include "$(RT-INCOMMON)/make/RT_0.h"
+CFLAGS+=-Werror -include "$(RT-INCOMMON)/make/RT_0.h"
 LINKFLAGS+= -l$(PROJECT)
 LIBFILE=$(LIBDIR)/lib$(PROJECT).a
 
 include $(RT-INCOMMON)/make/targets_developer
 -include $(DEPFILE)
-
diff --git a/developer/tool/makefile_mod b/developer/tool/makefile_mod
new file mode 100644 (file)
index 0000000..50485ca
--- /dev/null
@@ -0,0 +1,27 @@
+# tool/makefile
+
+RT_project_share:=$(REPO_HOME)/tool_shared/third_party/RT-project-share/release
+include $(RT_project_share)/make/environment_RT_0
+
+KBUILD_SRCDIR_List := $(SRCDIR_List)
+KBUILD_SRC_List := $(foreach dir, $(KBUILD_SRCDIR_List), $(wildcard $(dir)/*.mod.c))
+KBUILD_BASE_List := $(sort $(patsubst %.mod.c, %, $(notdir $(KBUILD_SRC_List))))
+
+DEPFILE := $(TMPDIR)/makefile-cc.deps
+
+-include $(DEPFILE)
+include $(RT_project_share)/make/targets_developer
+include $(RT_project_share)/make/targets_kernel
+
+# ----------------------------------------------------------------------
+# --- PUBLIC TARGET ORCHESTRATION (Must be last to win precedence) ---
+# ----------------------------------------------------------------------
+
+# 1. DEFAULT TARGET: Make the 'all' target the default for running 'make'.
+#    This must be defined last to override the 'all: usage' from the included targets files.
+.PHONY: all
+all: kernel_module
+
+# 2. CLEAN TARGET: Orchestrate the cleanup process.
+.PHONY: clean
+clean: clean_developer clean_kernel
diff --git a/rabit_kmod_seed.tar.gz b/rabit_kmod_seed.tar.gz
deleted file mode 100644 (file)
index 73480ed..0000000
Binary files a/rabit_kmod_seed.tar.gz and /dev/null differ