Skip to content

Commit 349df77

Browse files
authored
Merge pull request #3837 from BsAtHome/fix_includes
build: Fix include copying, references and RT/non-RT isolation
2 parents 656c300 + 82f05bc commit 349df77

File tree

414 files changed

+1353
-1635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

414 files changed

+1353
-1635
lines changed

src/Makefile

Lines changed: 34 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ cxx-option = $(shell if $(CXX) $(CXXFLAGS) $(1) -S -o /dev/null -xc++ /dev/null
135135
ifeq ($(origin KERNELRELEASE),undefined)
136136
# When KERNELRELEASE is not defined, this is the userspace build.
137137
# The "modules" target is the gateway to the kernel module build.
138-
build-software: userspace modules
138+
build-software: headers userspace modules
139139
ifeq ($(RUN_IN_PLACE),yes)
140140
ifneq ($(BUILD_SYS),uspace)
141141
@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
@@ -245,7 +245,7 @@ $(shell $(VECHO) 1>&2 Done reading dependencies)
245245
endif
246246

247247
# Each directory in $(INCLUDES) is passed as a -I directory when compiling.
248-
INCLUDE := $(patsubst %,-I%, $(INCLUDES)) -I$(RTDIR)/include
248+
INCLUDE := $(patsubst %,-I%, $(INCLUDES)) -I$(RTDIR)/../include
249249
INCLUDE += $(PYTHON_CPPFLAGS)
250250
INCLUDE += $(LIBTIRPC_CFLAGS)
251251

@@ -288,6 +288,7 @@ $(sort $(patsubst %.cpp,objects/%.o,$(filter %.cpp,$(RUCKIG_CXX_FILES)))) : obje
288288
@mkdir -p $(dir $@)
289289
@rm -f $@
290290
$(Q)$(CXX) -c $(CXXFLAGS) $(EXTRAFLAGS) -std=c++20 \
291+
-I$(BASEPWD)/emc/tp/ruckig/include \
291292
-MP -MD -MF "${@:.o=.d}" -MT "$@" \
292293
$< -o $@
293294

@@ -296,6 +297,7 @@ $(sort $(patsubst %.cc,objects/%.o,$(filter %.cc,$(RUCKIG_CXX_FILES)))) : object
296297
@mkdir -p $(dir $@)
297298
@rm -f $@
298299
$(Q)$(CXX) -c $(CXXFLAGS) $(EXTRAFLAGS) -std=c++20 \
300+
-I$(BASEPWD)/emc/tp/ruckig/include \
299301
-MP -MD -MF "${@:.o=.d}" -MT "$@" \
300302
$< -o $@
301303

@@ -377,117 +379,46 @@ INFILES = \
377379
$(INFILES): %: %.in config.status
378380
@./config.status --file=$@
379381

380-
build-software: $(INFILES)
382+
build-software: headers $(INFILES)
381383

382384
# For each file to be copied to ../include, its location in the source tree
383-
# is listed here. Note that due to $(INCLUDE), defined above, the include
384-
# files in the source tree are the ones used when building linuxcnc. The copy
385-
# in ../include is used when building external components of linuxcnc.
385+
# is listed here.
386+
# Note that due to $(INCLUDE), defined above, the include files in the source
387+
# tree are normally the ones used or not found at all when building linuxcnc if
388+
# you are not aware of the differences between "" and <> includes.
389+
#
390+
# All sources should #include <> (like in #include <rtapi.h>) for these special
391+
# headers in the ../include directory to ensure they are used.
392+
# The *only* exception is those sources that use the include and reside in the
393+
# /same/ source directory as the include. That means that the local version
394+
# should have precedence over the global one.
395+
#
396+
# If you add to these headers, then you must make absolutely sure that they are
397+
# required for out-of-tree components and that the proper #include type is
398+
# used.
399+
#
386400
SRCHEADERS := \
401+
hal/hal.h \
402+
hal/drivers/mesa-hostmot2/hostmot2-serial.h \
387403
emc/linuxcnc.h \
388-
emc/ini/emcIniFile.hh \
389-
emc/ini/iniaxis.hh \
390-
emc/ini/inijoint.hh \
391-
emc/ini/inispindle.hh \
392-
emc/ini/initraj.hh \
393-
emc/ini/inihal.hh \
394-
emc/kinematics/cubic.h \
395404
emc/kinematics/kinematics.h \
396-
emc/kinematics/switchkins.h \
397-
emc/kinematics/genhexkins.h \
398-
emc/kinematics/genserkins.h \
399-
emc/kinematics/pentakins.h \
400-
emc/kinematics/pumakins.h \
401-
emc/tp/tc.h \
402-
emc/tp/tc_types.h \
403-
emc/tp/tcq.h \
404-
emc/tp/tp.h \
405-
emc/tp/tp_types.h \
406-
emc/tp/spherical_arc.h \
407-
emc/tp/blendmath.h \
408405
emc/motion/emcmotcfg.h \
409-
emc/motion/motion.h \
410-
emc/motion/homing.h \
411-
emc/motion/simple_tp.h \
412-
emc/motion/sp_scurve.h \
413-
emc/motion/state_tag.h \
414-
emc/motion/usrmotintf.h \
415-
emc/motion/axis.h \
416-
emc/nml_intf/canon.hh \
417-
emc/nml_intf/canon_position.hh \
418-
emc/nml_intf/emctool.h \
419-
emc/nml_intf/emc.hh \
420-
emc/nml_intf/emc_nml.hh \
421-
emc/nml_intf/emccfg.h \
422-
emc/nml_intf/emcglb.h \
423406
emc/nml_intf/emcpos.h \
424407
emc/nml_intf/emcpose.h \
425-
emc/nml_intf/interp_return.hh \
426-
emc/nml_intf/interpl.hh \
427408
emc/nml_intf/motion_types.h \
428-
emc/nml_intf/debugflags.h \
429-
emc/rs274ngc/interp_internal.hh \
430-
emc/rs274ngc/interp_fwd.hh \
431-
emc/rs274ngc/interp_base.hh \
432-
emc/rs274ngc/modal_state.hh \
433-
emc/rs274ngc/rs274ngc.hh \
434-
emc/rs274ngc/saicanon.hh \
435-
emc/tooldata/tooldata.hh \
436-
hal/hal.h \
437-
hal/hal_parport.h \
438-
hal/drivers/mesa-hostmot2/hostmot2-serial.h \
439-
libnml/buffer/locmem.hh \
440-
libnml/buffer/memsem.hh \
441-
libnml/buffer/phantom.hh \
442-
libnml/buffer/physmem.hh \
443-
libnml/buffer/recvn.h \
444-
libnml/buffer/rem_msg.hh \
445-
libnml/buffer/sendn.h \
446-
libnml/buffer/shmem.hh \
447-
libnml/buffer/tcpmem.hh \
448-
libnml/cms/cms.hh \
449-
libnml/cms/cms_aup.hh \
450-
libnml/cms/cms_cfg.hh \
451-
libnml/cms/cms_dup.hh \
452-
libnml/cms/cms_srv.hh \
453-
libnml/cms/cms_up.hh \
454-
libnml/cms/cms_user.hh \
455-
libnml/cms/cms_xup.hh \
456-
libnml/cms/cmsdiag.hh \
457-
libnml/cms/tcp_opts.hh \
458-
libnml/cms/tcp_srv.hh \
459-
libnml/inifile/inifile.h \
460-
libnml/inifile/inifile.hh \
461-
libnml/linklist/linklist.hh \
462-
libnml/nml/cmd_msg.hh \
463-
libnml/nml/nml.hh \
464-
libnml/nml/nml_oi.hh \
465-
libnml/nml/nml_srv.hh \
466-
libnml/nml/nml_type.hh \
467-
libnml/nml/nmldiag.hh \
468-
libnml/nml/nmlmsg.hh \
469-
libnml/nml/stat_msg.hh \
470-
libnml/os_intf/_sem.h \
471-
libnml/os_intf/sem.hh \
472-
libnml/os_intf/_shm.h \
473-
libnml/os_intf/shm.hh \
474-
libnml/os_intf/_timer.h \
475-
libnml/os_intf/timer.hh \
476-
libnml/posemath/posemath.h \
477-
libnml/posemath/gotypes.h \
478409
libnml/posemath/gomath.h \
410+
libnml/posemath/gotypes.h \
411+
libnml/posemath/posemath.h \
479412
libnml/posemath/sincos.h \
480-
libnml/rcs/rcs.hh \
481-
libnml/rcs/rcs_exit.hh \
482-
libnml/rcs/rcs_print.hh \
483-
libnml/rcs/rcsversion.h \
484413
rtapi/rtapi.h \
485414
rtapi/rtapi_app.h \
486415
rtapi/rtapi_atomic.h \
487416
rtapi/rtapi_bitops.h \
488417
rtapi/rtapi_bool.h \
489418
rtapi/rtapi_byteorder.h \
419+
rtapi/rtapi_ctype.h \
490420
rtapi/rtapi_device.h \
421+
rtapi/rtapi_errno.h \
491422
rtapi/rtapi_firmware.h \
492423
rtapi/rtapi_gfp.h \
493424
rtapi/rtapi_io.h \
@@ -501,8 +432,6 @@ SRCHEADERS := \
501432
rtapi/rtapi_pci.h \
502433
rtapi/rtapi_slab.h \
503434
rtapi/rtapi_stdint.h \
504-
rtapi/rtapi_ctype.h \
505-
rtapi/rtapi_errno.h \
506435
rtapi/rtapi_string.h \
507436
rtapi/rtapi_vsnprintf.h
508437

@@ -652,10 +581,10 @@ endif
652581
# These rules allows a header file from this directory to be installed into
653582
# ../include. A pair of rules like these will exist in the Submakefile
654583
# of each file that contains headers.
655-
$(patsubst %,../include/%,$(wildcard *.h)): ../include/%.h: %.h
656-
$(Q)-cp $^ $@
657-
$(patsubst %,../include/%,$(wildcard *.hh)): ../include/%.hh: %.hh
658-
$(Q)-cp $^ $@
584+
#$(patsubst %,../include/%,$(wildcard *.h)): ../include/%.h: %.h
585+
# $(Q)-cp $^ $@
586+
#$(patsubst %,../include/%,$(wildcard *.hh)): ../include/%.hh: %.hh
587+
# $(Q)-cp $^ $@
659588

660589
INSTALL=install -o root
661590
DIR=$(INSTALL) -d -m 0755
@@ -924,11 +853,8 @@ endif
924853
# "kbuild" system. $(BASEPWD) is used here, instead of relative paths, because
925854
# that's what kbuild seems to require
926855

927-
EXTRA_CFLAGS := $(filter-out -ffast-math,$(RTFLAGS)) -D__MODULE__ -I$(BASEPWD)/../include -I$(BASEPWD) -I$(BASEPWD)/libnml/linklist -I$(BASEPWD)/emc/tp/ruckig/include \
928-
-I$(BASEPWD)/libnml/cms -I$(BASEPWD)/libnml/rcs -I$(BASEPWD)/libnml/inifile \
929-
-I$(BASEPWD)/libnml/os_intf -I$(BASEPWD)/libnml/nml -I$(BASEPWD)/libnml/buffer \
930-
-I$(BASEPWD)/libnml/posemath -I$(BASEPWD)/rtapi -I$(BASEPWD)/hal \
931-
-I$(BASEPWD)/emc/nml_intf -I$(BASEPWD)/emc/kinematics -I$(BASEPWD)/emc/tp -I$(BASEPWD)/emc/motion \
856+
EXTRA_CFLAGS := $(filter-out -ffast-math,$(RTFLAGS)) -D__MODULE__ \
857+
-I$(BASEPWD)/../include \
932858
-DSEQUENTIAL_SUPPORT -DHAL_SUPPORT -DDYNAMIC_PLCSIZE -DRT_SUPPORT -DOLD_TIMERS_MONOS_SUPPORT -DMODBUS_IO_MASTER \
933859
-fno-fast-math $(call cc-option,-mieee-fp) -fno-unsafe-math-optimizations \
934860
-Wno-declaration-after-statement \
@@ -1351,6 +1277,7 @@ objects/rtemc/tp/ruckig_wrapper.o : emc/tp/ruckig_wrapper.cc
13511277
@rm -f $@
13521278
@mkdir -p $(dir $@)
13531279
$(Q)$(CXX) -c $(OPT) $(DEBUG) $(EXTRA_DEBUG) -DRTAPI -std=c++20 \
1280+
-I$(BASEPWD)/emc/tp/ruckig/include \
13541281
$(RUCKIG_CXXFLAGS) \
13551282
-MP -MD -MF "${@:.o=.d}" -MT "$@" \
13561283
$< -o $@
@@ -1361,6 +1288,7 @@ objects/rtemc/tp/ruckig/src/ruckig/%.o : emc/tp/ruckig/src/ruckig/%.cpp
13611288
@rm -f $@
13621289
@mkdir -p $(dir $@)
13631290
$(Q)$(CXX) -c $(OPT) $(DEBUG) $(EXTRA_DEBUG) -DRTAPI -std=c++20 \
1291+
-I$(BASEPWD)/emc/tp/ruckig/include \
13641292
$(RUCKIG_CXXFLAGS) \
13651293
-MP -MD -MF "${@:.o=.d}" -MT "$@" \
13661294
$< -o $@

src/emc/Submakefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
INCLUDES += emc
22

3-
$(patsubst ./emc/%,../include/%,$(wildcard ./emc/*.h)): ../include/%.h: ./emc/%.h
4-
cp $^ $@
5-
6-
$(patsubst ./emc/%,../include/%,$(wildcard ./emc/*.hh)): ../include/%.hh: ./emc/%.hh
3+
# linuxcnc.h has some generic defines for many interfaces
4+
../include/linuxcnc.h: ./emc/linuxcnc.h
75
cp $^ $@

src/emc/canterp/canterp.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
#include <ctype.h> // isspace()
5555
#include <limits.h>
5656
#include <algorithm>
57+
#include <linuxcnc.h>
5758
#include "config.h"
58-
#include "emc/linuxcnc.h"
59-
#include "emc/nml_intf/interp_return.hh"
60-
#include "emc/nml_intf/canon.hh"
61-
#include "emc/rs274ngc/interp_base.hh"
62-
#include "modal_state.hh"
59+
#include "nml_intf/interp_return.hh"
60+
#include "nml_intf/canon.hh"
61+
#include "rs274ngc/interp_base.hh"
62+
#include "rs274ngc/modal_state.hh"
6363

6464
static char the_command[LINELEN] = { 0 }; // our current command
6565
static char the_command_name[LINELEN] = { 0 }; // just the name part

src/emc/ini/Submakefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
INCLUDES += emc/ini
2-
3-
$(patsubst ./emc/ini/%,../include/%,$(wildcard ./emc/ini/*.h)): ../include/%.h: ./emc/ini/%.h
4-
cp $^ $@
5-
$(patsubst ./emc/ini/%,../include/%,$(wildcard ./emc/ini/*.hh)): ../include/%.hh: ./emc/ini/%.hh
6-
cp $^ $@
71

82
../bin/update_ini: emc/ini/update_ini.py
93
@$(ECHO) Syntax checking python script $(notdir $@)

src/emc/ini/emcIniFile.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#ifndef _EMCINIFILE_HH_
3333
#define _EMCINIFILE_HH_
3434

35-
#include "emc.hh"
36-
#include "inifile.hh"
35+
#include "nml_intf/emc.hh"
36+
#include "libnml/inifile/inifile.hh"
3737

3838

3939
class EmcIniFile : public IniFile {

src/emc/ini/iniaxis.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#include <sys/types.h>
2222
#include <sys/stat.h>
2323

24-
#include "emc.hh"
25-
#include "rcs_print.hh"
24+
#include "nml_intf/emc.hh"
25+
#include "libnml/rcs/rcs_print.hh"
2626
#include "emcIniFile.hh"
2727
#include "iniaxis.hh" // these decls
28-
#include "emcglb.h" // EMC_DEBUG
29-
#include "emccfg.h" // default values for globals
28+
#include "nml_intf/emcglb.h" // EMC_DEBUG
29+
#include "nml_intf/emccfg.h" // default values for globals
3030

3131
#include "inihal.hh"
3232

src/emc/ini/iniaxis.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef INIAXIS_HH
1515
#define INIAXIS_HH
1616

17-
#include "emc.hh" // EMC_AXIS_STAT
17+
#include "nml_intf/emc.hh" // EMC_AXIS_STAT
1818

1919
/* initializes axis modules from INI file */
2020
extern int iniAxis(int axis, const char *filename);

src/emc/ini/inihal.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ You should have received a copy of the GNU General Public License
1818
along with this program; if not, write to the Free Software
1919
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020
----------------------------------------------------------------------*/
21-
#include "rcs_print.hh"
22-
#include "emc.hh"
23-
#include "emcglb.h"
21+
#include "libnml/rcs/rcs_print.hh"
22+
#include "nml_intf/emc.hh"
23+
#include "nml_intf/emcglb.h"
2424
#include <stdio.h>
25-
#include "hal.h"
26-
#include "rtapi.h"
25+
#include <hal.h>
26+
#include <rtapi.h>
2727
#include "inihal.hh"
2828
#include "iniaxis.hh"
2929
#include "inispindle.hh"

src/emc/ini/inihal.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1919
----------------------------------------------------------------------*/
2020
#ifndef INIHAL_H
2121
#define INIHAL_H
22-
#include "hal.h"
23-
#include "emcmotcfg.h"
22+
#include <hal.h>
23+
#include <emcmotcfg.h>
2424

2525
int check_ini_hal_items(int numjoints);
2626
int ini_hal_init(int numjoints);

src/emc/ini/inijoint.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
#include <sys/types.h>
2020
#include <sys/stat.h>
2121

22-
#include "emc.hh"
23-
#include "rcs_print.hh"
22+
#include "nml_intf/emc.hh"
23+
#include "libnml/rcs/rcs_print.hh"
2424
#include "emcIniFile.hh"
2525
#include "inijoint.hh" // these decls
26-
#include "emcglb.h" // EMC_DEBUG
27-
#include "emccfg.h" // default values for globals
26+
#include "nml_intf/emcglb.h" // EMC_DEBUG
27+
#include "nml_intf/emccfg.h" // default values for globals
2828

2929
#include "inihal.hh"
3030

0 commit comments

Comments
 (0)