1 ################################################################################ 31 ################################################################################ 35 #------------------------------------------------------------------------------ 38 # this makefile is last in the list (must call before any includes from this) 39 RNMAKE_ROOT = $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
41 # version of these makefile rules 42 RNMAKE_RULES_VER_MAJOR := 3
43 RNMAKE_RULES_VER_MINOR := 0
48 # list of command-line goals 49 GOAL_LIST = $(MAKECMDGOALS)
51 # add
default if empty
52 ifeq
"$(GOAL_LIST)" "" 53 GOAL_LIST = $(.DEFAULT_GOAL)
56 # save first and last goals 57 FIRST_GOAL = $(firstword $(GOAL_LIST))
58 LAST_GOAL = $(lastword $(GOAL_LIST))
60 # list of goals with subdirectory traversals 64 #------------------------------------------------------------------------------ 65 # Environment (Env.mk) 67 # Parse rnmake specific command-line and environment variables. 70 include $(RNMAKE_ROOT)/Env.mk
73 #------------------------------------------------------------------------------ 74 # Standard collection of RN Make System functions and varibbles (Std.mk) 77 include $(RNMAKE_ROOT)/Std.mk
80 #------------------------------------------------------------------------------ 81 # Print help (Help.mk) 83 # Check if any of the make goals contain help goals. If true, include the 84 # help makefile, which defines the help[-<subhelp>] rules. 86 $(call includeIfGoals,help help-%,$(RNMAKE_ROOT)/Help.mk)
88 #------------------------------------------------------------------------------ 89 # Compile and run unit tests (Rules.test.mk) 91 # Check if any of the make goals contain test goals. If true, include the 92 # test makefile, which defines the [run-]test rules. 94 $(call includeIfGoals,test run-test,$(RNMAKE_ROOT)/Rules.test.mk)
96 #------------------------------------------------------------------------------ 97 # Documentation makes (Rules.doc.mk) 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. 102 $(call includeIfGoals,install install-docs documents docs-%,\
103 $(RNMAKE_ROOT)/Rules.doc.mk)
105 #------------------------------------------------------------------------------ 106 # Tarball package repo builds (Rules.tarball.mk) 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. 111 $(call includeIfGoals,tarballs tarball-%,$(RNMAKE_ROOT)/Rules.tarball.mk)
113 #------------------------------------------------------------------------------ 114 # Debian package repo builds (Rules.dpkg.mk) 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. 120 $(call includeIfGoals,deb-pkgs deb-pkg-%,$(RNMAKE_ROOT)/Rules.dpkg.mk)
123 # ------------------------------------------------------------------------- 124 # Architecture Dependent Definitions 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)
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)
136 # Include the architecture make file. 137 ifeq ($(_ARCH_$(RNMAKE_ARCH_TAG)_MK),)
138 include $(RNMAKE_ARCH_MKFILE)
141 # Included architecture makefile must define RNMAKE_ARCH which defines the 143 ifeq ($(RNMAKE_ARCH),)
144 $(error
'RNMAKE_ARCH': Not defined in including arhitecture makefile)
148 #------------------------------------------------------------------------------
149 # Package Master Makefile (required)
152 # must be defined in including makefile 153 ifeq ($(RNMAKE_PKG_ROOT),)
154 $(error
'RNMAKE_PKG_ROOT': Not defined in including Makefile)
158 RNMAKE_PKG_MKFILE = $(call findReqFile,$(RNMAKE_PKG_ROOT)/make/Pkg.mk,)
160 # package root absolute path
161 RNMAKE_PKG_ROOT := $(realpath $(RNMAKE_PKG_ROOT))
165 include $(RNMAKE_PKG_MKFILE)
168 # Included package master makefile must define RNMAKE_PKG which defines the 170 ifeq ($(RNMAKE_PKG),)
171 $(error
'RNMAKE_PKG': Not defined in including arhitecture makefile)
175 #------------------------------------------------------------------------------
176 # Product Makefile (Optional)
178 ifdef RNMAKE_PROD_MKFILE
180 # optionally include (no error if not found) 181 -include $(RNMAKE_PROD_MKFILE)
186 #------------------------------------------------------------------------------
187 # Include helper make files (Cmds.mk, Colors.mk)
189 # Can conditionally define macros by architecuture definitions included above. 192 # basic host commands 194 include $(RNMAKE_ROOT)/Cmds.mk
198 ifeq ($(_COLORS_MK),)
199 ifneq "$(color)" "off"
200 include $(RNMAKE_ROOT)/Colors.mk
205 #------------------------------------------------------------------------------ 206 # Install Directories - Override as necessary in including Makefile. 208 # Note: These are traditional configuration names - keep the naming convention. 210 prefix := $(RNMAKE_INSTALL_PREFIX)
212 prefix := $(RNMAKE_INSTALL_XPREFIX)/$(RNMAKE_ARCH)
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
229 #------------------------------------------------------------------------------
230 # Distribution Directories (Architecture Dependent)
232 DIST_ROOT = $(RNMAKE_PKG_ROOT)/dist
233 DIST_ARCH = $(DIST_ROOT)/dist.$(RNMAKE_ARCH)
235 # Distributions Directories
236 DISTDIR_BIN = $(DIST_ARCH)/bin
237 DISTDIR_LIB = $(DIST_ARCH)/lib
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) \
258 # documentation subdirectories 260 DISTDIR_DOC_SRC = $(DISTDIR_DOC)/$(DIST_SRCDOC)
261 DISTDIR_DOC_SRC_IMG = $(DISTDIR_DOC_SRC)/images
263 # distribution linker loader library directories
264 DIST_LD_LIBDIRS = $(DISTDIR_LIB) \
265 $(addprefix $(DISTDIR_LIB)/,$(RNMAKE_PKG_LIB_SUBDIRS))
267 #
virtual library path
268 DIST_VPATH_LIB = $(call makePath,$(DIST_LD_LIBDIRS))
271 #------------------------------------------------------------------------------
272 # Local Directories (Architecture Dependent)
274 RNMAKE_LOCDIR_ROOT ?= $(RNMAKE_PKG_ROOT)/loc
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) \
283 LOC_VPATH_LIB = $(LOCDIR_LIB)
284 LOC_LD_LIBDIRS = $(LOCDIR_LIB)
287 OBJDIR = obj/obj.$(RNMAKE_ARCH)
289 # Dependencies Directory
293 DEPSFILE = $(DEPSDIR)/deps.$(RNMAKE_ARCH)
296 #------------------------------------------------------------------------------
298 LIBS_VPATH = $(LOC_VAPATH_LIB):$(DIST_VPATH_LIB)
299 vpath %.a $(LIBS_VPATH)
300 vpath %.so $(LIBS_VPATH)
303 #------------------------------------------------------------------------------
305 # Merge Architecture, Package and Parent Makefile variables into build 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)
326 $(EXTRA_SYS_INCLUDES) \
327 $(RNMAKE_PKG_SYS_INCLUDES)
330 override CPPFLAGS := $(EXTRA_CPPFLAGS) \
331 $(RNMAKE_PKG_CPPFLAGS) \
332 $(RNMAKE_ARCH_CPPFLAGS) \
333 -DARCH_$(RNMAKE_ARCH) \
334 -DARCH=
"\"$(RNMAKE_ARCH)\"" \
338 override CFLAGS := $(EXTRA_CFLAGS) \
339 $(RNMAKE_PKG_CFLAGS) \
340 $(RNMAKE_ARCH_CFLAGS)\
344 override CXXFLAGS := $(EXTRA_CXXFLAGS) \
345 $(RNMAKE_PKG_CXXFLAGS) \
346 $(RNMAKE_ARCH_CXXFLAGS) \
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) \
359 $(EXTRA_LD_LIBPATHS) \
364 LD_LIBS := $(EXTRA_LD_LIBS) $(RNMAKE_PKG_LD_LIBS) $(LD_LIBS)
367 LDFLAGS := $(EXTRA_LDFLAGS) $(RNMAKE_PKG_LDFLAGS) $(LDFLAGS)
369 #
default link-loader is c compiler -
override if using C++
374 # default link-loader is c compiler - override if using CUDA 375 ifeq
"$(LANG)" "CUDA" 379 #------------------------------------------------------------------------------
381 # Construct build target files and
set from parent makefile.
384 # Preferred Library Type
for Distribution
385 LIB_TYPE := $(LIB_TYPE)
387 # Complete list of core libraries 388 STLIBS = $(RNMAKE_LOC_STLIBS) $(RNMAKE_DIST_STLIBS)
389 SHLIBS = $(RNMAKE_DIST_SHLIBS)
390 DLLIBS = $(RNMAKE_DIST_DLLIBS)
392 # Complete list of core programs 393 PGMS = $(RNMAKE_LOC_PGMS) $(RNMAKE_DIST_PGMS)
396 REL_FILES = $(RNMAKE_PKG_REL_FILES) $(EXTRA_REL_FILES)
399 SHARE_TGT = $(RNMAKE_PKG_TGT_SHARE) $(EXTRA_TGT_SHARE)
402 ETC_TGT = $(RNMAKE_PKG_TGT_ETC) $(EXTRA_TGT_ETC)
404 # $(call fq_lib_names,dir,lib...,libprefix,libsuffix) 405 # Make fully qualified library name(s) from core name(s). 407 $(
foreach lib,$(2),$(
if $($(lib).SUBDIR),\
408 $(addprefix $(1)/$($(lib).SUBDIR)/$(3),$(addsuffix $(4),$(lib))),\
409 $(addprefix $(1)/$(3),$(addsuffix $(4),$(lib)))))
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)))
417 # $(call fq_stlib_names,dir,lib...) 418 # Make fully qualified static library name(s) from core name(s). 421 # fqlibs = $(call fq_stlib_names,my/lib,kung panda) 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))
426 # $(call fq_shlib_names,dir,lib...)
427 # Make fully qualified shared library name(s) from core name(s). 429 # lex.SUBDIR = villian 430 # fqlibs = $(call fq_shlib_names,/home/lib,supergirl lex) 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))
435 # $(call fq_dllib_names,dir,lib...)
436 # Make fully qualified dynamically linked library name(s) from core name(s). 438 # falcon9.SUBDIR = spacex 439 # newshepard.SUBDIR = blueorigin 440 # fqlibs = $(call fq_dllib_names,lib,falcon9 newshepard) 442 # Sets 'fqlibs' to '/lib/spacex/libfalcon9.so lib/blueorign/libnewshepard.so' 444 $(call fq_lib_names,$(1),$(2),$(DLLIB_PREFIX),$(DLLIB_SUFFIX))
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))
450 # Fully Qualified Shared Libraries
451 FQ_SHLIBS = $(call fq_shlib_names,$(DISTDIR_LIB),$(RNMAKE_DIST_SHLIBS))
453 # Fully Qualified Dynamically Linked Libraries 454 FQ_DLLIBS = $(call fq_dllib_names,$(DISTDIR_LIB),$(RNMAKE_DIST_DLLIBS))
456 # Fully Qualified Program Name(s) from Core Name(s)
457 fq_pgm_names = $(addprefix $(1)/$(PGM_PREFIX),\
458 $(addsuffix $(PGM_SUFFIX),$(2)))
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))
465 FQ_REL_FILES = $(addprefix $(DISTDIR_DOC)/,$(REL_FILES))
467 # Auto-Generated header files directory
468 AUTO_INCDIR = $(firstword $(RNMAKE_PKG_INCDIRS))
469 ifeq ($(AUTO_INCDIR),)
470 AUTO_INCDIR = $(LOCDIR_INCLUDE)
473 # Auto-Generated Header Files 474 AUTO_VERSION_H = $(AUTO_INCDIR)/version.h
475 AUTO_INSTALL_H = $(AUTO_INCDIR)/install-$(RNMAKE_ARCH).h
477 AUTOHDRS = $(AUTO_VERSION_H)
479 # DEPRECATED $(AUTO_INSTALL_H) 482 #------------------------------------------------------------------------------ 483 # Target Specific Variables 486 # Shared library compiled objects need special CFLAGS (e.g. -fPIC) 487 $(FQ_SHLIBS): CFLAGS += $(SHLIB_CFLAGS)
489 # Dynamically Linked library compiled objects need special CFLAGS 490 $(FQ_DLLIBS): CFLAGS += $(DLLIB_CFLAGS)
492 #------------------------------------------------------------------------------ 493 # Common Support Functions and Macros 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)))
502 # Make obj/obj-<RNMAKE_ARCH> in current directory 504 @test -d
"$(OBJDIR)" || $(MKDIR) $(OBJDIR); \
505 test -d
"$(dir $(1))" || test -z
"$(dir $(1))" || $(MKDIR)
"$(dir $(1))" 508 ########################### Explicit Rules #####################################
510 # -------------------------------------------------------------------------
511 # Target: all (
default)
512 # Desc: Front end for making the [sub]package(s) (libraries, programs, tools, 514 # Notes: There are two version: 515 # 1) only done once on the first invocation and 516 # 2) for all other invocations. 518 ifeq ($(MAKELEVEL),0)
519 all: pkgbanner check-deps once-all $(EXTRA_TGT_ALL) pkg subdirs-all $(EXTRA_TGT_ALL_POST)
522 all: check-deps $(EXTRA_TGT_ALL) pkg subdirs-all $(EXTRA_TGT_ALL_POST)
526 once-all: mkdistdirs mklocdirs autohdrs
529 # ------------------------------------------------------------------------- 531 # Desc: Makes the distribution [sub]package(s) (libraries, programs, tools, 534 pkg: libs pgms rel share
537 # ------------------------------------------------------------------------- 539 # Desc: Makes all libraries in current directory. 543 libs: stlibs shlibs dllibs
545 # Make all static libraries 549 # Make all shared libraries
553 # Make all dll libraries 557 # Make specific distribution
static librarary
558 .PHONY: $(RNMAKE_DIST_STLIBS)
559 $(RNMAKE_DIST_STLIBS): $(call fq_stlib_names,$(DISTDIR_LIB),$(GOAL_LIST))
561 # Make specific distribution shared librarary 562 .PHONY: $(RNMAKE_DIST_SHLIBS)
563 $(RNMAKE_DIST_SHLIBS): $(call fq_shlib_names,$(DISTDIR_LIB),$(GOAL_LIST))
565 # Make specific distribution dll librarary
566 .PHONY: $(RNMAKE_DIST_DLLIBS)
567 $(RNMAKE_DIST_DLLIBS): $(call fq_dllib_names,$(DISTDIR_LIB),$(GOAL_LIST))
569 # Make specific local static librarary 570 .PHONY: $(RNMAKE_LOC_STLIBS)
571 $(RNMAKE_LOC_STLIBS): $(call fq_stlib_names,$(LOCDIR_LIB),$(GOAL_LIST))
573 # $(call STLIBtemplate,lib,libdir)
574 # Template to build a static library including all necessary prerequisites 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)
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)
588 # Template to build a shared library including all necessary prerequisites 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)
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)
601 # Template to build a dynamically linke library including all necessary
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)
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 $$@
615 # For each library target, evaluate (i.e make) the template. 616 $(
foreach lib,$(RNMAKE_LOC_STLIBS),\
617 $(eval $(call STLIBtemplate,$(lib),$(LOCDIR_LIB))))
619 $(
foreach lib,$(RNMAKE_DIST_STLIBS),\
620 $(eval $(call STLIBtemplate,$(lib),$(DISTDIR_LIB))))
622 $(
foreach lib,$(RNMAKE_DIST_SHLIBS),\
623 $(eval $(call SHLIBtemplate,$(lib),$(DISTDIR_LIB))))
625 $(
foreach lib,$(RNMAKE_DIST_DLLIBS),\
626 $(eval $(call DLLIBtemplate,$(lib),$(DISTDIR_LIB))))
628 # ------------------------------------------------------------------------- 630 # Desc: Makes all programs in current directory. 636 # Make specific local program
637 .PHONY: $(RNMAKE_LOC_PGMS)
638 $(RNMAKE_LOC_PGMS): $(call fq_pgm_names,$(LOCDIR_BIN),$(GOAL_LIST))
640 # Make specific distribution program 641 .PHONY: $(RNMAKE_DIST_PGMS)
642 $(RNMAKE_DIST_PGMS): $(call fq_pgm_names,$(DISTDIR_BIN),$(GOAL_LIST))
644 # Template to build a program including all necessary prerequisites
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)
652 @printf
"$(color_tgt_pgm) $$@$(color_end)\n" 653 $$(LD) $$(LDFLAGS) $$(LD_LIBPATHS) $$($(1).OBJS) $$($(1).LIBS) $$(LD_LIBS) -o $$@
656 libdeps = $(shell
for lib in $(1);
do echo lib$${lib}.a; done)
658 # For each program target, evaluate (i.e make)
template.
659 $(
foreach prog,$(RNMAKE_LOC_PGMS),\
660 $(eval $(call PGMtemplate,$(prog),$(LOCDIR_BIN))))
662 $(
foreach prog,$(RNMAKE_DIST_PGMS),\
663 $(eval $(call PGMtemplate,$(prog),$(DISTDIR_BIN))))
665 ## RDK investigate for linking programs 666 # $(LINK.o) $^ $(LDLIBS) -o $@ 668 # ------------------------------------------------------------------------- 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)
675 # verion.h
auto-generated header
676 $(AUTO_VERSION_H): $(RNMAKE_PKG_MKFILE)
678 @test -d
"$(AUTO_INCDIR)" || $(MKDIR) $(AUTO_INCDIR)
679 @$(MAKE) -f $(RNMAKE_ROOT)/version_h.mk -s \
680 RNMAKE_PKG_ROOT=$(RNMAKE_PKG_ROOT) \
682 pkg_mk=$(RNMAKE_PKG_MKFILE) \
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) \
694 includedir=$(includedir) \
695 sysconfdir=$(sysconfdir) \
701 # -------------------------------------------------------------------------
703 # Desc: Makes interface header files
705 # List of all header tags
706 HDR_TAG_LIST = $(addsuffix .HDRS.H,$(RNMAKE_DIST_HDRS))
707 #$(info HDR_TAG_LIST: $(HDR_TAG_LIST))
709 # Complete list of headers
710 PREREQ_HDRS = $(
foreach tag,$(HDR_TAG_LIST),$($(tag)))
711 #$(info PREREQ_HDRS: $(PREREQ_HDRS))
713 # Make all distribution headers
715 hdrs: echo-hdrs $(PREREQ_HDRS)
719 $(call printGoalDesc,$(DISTDIR_INCLUDE),\
720 Copying tagged interfaces headers from $(RNMAKE_PKG_ROOT)/include.)
722 # Copy newer headers to distribution include [sub]directory 726 src=$(RNMAKE_PKG_ROOT)/include/$$h; \
727 dst=$(DISTDIR_INCLUDE)/$$h; \
728 hdir=$$(dirname $$dst); \
729 if [ ! -f $$dst -o $$src -nt $$dst ]; \
731 test -d $$hdir || $(MKDIR) $$hdir; \
736 # ------------------------------------------------------------------------- 738 # Desc: Makes all release files 739 # Notes: Release files are only made at top level 741 ifeq
"$(RNMAKE_PKG_ROOT)" "." 747 .PHONY: $(DISTDIR_DOC)/VERSION.txt
748 $(DISTDIR_DOC)/VERSION.txt:
751 @echo
"$(RNMAKE_PKG) v$(RNMAKE_PKG_VERSION_DOTTED)" > $@
752 @echo
"Copyright (C) $(RNMAKE_PKG_VERSION_DATE) RoadNarrows LLC" >> $@
754 @echo
"Compiled: `date`" >> $@
756 $(DISTDIR_DOC)/README.md: README.md
761 $(DISTDIR_DOC)/README.txt: README.txt
766 $(DISTDIR_DOC)/README.xml: README.xml
771 # -------------------------------------------------------------------------
773 # Desc: Makes all share files
774 # Notes: Share files are only made at top level
776 ifeq
"$(RNMAKE_PKG_ROOT)" "." 782 # ------------------------------------------------------------------------- 783 # Target: etc (not used yet) 784 # Desc: Makes all system configuration files 785 # Notes: Etc files are only made at top level 787 ifeq
"$(RNMAKE_PKG_ROOT)" "." 794 # -------------------------------------------------------------------------
796 # Desc: Make Distribution Directories
797 .PHONY: mkdistdirs $(DISTDIR_LIST)
798 mkdistdirs: echo-mkdistdirs $(DISTDIR_LIST)
800 .PHONY: echo-mkdistdirs
802 ifeq ($(realpath $(DIST_ARCH)),)
803 $(call printGoalDesc,\
804 $(patsubst $(RNMAKE_PKG_ROOT)/%,%,$(DIST_ARCH)),\
805 Making distribution directories.)
809 @test -d ${@} || $(MKDIR) ${@}
812 # ------------------------------------------------------------------------- 814 # Desc: Make Local Directories 815 .PHONY: mklocdirs $(LOCDIR_LIST)
816 mklocdirs: echo-mklocdirs $(LOCDIR_LIST)
818 .PHONY: echo-mklocdirs
820 ifeq ($(realpath $(LOCDIR_BIN)),)
821 $(call printGoalDesc,\
822 $(patsubst $(RNMAKE_PKG_ROOT)/%,%,$(RNMAKE_LOCDIR_ROOT)),\
823 Making local directories.)
827 @test -d ${@} || $(MKDIR) ${@}
830 # ------------------------------------------------------------------------- 832 # Desc: Install the distribution 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)
841 $(call printEchoTgtGoalDesc,Installing package $(RNMAKE_PKG_FULL_NAME))
845 @
if [ ! -f $(DISTDIR_DOC)/VERSION.txt ]; \
847 echo
"Error: The $(RNMAKE_PKG) package has not been built. Try \"make\" first."; \
848 echo
"Install aborted."; \
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))
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))
867 install-includes: hdrs
869 @printf
"Installing includes to $(includedir)\n" 870 @$(RNMAKE_ROOT)/utils/doinstall.sh 664 $(DISTDIR_INCLUDE) $(includedir)
872 # install documentation 873 install-docs: documents
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)
878 # install share files
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) ]; \
885 $(SYMLINK) $(sharedir)/$(RNMAKE_PKG_FULL_NAME) $(sharedir)/$(RNMAKE_PKG); \
886 elif [ -L $(sharedir)/$(RNMAKE_PKG) ]; \
888 $(UNLINK) $(sharedir)/$(RNMAKE_PKG); \
889 $(SYMLINK) $(sharedir)/$(RNMAKE_PKG_FULL_NAME) $(sharedir)/$(RNMAKE_PKG); \
895 @printf
"Installing system configuration to $(sysconfdir)\n" 897 @$(RNMAKE_ROOT)/utils/doinstall.sh 664 $(DISTDIR_ETC) $(sysconfdir)
899 # Post-Install directory component template 900 # Usage: POSTINStemplate postprocess source_dir dest_dir 901 define POSTINStemplate
903 srclist=$$($(FIND) . -type f); \
904 for src in $$srclist; \
906 dst=
"$(3)/$${src##./}"; \
907 -$(1) $$dst 2>/dev/null || echo
" $$dst"; \
912 # ------------------------------------------------------------------------- 914 # Desc: Makes dependencies 915 # File: .deps/deps.$(RNMAKE_ARCH) 916 # ------------------------------------------------------------------------- 918 deps: pkgbanner echo-deps autohdrs mkdepsdir $(EXTRA_TGT_DEPS) hdrdeps libdeps \
924 $(call printEchoTgtGoalDesc,Making dependencies
for $(CURDIR))
928 @$(call printGoalDesc,$(@),Making C/C++ dependencies)
929 @echo $(call hdrdeps_sh,$(STLIBS) $(SHLIBS) $(DLLIBS) $(PGMS))
932 $(shell $(RNMAKE_ROOT)/utils/hdrdeps.sh \
933 -c
"$(RNMAKE_MAKEDEPS)" \
939 $(sort $(addsuffix .SRC.C,$(1)) \
940 $(addsuffix .SRC.CXX,$(1)) \
941 $(addsuffix .SRC.CPP,$(1))),\
948 @test -d $(DEPSDIR) || $(MKDIR) $(DEPSDIR)
950 # Check if deps file exist or error. 951 # If the override variable 'nodeps' is not empty, then no check is performed. 954 $(
if $(realpath $(DEPSFILE)),,\
955 $(error No dependencies file - Try
'make deps' first)))
958 # Include dependency file or error canned sequence. 959 # If the override variable 'nodeps' is not empty, then no action is performed. 962 $(
if $(call isFile,$(DEPSFILE)),\
963 $(eval include $(DEPSFILE)),\
964 $(error No dependencies file - Try
'make deps' first)))
967 # Conditionally include any dependency file for specific targets only. 968 $(
if $(call findGoals,all test),$(call includeDeps),)
976 # ------------------------------------------------------------------------- 978 # Desc: Deletes generated intermediate files 979 # ------------------------------------------------------------------------- 981 clean: pkgbanner echo-clean
do-clean $(EXTRA_TGT_CLEAN) subdirs-clean
986 $(call printEchoTgtGoalDesc,)
990 @echo
"Cleaning $(CURDIR)" 991 $(RM) *.o *.ii *.c~ *.cxx~ .h~ *.pyc *.pyo \
992 $(RNMAKE_LOC_PGMS) $(RNMAKE_DIST_PGMS) a.out doxy.*.log
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))
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)
1013 # -------------------------------------------------------------------------
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
1019 # -------------------------------------------------------------------------
1022 .PHONY: subdirs $(RNMAKE_SUBDIRS)
1023 subdirs: $(RNMAKE_SUBDIRS)
1025 # Make all sub-directories with all command-line goals
1027 $(call printDirBanner,$(@),$(GOAL_LIST))
1028 @$(MAKE) $(EXTRA_MAKE_FLAGS) -C $(@) $(GOAL_LIST)
1029 @printf
" $(color_dir_banner)~~$(color_end)\n" 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.
1037 # subdirs-<goal>: $(RNMAKE_SUBDIRS.<goal>)
1038 # $(RNMAKE_SUBDIRS.<goal>: 1041 # Usage: $(call SUBDIRtemplate,goal) 1043 define SUBDIRtemplate
1044 RNMAKE_SUBDIRS.$(1) = $(addsuffix .$(1),$(RNMAKE_SUBDIRS))
1046 subdirs-$(1): $$(RNMAKE_SUBDIRS.$(1))
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" 1054 # all goals with subdirectory traversal prerequisite 1055 GOALS_WITH_SUBDIRS += deps all clean
1057 # build make rules for goal-specific subdirectories 1058 $(
foreach goal,$(GOALS_WITH_SUBDIRS),$(eval $(call SUBDIRtemplate,$(goal))))
1061 # -------------------------------------------------------------------------
1062 # Pretty Print Support.
1064 # Defines canned sequences, goal recipes, and goal prerequisite targets.
1065 # -------------------------------------------------------------------------
1067 # Pretty print make banner.
1070 $(call printPkgBanner,$(RNMAKE_PKG_FULL_NAME),$(RNMAKE_ARCH),$(GOAL_LIST))
1073 # Conditionally print footer. 1074 footer = $(call printFooter,$(@),$(LAST_GOAL))
1077 # -------------------------------------------------------------------------
1078 # force some targets to always make
1082 ########################### Pattern Rules ##################################### 1084 # C Rule: <name>.c -> $(OBJDIR)/<name>.o 1086 $(call mkobjdir,$(@))
1088 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1089 $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1091 # C++ Rule: <name>.cxx -> $(OBJDIR)/<name>.o
1092 $(OBJDIR)/%.o : %.cxx
1093 $(call mkobjdir,$(@))
1095 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1096 $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1098 # C++ Rule: <name>.cpp -> $(OBJDIR)/<name>.o
1099 $(OBJDIR)/%.o : %.cpp
1100 $(call mkobjdir,$(@))
1102 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1103 $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1105 # CUDA Rule: <name>.cu -> $(OBJDIR)/<name>.o
1106 $(OBJDIR)/%.o : %.cu
1107 $(call mkobjdir,$(@))
1109 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1110 $(CUDA) $(CUDAFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1112 # Compile a single c file. (Nice
for debugging)
1114 $(call mkobjdir,$(OBJDIR)/$(@))
1116 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1117 $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(OBJDIR)/$(@) -c $(<)
1119 # Compile a single cxx file. (Nice for debugging) 1121 $(call mkobjdir,$(OBJDIR)/$(@))
1123 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1124 $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(OBJDIR)/$(@) -c $(<)
1126 # Compile a single cpp file. (Nice for debugging) 1128 $(call mkobjdir,$(OBJDIR)/$(@))
1130 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1131 $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(OBJDIR)/$(@) -c $(<)
1133 # Compile a single cuda file. (Nice for debugging) 1135 $(call mkobjdir,$(@))
1137 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1138 $(CUDA) $(CUDAFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
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". 1147 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1148 $(CC) $(CFLAGS_CPP_ONLY) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1150 # C PreProcess Rule: <name>.cpp -> <name>.ii
1151 # Generate c preprocessor output (useful to debug compiling errors)
1154 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1155 $(CXX) $(CXXFLAGS_CPP_ONLY) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1157 # C PreProcess Rule: <name>.cpp -> <name>.ii
1158 # Generate c preprocessor output (useful to debug compiling errors)
1161 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1162 $(CXX) $(CXXFLAGS_CPP_ONLY) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1164 # C PreProcess Rule: <name>.cu -> <name>.ii
1165 # Generate c preprocessor output (useful to debug compiling errors)
1168 @printf
"$(color_tgt_file) $(<)$(color_end)\n" 1169 $(CUDA) $(CUDAFLAGS_CPP_ONLY) $(CUDAFLAGS) $(CPPFLAGS) $(INCLUDES) -o $(@) -c $(<)
1175 # -------------------------------------------------------------------------
1176 #
default error rule (doesn
't work yet) 1179 # @echo "$(@): Unknown target. See 'make help
' for help."