RN rnmake  3.0.0
Rules.mk
Go to the documentation of this file.
1 ################################################################################
2 #
3 # Rules.mk
4 #
5 ifdef RNMAKE_DOXY
6 /*!
7 \file
8 
9 \brief Master file for defining rules for make targets, variables, and macros.
10 
11 Include this file in each local make file (usually near the bottom).
12 
13 \pkgsynopsis
14 RN Make System
15 
16 \pkgfile{Rules.mk}
17 
18 \pkgauthor{Robin Knight,robin.knight@roadnarrows.com}
19 
20 \pkgcopyright{2005-2018,RoadNarrows LLC,http://www.roadnarrows.com}
21 
22 \license{MIT}
23 
24 \EulaBegin
25 \EulaEnd
26 
27 \cond RNMAKE_DOXY
28  */
29 endif
30 #
31 ################################################################################
32 
33 _RULES_MK = 1
34 
35 #------------------------------------------------------------------------------
36 # Prelims
37 
38 # this makefile is last in the list (must call before any includes from this)
39 RNMAKE_ROOT = $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
40 
41 # version of these makefile rules
42 RNMAKE_RULES_VER_MAJOR := 3
43 RNMAKE_RULES_VER_MINOR := 0
44 
45 # default goal
46 .DEFAULT_GOAL := all
47 
48 # list of command-line goals
49 GOAL_LIST = $(MAKECMDGOALS)
50 
51 # add default if empty
52 ifeq "$(GOAL_LIST)" ""
53  GOAL_LIST = $(.DEFAULT_GOAL)
54 endif
55 
56 # save first and last goals
57 FIRST_GOAL = $(firstword $(GOAL_LIST))
58 LAST_GOAL = $(lastword $(GOAL_LIST))
59 
60 # list of goals with subdirectory traversals
61 GOALS_WITH_SUBDIRS =
62 
63 
64 #------------------------------------------------------------------------------
65 # Environment (Env.mk)
66 #
67 # Parse rnmake specific command-line and environment variables.
68 
69 ifeq ($(_ENV_MK),)
70 include $(RNMAKE_ROOT)/Env.mk
71 endif
72 
73 #------------------------------------------------------------------------------
74 # Standard collection of RN Make System functions and varibbles (Std.mk)
75 
76 ifeq ($(_STD_MK),)
77 include $(RNMAKE_ROOT)/Std.mk
78 endif
79 
80 #------------------------------------------------------------------------------
81 # Print help (Help.mk)
82 #
83 # Check if any of the make goals contain help goals. If true, include the
84 # help makefile, which defines the help[-<subhelp>] rules.
85 
86 $(call includeIfGoals,help help-%,$(RNMAKE_ROOT)/Help.mk)
87 
88 #------------------------------------------------------------------------------
89 # Compile and run unit tests (Rules.test.mk)
90 #
91 # Check if any of the make goals contain test goals. If true, include the
92 # test makefile, which defines the [run-]test rules.
93 
94 $(call includeIfGoals,test run-test,$(RNMAKE_ROOT)/Rules.test.mk)
95 
96 #------------------------------------------------------------------------------
97 # Documentation makes (Rules.doc.mk)
98 #
99 # Check if any of the make goals contain documentation goals. If true, include
100 # the doc package makefile, which defines the documents and docs-<type> rules.
101 
102 $(call includeIfGoals,install install-docs documents docs-%,\
103  $(RNMAKE_ROOT)/Rules.doc.mk)
104 
105 #------------------------------------------------------------------------------
106 # Tarball package repo builds (Rules.tarball.mk)
107 #
108 # Check if any of the make goals contain tarball goals. If true, include the
109 # tarball package makefile, which defines the tarballs and tarball-<type> rules.
110 
111 $(call includeIfGoals,tarballs tarball-%,$(RNMAKE_ROOT)/Rules.tarball.mk)
112 
113 #------------------------------------------------------------------------------
114 # Debian package repo builds (Rules.dpkg.mk)
115 #
116 # Check if any of the make goals contain debian package goals. If true,
117 # include the debian package makefile, which defines the deb-pkgs and
118 # deb-pkg-<type> rules.
119 
120 $(call includeIfGoals,deb-pkgs deb-pkg-%,$(RNMAKE_ROOT)/Rules.dpkg.mk)
121 
122 
123 # -------------------------------------------------------------------------
124 # Architecture Dependent Definitions
125 
126 # Standard rnmake rules do not support the following targets.
127 ifneq "$(findstring $(RNMAKE_ARCH_TAG),atmega16)" ""
128  $(error Rules.mk does not support $(arch) rules)
129 endif
130 
131 # architecture makefile name
132 RNMAKE_ARCH_MKFILE = $(call findReqFile,\
133  $(RNMAKE_ROOT)/Arch/Arch.$(RNMAKE_ARCH_TAG).mk,\
134  See $(RNMAKE_ROOT)/Arch for available architectures)
135 
136 # Include the architecture make file.
137 ifeq ($(_ARCH_$(RNMAKE_ARCH_TAG)_MK),)
138  include $(RNMAKE_ARCH_MKFILE)
139 endif
140 
141 # Included architecture makefile must define RNMAKE_ARCH which defines the
142 # real architecture.
143 ifeq ($(RNMAKE_ARCH),)
144  $(error 'RNMAKE_ARCH': Not defined in including arhitecture makefile)
145 endif
146 
147 
148 #------------------------------------------------------------------------------
149 # Package Master Makefile (required)
150 #
151 
152 # must be defined in including makefile
153 ifeq ($(RNMAKE_PKG_ROOT),)
154  $(error 'RNMAKE_PKG_ROOT': Not defined in including Makefile)
155 endif
156 
157 # package makefile
158 RNMAKE_PKG_MKFILE = $(call findReqFile,$(RNMAKE_PKG_ROOT)/make/Pkg.mk,)
159 
160 # package root absolute path
161 RNMAKE_PKG_ROOT := $(realpath $(RNMAKE_PKG_ROOT))
162 
163 # required
164 ifeq ($(_PKG_MK),)
165 include $(RNMAKE_PKG_MKFILE)
166 endif
167 
168 # Included package master makefile must define RNMAKE_PKG which defines the
169 # package name.
170 ifeq ($(RNMAKE_PKG),)
171  $(error 'RNMAKE_PKG': Not defined in including arhitecture makefile)
172 endif
173 
174 
175 #------------------------------------------------------------------------------
176 # Product Makefile (Optional)
177 
178 ifdef RNMAKE_PROD_MKFILE
179  ifeq ($(_PROD_MK),)
180  # optionally include (no error if not found)
181  -include $(RNMAKE_PROD_MKFILE)
182  endif
183 endif
184 
185 
186 #------------------------------------------------------------------------------
187 # Include helper make files (Cmds.mk, Colors.mk)
188 #
189 # Can conditionally define macros by architecuture definitions included above.
190 #
191 
192 # basic host commands
193 ifeq ($(_CMDS_MK),)
194 include $(RNMAKE_ROOT)/Cmds.mk
195 endif
196 
197 # color schemes
198 ifeq ($(_COLORS_MK),)
199 ifneq "$(color)" "off"
200 include $(RNMAKE_ROOT)/Colors.mk
201 endif
202 endif
203 
204 
205 #------------------------------------------------------------------------------
206 # Install Directories - Override as necessary in including Makefile.
207 #
208 # Note: These are traditional configuration names - keep the naming convention.
209 
210 prefix := $(RNMAKE_INSTALL_PREFIX)
211 ifeq ($(prefix),)
212  prefix := $(RNMAKE_INSTALL_XPREFIX)/$(RNMAKE_ARCH)
213 endif
214 
215 exec_prefix ?= $(prefix)
216 bindir ?= $(exec_prefix)/bin
217 sbindir ?= $(exec_prefix)/sbin
218 libexecdir ?= $(exec_prefix)/libexec
219 sysconfdir ?= $(prefix)/etc
220 localstatedir ?= $(prefix)/var
221 libdir ?= $(exec_prefix)/lib
222 includedir ?= $(prefix)/include
223 sharedir ?= $(prefix)/share
224 infodir ?= $(prefix)/info
225 docdir ?= $(prefix)/share/doc
226 mandir ?= $(prefix)/man
227 
228 
229 #------------------------------------------------------------------------------
230 # Distribution Directories (Architecture Dependent)
231 
232 DIST_ROOT = $(RNMAKE_PKG_ROOT)/dist
233 DIST_ARCH = $(DIST_ROOT)/dist.$(RNMAKE_ARCH)
234 
235 # Distributions Directories
236 DISTDIR_BIN = $(DIST_ARCH)/bin
237 DISTDIR_LIB = $(DIST_ARCH)/lib
238 
239 DISTDIR_INCLUDE = $(DIST_ARCH)/include
240 DISTDIR_ETC = $(DIST_ARCH)/etc
241 DISTDIR_MAN = $(DIST_ARCH)/man
242 DISTDIR_SHARE = $(DIST_ARCH)/share/$(RNMAKE_PKG_FULL_NAME)
243 DISTDIR_DOC = $(DIST_ARCH)/doc/$(RNMAKE_PKG_FULL_NAME)-doc
244 DISTDIR_SRC = $(DIST_ARCH)/src/$(RNMAKE_PKG_FULL_NAME)
245 DISTDIR_REPO = $(DIST_ARCH)/repo
246 DISTDIR_TMP = $(DIST_ARCH)/tmp
247 DISTDIR_LIST = $(DISTDIR_BIN) \
248  $(DISTDIR_INCLUDE) \
249  $(DISTDIR_LIB) \
250  $(DISTDIR_ETC) \
251  $(DISTDIR_SHARE) \
252  $(DISTDIR_DOC) \
253  $(DISTDIR_SRC) \
254  $(DISTDIR_REPO) \
255  $(DISTDIR_TMP) \
256  $(DISTDIR_MAN)
257 
258 # documentation subdirectories
259 DIST_SRCDOC = srcdoc
260 DISTDIR_DOC_SRC = $(DISTDIR_DOC)/$(DIST_SRCDOC)
261 DISTDIR_DOC_SRC_IMG = $(DISTDIR_DOC_SRC)/images
262 
263 # distribution linker loader library directories
264 DIST_LD_LIBDIRS = $(DISTDIR_LIB) \
265  $(addprefix $(DISTDIR_LIB)/,$(RNMAKE_PKG_LIB_SUBDIRS))
266 
267 # virtual library path
268 DIST_VPATH_LIB = $(call makePath,$(DIST_LD_LIBDIRS))
269 
270 
271 #------------------------------------------------------------------------------
272 # Local Directories (Architecture Dependent)
273 #
274 RNMAKE_LOCDIR_ROOT ?= $(RNMAKE_PKG_ROOT)/loc
275 
276 LOCDIR_BIN = $(RNMAKE_LOCDIR_ROOT)/bin.$(RNMAKE_ARCH)
277 LOCDIR_LIB = $(RNMAKE_LOCDIR_ROOT)/lib.$(RNMAKE_ARCH)
278 LOCDIR_INCLUDE = $(RNMAKE_LOCDIR_ROOT)/include.$(RNMAKE_ARCH)
279 LOCDIR_LIST = $(LOCDIR_BIN) \
280  $(LOCDIR_LIB) \
281  $(LOCDIR_INCLUDE)
282 
283 LOC_VPATH_LIB = $(LOCDIR_LIB)
284 LOC_LD_LIBDIRS = $(LOCDIR_LIB)
285 
286 # Object Directory
287 OBJDIR = obj/obj.$(RNMAKE_ARCH)
288 
289 # Dependencies Directory
290 DEPSDIR = .deps
291 
292 # Dependencies File
293 DEPSFILE = $(DEPSDIR)/deps.$(RNMAKE_ARCH)
294 
295 
296 #------------------------------------------------------------------------------
297 # VPATH Search Path
298 LIBS_VPATH = $(LOC_VAPATH_LIB):$(DIST_VPATH_LIB)
299 vpath %.a $(LIBS_VPATH)
300 vpath %.so $(LIBS_VPATH)
301 
302 
303 #------------------------------------------------------------------------------
304 # Build Flags
305 # Merge Architecture, Package and Parent Makefile variables into build flags.
306 #
307 
308 # Include Flags
309 EXTRA_INCLUDES = $(addprefix -I,$(EXTRA_INCDIRS))
310 EXTRA_SYS_INCLUDES = $(addprefix -I,$(EXTRA_SYS_INCDIRS))
311 PKG_INCLUDES = $(addprefix -I,$(RNMAKE_PKG_INCDIRS))
312 PROD_INCLUDES = $(addprefix -I,$(RNMAKE_PROD_INCDIRS))
313 RNMAKE_ARCH_INCLUDES = $(addprefix -I,$(ARCH_INCDIRS))
314 PKG_SYS_INCLUDES = $(addprefix -I,$(RNMAKE_PKG_SYS_INCDIRS))
315 DIST_INCLUDES = -I$(DISTDIR_INCLUDE)
316 LOC_INCLUDES = -I$(LOCDIR_INCLUDE)
317 
318 INCLUDES = -I. \
319  $(EXTRA_INCLUDES) \
320  $(PKG_INCLUDES) \
321  $(PROD_INCLUDES) \
322  $(ARCH_INCLUDES) \
323  $(DIST_INCLUDES) \
324  $(LOC_INCLUDES) \
325  -I$(includedir) \
326  $(EXTRA_SYS_INCLUDES) \
327  $(RNMAKE_PKG_SYS_INCLUDES)
328 
329 # CPP Flags
330 override CPPFLAGS := $(EXTRA_CPPFLAGS) \
331  $(RNMAKE_PKG_CPPFLAGS) \
332  $(RNMAKE_ARCH_CPPFLAGS) \
333  -DARCH_$(RNMAKE_ARCH) \
334  -DARCH="\"$(RNMAKE_ARCH)\"" \
335  $(CPPFLAGS)
336 
337 # C Flags
338 override CFLAGS := $(EXTRA_CFLAGS) \
339  $(RNMAKE_PKG_CFLAGS) \
340  $(RNMAKE_ARCH_CFLAGS)\
341  $(CFLAGS)
342 
343 # CXX Flags
344 override CXXFLAGS := $(EXTRA_CXXFLAGS) \
345  $(RNMAKE_PKG_CXXFLAGS) \
346  $(RNMAKE_ARCH_CXXFLAGS) \
347  $(CXXFLAGS)
348 
349 # Library Search Paths
350 PKG_LD_LIBPATHS = $(addprefix -L,$(LOC_LD_LIBDIRS)) \
351  $(addprefix -L,$(DIST_LD_LIBDIRS))
352 INS_LD_LIBPATHS = -L$(libdir) \
353  $(addprefix -L$(libdir)/,$(RNMAKE_PKG_LIB_INS_SUBDIRS)) \
354  $(addprefix -L$(libdir)/,$(EXTRA_LIB_INS_SUBDIRS))
355 EXTRA_LD_LIBPATHS = $(addprefix -L,$(EXTRA_LD_LIBDIRS))
356 SYS_LD_LIBPATHS = $(addprefix -L,$(RNMAKE_PKG_LD_SYS_LIBDIRS))
357 LD_LIBPATHS := $(PKG_LD_LIBPATHS) \
358  $(INS_LD_LIBPATHS) \
359  $(EXTRA_LD_LIBPATHS) \
360  $(SYS_LD_LIBPATHS) \
361  $(LD_LIBPATHS)
362 
363 # Linked Libraries
364 LD_LIBS := $(EXTRA_LD_LIBS) $(RNMAKE_PKG_LD_LIBS) $(LD_LIBS)
365 
366 # Linker flags
367 LDFLAGS := $(EXTRA_LDFLAGS) $(RNMAKE_PKG_LDFLAGS) $(LDFLAGS)
368 
369 # default link-loader is c compiler - override if using C++
370 ifeq "$(LANG)" "C++"
371 LD = $(LD_CXX)
372 endif
373 
374 # default link-loader is c compiler - override if using CUDA
375 ifeq "$(LANG)" "CUDA"
376 LD = $(LD_CUDA)
377 endif
378 
379 #------------------------------------------------------------------------------
380 # Build Target Names
381 # Construct build target files and set from parent makefile.
382 #
383 
384 # Preferred Library Type for Distribution
385 LIB_TYPE := $(LIB_TYPE)
386 
387 # Complete list of core libraries
388 STLIBS = $(RNMAKE_LOC_STLIBS) $(RNMAKE_DIST_STLIBS)
389 SHLIBS = $(RNMAKE_DIST_SHLIBS)
390 DLLIBS = $(RNMAKE_DIST_DLLIBS)
391 
392 # Complete list of core programs
393 PGMS = $(RNMAKE_LOC_PGMS) $(RNMAKE_DIST_PGMS)
394 
395 # Release files
396 REL_FILES = $(RNMAKE_PKG_REL_FILES) $(EXTRA_REL_FILES)
397 
398 # Share make targets
399 SHARE_TGT = $(RNMAKE_PKG_TGT_SHARE) $(EXTRA_TGT_SHARE)
400 
401 # Etc make targets
402 ETC_TGT = $(RNMAKE_PKG_TGT_ETC) $(EXTRA_TGT_ETC)
403 
404 # $(call fq_lib_names,dir,lib...,libprefix,libsuffix)
405 # Make fully qualified library name(s) from core name(s).
406 fq_lib_names = \
407 $(foreach lib,$(2),$(if $($(lib).SUBDIR),\
408  $(addprefix $(1)/$($(lib).SUBDIR)/$(3),$(addsuffix $(4),$(lib))),\
409  $(addprefix $(1)/$(3),$(addsuffix $(4),$(lib)))))
410 
411 # $(call fq_loc_stlib_name,dir,libs)
412 # Make fully qualified local static library name(s) from core name(s). Note
413 # that local libraries do not support library subdirecties.
414 fq_loc_stlib_names = $(addprefix $(1)/$(STLIB_PREFIX),\
415  $(addsuffix $(STLIB_SUFFIX),$(2)))
416 
417 # $(call fq_stlib_names,dir,lib...)
418 # Make fully qualified static library name(s) from core name(s).
419 # Example:
420 # panda.SUBDIR = fu
421 # fqlibs = $(call fq_stlib_names,my/lib,kung panda)
422 #
423 # Sets 'fqlibs' to 'my/libs/libkung.a my/libs/fu/libpanda.a'
424 fq_stlib_names = $(call fq_lib_names,$(1),$(2),$(STLIB_PREFIX),$(STLIB_SUFFIX))
425 
426 # $(call fq_shlib_names,dir,lib...)
427 # Make fully qualified shared library name(s) from core name(s).
428 # Example:
429 # lex.SUBDIR = villian
430 # fqlibs = $(call fq_shlib_names,/home/lib,supergirl lex)
431 #
432 # Sets 'fqlibs' to '/home/lib/libsupergirl.so /home/lib/villian/liblex.so'
433 fq_shlib_names = $(call fq_lib_names,$(1),$(2),$(SHLIB_PREFIX),$(SHLIB_SUFFIX))
434 
435 # $(call fq_dllib_names,dir,lib...)
436 # Make fully qualified dynamically linked library name(s) from core name(s).
437 # Example:
438 # falcon9.SUBDIR = spacex
439 # newshepard.SUBDIR = blueorigin
440 # fqlibs = $(call fq_dllib_names,lib,falcon9 newshepard)
441 #
442 # Sets 'fqlibs' to '/lib/spacex/libfalcon9.so lib/blueorign/libnewshepard.so'
443 fq_dllib_names = \
444  $(call fq_lib_names,$(1),$(2),$(DLLIB_PREFIX),$(DLLIB_SUFFIX))
445 
446 # Fully Qualified Static Libraries
447 FQ_STLIBS = $(call fq_loc_stlib_names,$(LOCDIR_LIB),$(RNMAKE_LOC_STLIBS)) \
448  $(call fq_stlib_names,$(DISTDIR_LIB),$(RNMAKE_DIST_STLIBS))
449 
450 # Fully Qualified Shared Libraries
451 FQ_SHLIBS = $(call fq_shlib_names,$(DISTDIR_LIB),$(RNMAKE_DIST_SHLIBS))
452 
453 # Fully Qualified Dynamically Linked Libraries
454 FQ_DLLIBS = $(call fq_dllib_names,$(DISTDIR_LIB),$(RNMAKE_DIST_DLLIBS))
455 
456 # Fully Qualified Program Name(s) from Core Name(s)
457 fq_pgm_names = $(addprefix $(1)/$(PGM_PREFIX),\
458  $(addsuffix $(PGM_SUFFIX),$(2)))
459 
460 # Fully Qualified Programs
461 FQ_PGMS = $(call fq_pgm_names,$(LOCDIR_BIN),$(RNMAKE_LOC_PGMS)) \
462  $(call fq_pgm_names,$(DISTDIR_BIN),$(RNMAKE_DIST_PGMS))
463 
464 # Release Files
465 FQ_REL_FILES = $(addprefix $(DISTDIR_DOC)/,$(REL_FILES))
466 
467 # Auto-Generated header files directory
468 AUTO_INCDIR = $(firstword $(RNMAKE_PKG_INCDIRS))
469 ifeq ($(AUTO_INCDIR),)
470  AUTO_INCDIR = $(LOCDIR_INCLUDE)
471 endif
472 
473 # Auto-Generated Header Files
474 AUTO_VERSION_H = $(AUTO_INCDIR)/version.h
475 AUTO_INSTALL_H = $(AUTO_INCDIR)/install-$(RNMAKE_ARCH).h
476 
477 AUTOHDRS = $(AUTO_VERSION_H)
478 
479 # DEPRECATED $(AUTO_INSTALL_H)
480 
481 
482 #------------------------------------------------------------------------------
483 # Target Specific Variables
484 #
485 
486 # Shared library compiled objects need special CFLAGS (e.g. -fPIC)
487 $(FQ_SHLIBS): CFLAGS += $(SHLIB_CFLAGS)
488 
489 # Dynamically Linked library compiled objects need special CFLAGS
490 $(FQ_DLLIBS): CFLAGS += $(DLLIB_CFLAGS)
491 
492 #------------------------------------------------------------------------------
493 # Common Support Functions and Macros
494 #
495 
496 # Generate list of objects from sources given the core target name
497 objs_from_src = $(addprefix $(OBJDIR)/,$(subst .c,.o,$($(1).SRC.C))) \
498  $(addprefix $(OBJDIR)/,$(subst .cxx,.o,$($(1).SRC.CXX))) \
499  $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$($(1).SRC.CPP))) \
500  $(addprefix $(OBJDIR)/,$(subst .cu,.o,$($(1).SRC.CU)))
501 
502 # Make obj/obj-<RNMAKE_ARCH> in current directory
503 mkobjdir = \
504  @test -d "$(OBJDIR)" || $(MKDIR) $(OBJDIR); \
505  test -d "$(dir $(1))" || test -z "$(dir $(1))" || $(MKDIR) "$(dir $(1))"
506 
507 
508 ########################### Explicit Rules #####################################
509 
510 # -------------------------------------------------------------------------
511 # Target: all (default)
512 # Desc: Front end for making the [sub]package(s) (libraries, programs, tools,
513 # documents, etc).
514 # Notes: There are two version:
515 # 1) only done once on the first invocation and
516 # 2) for all other invocations.
517 .PHONY: all
518 ifeq ($(MAKELEVEL),0)
519 all: pkgbanner check-deps once-all $(EXTRA_TGT_ALL) pkg subdirs-all $(EXTRA_TGT_ALL_POST)
520  $(footer)
521 else
522 all: check-deps $(EXTRA_TGT_ALL) pkg subdirs-all $(EXTRA_TGT_ALL_POST)
523 endif
524 
525 .PHONY: once-all
526 once-all: mkdistdirs mklocdirs autohdrs
527 
528 
529 # -------------------------------------------------------------------------
530 # Target: pkg
531 # Desc: Makes the distribution [sub]package(s) (libraries, programs, tools,
532 # documents, etc).
533 .PHONY: pkg
534 pkg: libs pgms rel share
535 
536 
537 # -------------------------------------------------------------------------
538 # Target: libs
539 # Desc: Makes all libraries in current directory.
540 
541 # Make all libraries
542 .PHONY: libs
543 libs: stlibs shlibs dllibs
544 
545 # Make all static libraries
546 .PHONY: stlibs
547 stlibs: $(FQ_STLIBS)
548 
549 # Make all shared libraries
550 .PHONY: shlibs
551 shlibs: $(FQ_SHLIBS)
552 
553 # Make all dll libraries
554 .PHONY: dllibs
555 dllibs: $(FQ_DLLIBS)
556 
557 # Make specific distribution static librarary
558 .PHONY: $(RNMAKE_DIST_STLIBS)
559 $(RNMAKE_DIST_STLIBS): $(call fq_stlib_names,$(DISTDIR_LIB),$(GOAL_LIST))
560 
561 # Make specific distribution shared librarary
562 .PHONY: $(RNMAKE_DIST_SHLIBS)
563 $(RNMAKE_DIST_SHLIBS): $(call fq_shlib_names,$(DISTDIR_LIB),$(GOAL_LIST))
564 
565 # Make specific distribution dll librarary
566 .PHONY: $(RNMAKE_DIST_DLLIBS)
567 $(RNMAKE_DIST_DLLIBS): $(call fq_dllib_names,$(DISTDIR_LIB),$(GOAL_LIST))
568 
569 # Make specific local static librarary
570 .PHONY: $(RNMAKE_LOC_STLIBS)
571 $(RNMAKE_LOC_STLIBS): $(call fq_stlib_names,$(LOCDIR_LIB),$(GOAL_LIST))
572 
573 # $(call STLIBtemplate,lib,libdir)
574 # Template to build a static library including all necessary prerequisites
575 define STLIBtemplate
576  $(1).OBJS = $(call objs_from_src,$(1))
577  $(1).FQ_LIB = $(call fq_stlib_names,$(2),$(1))
578  OUTDIR = $$(dir $$($(1).FQ_LIB))
579  $$($(1).FQ_LIB): $$($(1).OBJS)
580  @printf "\n"
581  @printf "$(color_tgt_lib) $$@$(color_end)\n"
582  @test -d "$$(OUTDIR)" || $(MKDIR) $$(OUTDIR)
583  $$(STLIB_LD) $$(STLIB_LD_FLAGS) $$(STLIB_LD_EXTRAS) $$@ $$($(1).OBJS)
584  $$(RANLIB) $$@
585 endef
586 
587 
588 # Template to build a shared library including all necessary prerequisites
589 define SHLIBtemplate
590  $(1).OBJS = $(call objs_from_src,$(1))
591  $(1).LIBS := $(addprefix -l, $($(1).LIBS))
592  $(1).FQ_LIB = $(call fq_shlib_names,$(2),$(1))
593  OUTDIR = $$(dir $$($(1).FQ_LIB))
594  $$($(1).FQ_LIB): $$($(1).OBJS)
595  @printf "\n"
596  @printf "$(color_tgt_lib) $$@$(color_end)\n"
597  @test -d "$$(OUTDIR)" || $(MKDIR) $$(OUTDIR)
598  $$(SHLIB_LD) $$(SHLIB_LD_FLAGS) $$(SHLIB_LD_EXTRAS) -o $$@ $$($(1).OBJS) $$(LD_LIBPATHS) $$($(1).LIBS) $$(LD_LIBS)
599 endef
600 
601 # Template to build a dynamically linke library including all necessary
602 # prerequisites
603 define DLLIBtemplate
604  $(1).OBJS = $(call objs_from_src,$(1))
605  $(1).LIBS := $(addprefix -l, $($(1).LIBS))
606  $(1).FQ_LIB = $(call fq_dllib_names,$(2),$(1))
607  OUTDIR = $$(dir $$($(1).FQ_LIB))
608  $$($(1).FQ_LIB): $$($(1).OBJS)
609  @printf "\n"
610  @printf "$(color_tgt_lib) $$@$(color_end)\n"
611  @test -d "$$(OUTDIR)" || $(MKDIR) $$(OUTDIR)
612  $$(DLLIB_LD) $$(DLLIB_LD_FLAGS) $$(DLLIB_LD_EXTRAS) $$($(1).OBJS) $$(LD_LIBPATHS) $$($(1).LIBS) $$(LD_LIBS) -o $$@
613 endef
614 
615 # For each library target, evaluate (i.e make) the template.
616 $(foreach lib,$(RNMAKE_LOC_STLIBS),\
617  $(eval $(call STLIBtemplate,$(lib),$(LOCDIR_LIB))))
618 
619 $(foreach lib,$(RNMAKE_DIST_STLIBS),\
620  $(eval $(call STLIBtemplate,$(lib),$(DISTDIR_LIB))))
621 
622 $(foreach lib,$(RNMAKE_DIST_SHLIBS),\
623  $(eval $(call SHLIBtemplate,$(lib),$(DISTDIR_LIB))))
624 
625 $(foreach lib,$(RNMAKE_DIST_DLLIBS),\
626  $(eval $(call DLLIBtemplate,$(lib),$(DISTDIR_LIB))))
627 
628 # -------------------------------------------------------------------------
629 # Target: pgms
630 # Desc: Makes all programs in current directory.
631 
632 # Make all programs
633 .PHONY: pgms
634 pgms: $(FQ_PGMS)
635 
636 # Make specific local program
637 .PHONY: $(RNMAKE_LOC_PGMS)
638 $(RNMAKE_LOC_PGMS): $(call fq_pgm_names,$(LOCDIR_BIN),$(GOAL_LIST))
639 
640 # Make specific distribution program
641 .PHONY: $(RNMAKE_DIST_PGMS)
642 $(RNMAKE_DIST_PGMS): $(call fq_pgm_names,$(DISTDIR_BIN),$(GOAL_LIST))
643 
644 # Template to build a program including all necessary prerequisites
645 define PGMtemplate
646  $(1).OBJS = $(call objs_from_src,$(1))
647  $(1).LIBDEPS = $(shell $(RNMAKE_ROOT)/utils/libdeps.sh $(LIBS_VPATH) $($(1).LIBDEPS))
648  $(1).LIBS := $(addprefix -l, $($(1).LIBS))
649  $(1).FQ_PGM = $(call fq_pgm_names,$(2),$(1))
650  $$($(1).FQ_PGM): $$($(1).OBJS) $$($(1).LIBDEPS)
651  @printf "\n"
652  @printf "$(color_tgt_pgm) $$@$(color_end)\n"
653  $$(LD) $$(LDFLAGS) $$(LD_LIBPATHS) $$($(1).OBJS) $$($(1).LIBS) $$(LD_LIBS) -o $$@
654 endef
655 
656 libdeps = $(shell for lib in $(1); do echo lib$${lib}.a; done)
657 
658 # For each program target, evaluate (i.e make) template.
659 $(foreach prog,$(RNMAKE_LOC_PGMS),\
660  $(eval $(call PGMtemplate,$(prog),$(LOCDIR_BIN))))
661 
662 $(foreach prog,$(RNMAKE_DIST_PGMS),\
663  $(eval $(call PGMtemplate,$(prog),$(DISTDIR_BIN))))
664 
665 ## RDK investigate for linking programs
666 # $(LINK.o) $^ $(LDLIBS) -o $@
667 
668 # -------------------------------------------------------------------------
669 # Target: autohdrs
670 # Desc: Makes auto-generated header files.
671 # Notes: Auto-headers are only made at top level.
672 # May make a shell script to do this.
673 autohdrs: $(AUTOHDRS)
674 
675 # verion.h auto-generated header
676 $(AUTO_VERSION_H): $(RNMAKE_PKG_MKFILE)
677  $(printTgtGoal)
678  @test -d "$(AUTO_INCDIR)" || $(MKDIR) $(AUTO_INCDIR)
679  @$(MAKE) -f $(RNMAKE_ROOT)/version_h.mk -s \
680  RNMAKE_PKG_ROOT=$(RNMAKE_PKG_ROOT) \
681  version_h=$(@) \
682  pkg_mk=$(RNMAKE_PKG_MKFILE) \
683  autogen
684 
685 # install.h auto-generated header DEPRECATED
686 $(AUTO_INSTALL_H): $(RNMAKE_ARCH_MKFILE)
687  @test -d "$(AUTO_INCDIR)" || $(MKDIR) $(AUTO_INCDIR)
688  @$(MAKE) -f $(RNMAKE_ROOT)/install_h.mk -s \
689  RNMAKE_PKG_ROOT=$(RNMAKE_PKG_ROOT) install_h=$@ \
690  arch=$(RNMAKE_ARCH) \
691  bindir=$(bindir) \
692  sbindir=$(sbindir) \
693  libdir=$(libdir) \
694  includedir=$(includedir) \
695  sysconfdir=$(sysconfdir) \
696  docdir=$(docdir) \
697  mandir=$(mandir) \
698  infodir=$(infodir)
699 
700 
701 # -------------------------------------------------------------------------
702 # Target: hdrs
703 # Desc: Makes interface header files
704 
705 # List of all header tags
706 HDR_TAG_LIST = $(addsuffix .HDRS.H,$(RNMAKE_DIST_HDRS))
707 #$(info HDR_TAG_LIST: $(HDR_TAG_LIST))
708 
709 # Complete list of headers
710 PREREQ_HDRS = $(foreach tag,$(HDR_TAG_LIST),$($(tag)))
711 #$(info PREREQ_HDRS: $(PREREQ_HDRS))
712 
713 # Make all distribution headers
714 .PHONY: hdrs
715 hdrs: echo-hdrs $(PREREQ_HDRS)
716 
717 .PHONY: echo-hdrs
718 echo-hdrs:
719  $(call printGoalDesc,$(DISTDIR_INCLUDE),\
720  Copying tagged interfaces headers from $(RNMAKE_PKG_ROOT)/include.)
721 
722 # Copy newer headers to distribution include [sub]directory
723 $(PREREQ_HDRS):
724  @for h in $(@); \
725  do\
726  src=$(RNMAKE_PKG_ROOT)/include/$$h; \
727  dst=$(DISTDIR_INCLUDE)/$$h; \
728  hdir=$$(dirname $$dst); \
729  if [ ! -f $$dst -o $$src -nt $$dst ]; \
730  then \
731  test -d $$hdir || $(MKDIR) $$hdir; \
732  $(CP) $$src $$dst; \
733  fi; \
734  done
735 
736 # -------------------------------------------------------------------------
737 # Target: rel
738 # Desc: Makes all release files
739 # Notes: Release files are only made at top level
740 .PHONY: rel
741 ifeq "$(RNMAKE_PKG_ROOT)" "."
742 rel: $(FQ_REL_FILES)
743 else
744 rel:
745 endif
746 
747 .PHONY: $(DISTDIR_DOC)/VERSION.txt
748 $(DISTDIR_DOC)/VERSION.txt:
749  @echo ""
750  @echo " $@"
751  @echo "$(RNMAKE_PKG) v$(RNMAKE_PKG_VERSION_DOTTED)" > $@
752  @echo "Copyright (C) $(RNMAKE_PKG_VERSION_DATE) RoadNarrows LLC" >> $@
753  @echo "" >> $@
754  @echo "Compiled: `date`" >> $@
755 
756 $(DISTDIR_DOC)/README.md: README.md
757  @echo ""
758  @echo " $@"
759  -$(CP) README.md $@
760 
761 $(DISTDIR_DOC)/README.txt: README.txt
762  @echo ""
763  @echo " $@"
764  -$(CP) README.txt $@
765 
766 $(DISTDIR_DOC)/README.xml: README.xml
767  @echo ""
768  @echo " $@"
769  -$(CP) README.xml $@
770 
771 # -------------------------------------------------------------------------
772 # Target: share
773 # Desc: Makes all share files
774 # Notes: Share files are only made at top level
775 .PHONY: share
776 ifeq "$(RNMAKE_PKG_ROOT)" "."
777 share: $(SHARE_TGT)
778 else
779 share:
780 endif
781 
782 # -------------------------------------------------------------------------
783 # Target: etc (not used yet)
784 # Desc: Makes all system configuration files
785 # Notes: Etc files are only made at top level
786 .PHONY: etc
787 ifeq "$(RNMAKE_PKG_ROOT)" "."
788 etc: $(ETC_TGT)
789 else
790 etc:
791 endif
792 
793 
794 # -------------------------------------------------------------------------
795 # Target: mkdistdirs
796 # Desc: Make Distribution Directories
797 .PHONY: mkdistdirs $(DISTDIR_LIST)
798 mkdistdirs: echo-mkdistdirs $(DISTDIR_LIST)
799 
800 .PHONY: echo-mkdistdirs
801 echo-mkdistdirs:
802 ifeq ($(realpath $(DIST_ARCH)),)
803  $(call printGoalDesc,\
804  $(patsubst $(RNMAKE_PKG_ROOT)/%,%,$(DIST_ARCH)),\
805  Making distribution directories.)
806 endif
807 
808 $(DISTDIR_LIST):
809  @test -d ${@} || $(MKDIR) ${@}
810 
811 
812 # -------------------------------------------------------------------------
813 # Target: mklocdirs
814 # Desc: Make Local Directories
815 .PHONY: mklocdirs $(LOCDIR_LIST)
816 mklocdirs: echo-mklocdirs $(LOCDIR_LIST)
817 
818 .PHONY: echo-mklocdirs
819 echo-mklocdirs:
820 ifeq ($(realpath $(LOCDIR_BIN)),)
821  $(call printGoalDesc,\
822  $(patsubst $(RNMAKE_PKG_ROOT)/%,%,$(RNMAKE_LOCDIR_ROOT)),\
823  Making local directories.)
824 endif
825 
826 $(LOCDIR_LIST):
827  @test -d ${@} || $(MKDIR) ${@}
828 
829 
830 # -------------------------------------------------------------------------
831 # Target: install
832 # Desc: Install the distribution
833 .PHONY: install
834 install: pkgbanner all echo-install $(EXTRA_TGT_INSTALL) install-bin \
835  install-lib install-includes install-docs install-share install-etc \
836  $(EXTRA_TGT_INSTALL_POST)
837  $(footer)
838 
839 .PHONY: echo-install
840 echo-install:
841  $(call printEchoTgtGoalDesc,Installing package $(RNMAKE_PKG_FULL_NAME))
842 
843 # DEPRECATED
844 instest:
845  @if [ ! -f $(DISTDIR_DOC)/VERSION.txt ]; \
846  then \
847  echo "Error: The $(RNMAKE_PKG) package has not been built. Try \"make\" first."; \
848  echo "Install aborted."; \
849  exit 4; \
850  fi
851 
852 # install bin
853 install-bin:
854  $(printTgtGoal)
855  @printf "Installing executables to $(bindir)\n"
856  @$(RNMAKE_ROOT)/utils/doinstall.sh 755 $(DISTDIR_BIN) $(bindir)
857  $(call POSTINStemplate,$(STRIP_EXE),$(DISTDIR_BIN),$(bindir))
858 
859 # install lib
860 install-lib:
861  $(printTgtGoal)
862  @printf "Installing libraries to $(libdir)\n"
863  @$(RNMAKE_ROOT)/utils/doinstall.sh 755 $(DISTDIR_LIB) $(libdir)
864  $(call POSTINStemplate,$(STRIP_LIB),$(DISTDIR_LIB),$(libdir))
865 
866 # install includes
867 install-includes: hdrs
868  $(printTgtGoal)
869  @printf "Installing includes to $(includedir)\n"
870  @$(RNMAKE_ROOT)/utils/doinstall.sh 664 $(DISTDIR_INCLUDE) $(includedir)
871 
872 # install documentation
873 install-docs: documents
874  $(printTgtGoal)
875  @printf "Installing documents to $(docdir)/$(RNMAKE_PKG_FULL_NAME)\n"
876  @$(RNMAKE_ROOT)/utils/doinstall.sh -s 664 $(DISTDIR_DOC) $(docdir)/$(RNMAKE_PKG_FULL_NAME)
877 
878 # install share files
879 install-share:
880  $(printTgtGoal)
881  @printf "Installing system share files to $(sharedir)\n"
882  @$(RNMAKE_ROOT)/utils/doinstall.sh -s 664 $(DISTDIR_SHARE) $(sharedir)/$(RNMAKE_PKG_FULL_NAME)
883  @if [ ! -e $(sharedir)/$(RNMAKE_PKG) ]; \
884  then \
885  $(SYMLINK) $(sharedir)/$(RNMAKE_PKG_FULL_NAME) $(sharedir)/$(RNMAKE_PKG); \
886  elif [ -L $(sharedir)/$(RNMAKE_PKG) ]; \
887  then \
888  $(UNLINK) $(sharedir)/$(RNMAKE_PKG); \
889  $(SYMLINK) $(sharedir)/$(RNMAKE_PKG_FULL_NAME) $(sharedir)/$(RNMAKE_PKG); \
890  fi
891 
892 # install etc
893 install-etc:
894  $(printTgtGoal)
895  @printf "Installing system configuration to $(sysconfdir)\n"
896  @printf "\n"
897  @$(RNMAKE_ROOT)/utils/doinstall.sh 664 $(DISTDIR_ETC) $(sysconfdir)
898 
899 # Post-Install directory component template
900 # Usage: POSTINStemplate postprocess source_dir dest_dir
901 define POSTINStemplate
902  @cd $(2); \
903  srclist=$$($(FIND) . -type f); \
904  for src in $$srclist; \
905  do \
906  dst="$(3)/$${src##./}"; \
907  -$(1) $$dst 2>/dev/null || echo " $$dst"; \
908  done;
909 endef
910 
911 
912 # -------------------------------------------------------------------------
913 # Target: deps
914 # Desc: Makes dependencies
915 # File: .deps/deps.$(RNMAKE_ARCH)
916 # -------------------------------------------------------------------------
917 .PHONY: deps
918 deps: pkgbanner echo-deps autohdrs mkdepsdir $(EXTRA_TGT_DEPS) hdrdeps libdeps \
919  subdirs-deps
920  $(footer)
921 
922 .PHONY: echo-deps
923 echo-deps:
924  $(call printEchoTgtGoalDesc,Making dependencies for $(CURDIR))
925 
926 .PHONY: hdrdeps
927 hdrdeps:
928  @$(call printGoalDesc,$(@),Making C/C++ dependencies)
929  @echo $(call hdrdeps_sh,$(STLIBS) $(SHLIBS) $(DLLIBS) $(PGMS))
930 
931 hdrdeps_sh = \
932  $(shell $(RNMAKE_ROOT)/utils/hdrdeps.sh \
933  -c "$(RNMAKE_MAKEDEPS)" \
934  -f $(DEPSFILE) \
935  -o $(OBJDIR) \
936  -d "$(CPPFLAGS)" \
937  $(INCLUDES) \
938  $(foreach f,\
939  $(sort $(addsuffix .SRC.C,$(1)) \
940  $(addsuffix .SRC.CXX,$(1)) \
941  $(addsuffix .SRC.CPP,$(1))),\
942  $($(f))))
943 
944 libdeps:
945 
946 .PHONY: mkdepsdir
947 mkdepsdir:
948  @test -d $(DEPSDIR) || $(MKDIR) $(DEPSDIR)
949 
950 # Check if deps file exist or error.
951 # If the override variable 'nodeps' is not empty, then no check is performed.
952 define checkDeps
953  $(if $(nodeps),,\
954  $(if $(realpath $(DEPSFILE)),,\
955  $(error No dependencies file - Try 'make deps' first)))
956 endef
957 
958 # Include dependency file or error canned sequence.
959 # If the override variable 'nodeps' is not empty, then no action is performed.
960 define includeDeps
961  $(if $(nodeps),,\
962  $(if $(call isFile,$(DEPSFILE)),\
963  $(eval include $(DEPSFILE)),\
964  $(error No dependencies file - Try 'make deps' first)))
965 endef
966 
967 # Conditionally include any dependency file for specific targets only.
968 $(if $(call findGoals,all test),$(call includeDeps),)
969 
970 # Check deps target
971 .PHONY: check-deps
972 check-deps:
973  $(call checkDeps)
974 
975 
976 # -------------------------------------------------------------------------
977 # Target: clean
978 # Desc: Deletes generated intermediate files
979 # -------------------------------------------------------------------------
980 .PHONY: clean
981 clean: pkgbanner echo-clean do-clean $(EXTRA_TGT_CLEAN) subdirs-clean
982  $(footer)
983 
984 .PHONY: echo-clean
985 echo-clean:
986  $(call printEchoTgtGoalDesc,)
987 
988 .PHONY: do-clean
989 do-clean:
990  @echo "Cleaning $(CURDIR)"
991  $(RM) *.o *.ii *.c~ *.cxx~ .h~ *.pyc *.pyo \
992  $(RNMAKE_LOC_PGMS) $(RNMAKE_DIST_PGMS) a.out doxy.*.log
993  $(RM) $(OBJDIR)
994 
995 
996 # -------------------------------------------------------------------------
997 # Target: distclean (clobber)
998 # Desc: Cleans plus deletes distribution
999 # -------------------------------------------------------------------------
1000 .PHONY: distclean clobber
1001 distclean clobber: pkgbanner clean $(EXTRA_TGT_DISTCLEAN)
1002  $(call printGoalDesc,$(@),Clobbering distribution $(CURDIR))
1003  $(RM) $(DIST_ARCH)
1004  $(RM) $(DIST_ROOT)/$(RNMAKE_PKG_FULL_NAME)-$(RNMAKE_ARCH).tar.gz
1005  $(RM) $(DIST_ROOT)/$(RNMAKE_PKG_FULL_NAME)-doc.tar.gz
1006  $(RM) $(DIST_ROOT)/$(RNMAKE_PKG_FULL_NAME)-src.tar.gz
1007  $(RM) $(LOCDIR_LIST)
1008  $(RM) $(AUTOHDRS)
1009  $(RM) $(DEPSFILE)
1010  $(footer)
1011 
1012 
1013 # -------------------------------------------------------------------------
1014 # Target: subdirs
1015 # Desc: Recursively make subdirectories.
1016 # Notes: Any two or more goals that traverse the subdirectory tree need
1017 # separate subdirectory targets. Otherwise, only the first goal
1018 # will traverse.
1019 # -------------------------------------------------------------------------
1020 
1021 # Subdirectory call
1022 .PHONY: subdirs $(RNMAKE_SUBDIRS)
1023 subdirs: $(RNMAKE_SUBDIRS)
1024 
1025 # Make all sub-directories with all command-line goals
1026 $(RNMAKE_SUBDIRS):
1027  $(call printDirBanner,$(@),$(GOAL_LIST))
1028  @$(MAKE) $(EXTRA_MAKE_FLAGS) -C $(@) $(GOAL_LIST)
1029  @printf " $(color_dir_banner)~~$(color_end)\n"
1030 
1031 #
1032 # Template to build subdirectories by goal rules. Since rnmake traverses the
1033 # command-line goals depth first, and GNU make will only execute a rule once,
1034 # this template builds unique subdirectory rules.
1035 #
1036 # Built Rules:
1037 # subdirs-<goal>: $(RNMAKE_SUBDIRS.<goal>)
1038 # $(RNMAKE_SUBDIRS.<goal>:
1039 # <recipe>
1040 #
1041 # Usage: $(call SUBDIRtemplate,goal)
1042 #
1043 define SUBDIRtemplate
1044 RNMAKE_SUBDIRS.$(1) = $(addsuffix .$(1),$(RNMAKE_SUBDIRS))
1045 
1046 subdirs-$(1): $$(RNMAKE_SUBDIRS.$(1))
1047 
1048 $$(RNMAKE_SUBDIRS.$(1)):
1049  $$(call printDirBanner,$$(basename $$(@)),$(1))
1050  @$$(MAKE) $$(EXTRA_MAKE_FLAGS) -C $$(basename $$(@)) $(1)
1051  @printf " $(color_dir_banner)~~$(color_end)\n"
1052 endef
1053 
1054 # all goals with subdirectory traversal prerequisite
1055 GOALS_WITH_SUBDIRS += deps all clean
1056 
1057 # build make rules for goal-specific subdirectories
1058 $(foreach goal,$(GOALS_WITH_SUBDIRS),$(eval $(call SUBDIRtemplate,$(goal))))
1059 
1060 
1061 # -------------------------------------------------------------------------
1062 # Pretty Print Support.
1063 #
1064 # Defines canned sequences, goal recipes, and goal prerequisite targets.
1065 # -------------------------------------------------------------------------
1066 
1067 # Pretty print make banner.
1068 .PHONY: pkgbanner
1069 pkgbanner:
1070  $(call printPkgBanner,$(RNMAKE_PKG_FULL_NAME),$(RNMAKE_ARCH),$(GOAL_LIST))
1071 
1072 # $(footer)
1073 # Conditionally print footer.
1074 footer = $(call printFooter,$(@),$(LAST_GOAL))
1075 
1076 
1077 # -------------------------------------------------------------------------
1078 # force some targets to always make
1079 force: ;
1080 
1081 
1082 ########################### Pattern Rules #####################################
1083 
1084 # C Rule: <name>.c -> $(OBJDIR)/<name>.o
1085 $(OBJDIR)/%.o : %.c
1086  $(call mkobjdir,$(@))
1087  @printf "\n"
1088  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1089  $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1090 
1091 # C++ Rule: <name>.cxx -> $(OBJDIR)/<name>.o
1092 $(OBJDIR)/%.o : %.cxx
1093  $(call mkobjdir,$(@))
1094  @printf "\n"
1095  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1096  $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1097 
1098 # C++ Rule: <name>.cpp -> $(OBJDIR)/<name>.o
1099 $(OBJDIR)/%.o : %.cpp
1100  $(call mkobjdir,$(@))
1101  @printf "\n"
1102  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1103  $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1104 
1105 # CUDA Rule: <name>.cu -> $(OBJDIR)/<name>.o
1106 $(OBJDIR)/%.o : %.cu
1107  $(call mkobjdir,$(@))
1108  @printf "\n"
1109  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1110  $(CUDA) $(CUDAFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1111 
1112 # Compile a single c file. (Nice for debugging)
1113 %.o : %.c force
1114  $(call mkobjdir,$(OBJDIR)/$(@))
1115  @printf "\n"
1116  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1117  $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(OBJDIR)/$(@) -c $(<)
1118 
1119 # Compile a single cxx file. (Nice for debugging)
1120 %.o : %.cxx force
1121  $(call mkobjdir,$(OBJDIR)/$(@))
1122  @printf "\n"
1123  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1124  $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(OBJDIR)/$(@) -c $(<)
1125 
1126 # Compile a single cpp file. (Nice for debugging)
1127 %.o : %.cpp force
1128  $(call mkobjdir,$(OBJDIR)/$(@))
1129  @printf "\n"
1130  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1131  $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(OBJDIR)/$(@) -c $(<)
1132 
1133 # Compile a single cuda file. (Nice for debugging)
1134 %.o : %.cu force
1135  $(call mkobjdir,$(@))
1136  @printf "\n"
1137  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1138  $(CUDA) $(CUDAFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1139 
1140 # C PreProcess Rule: <name>.c -> <name>.ii
1141 # Generate c preprocessor output (useful to debug compiling errors)
1142 # Historically the output suffix is .i but this can interfere with swig
1143 # interface files that also have the .i suffix. So .ii will be used until
1144 # I find another "standard".
1145 %.ii : %.c force
1146  @printf "\n"
1147  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1148  $(CC) $(CFLAGS_CPP_ONLY) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1149 
1150 # C PreProcess Rule: <name>.cpp -> <name>.ii
1151 # Generate c preprocessor output (useful to debug compiling errors)
1152 %.ii : %.cxx force
1153  @printf "\n"
1154  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1155  $(CXX) $(CXXFLAGS_CPP_ONLY) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1156 
1157 # C PreProcess Rule: <name>.cpp -> <name>.ii
1158 # Generate c preprocessor output (useful to debug compiling errors)
1159 %.ii : %.cpp force
1160  @printf "\n"
1161  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1162  $(CXX) $(CXXFLAGS_CPP_ONLY) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1163 
1164 # C PreProcess Rule: <name>.cu -> <name>.ii
1165 # Generate c preprocessor output (useful to debug compiling errors)
1166 %.ii : %.cu force
1167  @printf "\n"
1168  @printf "$(color_tgt_file) $(<)$(color_end)\n"
1169  $(CUDA) $(CUDAFLAGS_CPP_ONLY) $(CUDAFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1170 
1171 null:
1172  @echo "null me"
1173 
1174 
1175 # -------------------------------------------------------------------------
1176 # default error rule (doesn't work yet)
1177 
1178 #%::
1179 # @echo "$(@): Unknown target. See 'make help' for help."
1180 
1181 
1182 ifdef RNMAKE_DOXY
1183 /*! \endcond RNMAKE_DOXY */
1184 endif