From 2774865951f0a95ef6cc65e47640c54abf5f80ee Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Thu, 15 Oct 2026 11:39:41 +1100 Subject: [PATCH 1/3] include: keep the exported headers where they are used from The 39 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. 27 include sites in 24 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. The cppcheck job ran "make headers" so that include/ was populated before checking; include/ is now populated in the checkout, so that step and its build-headers.sh script go too. --- .github/scripts/build-headers.sh | 11 --- .github/workflows/ci.yml | 4 - 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/ini => include}/axis_kinds.hh | 0 {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 {src/emc/kinematics => include}/switchkins.h | 0 lib/python/mtc/kinematics.py | 2 +- src/Makefile | 85 ++----------------- src/Submakefile.skel | 3 +- src/emc/ini/inifile.cc | 2 +- src/emc/kinematics/switchkins.c | 2 +- src/emc/kinematics/switchkins_main.c | 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 +- 75 files changed, 43 insertions(+), 132 deletions(-) delete mode 100755 .github/scripts/build-headers.sh delete mode 100644 include/.gitignore rename {src/emc/ini => include}/axis_kinds.hh (100%) 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%) rename {src/emc/kinematics => include}/switchkins.h (100%) diff --git a/.github/scripts/build-headers.sh b/.github/scripts/build-headers.sh deleted file mode 100755 index da4b339d46c..00000000000 --- a/.github/scripts/build-headers.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -eu #Needed so CI fails when anything is wrong -set -x - -#Any arguments are passed to configure - -cd src -./autogen.sh -./configure "$@" --disable-check-runtime-deps --enable-werror -make headers diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f943a1152a9..d412317f24f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -219,10 +219,6 @@ jobs: set -x .github/scripts/install-deps.sh sudo apt-get --yes install cppcheck - - name: Build headers - run: | - set -x - .github/scripts/build-headers.sh --with-realtime=uspace - name: Cppcheck run: | set -x diff --git a/debian/copyright b/debian/copyright index 2990935668f..61a2dc22b4f 100644 --- a/debian/copyright +++ b/debian/copyright @@ -241,7 +241,6 @@ Files: src/hal/drivers/hal_pi_gpio.c src/hal/drivers/hal_ppmc.c src/hal/drivers/hal_speaker.c - 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 @@ -276,6 +275,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 @@ -331,7 +331,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 d0c85851c79..dc81d1257e9 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 4309238f2df..6829973a010 100644 --- a/docs/src/config/core-components.adoc +++ b/docs/src/config/core-components.adoc @@ -123,7 +123,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' - (bool, out) TRUE if the machine is in position. * 'motion.motion-enabled' - (bool, out) TRUE when in 'machine on' state. -* 'motion.motion-type' - (sint, out) These values are from src/emc/nml_intf/motion_types.h +* 'motion.motion-type' - (sint, 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 3f16d6cdbee..d81fed1c8ed 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 da53187d3e8..69ac0e52dec 100644 --- a/docs/src/man/man9/motion.9.adoc +++ b/docs/src/man/man9/motion.9.adoc @@ -224,7 +224,7 @@ Note: feed-inhibit applies to G-code commands -- not jogs. *motion.motion-enabled* OUT BOOL:: + *motion.motion-type* OUT SINT:: - 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/ini/axis_kinds.hh b/include/axis_kinds.hh similarity index 100% rename from src/emc/ini/axis_kinds.hh rename to include/axis_kinds.hh 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/src/emc/kinematics/switchkins.h b/include/switchkins.h similarity index 100% rename from src/emc/kinematics/switchkins.h rename to include/switchkins.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 b00a222f23e..df19b0c3dc7 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,79 +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/kinematics/switchkins.h \ - emc/nml_intf/emcmotcfg.h \ - emc/ini/axis_kinds.hh \ - 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)) @@ -515,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 b6fe5694e8c..530f5c907f1 100644 --- a/src/emc/ini/inifile.cc +++ b/src/emc/ini/inifile.cc @@ -32,7 +32,7 @@ #include "nml_intf/emc.hh" -#include "inifile.hh" +#include using namespace linuxcnc; diff --git a/src/emc/kinematics/switchkins.c b/src/emc/kinematics/switchkins.c index 472394cefdd..2509e4a9d47 100644 --- a/src/emc/kinematics/switchkins.c +++ b/src/emc/kinematics/switchkins.c @@ -30,7 +30,7 @@ #include #include -#include "switchkins.h" +#include //********************************************************************* // kinematic functions (default=0 for err detection): diff --git a/src/emc/kinematics/switchkins_main.c b/src/emc/kinematics/switchkins_main.c index 4a4cc05153c..38f726e1e43 100644 --- a/src/emc/kinematics/switchkins_main.c +++ b/src/emc/kinematics/switchkins_main.c @@ -27,7 +27,7 @@ #include #include -#include "switchkins.h" +#include static char *coordinates; RTAPI_MP_STRING(coordinates, "Axes-to-joints-ordering"); diff --git a/src/emc/nml_intf/emc.cc b/src/emc/nml_intf/emc.cc index 22d49402a16..da9b88e1e78 100644 --- a/src/emc/nml_intf/emc.cc +++ b/src/emc/nml_intf/emc.cc @@ -23,7 +23,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 f9c8ff80a3f..d251e08abc6 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 34e6133d942..7961bdf32b2 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 a17372a43ff..79d80d46a21 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 c15efe70add..f2c92d8bc10 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 0c4cc2322f1..c6f90746848 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 699eabb36c7..2b4bcb0f9a6 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 43e55b6b5a6..20e1ab1871c 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 32c5ddd8df4..9946f3d16d1 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 f4448fc392a991ae6f0d377cc16cd1425fe4b862 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 2d7d09ac7ae2cfcdb9427cfc89a2b6cb07b98dc4 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 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 f2c92d8bc10..3eb1bae6101 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