# This is a skeleton makefile for a subdirectory

# FOOSRCS is a nice way to collect some source file names.  Use $(patsubst) or
# $(addprefix) if you are listing a bunch of files from a subdirectory and
# would like to save a few keystrokes.
FOOSRCS := \
	path/src.cc
USERSRCS += $(FOOSRCS)

# This next line causes things in FOOSRCS to be compiled with an extra
# preprocessor symbol defined.  EXTRAFLAGS can be used to specify any C
# compiler flag.
$(call TOOBJSDEPS, $(FOOSRCS)) : EXTRAFLAGS = -Dfoo

# This is how the binary 'foo' is linked.
../bin/foo: $(call TOOBJS, $(FOOSRCS)) ../lib/libemc.a ../lib/libnml.so.0
	$(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 rtapi/Submakefile for an example of how to make some other kind of
# file (in this case, ../etc/linuxcnc/rtapi.ini)


# building specific objects with specific flags:
#
# first, the layout of build artefacts:
#
# - all build artecfacts live under src/objects/
#
# - the src/ hierarchy is replicated under src/objects for normal
#   userland build artefacts, so there will be:
#   src/objects/emc
#   src/objects/hal
#   src/objects/emc/libnml etc
#
# - for RT objects, there will be one <flavor> subdirectory under
#   src/objects, where flavor is one of:
#       posix xenomai rt-preempt rtai-kernel xenomai-kernel
#
# now, to compile a specifc object file with a certain CFLAG, specify
# a rule like so:
#
# objects/<path-to-object-possibly-with-wildcards>: EXTRA_CFLAGS += <whatever>
#
# example 1/RT: compile emc/tp/tp.o with -DFOO for all flavors:
#
# objects/*/emc/tp/tp.o:  EXTRA_CFLAGS += -DFOO
#
# example 2/RT: compile the complete emc/tp/* subdirectory for the Xenomai flavor only,
#            with -DBAR:
# objects/xenomai/emc/tp/*.o: EXTRA_CFLAGS += -DBAR
#
# the same goes for EXTRA_LDFLAGS for the link phase of RT objects.


# NB: for plain (non-RT) userland flags, the make variable is EXTRAFLAGS,
# not EXTRA_CFLAGS (!)
# so, example 3/userland: compile src/libnml/inifile/inivar.c with -DBAZ:
#
#objects/libnml/inifile/inivar.o: EXTRAFLAGS += -DBAZ
#
# to link a certain userland target with custom ld flags, add a rule like so:
# ../libexec/inivar: LDFLAGS += <my custom linker flags>
#
#
# how's that for regularity?
#
#
# custom flags for RT objects - kernel modules:
# I dont know yet.
