From 20e1a2f217440bbd3b9f3f62c5c833fa509b6f8c Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 25 Aug 2026 00:12:39 +1000 Subject: [PATCH 1/3] include: keep the exported headers where they are used from The 37 headers listed in SRCHEADERS are the API an out-of-tree component may use. They were spread over eight source directories, mixed in with the private headers of the libraries publishing them, and the build copied them into ../include by basename so that an angled include would find them. That copy is what makes the rule in the comment above SRCHEADERS necessary: a source beside an exported header must include it quoted, because the copy is not the file its own directory should compile against, while every other source must include it angled. Which form is correct therefore depends on where the includer sits, and getting it wrong is silent, because the wrong file is found rather than no file. Keep them in ../include instead, where every compile in and out of the tree already looks for them. There is then one copy rather than two, nothing sits beside an exported header, and every source in the tree takes them angled. SRCHEADERS, the rule that did the copying and headersclean all go; the directory is the list, and installing it is a wildcard. 25 include sites in 22 files change from quoted to angled. The local hal.h in hal/user_comps/xhc-whb04b-6 is a different header of the same name and keeps its "./hal.h" form. Inside include/ the headers keep quoting each other, which is now simply a same-directory include. No code changes, no -I flag changes, and $(EMC2_HOME)/include keeps meaning what it meant. --- debian/copyright | 4 +- docs/src/code/code-notes.adoc | 2 +- docs/src/config/core-components.adoc | 2 +- docs/src/hal/tutorial.adoc | 2 +- docs/src/man/man9/motion.9.adoc | 2 +- include/.gitignore | 2 - {src/emc/nml_intf => include}/emcmotcfg.h | 0 {src/emc/nml_intf => include}/emcpos.h | 0 {src/libposemath => include}/emcpose.h | 0 {src/hal => include}/hal.h | 0 .../hostmot2-serial.h | 0 {src/emc/ini => include}/inifile.h | 0 {src/emc/ini => include}/inifile.hh | 0 {src/emc/kinematics => include}/kinematics.h | 0 {src/emc => include}/linuxcnc.h | 0 {src/emc/nml_intf => include}/motion_types.h | 0 {src/libposemath => include}/posemath.h | 0 {src/libposemath => include}/posemath.hh | 0 {src/libposemath => include}/posemath_types.h | 0 {src/rtapi => include}/rtapi.h | 0 {src/rtapi => include}/rtapi_app.h | 0 {src/rtapi => include}/rtapi_atomic.h | 0 {src/rtapi => include}/rtapi_bitops.h | 0 {src/rtapi => include}/rtapi_bool.h | 0 {src/rtapi => include}/rtapi_byteorder.h | 0 {src/rtapi => include}/rtapi_ctype.h | 0 {src/rtapi => include}/rtapi_device.h | 0 {src/rtapi => include}/rtapi_errno.h | 0 {src/rtapi => include}/rtapi_firmware.h | 0 {src/rtapi => include}/rtapi_gfp.h | 0 {src/rtapi => include}/rtapi_io.h | 0 {src/rtapi => include}/rtapi_limits.h | 0 {src/rtapi => include}/rtapi_list.h | 0 {src/rtapi => include}/rtapi_math.h | 0 {src/rtapi => include}/rtapi_math64.h | 0 {src/rtapi => include}/rtapi_math_i386.h | 0 {src/rtapi => include}/rtapi_mutex.h | 0 {src/rtapi => include}/rtapi_parport.h | 0 {src/rtapi => include}/rtapi_pci.h | 0 {src/rtapi => include}/rtapi_slab.h | 0 {src/rtapi => include}/rtapi_stdint.h | 0 {src/rtapi => include}/rtapi_string.h | 0 {src/rtapi => include}/rtapi_vsnprintf.h | 0 lib/python/mtc/kinematics.py | 2 +- src/Makefile | 83 ++----------------- src/Submakefile.skel | 3 +- src/emc/ini/inifile.cc | 2 +- src/emc/nml_intf/emc.cc | 2 +- src/emc/nml_intf/emc.hh | 2 +- src/hal/drivers/mesa-hostmot2/pktuart.c | 2 +- src/hal/hal_lib.c | 2 +- src/hal/hal_lib_extra.c | 2 +- src/hal/hal_lib_query.c | 2 +- src/libposemath/_posemath.c | 2 +- src/libposemath/emcpose.c | 4 +- src/libposemath/posemath.cc | 2 +- src/rtapi/mathstubs.c | 2 +- src/rtapi/rtai_rtapi.c | 4 +- src/rtapi/rtai_ulapi.c | 2 +- src/rtapi/rtapi_common.h | 2 +- src/rtapi/uspace_posix.cc | 2 +- src/rtapi/uspace_rtai.cc | 2 +- src/rtapi/uspace_rtapi_app.cc | 2 +- src/rtapi/uspace_rtapi_app.hh | 4 +- src/rtapi/uspace_rtapi_main.cc | 2 +- src/rtapi/uspace_ulapi.c | 2 +- src/rtapi/uspace_xenomai.cc | 2 +- src/rtapi/uspace_xenomai_evl.cc | 2 +- tcl/tklinuxcnc.tcl | 2 +- 69 files changed, 41 insertions(+), 113 deletions(-) delete mode 100644 include/.gitignore rename {src/emc/nml_intf => include}/emcmotcfg.h (100%) rename {src/emc/nml_intf => include}/emcpos.h (100%) rename {src/libposemath => include}/emcpose.h (100%) rename {src/hal => include}/hal.h (100%) rename {src/hal/drivers/mesa-hostmot2 => include}/hostmot2-serial.h (100%) rename {src/emc/ini => include}/inifile.h (100%) rename {src/emc/ini => include}/inifile.hh (100%) rename {src/emc/kinematics => include}/kinematics.h (100%) rename {src/emc => include}/linuxcnc.h (100%) rename {src/emc/nml_intf => include}/motion_types.h (100%) rename {src/libposemath => include}/posemath.h (100%) rename {src/libposemath => include}/posemath.hh (100%) rename {src/libposemath => include}/posemath_types.h (100%) rename {src/rtapi => include}/rtapi.h (100%) rename {src/rtapi => include}/rtapi_app.h (100%) rename {src/rtapi => include}/rtapi_atomic.h (100%) rename {src/rtapi => include}/rtapi_bitops.h (100%) rename {src/rtapi => include}/rtapi_bool.h (100%) rename {src/rtapi => include}/rtapi_byteorder.h (100%) rename {src/rtapi => include}/rtapi_ctype.h (100%) rename {src/rtapi => include}/rtapi_device.h (100%) rename {src/rtapi => include}/rtapi_errno.h (100%) rename {src/rtapi => include}/rtapi_firmware.h (100%) rename {src/rtapi => include}/rtapi_gfp.h (100%) rename {src/rtapi => include}/rtapi_io.h (100%) rename {src/rtapi => include}/rtapi_limits.h (100%) rename {src/rtapi => include}/rtapi_list.h (100%) rename {src/rtapi => include}/rtapi_math.h (100%) rename {src/rtapi => include}/rtapi_math64.h (100%) rename {src/rtapi => include}/rtapi_math_i386.h (100%) rename {src/rtapi => include}/rtapi_mutex.h (100%) rename {src/rtapi => include}/rtapi_parport.h (100%) rename {src/rtapi => include}/rtapi_pci.h (100%) rename {src/rtapi => include}/rtapi_slab.h (100%) rename {src/rtapi => include}/rtapi_stdint.h (100%) rename {src/rtapi => include}/rtapi_string.h (100%) rename {src/rtapi => include}/rtapi_vsnprintf.h (100%) diff --git a/debian/copyright b/debian/copyright index 3908cc8cb82..70bd128bfc7 100644 --- a/debian/copyright +++ b/debian/copyright @@ -251,7 +251,6 @@ Files: src/hal/drivers/hal_vti.c src/hal/drivers/hal_vti.h src/hal/drivers/motenc.h - src/hal/hal.h src/hal/user_comps/gs2_vfd.c src/hal/user_comps/hy_gt_vfd.c src/hal/user_comps/pi500_vfd/pi500_vfd.comp @@ -286,6 +285,7 @@ Files: src/hal/utils/scope_vert.c src/hal/utils/upci.c src/hal/utils/upci.h + include/hal.h Copyright: same flock of LinuxCNC devs as above License: GPL-2 @@ -341,7 +341,7 @@ Files: src/hal/hal_lib.c Copyright: 2003 John Kasunich License: LGPL-2 -Files: src/emc/linuxcnc.h +Files: include/linuxcnc.h Copyright: 2021 Petter Reinholdtsen License: LGPL-2 diff --git a/docs/src/code/code-notes.adoc b/docs/src/code/code-notes.adoc index 3874fd37002..c66404b8bff 100644 --- a/docs/src/code/code-notes.adoc +++ b/docs/src/code/code-notes.adoc @@ -127,7 +127,7 @@ of the HAL, and uses terms like HAL pins, HAL signals, etc, without explaining them. For more information about the HAL, see the HAL Manual. Another chapter of this document will eventually go into the internals of the HAL itself, but in this -chapter, we only use the HAL API as defined in src/hal/hal.h. +chapter, we only use the HAL API as defined in include/hal.h. === Motion Controller Modules diff --git a/docs/src/config/core-components.adoc b/docs/src/config/core-components.adoc index 9ea4b39098b..1902c94a49d 100644 --- a/docs/src/config/core-components.adoc +++ b/docs/src/config/core-components.adoc @@ -119,7 +119,7 @@ These pins, parameters, and functions are created by the realtime 'motmod' modul This will be delayed during spindle synch moves till the end of the move. * 'motion.in-position' - (bit, out) TRUE if the machine is in position. * 'motion.motion-enabled' - (bit, out) TRUE when in 'machine on' state. -* 'motion.motion-type' - (s32, out) These values are from src/emc/nml_intf/motion_types.h +* 'motion.motion-type' - (s32, out) These values are from include/motion_types.h - 0: Idle (no motion) - 1: Traverse - 2: Linear feed diff --git a/docs/src/hal/tutorial.adoc b/docs/src/hal/tutorial.adoc index 87dcfa00d74..33cce8f845b 100644 --- a/docs/src/hal/tutorial.adoc +++ b/docs/src/hal/tutorial.adoc @@ -76,7 +76,7 @@ does things a little differently. To address these differences, the LinuxCNC team came up with RTAPI, which provides a consistent way for programs to talk to the RTOS. If you are a programmer who wants to work on the internals of LinuxCNC, you may want to -study 'linuxcnc/src/rtapi/rtapi.h' to understand the API. +study 'linuxcnc/include/rtapi.h' to understand the API. But if you are a normal person, all you need to know about RTAPI is that it (and the RTOS) needs to be loaded into the memory of your computer before you do anything with HAL. diff --git a/docs/src/man/man9/motion.9.adoc b/docs/src/man/man9/motion.9.adoc index 43859fcef14..6ff2186f7f8 100644 --- a/docs/src/man/man9/motion.9.adoc +++ b/docs/src/man/man9/motion.9.adoc @@ -216,7 +216,7 @@ Note: feed-inhibit applies to G-code commands -- not jogs. *motion.motion-enabled* OUT BIT:: + *motion.motion-type* OUT S32:: - These values are from src/emc/nml_intf/motion_types.h: + These values are from include/motion_types.h: 0: Idle (no motion) diff --git a/include/.gitignore b/include/.gitignore deleted file mode 100644 index 78f5e95a245..00000000000 --- a/include/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.hh -*.h diff --git a/src/emc/nml_intf/emcmotcfg.h b/include/emcmotcfg.h similarity index 100% rename from src/emc/nml_intf/emcmotcfg.h rename to include/emcmotcfg.h diff --git a/src/emc/nml_intf/emcpos.h b/include/emcpos.h similarity index 100% rename from src/emc/nml_intf/emcpos.h rename to include/emcpos.h diff --git a/src/libposemath/emcpose.h b/include/emcpose.h similarity index 100% rename from src/libposemath/emcpose.h rename to include/emcpose.h diff --git a/src/hal/hal.h b/include/hal.h similarity index 100% rename from src/hal/hal.h rename to include/hal.h diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2-serial.h b/include/hostmot2-serial.h similarity index 100% rename from src/hal/drivers/mesa-hostmot2/hostmot2-serial.h rename to include/hostmot2-serial.h diff --git a/src/emc/ini/inifile.h b/include/inifile.h similarity index 100% rename from src/emc/ini/inifile.h rename to include/inifile.h diff --git a/src/emc/ini/inifile.hh b/include/inifile.hh similarity index 100% rename from src/emc/ini/inifile.hh rename to include/inifile.hh diff --git a/src/emc/kinematics/kinematics.h b/include/kinematics.h similarity index 100% rename from src/emc/kinematics/kinematics.h rename to include/kinematics.h diff --git a/src/emc/linuxcnc.h b/include/linuxcnc.h similarity index 100% rename from src/emc/linuxcnc.h rename to include/linuxcnc.h diff --git a/src/emc/nml_intf/motion_types.h b/include/motion_types.h similarity index 100% rename from src/emc/nml_intf/motion_types.h rename to include/motion_types.h diff --git a/src/libposemath/posemath.h b/include/posemath.h similarity index 100% rename from src/libposemath/posemath.h rename to include/posemath.h diff --git a/src/libposemath/posemath.hh b/include/posemath.hh similarity index 100% rename from src/libposemath/posemath.hh rename to include/posemath.hh diff --git a/src/libposemath/posemath_types.h b/include/posemath_types.h similarity index 100% rename from src/libposemath/posemath_types.h rename to include/posemath_types.h diff --git a/src/rtapi/rtapi.h b/include/rtapi.h similarity index 100% rename from src/rtapi/rtapi.h rename to include/rtapi.h diff --git a/src/rtapi/rtapi_app.h b/include/rtapi_app.h similarity index 100% rename from src/rtapi/rtapi_app.h rename to include/rtapi_app.h diff --git a/src/rtapi/rtapi_atomic.h b/include/rtapi_atomic.h similarity index 100% rename from src/rtapi/rtapi_atomic.h rename to include/rtapi_atomic.h diff --git a/src/rtapi/rtapi_bitops.h b/include/rtapi_bitops.h similarity index 100% rename from src/rtapi/rtapi_bitops.h rename to include/rtapi_bitops.h diff --git a/src/rtapi/rtapi_bool.h b/include/rtapi_bool.h similarity index 100% rename from src/rtapi/rtapi_bool.h rename to include/rtapi_bool.h diff --git a/src/rtapi/rtapi_byteorder.h b/include/rtapi_byteorder.h similarity index 100% rename from src/rtapi/rtapi_byteorder.h rename to include/rtapi_byteorder.h diff --git a/src/rtapi/rtapi_ctype.h b/include/rtapi_ctype.h similarity index 100% rename from src/rtapi/rtapi_ctype.h rename to include/rtapi_ctype.h diff --git a/src/rtapi/rtapi_device.h b/include/rtapi_device.h similarity index 100% rename from src/rtapi/rtapi_device.h rename to include/rtapi_device.h diff --git a/src/rtapi/rtapi_errno.h b/include/rtapi_errno.h similarity index 100% rename from src/rtapi/rtapi_errno.h rename to include/rtapi_errno.h diff --git a/src/rtapi/rtapi_firmware.h b/include/rtapi_firmware.h similarity index 100% rename from src/rtapi/rtapi_firmware.h rename to include/rtapi_firmware.h diff --git a/src/rtapi/rtapi_gfp.h b/include/rtapi_gfp.h similarity index 100% rename from src/rtapi/rtapi_gfp.h rename to include/rtapi_gfp.h diff --git a/src/rtapi/rtapi_io.h b/include/rtapi_io.h similarity index 100% rename from src/rtapi/rtapi_io.h rename to include/rtapi_io.h diff --git a/src/rtapi/rtapi_limits.h b/include/rtapi_limits.h similarity index 100% rename from src/rtapi/rtapi_limits.h rename to include/rtapi_limits.h diff --git a/src/rtapi/rtapi_list.h b/include/rtapi_list.h similarity index 100% rename from src/rtapi/rtapi_list.h rename to include/rtapi_list.h diff --git a/src/rtapi/rtapi_math.h b/include/rtapi_math.h similarity index 100% rename from src/rtapi/rtapi_math.h rename to include/rtapi_math.h diff --git a/src/rtapi/rtapi_math64.h b/include/rtapi_math64.h similarity index 100% rename from src/rtapi/rtapi_math64.h rename to include/rtapi_math64.h diff --git a/src/rtapi/rtapi_math_i386.h b/include/rtapi_math_i386.h similarity index 100% rename from src/rtapi/rtapi_math_i386.h rename to include/rtapi_math_i386.h diff --git a/src/rtapi/rtapi_mutex.h b/include/rtapi_mutex.h similarity index 100% rename from src/rtapi/rtapi_mutex.h rename to include/rtapi_mutex.h diff --git a/src/rtapi/rtapi_parport.h b/include/rtapi_parport.h similarity index 100% rename from src/rtapi/rtapi_parport.h rename to include/rtapi_parport.h diff --git a/src/rtapi/rtapi_pci.h b/include/rtapi_pci.h similarity index 100% rename from src/rtapi/rtapi_pci.h rename to include/rtapi_pci.h diff --git a/src/rtapi/rtapi_slab.h b/include/rtapi_slab.h similarity index 100% rename from src/rtapi/rtapi_slab.h rename to include/rtapi_slab.h diff --git a/src/rtapi/rtapi_stdint.h b/include/rtapi_stdint.h similarity index 100% rename from src/rtapi/rtapi_stdint.h rename to include/rtapi_stdint.h diff --git a/src/rtapi/rtapi_string.h b/include/rtapi_string.h similarity index 100% rename from src/rtapi/rtapi_string.h rename to include/rtapi_string.h diff --git a/src/rtapi/rtapi_vsnprintf.h b/include/rtapi_vsnprintf.h similarity index 100% rename from src/rtapi/rtapi_vsnprintf.h rename to include/rtapi_vsnprintf.h diff --git a/lib/python/mtc/kinematics.py b/lib/python/mtc/kinematics.py index d4545b3c8f9..16abfe92291 100644 --- a/lib/python/mtc/kinematics.py +++ b/lib/python/mtc/kinematics.py @@ -48,7 +48,7 @@ } # Human-readable name for LinuxCNC's KINEMATICS_TYPE enum -# (src/emc/kinematics/kinematics.h). +# (include/kinematics.h). KINEMATICS_TYPE_NAMES = { 1: "IDENTITY", 2: "FORWARD_ONLY", diff --git a/src/Makefile b/src/Makefile index 2c56a18ed3a..da7b2dea5fe 100644 --- a/src/Makefile +++ b/src/Makefile @@ -135,7 +135,7 @@ cxx-option = $(shell if $(CXX) $(CXXFLAGS) $(1) -S -o /dev/null -xc++ /dev/null ifeq ($(origin KERNELRELEASE),undefined) # When KERNELRELEASE is not defined, this is the userspace build. # The "modules" target is the gateway to the kernel module build. -build-software: headers userspace modules +build-software: userspace modules ifeq ($(RUN_IN_PLACE),yes) ifneq ($(BUILD_SYS),uspace) @if [ -f ../bin/linuxcnc_module_helper ]; then if ! [ `id -u` = 0 -a -O ../bin/linuxcnc_module_helper -a -u ../bin/linuxcnc_module_helper ]; then $(VECHO) "You now need to run 'sudo make setuid' in order to run in place."; fi; fi @@ -379,77 +379,12 @@ INFILES = \ $(INFILES): %: %.in config.status @./config.status --file=$@ -build-software: headers $(INFILES) +build-software: $(INFILES) -# For each file to be copied to ../include, its location in the source tree -# is listed here. -# Note that due to $(INCLUDE), defined above, the include files in the source -# tree are normally the ones used or not found at all when building linuxcnc if -# you are not aware of the differences between "" and <> includes. -# -# All sources should #include <> (like in #include ) for these special -# headers in the ../include directory to ensure they are used. -# The *only* exception is those sources that use the include and reside in the -# /same/ source directory as the include. That means that the local version -# should have precedence over the global one. -# -# If you add to these headers, then you must make absolutely sure that they are -# required for out-of-tree components and that the proper #include type is -# used. -# -SRCHEADERS := \ - hal/hal.h \ - hal/drivers/mesa-hostmot2/hostmot2-serial.h \ - emc/linuxcnc.h \ - emc/kinematics/kinematics.h \ - emc/nml_intf/emcmotcfg.h \ - emc/ini/inifile.hh \ - emc/ini/inifile.h \ - emc/nml_intf/emcpos.h \ - emc/nml_intf/motion_types.h \ - libposemath/emcpose.h \ - libposemath/posemath.h \ - libposemath/posemath.hh \ - libposemath/posemath_types.h \ - rtapi/rtapi.h \ - rtapi/rtapi_app.h \ - rtapi/rtapi_atomic.h \ - rtapi/rtapi_bitops.h \ - rtapi/rtapi_bool.h \ - rtapi/rtapi_byteorder.h \ - rtapi/rtapi_ctype.h \ - rtapi/rtapi_device.h \ - rtapi/rtapi_errno.h \ - rtapi/rtapi_firmware.h \ - rtapi/rtapi_gfp.h \ - rtapi/rtapi_io.h \ - rtapi/rtapi_limits.h \ - rtapi/rtapi_list.h \ - rtapi/rtapi_math.h \ - rtapi/rtapi_math_i386.h \ - rtapi/rtapi_math64.h \ - rtapi/rtapi_mutex.h \ - rtapi/rtapi_parport.h \ - rtapi/rtapi_pci.h \ - rtapi/rtapi_slab.h \ - rtapi/rtapi_stdint.h \ - rtapi/rtapi_string.h \ - rtapi/rtapi_vsnprintf.h - -# the "headers" target installs all the header files in ../include. One rule -# does the copying for every entry in SRCHEADERS, so a directory that exports a -# header does not carry a recipe of its own. Two headers sharing a basename -# would collide here, and make says so rather than letting one cp win. -.PHONY: headers -HEADERS := $(patsubst %,../include/%,$(notdir $(SRCHEADERS))) -$(foreach h,$(SRCHEADERS),$(eval ../include/$(notdir $(h)): $(h))) -$(HEADERS): - $(ECHO) Exporting $(notdir $@) - $(Q)cp $< $@ -headers: $(HEADERS) - -# install header files as part of the build -TARGETS += headers +# ../include holds the headers an out-of-tree component may use and nothing +# else, so the whole directory is what gets installed. They are sources kept +# where they are used from, not copies, which is why no rule builds them. +HEADERS := $(wildcard ../include/*.h ../include/*.hh) # Add converting of %.po files TARGETS += $(patsubst po/%.po, ../share/locale/%/LC_MESSAGES/linuxcnc.mo, $(wildcard po/*.po)) @@ -513,11 +448,7 @@ python: $(PYTARGETS) userspace: python inclean: $(RM) $(INFILES) -# Not just $(HEADERS): a header that has been dropped from SRCHEADERS still has -# a copy sitting in ../include, and that copy is what an angled include finds. -headersclean: - $(RM) ../include/*.h ../include/*.hh -clean: docclean pythonclean cscopeclean headersclean +clean: docclean pythonclean cscopeclean distclean: clean inclean # This is the gateway into the crazy world of "kbuild", the linux 2.6 system diff --git a/src/Submakefile.skel b/src/Submakefile.skel index c8f67635d4f..cd87c3e27e6 100644 --- a/src/Submakefile.skel +++ b/src/Submakefile.skel @@ -17,8 +17,7 @@ $(call TOOBJSDEPS, $(FOOSRCS)) : EXTRAFLAGS = -Dfoo $(CXX) -o $@ $^ userspace: ../bin/foo -# See emc/rs274ngc/Submakefile for an example of creating a shared library -# or allowing headers to be copied to ../include. +# See emc/rs274ngc/Submakefile for an example of creating a shared library. # See rtapi/Submakefile for an example of how to make some other kind of # file (in this case, ../scripts/rtapi.conf) diff --git a/src/emc/ini/inifile.cc b/src/emc/ini/inifile.cc index 2720ce2d70d..461fa7ad5b5 100644 --- a/src/emc/ini/inifile.cc +++ b/src/emc/ini/inifile.cc @@ -33,7 +33,7 @@ #include "nml_intf/emc.hh" -#include "inifile.hh" +#include using namespace linuxcnc; diff --git a/src/emc/nml_intf/emc.cc b/src/emc/nml_intf/emc.cc index 3eb7360bdd3..5d0a2d9a13e 100644 --- a/src/emc/nml_intf/emc.cc +++ b/src/emc/nml_intf/emc.cc @@ -24,7 +24,7 @@ #include "canon.hh" #include "emc.hh" #include "emc_nml.hh" -#include "emcpos.h" +#include #include "libnml/cms/cms.hh" // diff --git a/src/emc/nml_intf/emc.hh b/src/emc/nml_intf/emc.hh index 2738b34144b..5bd04ad369e 100644 --- a/src/emc/nml_intf/emc.hh +++ b/src/emc/nml_intf/emc.hh @@ -17,7 +17,7 @@ #include // EMC_JOINT_MAX, EMC_AXIS_MAX #include "libnml/nml/nml_type.hh" -#include "motion_types.h" +#include #include #include "modal_state.hh" diff --git a/src/hal/drivers/mesa-hostmot2/pktuart.c b/src/hal/drivers/mesa-hostmot2/pktuart.c index 4560ba18059..f64720b8538 100644 --- a/src/hal/drivers/mesa-hostmot2/pktuart.c +++ b/src/hal/drivers/mesa-hostmot2/pktuart.c @@ -20,7 +20,7 @@ #include #include #include "hostmot2.h" -#include "hostmot2-serial.h" +#include #define MAX_TX_FRAMES (16) // Send counts are written to 16 deep FIFO, burst mode diff --git a/src/hal/hal_lib.c b/src/hal/hal_lib.c index c4aa81eb636..7efceb0f22b 100644 --- a/src/hal/hal_lib.c +++ b/src/hal/hal_lib.c @@ -68,7 +68,7 @@ #endif #include /* RTAPI realtime OS API */ -#include "hal.h" /* HAL public API decls */ +#include /* HAL public API decls */ #define __HAL_LIBRARY_INTERNAL_ONLY 1 #include "hal_priv.h" /* HAL private decls */ diff --git a/src/hal/hal_lib_extra.c b/src/hal/hal_lib_extra.c index 8bd666611c0..c39d3e4755b 100644 --- a/src/hal/hal_lib_extra.c +++ b/src/hal/hal_lib_extra.c @@ -15,7 +15,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -#include "hal.h" +#include #define __HAL_LIBRARY_INTERNAL_ONLY 1 #include "hal_priv.h" diff --git a/src/hal/hal_lib_query.c b/src/hal/hal_lib_query.c index 909ca9afd92..d62bdb35dd8 100644 --- a/src/hal/hal_lib_query.c +++ b/src/hal/hal_lib_query.c @@ -15,7 +15,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -#include "hal.h" +#include #define __HAL_LIBRARY_INTERNAL_ONLY 1 #include "hal_priv.h" diff --git a/src/libposemath/_posemath.c b/src/libposemath/_posemath.c index ec177a10c0e..2dc47db84a5 100644 --- a/src/libposemath/_posemath.c +++ b/src/libposemath/_posemath.c @@ -27,7 +27,7 @@ #include #include #endif -#include "posemath.h" +#include #include #include diff --git a/src/libposemath/emcpose.c b/src/libposemath/emcpose.c index 3fade1f5e2d..39877481657 100644 --- a/src/libposemath/emcpose.c +++ b/src/libposemath/emcpose.c @@ -12,8 +12,8 @@ * ********************************************************************/ -#include "emcpose.h" -#include "posemath.h" +#include +#include #include //#define EMCPOSE_PEDANTIC diff --git a/src/libposemath/posemath.cc b/src/libposemath/posemath.cc index 0589477d14d..17647afbaea 100644 --- a/src/libposemath/posemath.cc +++ b/src/libposemath/posemath.cc @@ -14,7 +14,7 @@ * Last change: ********************************************************************/ -#include "posemath.h" +#include #ifdef PM_PRINT_ERROR #define PM_DEBUG // need debug with printing diff --git a/src/rtapi/mathstubs.c b/src/rtapi/mathstubs.c index c17318a65f1..52283d2c1f0 100644 --- a/src/rtapi/mathstubs.c +++ b/src/rtapi/mathstubs.c @@ -29,7 +29,7 @@ */ #include /* u_int16_t */ -#include "rtapi_math.h" +#include int stderr; diff --git a/src/rtapi/rtai_rtapi.c b/src/rtapi/rtai_rtapi.c index 0ac0e050361..f3c73c9befb 100644 --- a/src/rtapi/rtai_rtapi.c +++ b/src/rtapi/rtai_rtapi.c @@ -73,7 +73,7 @@ #include /* NR_CPUS, cpu_online() */ -#include "rtapi_vsnprintf.h" +#include #include #include @@ -83,7 +83,7 @@ #include #include -#include "rtapi.h" /* public RTAPI decls */ +#include /* public RTAPI decls */ #include #include "rtapi_common.h" /* shared realtime/nonrealtime stuff */ diff --git a/src/rtapi/rtai_ulapi.c b/src/rtapi/rtai_ulapi.c index b2180e1cdf4..cc73ead56b2 100644 --- a/src/rtapi/rtai_ulapi.c +++ b/src/rtapi/rtai_ulapi.c @@ -70,7 +70,7 @@ #include /* inb(), outb() */ #include /* errno */ -#include "rtapi.h" /* public RTAPI decls */ +#include /* public RTAPI decls */ #include #include "rtapi_common.h" /* shared realtime/nonrealtime stuff */ diff --git a/src/rtapi/rtapi_common.h b/src/rtapi/rtapi_common.h index 99af139baeb..8c278a7602c 100644 --- a/src/rtapi/rtapi_common.h +++ b/src/rtapi/rtapi_common.h @@ -71,7 +71,7 @@ #include /* for blocking when needed */ #endif -#include "rtapi_bitops.h" +#include #include /* maximum number of various resources */ diff --git a/src/rtapi/uspace_posix.cc b/src/rtapi/uspace_posix.cc index 62df499a0a2..e7d0b88bb30 100644 --- a/src/rtapi/uspace_posix.cc +++ b/src/rtapi/uspace_posix.cc @@ -16,7 +16,7 @@ */ #include "config.h" -#include "rtapi.h" +#include #include "uspace_rtapi_app.hh" #include #include diff --git a/src/rtapi/uspace_rtai.cc b/src/rtapi/uspace_rtai.cc index d2776769fb2..5b272d49d04 100644 --- a/src/rtapi/uspace_rtai.cc +++ b/src/rtapi/uspace_rtai.cc @@ -15,7 +15,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" -#include "rtapi.h" +#include #include "uspace_rtapi_app.hh" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnarrowing" diff --git a/src/rtapi/uspace_rtapi_app.cc b/src/rtapi/uspace_rtapi_app.cc index eecca0ae0d4..16b57ab79a9 100644 --- a/src/rtapi/uspace_rtapi_app.cc +++ b/src/rtapi/uspace_rtapi_app.cc @@ -15,7 +15,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "rtapi.h" +#include #include "uspace_rtapi_app.hh" #include diff --git a/src/rtapi/uspace_rtapi_app.hh b/src/rtapi/uspace_rtapi_app.hh index beea58e4020..368b53298c2 100644 --- a/src/rtapi/uspace_rtapi_app.hh +++ b/src/rtapi/uspace_rtapi_app.hh @@ -22,8 +22,8 @@ #endif #include #include -#include "rtapi_atomic.h" -#include "rtapi_stdint.h" +#include +#include static inline void rtapi_timespec_add(timespec &result, const timespec &ta, const timespec &tb) { result.tv_sec = ta.tv_sec + tb.tv_sec; diff --git a/src/rtapi/uspace_rtapi_main.cc b/src/rtapi/uspace_rtapi_main.cc index 99f0af8b17d..95b5df64413 100644 --- a/src/rtapi/uspace_rtapi_main.cc +++ b/src/rtapi/uspace_rtapi_main.cc @@ -55,7 +55,7 @@ #include #include -#include "rtapi.h" +#include #include "uspace_common.h" static RtapiApp &App(); diff --git a/src/rtapi/uspace_ulapi.c b/src/rtapi/uspace_ulapi.c index 41187bd0640..0bec4b70257 100644 --- a/src/rtapi/uspace_ulapi.c +++ b/src/rtapi/uspace_ulapi.c @@ -20,7 +20,7 @@ #include #include #include -#include "rtapi.h" +#include #include #include "rtapi/uspace_common.h" diff --git a/src/rtapi/uspace_xenomai.cc b/src/rtapi/uspace_xenomai.cc index c9d887f9e35..bd6813ea9bb 100644 --- a/src/rtapi/uspace_xenomai.cc +++ b/src/rtapi/uspace_xenomai.cc @@ -15,7 +15,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" -#include "rtapi.h" +#include #include "uspace_rtapi_app.hh" #include #include diff --git a/src/rtapi/uspace_xenomai_evl.cc b/src/rtapi/uspace_xenomai_evl.cc index 84f997900fa..b0de3440e19 100644 --- a/src/rtapi/uspace_xenomai_evl.cc +++ b/src/rtapi/uspace_xenomai_evl.cc @@ -18,7 +18,7 @@ */ #include "config.h" -#include "rtapi.h" +#include #include "uspace_rtapi_app.hh" #include diff --git a/tcl/tklinuxcnc.tcl b/tcl/tklinuxcnc.tcl index d35db338406..5acd2e3735a 100755 --- a/tcl/tklinuxcnc.tcl +++ b/tcl/tklinuxcnc.tcl @@ -25,7 +25,7 @@ eval emc_init $argv set ::prog [file tail $::argv0] ;# program name set ::JOGJOINT 1 ;# joint jog set ::JOGTELEOP 0 ;# teleop jog -set ::KINEMATICS_IDENTITY 1 ;# src/emc/kinematics/kinematics.h +set ::KINEMATICS_IDENTITY 1 ;# include/kinematics.h set ::MAX_JOINTS 9 ;# src/emc/motion/emcmotcfg.h From cd3913ca64be2d4dc8bdcf37174048d534648933 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 25 Aug 2026 00:12:47 +1000 Subject: [PATCH 2/3] include-dep-report: take the exported set from the include directory SRCHEADERS is gone, so read the directory instead. It is the better source anyway: the list cannot drift from what is installed when the directory is the list. The headers are scanned along with the sources so their own includes still count, they bucket as "include", and paths print relative to the tree root rather than to src, which the exported headers now sit beside rather than under. The "no in-tree user outside their own directory" section had its meaning taken away by the move, since no source shares a directory with an exported header any more. It now reports the headers with at most two in-tree users, which is the question that section was really asking. --- scripts/include-dep-report.py | 64 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/scripts/include-dep-report.py b/scripts/include-dep-report.py index 7dcf8e84ef7..367e4ecf729 100755 --- a/scripts/include-dep-report.py +++ b/scripts/include-dep-report.py @@ -3,8 +3,8 @@ Resolves every #include the way the compiler does, aggregates the result to the directory that builds each file, finds the strongly connected components, and -writes a markdown report. The exported-header list is read out of SRCHEADERS in -src/Makefile, so the report follows what the build actually installs. +writes a markdown report. The exported headers are the contents of the include/ +directory beside src, which is the set an out-of-tree component may use. ./scripts/include-dep-report.py [src] > report.md """ @@ -15,6 +15,7 @@ from collections import defaultdict SRC = os.path.abspath(sys.argv[1] if len(sys.argv) > 1 else "src") +INC = os.path.join(os.path.dirname(SRC), "include") SKIP_DIRS = {"objects", "autom4te.cache", "m4", "depends"} EXTS = (".c", ".cc", ".cpp", ".h", ".hh", ".hpp", ".comp", ".icomp") INC_RE = re.compile(r'^\s*#\s*include\s*([<"])([^>"]+)[>"]') @@ -29,20 +30,10 @@ SEARCH = {"user": ["", "emc"], "rt": [""], "comp": [""]} -def read_srcheaders(): - out, collecting = [], False - for line in open(os.path.join(SRC, "Makefile"), encoding="utf-8", errors="replace"): - if not collecting: - if re.match(r'^\s*SRCHEADERS\s*:?=', line): - collecting = True - line = line.split("=", 1)[1] - else: - continue - cont = line.rstrip("\n").endswith("\\") - out += [t for t in line.replace("\\", " ").split() if t.endswith((".h", ".hh"))] - if not cont: - break - return out +def read_exported(): + """The headers an out-of-tree component may use. They are the whole content + of the include/ directory beside src, so the directory is the list.""" + return sorted(fn for fn in os.listdir(INC) if fn.endswith((".h", ".hh"))) def walk_sources(): @@ -51,6 +42,8 @@ def walk_sources(): for fn in filenames: if fn.endswith(EXTS): yield os.path.join(dirpath, fn) + for fn in read_exported(): + yield os.path.join(INC, fn) def read_rt_sources(): @@ -135,8 +128,16 @@ def folded_dirs(): FOLD = folded_dirs() +def show(rel): + """A path relative to the tree root. Everything the walk finds is relative + to src, except the exported headers, which sit beside it.""" + return os.path.normpath(os.path.join("src", rel)) + + def module_of(rel): parts = rel.split("/") + if parts[0] == "..": + return "include" if len(parts) == 1: return "src" if parts[0] in ("emc", "hal", "libnml", "rtapi") and len(parts) > 2: @@ -182,7 +183,7 @@ def sccs(adj, nodes): def analyse(): - exported = {os.path.basename(h): h for h in read_srcheaders()} + exported = {h: os.path.join("..", "include", h) for h in read_exported()} relfiles = {os.path.relpath(f, SRC): f for f in walk_sources()} by_name = defaultdict(list) for rel in relfiles: @@ -302,7 +303,7 @@ def main(): "compile it actually goes through, taken from the `-objs` lists in `src/Makefile`; " "`.comp` sources are scanned below their `;;` line and resolved the way " "halcompile does, with the component's own directory ahead of the rest. The " - "exported-header set is read out of `SRCHEADERS`, so it follows what the build " + "exported-header set is the content of the include/ directory, so it follows what the build " "installs rather than a list of its own. Includes that resolve outside the tree " "are dropped.\n\n") @@ -337,8 +338,8 @@ def main(): for (a, b), v in sorted(thin.items()): rel, ln, tgt, style = sorted(v)[0] close = '"' if style == '"' else '>' - w(f"| `{a}` -> `{b}` | `src/{rel}:{ln}` | " - f"`{style}{os.path.basename(tgt)}{close}` = `src/{tgt}` |\n") + w(f"| `{a}` -> `{b}` | `{show(rel)}:{ln}` | " + f"`{style}{os.path.basename(tgt)}{close}` = `{show(tgt)}` |\n") w("\n") heavy = [(k, v) for k, v in intra.items() if len(v) > 1] @@ -363,7 +364,7 @@ def main(): else: w("| file | line | include | resolved in userspace by |\n|---|---|---|---|\n") for rel, ln, name, via in sorted(rtbad): - w(f"| `src/{rel}` | {ln} | `{name}` | {via} |\n") + w(f"| `{show(rel)}` | {ln} | `{name}` | {via} |\n") w("\n") both = sorted(h for h in data["rt_reach"] & data["user_reach"] @@ -385,19 +386,18 @@ def main(): w(f"| `{d}` | {len(bydir[d])} | {names} |\n") w("\n") - w("## Exported headers with no in-tree user outside their own directory\n\n") - w("A header reached only from its own directory is a candidate for coming off " - "`SRCHEADERS`, but not automatically: a header included by its umbrella beside " - "it, or by code in a subdirectory that falls in the same bucket, shows up here " - "too.\n\n") - w("| header | users elsewhere |\n|---|---|\n") + w("## Exported headers with at most two in-tree users\n\n") + w("An exported header is there for code outside the tree, so a thin in-tree " + "user list says nothing on its own. It does say where to look: a header with " + "no in-tree user at all is either an interface only out-of-tree code needs, " + "or a leftover nobody has taken off the list.\n\n") + w("| header | in-tree users |\n|---|---|\n") for h in sorted(exported.values()): - own = module_of(h) - outside = sorted({u for u in exported_users.get(h, set()) if module_of(u) != own}) - if len(outside) > 2: + users = sorted(exported_users.get(h, set())) + if len(users) > 2: continue - cell = ", ".join(f"`src/{u}`" for u in outside) or "none" - w(f"| `{h}` | {cell} |\n") + cell = ", ".join(f"`{show(u)}`" for u in users) or "none" + w(f"| `include/{os.path.basename(h)}` | {cell} |\n") w("\n") w("
Full directory edge list\n\n") From 3a67b0bbebfccce4af9e84d577fc9a380cd88c0c Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 25 Aug 2026 09:03:54 +1000 Subject: [PATCH 3/3] rtapi: stop exporting the vsnprintf implementation rtapi_vsnprintf.h is 475 lines of implementation, not an interface, and the only code that includes it is rtai_rtapi.c beside it and the unit test. The documented entry point, rtapi_vsnprintf(), is declared in rtapi.h and stays exported, so nothing an out-of-tree component may legitimately call moves. The header goes to rtapi/ and rtai_rtapi.c takes it from its own directory. The three exported headers it pulls in go angled, since they are no longer beside it. tests/rtapi_printf.0 compiles the header, so it now needs the source tree and is skipped on installed packages, the same way tests/blendmath already is. --- src/rtapi/rtai_rtapi.c | 2 +- {include => src/rtapi}/rtapi_vsnprintf.h | 6 +++--- tests/rtapi_printf.0/skip | 4 ++++ tests/rtapi_printf.0/test.sh | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) rename {include => src/rtapi}/rtapi_vsnprintf.h (99%) create mode 100755 tests/rtapi_printf.0/skip diff --git a/src/rtapi/rtai_rtapi.c b/src/rtapi/rtai_rtapi.c index f3c73c9befb..035aa602cd0 100644 --- a/src/rtapi/rtai_rtapi.c +++ b/src/rtapi/rtai_rtapi.c @@ -73,7 +73,7 @@ #include /* NR_CPUS, cpu_online() */ -#include +#include "rtapi_vsnprintf.h" #include #include diff --git a/include/rtapi_vsnprintf.h b/src/rtapi/rtapi_vsnprintf.h similarity index 99% rename from include/rtapi_vsnprintf.h rename to src/rtapi/rtapi_vsnprintf.h index 64e216d3f8c..18d0481d9a8 100644 --- a/include/rtapi_vsnprintf.h +++ b/src/rtapi/rtapi_vsnprintf.h @@ -38,9 +38,9 @@ values (or floating point). #include #include -#include "rtapi_ctype.h" -#include "rtapi_math.h" -#include "rtapi_string.h" +#include +#include +#include /* we use this so that we can do without the string library */ static int strn_len(const char *s, int count) diff --git a/tests/rtapi_printf.0/skip b/tests/rtapi_printf.0/skip new file mode 100755 index 00000000000..44b54e6d2cd --- /dev/null +++ b/tests/rtapi_printf.0/skip @@ -0,0 +1,4 @@ +#!/bin/sh +# This test compiles rtapi_vsnprintf.h from the source tree, which is only +# available in run-in-place builds. Skip when testing installed packages. +[ -z "$SYSTEM_BUILD" ] diff --git a/tests/rtapi_printf.0/test.sh b/tests/rtapi_printf.0/test.sh index cb29b975ab2..49397382a0c 100755 --- a/tests/rtapi_printf.0/test.sh +++ b/tests/rtapi_printf.0/test.sh @@ -1,6 +1,6 @@ #!/bin/bash -xe -g++ -DULAPI -I"${HEADERS}" -std=c++0x \ +g++ -DULAPI -I"${EMC2_HOME}/src/rtapi" -I"${HEADERS}" -std=c++0x \ -DSIM -rdynamic -L"${LIBDIR}" \ -o test_rtapi_vsnprintf test_rtapi_vsnprintf.c ./test_rtapi_vsnprintf