From d7a4934b3e641af54fbf42e98a7b15c6f30ef82e Mon Sep 17 00:00:00 2001 From: Richard Bradley Date: Tue, 8 Aug 2023 09:12:12 +0900 Subject: [PATCH] version 2.2 --- HISTORY.md | 7 ++++++ Makefile.mk | 70 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index ef92edc..0b02ed8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,12 @@ # Version release history +## 2.2 - minor release (2023/8/5) +NEW FEATURES: +* Added 'mapfile' option to generate link map output for built binaries & shared libraries. + +FIXES: +* Binary link commands on Windows no longer have .exe added to the output name to fix issues for cross compiling. + ## 2.1.1 - bug fix release (2023/7/28) FIXES: * Fixed Windows specific issues for project shared library linking and loading for unit tests. diff --git a/Makefile.mk b/Makefile.mk index a7711ef..601b7ca 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -1,5 +1,5 @@ # -# Makefile.mk - version 2.1.1 (2023/7/28) +# Makefile.mk - version 2.2 (2023/8/5) # Copyright (C) 2023 Richard Bradley # # Additional contributions from: @@ -120,6 +120,7 @@ # pedantic enforces strict ISO C/C++ compliance # static_rtlib statically link with runtime library (libgcc usually) # static_stdlib statically link with C++ standard library (libstdc++ usually) +# mapfile generate a link map file for binaries & shared libraries # OPTIONS_TEST additional options for all tests # FLAGS additional compiler flags not otherwise specified # FLAGS_TEST additional compiler flags for all tests @@ -381,7 +382,7 @@ endef #### OPTIONS handling #### -override _op_list := warn_error pthread lto modern_c++ no_rtti no_except pedantic static_rtlib static_stdlib +override _op_list := warn_error pthread lto modern_c++ no_rtti no_except pedantic static_rtlib static_stdlib mapfile override define _check_options # <1:options var> <2:set prefix> ifneq ($$(strip $$($1)),) @@ -598,8 +599,8 @@ override _output_lib_dir = $(patsubst %/,%,$(or $(strip $(OUTPUT_LIB_DIR)),$(str override _src_path := $(if $(SOURCE_DIR),$(filter-out ./,$(SOURCE_DIR:%/=%)/)) # output target name generation macros - <1:build env> <2:label> -override _gen_bin_name = $(_$1_bdir)$($2)$(_$1_bsfx)$(_binext) -override _gen_bin_aliases = $(if $(_$1_bdir),$($2)$(_$1_sfx)) $(if $(_binext),$(_$1_bdir)$($2)$(_$1_bsfx)) +override _gen_bin_name = $(_$1_bdir)$($2)$(_$1_bsfx) +override _gen_bin_aliases = $(if $(_$1_bdir),$($2)$(_$1_sfx)) $(if $(_binext),$(_$1_bdir)$($2)$(_$1_bsfx)$(_binext)) override _gen_static_lib_name = $(_$1_ldir)$($2)$(_$1_lsfx).a override _gen_static_lib_aliases = $($2)$(_$1_sfx) $(if $(_$1_ldir),$($2)$(_$1_sfx).a) override _gen_implib_name = $(_$1_ldir)$($2)$(_$1_lsfx).dll.a @@ -646,14 +647,15 @@ ifneq ($$(_windows),) override _$1_implibs := $$(foreach x,$$(_shared_lib_labels),$$(call _gen_implib_name,$1,$$x)) endif -override _$1_libbin_targets :=\ +override _$1_lib_targets :=\ $$(_$1_shared_libs) $$(_$1_implibs)\ - $$(foreach x,$$(_static_lib_labels),$$(call _gen_static_lib_name,$1,$$x))\ + $$(foreach x,$$(_static_lib_labels),$$(call _gen_static_lib_name,$1,$$x)) +override _$1_bin_targets :=\ $$(foreach x,$$(_bin_labels),$$(call _gen_bin_name,$1,$$x)) override _$1_file_targets := $$(foreach x,$$(_file_labels),$$($$x)) override _$1_test_targets := $$(foreach x,$$(_test_labels),$$x$$(_$1_sfx)) -override _$1_build_targets := $$(_$1_file_targets) $$(_$1_libbin_targets) $$(_$1_test_targets) +override _$1_build_targets := $$(_$1_file_targets) $$(_$1_lib_targets) $$(_$1_bin_targets) $$(_$1_test_targets) override _$1_filter_targets :=\ $$(foreach x,$$(EXCLUDE_TARGETS),$$(call _gen_filter_targets,$1,$$(subst *,%,$$x))) @@ -836,41 +838,43 @@ else ifneq ($(_build_env),) endif ifeq ($$(strip $$($1.OPTIONS)),) - override _$1_op_warn := $$(_op_warn) $$(if $2,$$(_op_test_warn)) - override _$1_op_flags := $$(_op_flags) $$(if $2,$$(_op_test_flags)) - override _$1_op_link := $$(_op_link) $$(if $2,$$(_op_test_link)) - override _$1_op_cxx_warn := $$(_op_cxx_warn) $$(if $2,$$(_op_test_cxx_warn)) - override _$1_op_cxx_flags := $$(_op_cxx_flags) $$(if $2,$$(_op_test_cxx_flags)) - override _$1_op_cxx_link := $$(_op_cxx_link) $$(if $2,$$(_op_test_cxx_link)) + override _$1_options := $$(OPTIONS) $(if $2,$$(OPTIONS_TEST)) + override _$1_op_warn := $$(_op_warn) $(if $2,$$(_op_test_warn)) + override _$1_op_flags := $$(_op_flags) $(if $2,$$(_op_test_flags)) + override _$1_op_link := $$(_op_link) $(if $2,$$(_op_test_link)) + override _$1_op_cxx_warn := $$(_op_cxx_warn) $(if $2,$$(_op_test_cxx_warn)) + override _$1_op_cxx_flags := $$(_op_cxx_flags) $(if $2,$$(_op_test_cxx_flags)) + override _$1_op_cxx_link := $$(_op_cxx_link) $(if $2,$$(_op_test_cxx_link)) else ifneq ($$(strip $$($1.OPTIONS)),-) + override _$1_options := $$($1.OPTIONS) $$(eval $$(call _check_options,$1.OPTIONS,_$1_op)) endif ifneq ($$(strip $$($1.PACKAGES)),-) - override _$1_pkgs := $$(or $$(call _check_pkgs,$1.PACKAGES),$$(_pkgs) $$(if $2,$$(_pkgs_test))) + override _$1_pkgs := $$(or $$(call _check_pkgs,$1.PACKAGES),$$(_pkgs) $(if $2,$$(_pkgs_test))) endif ifneq ($$(strip $$($1.LIBS)),-) - override _$1_libs := $$(filter-out $1,$$(or $$($1.LIBS),$$(LIBS) $$(if $2,$$(LIBS_TEST)))) + override _$1_libs := $$(filter-out $1,$$(or $$($1.LIBS),$$(LIBS) $(if $2,$$(LIBS_TEST)))) endif ifneq ($$(strip $$($1.DEFINE)),-) - override _$1_define := $$(or $$(call _format_define,$$($1.DEFINE)),$$(_define) $$(if $2,$$(_define_test))) + override _$1_define := $$(or $$(call _format_define,$$($1.DEFINE)),$$(_define) $(if $2,$$(_define_test))) endif ifneq ($$(strip $$($1.INCLUDE)),-) - override _$1_include := $$(or $$(call _format_include,$$($1.INCLUDE)),$$(_include) $$(if $2,$$(_include_test))) + override _$1_include := $$(or $$(call _format_include,$$($1.INCLUDE)),$$(_include) $(if $2,$$(_include_test))) endif ifneq ($$(strip $$($1.FLAGS)),-) - override _$1_flags := $$(or $$($1.FLAGS),$$(FLAGS) $$(if $2,$$(FLAGS_TEST))) + override _$1_flags := $$(or $$($1.FLAGS),$$(FLAGS) $(if $2,$$(FLAGS_TEST))) endif endef $(foreach x,$(_lib_labels) $(_bin_labels),$(eval $(call _build_entry1,$x,))) $(foreach x,$(_test_labels),$(eval $(call _build_entry1,$x,test))) ## general entry setting parsing (post) - override define _build_entry2 # <1:label> <2:test flag> + override define _build_entry2 # <1:label> override _$1_req_pkgs := $$(foreach x,$$(_$1_libs) $$(_$1_objs),$$(if $$(filter $$x,$$(_lib_labels)),$$(_$$x_pkgs))) override _$1_req_libs := $$(filter-out $1,$$(foreach x,$$(_$1_libs) $$(_$1_objs),$$(if $$(filter $$x,$$(_lib_labels)),$$(_$$x_libs)))) override _$1_link_deps := $$(foreach x,$$(_$1_libs),$$(if $$(filter $$x,$$(_lib_labels)),$$(or $$(_$$x_shared_name),$$(_$$x_name)))) @@ -912,8 +916,7 @@ else ifneq ($(_build_env),) override _$1_build_dir := $$(_build_dir)/$$(_$1_build) override _$1_all_objs := $$(addprefix $$(_$1_build_dir)/,$$(_$1_src_objs)) endef - $(foreach x,$(_lib_labels) $(_bin_labels),$(eval $(call _build_entry2,$x,))) - $(foreach x,$(_test_labels),$(eval $(call _build_entry2,$x,test))) + $(foreach x,$(_src_labels),$(eval $(call _build_entry2,$x))) # NOTES: # -