diff --git a/LICENSE b/LICENSE index 484d6df..87b5c36 100644 --- a/LICENSE +++ b/LICENSE @@ -1,12 +1,12 @@ -MIT No Attribution - -Copyright 2023 Martinus Theodorus Johannes Helena ten Velden +Copyright (c) 2024 Martinus Theodorus Johannes Helena ten Velden Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so. +permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A diff --git a/makefile_mini.mk b/makefile_mini.mk index 329c4ed..878c0cd 100644 --- a/makefile_mini.mk +++ b/makefile_mini.mk @@ -1,4 +1,4 @@ -MAKEFILE_MINI_VERSION:=0.1 +MAKEFILE_MINI_VERSION:=0.1.1 # usage.. # make #< default target makes all not ignored binaries @@ -126,10 +126,12 @@ MM_EXECUTABLE_EXTENSION_OR_DOT:=$(if $(MM_EXECUTABLE_EXTENSION),$(MM_EXECUTABLE_ ifndef OS #< linux # NOTE: $(1) = non cli (see windows version of mm_cli_mkdir) -mm_cli_mkdir=mkdir $(1) +mm_cli_mkdir=mkdir -p $(1) # TODO: not tested # NOTE: $(1) == non cli (see windows version of mm_cli_rmdir) -mm_cli_rmdir=rmdir $(1) +mm_cli_rmdir=rm -d -f $(1) +# NOTE: ^ +# not using rmdir because that will error if folder doesn't exist mm_cli_rm=rm -f $(1) @@ -211,11 +213,18 @@ ifndef OS #< linux # $(2) == inputfile (cli) # $(3) == outputfile (cli) define mm_cli_hfile_from_file= -$(eval mm_cli_hfile_from_file_a:=$(shell tr -c a-zA-Z0-9 _ $(1))) -$(eval mm_cli_hfile_from_file_b:=$(shell tr a-z A-Z $(mm_cli_hfile_from_file_a))) -echo #ifndef $(mm_hfile_from_file_b)_H`n#define $(mm_cli_hfile_from_file_b)_H`n`n`nchar $(mm_cli_hfile_from_file_a)_h[] = {\" > $(3) -od -An -v -td1 $(2) | tr -s " " | tr -d "\n" | sed -z -e "s/ /, /g;s/^, //;s/, $ //" >> $(3) -echo \"`n`n#endif`n\" >> $(3) +$(strip\ + $(eval $(0)_a:=$(shell echo -n $(1) | tr -c a-zA-Z0-9 _))\ + $(eval $(0)_b:=$(shell echo -n $($(0)_a) | tr a-z A-Z))\ + echo "#ifndef $($(0)_b)_H" > $(3);\ + echo "#define $($(0)_b)_H" >> $(3);\ + echo >> $(3); echo >> $(3);\ + echo -n "char $($(0)_a)_h[] = { " >> $(3);\ + od -An -v -td1 $(2) | tr -s " " | tr -d "\n" | sed -z -e "s/ /, /g;s/^, //;s/, $$$$//" >> $(3);\ + echo " };" >> $(3);\ + echo >> $(3);\ + echo "#endif" >> $(3)\ +) endef # NOTE: ^ # https://unix.stackexchange.com/a/758531 @@ -225,9 +234,9 @@ else #< windows # $(3) == outputfile (cli) define mm_cli_hfile_from_file= $(strip\ - $(eval mm_cli_hfile_from_file_a:=$(shell powershell.exe "\"$(1)\" -Replace \"[^a-zA-Z0-9]\",\"_\""))\ - $(eval mm_cli_hfile_from_file_b:=$(shell powershell.exe ""\"$(mm_cli_hfile_from_file_a)\".ToUpper()"))\ - powershell.exe "$$$$a=(Get-Content -Encoding Byte -Raw $(2) | Out-String).Replace(\"`r`n\",\", \").TrimEnd(\", \"); Set-Content -NoNewline \"#ifndef $(mm_cli_hfile_from_file_b)_H`n#define $(mm_cli_hfile_from_file_b)_H`n`n`nchar $(mm_cli_hfile_from_file_a)_h[] = { $$$$a };`n`n#endif`n\"" $(3)\ + $(eval $(0)_a:=$(shell powershell.exe "\"$(1)\" -Replace \"[^a-zA-Z0-9]\",\"_\""))\ + $(eval $(0)_b:=$(shell powershell.exe ""\"$($(0)_a)\".ToUpper()"))\ + powershell.exe "$$$$a=(Get-Content -Encoding Byte -Raw $(2) | Out-String).Replace(\"`r`n\",\", \").TrimEnd(\", \"); Set-Content -NoNewline \"#ifndef $($(0)_b)_H`n#define $($(0)_b)_H`n`n`nchar $($(0)_a)_h[] = { $$$$a };`n`n#endif`n\"" $(3)\ ) endef endif @@ -239,13 +248,13 @@ endif # NOTE: not the same as $(if $(filter $(1),$(2),,) as mm_equals also.. # .. returns 1 if both $(1) and $(2) are both empty define mm_equals= -$(eval mm_equals_a:=$(strip $(1))) -$(eval mm_equals_b:=$(strip $(2))) -$(eval mm_equals_bAreBothEmpty:=0) -$(if $(mm_equals_a),,$(if $(mm_equals_b),,$(eval mm_equals_bAreBothEmpty:=1))) -$(if $(filter 1,$(mm_equals_bAreBothEmpty)),\ +$(eval $(0)_a:=$(strip $(1))) +$(eval $(0)_b:=$(strip $(2))) +$(eval $(0)_bAreBothEmpty:=0) +$(if $($(0)_a),,$(if $($(0)_b),,$(eval $(0)_bAreBothEmpty:=1))) +$(if $(filter 1,$($(0)_bAreBothEmpty)),\ 1,\ - $(if $(filter $(mm_equals_a),$(mm_equals_b)),1,0)\ + $(if $(filter $($(0)_a),$($(0)_b)),1,0)\ ) endef @@ -262,11 +271,11 @@ endef define mm_switch= $(if $(filter 1,$(call mm_equals,$(1),$(firstword $(2)))),\ $(firstword $(3)),\ - $(eval mm_switch_a:=$(words $(2)))\ - $(if $(filter 1,$(mm_switch_a)),,\ - $(eval mm_switch_b:=$(wordlist 2,$(mm_switch_a),$(2)))\ - $(eval mm_switch_c:=$(wordlist 2,$(mm_switch_a),$(3)))\ - $(call mm_switch,$(1),$(mm_switch_b),$(mm_switch_c))\ + $(eval $(0)_a:=$(words $(2)))\ + $(if $(filter 1,$($(0)_a)),,\ + $(eval $(0)_b:=$(wordlist 2,$($(0)_a),$(2)))\ + $(eval $(0)_c:=$(wordlist 2,$($(0)_a),$(3)))\ + $(call mm_switch,$(1),$($(0)_b),$($(0)_c))\ )\ ) endef @@ -279,13 +288,13 @@ mm_add_or_append_one_element=$(eval $(1)+=$(1).$(words $($(1)))) # NOTE: like $(filter <..>) but using regular expression pattern define mm_filter_using_patterns= $(strip\ - $(eval mm_filter_using_patterns_a:=$(firstword $(2)))\ - $(eval mm_filter_using_patterns_b:=$(wordlist 2,$(words $(2)),$(2)))\ - $(eval mm_filter_using_patterns_c:=$(firstword $(1)))\ - $(eval mm_filter_using_patterns_d:=$(wordlist 2,$(words $(1)),$(1)))\ + $(eval $(0)_a:=$(firstword $(2)))\ + $(eval $(0)_b:=$(wordlist 2,$(words $(2)),$(2)))\ + $(eval $(0)_c:=$(firstword $(1)))\ + $(eval $(0)_d:=$(wordlist 2,$(words $(1)),$(1)))\ $(if $(OS),\ - $(shell powershell "\"$(mm_filter_using_patterns_a)\"$(patsubst %,$(MM_COMMA)\"%\",$(mm_filter_using_patterns_b)) | Select-String -Pattern \"$(mm_filter_using_patterns_c)\"$(patsubst %,$(MM_COMMA)\"%\",$(mm_filter_using_patterns_d))"),\ - $(shell (echo "$(mm_filter_using_patterns_a)"$(patsubst %,; echo "%",$(mm_filter_using_patterns_b))) | grep -i -E "$(mm_filter_using_patterns_c)$(addprefix |,$(mm_filter_using_patterns_d))")\ + $(shell powershell "\"$($(0)_a)\"$(patsubst %,$(MM_COMMA)\"%\",$($(0)_b)) | Select-String -Pattern \"$($(0)_c)\"$(patsubst %,$(MM_COMMA)\"%\",$($(0)_d))"),\ + $(shell (echo "$($(0)_a)"$(patsubst %,; echo "%",$($(0)_b))) | grep -i -E "$($(0)_c)$(addprefix |,$($(0)_d))")\ )\ ) endef @@ -332,16 +341,16 @@ mm_check_if_defined=$(if $(filter undefined,$(origin $(2))),$(error $(2) is not # $(2) == value pattern # $(3) == values variablename define mm_check_if_valid_values= -$(eval mm_check_if_valid_values_a:=$(filter-out $(2),$($(3)))) -$(if $(mm_check_if_valid_values_a),$(error $(3) contains invalid element(s) $(mm_check_if_valid_values_a) in $(1)),) +$(eval $(0)_a:=$(filter-out $(2),$($(3)))) +$(if $($(0)_a),$(error $(3) contains invalid element(s) $($(0)_a) in $(1)),) endef # NOTE: $(1) == functionname # $(2) == value pattern # $(3) == value variablename define mm_check_if_valid_value= -$(eval mm_check_if_valid_value_a:=$(filter-out $(2),$($(3)))) -$(if $(mm_check_if_valid_value_a),$(error $(3) contains invalid value $(mm_check_if_valid_value_a) in $(1)),) +$(eval $(0)_a:=$(filter-out $(2),$($(3)))) +$(if $($(0)_a),$(error $(3) contains invalid value $($(0)_a) in $(1)),) endef #****************************************************************************** @@ -425,23 +434,23 @@ mm_get_binaryfilepath_from_binary=$(if $(filter 1,$(call mm_is_binary_ignored,$( # $(2) == filepath variablename # NOTE: assumes $(1) does not start with .makefile-mini/ define mm_add_binary= -$(eval mm_add_binary_filepath:=) +$(eval $(0)_filepath:=) $(if $(filter 1,$(call mm_is_binary_ignored,$(1))),\ - $(eval mm_add_binary_filepath:=.makefile-mini/$(1))\ + $(eval $(0)_filepath:=.makefile-mini/$(1))\ $(eval MM_IGNOREDBINARIES+=$(1)),\ - $(eval mm_add_binary_filepath:=$(1))\ + $(eval $(0)_filepath:=$(1))\ $(eval MM_NOTIGNOREDBINARIES+=$(1))\ ) -$(eval MM_FILEPATH_PER_BINARY+=$(mm_add_binary_filepath)) -$(eval $(2):=$(mm_add_binary_filepath)) +$(eval MM_FILEPATH_PER_BINARY+=$($(0)_filepath)) +$(eval $(2):=$($(0)_filepath)) endef # NOTE: $(1) == binarypart define mm_get_binarypartfolderpathpart_from_binarypart= $(strip \ - $(eval mm_get_binarypartfolderpathpart_from_binarypart_a:=$(dir $(1)))\ - $(if $(filter ./,$(mm_get_binarypartfolderpathpart_from_binarypart_a)),,\ - $(mm_get_binarypartfolderpathpart_from_binarypart_a)\ + $(eval $(0)_a:=$(dir $(1)))\ + $(if $(filter ./,$($(0)_a)),,\ + $($(0)_a)\ )\ ) endef @@ -449,9 +458,9 @@ endef # NOTE: $(1) == binarypart define mm_get_binarypartfolderpath_from_binarypart= $(strip \ - $(eval mm_get_binarypartfolderpath_from_binarypart_binarypartfolderpathpart:=$(call mm_get_binarypartfolderpathpart_from_binarypart,$(1)))\ - $(if $(mm_get_binarypartfolderpath_from_binarypart_binarypartfolderpathpart),\ - .makefile-mini/$(mm_get_binarypartfolderpath_from_binarypart_binarypartfolderpathpart)\ + $(eval $(0)_binarypartfolderpathpart:=$(call mm_get_binarypartfolderpathpart_from_binarypart,$(1)))\ + $(if $($(0)_binarypartfolderpathpart),\ + .makefile-mini/$($(0)_binarypartfolderpathpart)\ ,)\ ) endef @@ -460,9 +469,9 @@ endef # NOTE: assumes $(1) does not start with .makefile-mini/ define mm_add_binarypart= $(eval MM_BINARYPARTS+=$(1)) -$(eval mm_add_binarypart_binarypartfolderpathpart:=$(call mm_get_binarypartfolderpathpart_from_binarypart,$(1))) -$(if $(filter $(mm_add_binarypart_binarypartfolderpathpart),$(MM_FOLDERPATHPART_PER_BINARYPART)),,\ - $(eval MM_FOLDERPATHPART_PER_BINARYPART+=$(mm_add_binarypart_binarypartfolderpathpart))\ +$(eval $(0)_binarypartfolderpathpart:=$(call mm_get_binarypartfolderpathpart_from_binarypart,$(1))) +$(if $(filter $($(0)_binarypartfolderpathpart),$(MM_FOLDERPATHPART_PER_BINARYPART)),,\ + $(eval MM_FOLDERPATHPART_PER_BINARYPART+=$($(0)_binarypartfolderpathpart))\ ) endef @@ -481,8 +490,8 @@ endef # $(3) == RESOURCETYPE plural # $(4) == resources variablename define mm_check_resources= -$(eval mm_check_resources_a:=$(filter-out $(MM_$(3)),$($(4)))) -$(if $(mm_check_resources_a),$(error $(3) contains element(s) that aren't $(2) in $(1)),) +$(eval $(0)_a:=$(filter-out $(MM_$(3)),$($(4)))) +$(if $($(0)_a),$(error $(3) contains element(s) that aren't $(2) in $(1)),) endef #****************************************************************************** @@ -493,24 +502,24 @@ endef # .. $(2).. returns 1 # otherwise.. returns 0 define mm_is_resource= -$(eval mm_is_resource_bIsResource:=0) -$(foreach mm_is_resource_infoAboutResource,$(MM_INFO_PER_$(1)),\ - $(if $(filter $($(mm_is_resource_infoAboutResource).name),$(2)),\ - $(eval mm_is_resource_bIsResource:=1)\ +$(eval $(0)_bIsResource:=0) +$(foreach $(0)_infoAboutResource,$(MM_INFO_PER_$(1)),\ + $(if $(filter $($($(0)_infoAboutResource).name),$(2)),\ + $(eval $(0)_bIsResource:=1)\ ,)\ ) -$(if $(filter 1,$(mm_is_resource_bIsResource)),1,0) +$(if $(filter 1,$($(0)_bIsResource)),1,0) endef # NOTE: $(1) == RESOURCETYPE # $(2) == variablename(s) # $(3) == resources define mm_get_variables_from_resources= -$(foreach mm_get_variables_from_resources_resource,$(3),\ - $(foreach mm_get_variables_from_resources_infoAboutResource,$(MM_INFO_PER_$(1)),\ - $(if $(filter $($(mm_get_variables_from_resources_infoAboutResource).name),$(mm_get_variables_from_resources_resource)),\ - $(foreach mm_get_variables_from_resources_a,$(2),\ - $($(mm_get_variables_from_resources_infoAboutResource).$(mm_get_variables_from_resources_a))\ +$(foreach $(0)_resource,$(3),\ + $(foreach $(0)_infoAboutResource,$(MM_INFO_PER_$(1)),\ + $(if $(filter $($($(0)_infoAboutResource).name),$($(0)_resource)),\ + $(foreach $(0)_a,$(2),\ + $($($(0)_infoAboutResource).$($(0)_a))\ )\ ,)\ )\ @@ -622,40 +631,40 @@ $(if $(filter undefined,$(origin MM_SAFETY)),,\ $(call mm_check_add_shader_parameters_t,$(0),$(2))\ ) $(call mm_add_or_append_one_element,MM_INFO_PER_SHADER) -$(eval mm_add_shader_infoAboutShader:=$(lastword $(MM_INFO_PER_SHADER))) -$(call mm_info_about_shader_t,$(mm_add_shader_infoAboutShader)) -$(eval $(mm_add_shader_infoAboutShader).name:=$(1)) -$(eval $(mm_add_shader_infoAboutShader).type:=$($(2).type)) -$(eval $(mm_add_shader_infoAboutShader).filetypes:=$($(2).filetypes)) -$(eval $(mm_add_shader_infoAboutShader).spvasm:=$(patsubst %.glsl,%.spvasm,$($(2).glsl))) -$(eval $(mm_add_shader_infoAboutShader).spv:=$($(1).spv)) -$(eval mm_add_shader_bIsSpvasmFromGlsl:=0) -$(foreach mm_add_shader_infoAboutSpvasmFromGlsl,$(MM_INFO_PER_SPVASM_FROM_GLSL),\ - $(if $(filter $($(mm_add_shader_infoAboutSpvasmFromGlsl).spvasm),$($(2).spvasm)),\ - $(if $(filter $($(mm_add_shader_infoAboutSpvasmFromGlsl).type),$($(2).type)),,\ +$(eval $(0)_infoAboutShader:=$(lastword $(MM_INFO_PER_SHADER))) +$(call mm_info_about_shader_t,$($(0)_infoAboutShader)) +$(eval $($(0)_infoAboutShader).name:=$(1)) +$(eval $($(0)_infoAboutShader).type:=$($(2).type)) +$(eval $($(0)_infoAboutShader).filetypes:=$($(2).filetypes)) +$(eval $($(0)_infoAboutShader).spvasm:=$(patsubst %.glsl,%.spvasm,$($(2).glsl))) +$(eval $($(0)_infoAboutShader).spv:=$($(1).spv)) +$(eval $(0)_bIsSpvasmFromGlsl:=0) +$(foreach $(0)_infoAboutSpvasmFromGlsl,$(MM_INFO_PER_SPVASM_FROM_GLSL),\ + $(if $(filter $($($(0)_infoAboutSpvasmFromGlsl).spvasm),$($(2).spvasm)),\ + $(if $(filter $($($(0)_infoAboutSpvasmFromGlsl).type),$($(2).type)),,\ $(error $($(2).spvasm) required more than once but with different type value in $(0))\ )\ - $(if $(filter 0,$(call mm_equals,$($(mm_add_vertexshader_infoAboutSpvasmFromGlsl).glslangValidator).$($(2).glslangValidator)))\ + $(if $(filter 0,$(call mm_equals,$($($(0)_infoAboutSpvasmFromGlsl).glslangValidator).$($(2).glslangValidator)))\ $(error $($(2).spvasm) required more than once but with different glslangValidator value in $(0))\ ,)\ - $(eval mm_add_shader_bIsSpvasmFromGlsl:=1)\ + $(eval $(0)_bIsSpvasmFromGlsl:=1)\ ,)\ ) -$(if $(filter 0,$(mm_add_shader_bIsSpvasmFromGlsl)),\ +$(if $(filter 0,$($(0)_bIsSpvasmFromGlsl)),\ $(call mm_add_or_append_one_element,MM_INFO_PER_SPVASM_FROM_GLSL)\ - $(eval mm_add_shader_infoAboutSpvasmFromGlsl:=$(lastword $(MM_INFO_PER_SPVASM_FROM_GLSL)))\ - $(eval $(mm_add_shader_infoAboutSpvasmFromGlsl).type:=$($(2).type))\ - $(eval $(mm_add_shader_infoAboutSpvasmFromGlsl).spvasm:=$($(mm_add_shader_infoAboutShader).spvasm))\ - $(eval $(mm_add_shader_infoAboutSpvasmFromGlsl).glslangValidator:=$($(2).glslangValidator))\ - $(call mm_add_binarypart,$($(mm_add_shader_infoAboutShader).spvasm))\ + $(eval $(0)_infoAboutSpvasmFromGlsl:=$(lastword $(MM_INFO_PER_SPVASM_FROM_GLSL)))\ + $(eval $($(0)_infoAboutSpvasmFromGlsl).type:=$($(2).type))\ + $(eval $($(0)_infoAboutSpvasmFromGlsl).spvasm:=$($($(0)_infoAboutShader).spvasm))\ + $(eval $($(0)_infoAboutSpvasmFromGlsl).glslangValidator:=$($(2).glslangValidator))\ + $(call mm_add_binarypart,$($($(0)_infoAboutShader).spvasm))\ ,) $(if $(filter EMMShaderfiletype_Shared,$($(2).filetypes)),\ - $(call mm_add_binary,$(1).spv,$(mm_add_shader_infoAboutShader).spvFilepath),\ + $(call mm_add_binary,$(1).spv,$($(0)_infoAboutShader).spvFilepath),\ $(call mm_add_binarypart,$(1).spv)\ - $(eval $(mm_add_shader_infoAboutShader).spvFilepath:=.makefile-mini/$(1).spv)\ + $(eval $($(0)_infoAboutShader).spvFilepath:=.makefile-mini/$(1).spv)\ ) $(if $(filter EMMShaderfiletype_Static,$($(2).filetypes)),\ - $(call mm_add_binary,$(1).spv.h,$(mm_add_shader_infoAboutShader).spvHFilepath)\ + $(call mm_add_binary,$(1).spv.h,$($(0)_infoAboutShader).spvHFilepath)\ ,) endef # TODO: ^ @@ -701,14 +710,14 @@ MM_INFO_PER_O_FROM_CPP:= # NOTE: $(1) == functionname # $(2) == lib define mm_check_lib= -$(eval mm_check_lib_invalidLib:=) -$(foreach mm_check_lib_lib,$($(2)),\ - $(if $(findstring .,$(mm_check_lib_lib)),\ - $(eval mm_check_lib_invalidLib+=$(mm_check_lib_lib))\ +$(eval $(0)_invalidLib:=) +$(foreach $(0)_lib,$($(2)),\ + $(if $(findstring .,$($(0)_lib)),\ + $(eval $(0)_invalidLib+=$($(0)_lib))\ )\ ) -$(if $(mm_check_lib_invalidLib),\ - $(error $(2) contains invalid value(s) $(mm_check_lib_invalidLib) in $(1))\ +$(if $($(0)_invalidLib),\ + $(error $(2) contains invalid value(s) $($(0)_invalidLib) in $(1))\ ,) endef @@ -723,38 +732,38 @@ endef # $(7) == .gcc/.g++ # $(8) == .o define mm_add_o_from_c_or_cpp= -$(foreach mm_add_o_from_c_or_cpp_o,$(8),\ +$(foreach $(0)_o,$(8),\ $(if $(OS),\ - $(eval mm_add_o_from_c_or_cpp_cOrCpp:=$(basename $(mm_add_o_from_c_or_cpp_o))),\ - $(eval mm_add_o_from_c_or_cpp_cOrCpp:=$(basename $(basename $(mm_add_o_from_c_or_cpp_o))))\ + $(eval $(0)_cOrCpp:=$(basename $($(0)_o))),\ + $(eval $(0)_cOrCpp:=$(basename $(basename $($(0)_o))))\ )\ - $(eval mm_add_o_from_c_or_cpp_gccOrG++:=$(7))\ + $(eval $(0)_gccOrG++:=$(7))\ $(if $(OS),,\ - $(if $(patsubst %.shared.o,%,$(mm_add_o_from_c_or_cpp_gccOrG++)),\ - $(eval mm_add_o_from_c_or_cpp_gccOrG++ +=-fpic -fvisibility=hidden)\ + $(if $(filter %.shared.o,$($(0)_o)),\ + $(eval $(0)_gccOrG++ +=-fpic -fvisibility=hidden)\ ,)\ )\ - $(eval mm_add_o_from_c_or_cpp_bIsOFromCOrCpp:=0)\ - $(foreach mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp,$(MM_INFO_PER_O_FROM_$(2)),\ - $(if $(filter $($(mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp).o),$(mm_add_o_from_c_or_cpp_o)),\ - $(if $(filter 0,$(call mm_equals,$($(mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp).$(4)Folders),$(6))),\ - $(error $(mm_add_o_from_c_or_cpp_o) required more than once but with different $(4)Folders value in $(1))\ + $(eval $(0)_bIsOFromCOrCpp:=0)\ + $(foreach $(0)_infoAboutOFromCOrCpp,$(MM_INFO_PER_O_FROM_$(2)),\ + $(if $(filter $($($(0)_infoAboutOFromCOrCpp).o),$($(0)_o)),\ + $(if $(filter 0,$(call mm_equals,$($($(0)_infoAboutOFromCOrCpp).$(4)Folders),$(6))),\ + $(error $($(0)_o) required more than once but with different $(4)Folders value in $(1))\ ,)\ - $(if $(filter 0,$(call mm_equals,$($(mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp).$(5)),$(mm_add_o_from_c_or_cpp_gccOrG++))),\ - $(error $(mm_add_o_from_c_or_cpp_o) required more than once but with different $(5) value in $(1))\ + $(if $(filter 0,$(call mm_equals,$($($(0)_infoAboutOFromCOrCpp).$(5)),$($(0)_gccOrG++))),\ + $(error $($(0)_o) required more than once but with different $(5) value in $(1))\ ,)\ - $(eval mm_add_o_from_c_or_cpp_bIsOFromCOrCpp:=1)\ + $(eval $(0)_bIsOFromCOrCpp:=1)\ ,)\ )\ - $(if $(filter 0,$(mm_add_o_from_c_or_cpp_bIsOFromCOrCpp)),\ + $(if $(filter 0,$($(0)_bIsOFromCOrCpp)),\ $(call mm_add_or_append_one_element,MM_INFO_PER_O_FROM_$(2))\ - $(eval mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp:=$(lastword $(MM_INFO_PER_O_FROM_$(2))))\ - $(call mm_info_about_o_from_c_or_cpp_t,$(mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp))\ - $(eval $(mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp).$(3):=$(mm_add_o_from_c_or_cpp_cOrCpp))\ - $(eval $(mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp).$(4)Folders:=$(6))\ - $(eval $(mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp).$(5):=$(mm_add_o_from_c_or_cpp_gccOrG++))\ - $(eval $(mm_add_o_from_c_or_cpp_infoAboutOFromCOrCpp).o:=$(mm_add_o_from_c_or_cpp_o))\ - $(call mm_add_binarypart,$(mm_add_o_from_c_or_cpp_o))\ + $(eval $(0)_infoAboutOFromCOrCpp:=$(lastword $(MM_INFO_PER_O_FROM_$(2))))\ + $(call mm_info_about_o_from_c_or_cpp_t,$($(0)_infoAboutOFromCOrCpp))\ + $(eval $($(0)_infoAboutOFromCOrCpp).$(3):=$($(0)_cOrCpp))\ + $(eval $($(0)_infoAboutOFromCOrCpp).$(4)Folders:=$(6))\ + $(eval $($(0)_infoAboutOFromCOrCpp).$(5):=$($(0)_gccOrG++))\ + $(eval $($(0)_infoAboutOFromCOrCpp).o:=$($(0)_o))\ + $(call mm_add_binarypart,$($(0)_o))\ ,)\ ) endef @@ -889,10 +898,10 @@ define mm_check_libraries_and_staticlibraries_and_sharedlibraries= $(call mm_check_libraries,$(1),$(2).libraries) $(call mm_check_libraries,$(1).$(2).staticlibraries) $(call mm_check_libraries,$(1).$(2).sharedlibraries) -$(eval mm_check_libraries_and_staticlibraries_and_sharedlibraries_a:=$(filter $($(2).staticlibraries),$($(2).libraries))) -$(if $(mm_check_libraries_and_staticlibraries_and_sharedlibraries_a),$(error $(mm_check_libraries_and_staticlibraries_and_sharedlibraries_a) specified both in $(2).libraries and $(2).staticlibraries) in $(1),) -$(eval mm_check_libraries_and_staticlibraries_and_sharedlibraries_b:=$(filter $($(2).sharedlibraries),$($(2).libraries))) -$(if $(mm_check_libraries_and_staticlibraries_and_sharedlibraries_b),$(error $(mm_check_libraries_and_staticlibraries_and_sharedlibraries_b) specified both in $(2).libraries and $(2).sharedlibaries) in $(1),) +$(eval $(0)_a:=$(filter $($(2).staticlibraries),$($(2).libraries))) +$(if $($(0)_a),$(error $($(0)_a) specified both in $(2).libraries and $(2).staticlibraries) in $(1),) +$(eval $(0)_b:=$(filter $($(2).sharedlibraries),$($(2).libraries))) +$(if $($(0)_b),$(error $($(0)_b) specified both in $(2).libraries and $(2).sharedlibaries) in $(1),) endef # NOTE: $(1) == functionname @@ -917,7 +926,7 @@ $(call mm_check_if_defined,$(1),$(2).libraries) $(call mm_check_if_defined,$(1),$(2).staticlibraries) $(call mm_check_if_defined,$(1),$(2).sharedlibraries) -$(if $($(2).filetypes), +$(if $($(2).filetypes),\ $(call mm_check_if_valid_values,$(1),$(EMMLibraryfiletype_All),$(2).filetypes)\ $(if $($(2).c) $($(2).cpp),,$(error if $(2).filetypes is not empty.. $(2).c and $(2).cpp may not both be empty in $(1)))\ $(call mm_check_if_valid_values,$(1),%.c,$(2).c)\ @@ -958,73 +967,73 @@ $(if $(filter undefined,$(origin MM_SAFETY)),,\ $(call mm_check_add_library_parameters_t,$(0),$(2))\ ) $(eval MM_INFO_PER_LIBRARY+=MM_INFO_PER_LIBRARY.$(words $(MM_INFO_PER_LIBRARY))) -$(eval mm_add_library_infoAboutLibrary:=$(lastword $(MM_INFO_PER_LIBRARY))) -$(call mm_info_about_library_t,$(mm_add_library_infoAboutLibrary)) -$(eval $(mm_add_library_infoAboutLibrary).name:=$(1)) -$(eval $(mm_add_library_infoAboutLibrary).filetypes:=$($(2).filetypes)) -$(eval mm_add_library_oFromC:=) -$(eval mm_add_library_oFromLocalC:=) -$(eval mm_add_library_oFromCpp:=) -$(eval mm_add_library_oFromLocalCpp:=) +$(eval $(0)_infoAboutLibrary:=$(lastword $(MM_INFO_PER_LIBRARY))) +$(call mm_info_about_library_t,$($(0)_infoAboutLibrary)) +$(eval $($(0)_infoAboutLibrary).name:=$(1)) +$(eval $($(0)_infoAboutLibrary).filetypes:=$($(2).filetypes)) +$(eval $(0)_oFromC:=) +$(eval $(0)_oFromLocalC:=) +$(eval $(0)_oFromCpp:=) +$(eval $(0)_oFromLocalCpp:=) $(if $(OS),\ - $(eval mm_add_library_oFromC:=$(addsuffix .o,$($(2).c)))\ - $(eval mm_add_library_oFromLocalC:=$(addsuffix .o,$($(2).localC)))\ - $(eval mm_add_library_oFromCpp:=$(addsuffix .o,$($(2).cpp)))\ - $(eval mm_add_library_oFromLocalCpp:=$(addsuffix .o,$($(2).localCpp)))\ - $(eval $(mm_add_library_infoAboutLibrary).o:=$(mm_add_library_oFromC) $(mm_add_library_oFromLocalC) $(mm_add_library_oFromCpp) $(mm_add_library_oFromLocalCpp))\ - $(eval $(mm_add_library_infoAboutLibrary).staticO:=$($(mm_add_library_infoAboutLibrary).o))\ - $(eval $(mm_add_library_infoAboutLibrary).sharedO:=$($(mm_add_library_infoAboutLibrary).o)),\ - $(if $(filter EMMLibraryfiletype_Static,$($(mm_add_library_infoAboutLibrary).filetypes)),\ - $(eval mm_add_library_staticOFromC:=$(addsuffix .static.o,$($(2).c)))\ - $(eval mm_add_library_staticOFromLocalC:=$(addsuffix .static.o,$($(2).localC)))\ - $(eval mm_add_library_staticOFromCpp:=$(addsuffix .static.o,$($(2).cpp)))\ - $(eval mm_add_library_staticOFromLocalCpp:=$(addsuffix .static.o,$($(2).localCpp)))\ - $(eval $(mm_add_library_infoAboutLibrary).staticO:=$(mm_add_library_staticOFromC) $(mm_add_library_staticOFromLocalC) $(mm_add_library_staticOFromCpp) $(mm_add_library_staticOFromLocalCpp))\ - $(eval $(mm_add_library_infoAboutLibrary).o+=$($(mm_add_library_infoAboutLibrary).staticO))\ - $(eval mm_add_library_oFromC+=$(mm_add_library_staticOFromC))\ - $(eval mm_add_library_oFromLocalC+=$(mm_add_library_staticOFromLocalC))\ - $(eval mm_add_library_oFromCpp+=$(mm_add_library_staticOFromCpp))\ - $(eval mm_add_library_oFromLocalCpp+=$(mm_add_library_staticOFromLocalCpp))\ + $(eval $(0)_oFromC:=$(addsuffix .o,$($(2).c)))\ + $(eval $(0)_oFromLocalC:=$(addsuffix .o,$($(2).localC)))\ + $(eval $(0)_oFromCpp:=$(addsuffix .o,$($(2).cpp)))\ + $(eval $(0)_oFromLocalCpp:=$(addsuffix .o,$($(2).localCpp)))\ + $(eval $($(0)_infoAboutLibrary).o:=$($(0)_oFromC) $($(0)_oFromLocalC) $($(0)_oFromCpp) $($(0)_oFromLocalCpp))\ + $(eval $($(0)_infoAboutLibrary).staticO:=$($($(0)_infoAboutLibrary).o))\ + $(eval $($(0)_infoAboutLibrary).sharedO:=$($($(0)_infoAboutLibrary).o)),\ + $(if $(filter EMMLibraryfiletype_Static,$($($(0)_infoAboutLibrary).filetypes)),\ + $(eval $(0)_staticOFromC:=$(addsuffix .static.o,$($(2).c)))\ + $(eval $(0)_staticOFromLocalC:=$(addsuffix .static.o,$($(2).localC)))\ + $(eval $(0)_staticOFromCpp:=$(addsuffix .static.o,$($(2).cpp)))\ + $(eval $(0)_staticOFromLocalCpp:=$(addsuffix .static.o,$($(2).localCpp)))\ + $(eval $($(0)_infoAboutLibrary).staticO:=$($(0)_staticOFromC) $($(0)_staticOFromLocalC) $($(0)_staticOFromCpp) $($(0)_staticOFromLocalCpp))\ + $(eval $($(0)_infoAboutLibrary).o+=$($($(0)_infoAboutLibrary).staticO))\ + $(eval $(0)_oFromC+=$($(0)_staticOFromC))\ + $(eval $(0)_oFromLocalC+=$($(0)_staticOFromLocalC))\ + $(eval $(0)_oFromCpp+=$($(0)_staticOFromCpp))\ + $(eval $(0)_oFromLocalCpp+=$($(0)_staticOFromLocalCpp))\ ,)\ - $(if $(filter EMMLibraryfiletype_Shared,$($(mm_add_library_infoAboutLibrary).filetypes)),\ - $(eval mm_add_library_sharedOFromC:=$(addsuffix .shared.o,$($(2).c)))\ - $(eval mm_add_library_sharedOFromLocalC:=$(addsuffix .shared.o,$($(2).localC)))\ - $(eval mm_add_library_sharedOFromCpp:=$(addsuffix .shared.o,$($(2).cpp)))\ - $(eval mm_add_library_sharedOFromLocalCpp:=$(addsuffix .shared.o,$($(2).localCpp)))\ - $(eval $(mm_add_library_infoAboutLibrary).sharedO:=$(mm_add_library_sharedOFromC) $(mm_add_library_sharedOFromLocalC) $(mm_add_library_sharedOFromCpp) $(mm_add_library_sharedOFromLocalCpp))\ - $(eval $(mm_add_library_infoAboutLibrary).o+=$($(mm_add_library_infoAboutLibrary).sharedO))\ - $(eval mm_add_library_oFromC+=$(mm_add_library_sharedOFromC))\ - $(eval mm_add_library_oFromLocalC+=$(mm_add_library_sharedOFromLocalC))\ - $(eval mm_add_library_oFromCpp+=$(mm_add_library_sharedOFromCpp))\ - $(eval mm_add_library_oFromLocalCpp+=$(mm_add_library_sharedOFromLocalCpp))\ + $(if $(filter EMMLibraryfiletype_Shared,$($($(0)_infoAboutLibrary).filetypes)),\ + $(eval $(0)_sharedOFromC:=$(addsuffix .shared.o,$($(2).c)))\ + $(eval $(0)_sharedOFromLocalC:=$(addsuffix .shared.o,$($(2).localC)))\ + $(eval $(0)_sharedOFromCpp:=$(addsuffix .shared.o,$($(2).cpp)))\ + $(eval $(0)_sharedOFromLocalCpp:=$(addsuffix .shared.o,$($(2).localCpp)))\ + $(eval $($(0)_infoAboutLibrary).sharedO:=$($(0)_sharedOFromC) $($(0)_sharedOFromLocalC) $($(0)_sharedOFromCpp) $($(0)_sharedOFromLocalCpp))\ + $(eval $($(0)_infoAboutLibrary).o+=$($($(0)_infoAboutLibrary).sharedO))\ + $(eval $(0)_oFromC+=$($(0)_sharedOFromC))\ + $(eval $(0)_oFromLocalC+=$($(0)_sharedOFromLocalC))\ + $(eval $(0)_oFromCpp+=$($(0)_sharedOFromCpp))\ + $(eval $(0)_oFromLocalCpp+=$($(0)_sharedOFromLocalCpp))\ ,)\ ) -$(eval $(mm_add_library_infoAboutLibrary).localStaticO:=$(mm_add_library_oFromLocalC) $(mm_add_library_oFromLocalCpp)) -$(eval $(mm_add_library_infoAboutLibrary).h:=$($(2).h)) -$(eval $(mm_add_library_infoAboutLibrary).hpp:=$($(2).hpp)) -$(eval $(mm_add_library_infoAboutLibrary).cc:=$(if $($(2).cpp),g++,gcc)) -$(eval $(mm_add_library_infoAboutLibrary).otherLibraries:=$(filter $($(2).libraries),$(MM_LIBRARIES))) -$(eval $(mm_add_library_infoAboutLibrary).otherStaticlibraries:=$(filter $($(2).staticlibraries),$(MM_STATICLIBRARIES))) -$(eval $(mm_add_library_infoAboutLibrary).otherSharedlibraries:=$(filter $($(2).sharedlibraries),$(MM_SHAREDLIBRARIES))) -$(eval $(mm_add_library_infoAboutLibrary).hAndHppFilepathPerOtherLibrary:=$(call mm_get_filepath_per_h_and_hpp_from_libraries,$($(mm_add_library_infoAboutLibrary).otherLibraries))) -$(eval $(mm_add_library_infoAboutLibrary).binaryfilepathPerOtherStaticlibrary:=$(call mm_get_filepath_per_binary_from_staticlibraries,$($(mm_add_library_infoAboutLibrary).otherStaticlibraries) $($(mm_add_library_infoAboutLibrary).otherLibraries))) -$(eval $(mm_add_library_infoAboutLibrary).binaryfilepathPerOtherSharedlibrary:=$(call mm_get_filepath_per_binary_from_sharedlibraries,$($(mm_add_library_infoAboutLibrary).otherSharedlibraries) $($(mm_add_library_infoAboutLibrary).otherLibraries))) -$(eval mm_add_library_a:=$(sort $(notdir,$($(mm_add_library_infoAboutLibrary).hAndHppFilepathPerOtherLibrary)))) -$(if $(mm_add_library_oFromC),\ - $(call mm_add_o_from_c,$(0),$(mm_add_library_a) $($(2).hAndHppFolders) $($(2).hFolders),$($(2).cGcc),$(mm_add_library_oFromC) $(mm_add_library_oFromLocalC))\ +$(eval $($(0)_infoAboutLibrary).localStaticO:=$($(0)_staticOFromLocalC) $($(0)_staticOFromLocalCpp)) +$(eval $($(0)_infoAboutLibrary).h:=$($(2).h)) +$(eval $($(0)_infoAboutLibrary).hpp:=$($(2).hpp)) +$(eval $($(0)_infoAboutLibrary).cc:=$(if $($(2).cpp),g++,gcc)) +$(eval $($(0)_infoAboutLibrary).otherLibraries:=$(filter $($(2).libraries),$(MM_LIBRARIES))) +$(eval $($(0)_infoAboutLibrary).otherStaticlibraries:=$(filter $($(2).staticlibraries),$(MM_STATICLIBRARIES))) +$(eval $($(0)_infoAboutLibrary).otherSharedlibraries:=$(filter $($(2).sharedlibraries),$(MM_SHAREDLIBRARIES))) +$(eval $($(0)_infoAboutLibrary).hAndHppFilepathPerOtherLibrary:=$(call mm_get_filepath_per_h_and_hpp_from_libraries,$($($(0)_infoAboutLibrary).otherLibraries))) +$(eval $($(0)_infoAboutLibrary).binaryfilepathPerOtherStaticlibrary:=$(call mm_get_filepath_per_binary_from_staticlibraries,$($($(0)_infoAboutLibrary).otherStaticlibraries) $($($(0)_infoAboutLibrary).otherLibraries))) +$(eval $($(0)_infoAboutLibrary).binaryfilepathPerOtherSharedlibrary:=$(call mm_get_filepath_per_binary_from_sharedlibraries,$($($(0)_infoAboutLibrary).otherSharedlibraries) $($($(0)_infoAboutLibrary).otherLibraries))) +$(eval $(0)_a:=$(sort $(dir $($($(0)_infoAboutLibrary).hAndHppFilepathPerOtherLibrary)))) +$(if $($(0)_oFromC),\ + $(call mm_add_o_from_c,$(0),$($(0)_a) $($(2).hAndHppFolders) $($(2).hFolders),$($(2).cGcc),$($(0)_oFromC) $($(0)_oFromLocalC))\ ,) -$(if $(mm_add_library_oFromCpp),\ - $(call mm_add_o_from_cpp,$(0),$(mm_add_library_a) $($(2).hAndHppFolders) $($(2).hppFolders),$($(2).cppG++),$(mm_add_library_oFromCpp) $(mm_add_library_oFromLocalCpp))\ +$(if $($(0)_oFromCpp),\ + $(call mm_add_o_from_cpp,$(0),$($(0)_a) $($(2).hAndHppFolders) $($(2).hppFolders),$($(2).cppG++),$($(0)_oFromCpp) $($(0)_oFromLocalCpp))\ ,) $(if $(filter EMMLibraryfiletype_Static,$($(2).filetypes)),\ - $(if $(strip $($(mm_add_library_infoAboutLibrary).localStaticO)),\ + $(if $(strip $($($(0)_infoAboutLibrary).localStaticO)),\ $(call mm_add_binarypart,lib$(1)$(MM_STATICLIBRARY_EXTENSION).nm)\ $(call mm_add_binarypart,lib$(1)$(MM_STATICLIBRARY_EXTENSION).o)\ ,)\ - $(call mm_add_binary,lib$(1)$(MM_STATICLIBRARY_EXTENSION),$(mm_add_library_infoAboutLibrary).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath)\ + $(call mm_add_binary,lib$(1)$(MM_STATICLIBRARY_EXTENSION),$($(0)_infoAboutLibrary).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath)\ ,) $(if $(filter EMMLibraryfiletype_Shared,$($(2).filetypes)),\ - $(call mm_add_binary,lib$(1)$(MM_SHAREDLIBRARY_EXTENSION),$(mm_add_library_infoAboutLibrary).$(MM_OS)$(MM_SHAREDLIBRARY_EXTENSION)filepath)\ + $(call mm_add_binary,lib$(1)$(MM_SHAREDLIBRARY_EXTENSION),$($(0)_infoAboutLibrary).$(MM_OS)$(MM_SHAREDLIBRARY_EXTENSION)filepath)\ ,) $(eval MM_LIBRARIES+=$(1)) endef @@ -1033,6 +1042,9 @@ endef # TODO: mm_not_add_library and mm_add_library=$(eval $(call mm_not_add_library,<...>))? # ^ # to allow for comments in mm_not_add_library? +# NOTE: ^ +# for shared library .localC is identical to .c +# this is fine as default visibility for .shared.o is hidden? #********************************* executable ********************************* @@ -1130,34 +1142,38 @@ $(if $(filter undefined,$(origin MM_SAFETY)),,\ $(call mm_check_add_executable_parameters_t,$(0),$(2))\ ) $(eval MM_INFO_PER_EXECUTABLE+=MM_INFO_PER_EXECUTABLE.$(words $(MM_INFO_PER_EXECUTABLE))) -$(eval mm_add_executable_infoAboutExecutable:=$(lastword $(MM_INFO_PER_EXECUTABLE))) -$(eval $(mm_add_executable_infoAboutExecutable).name:=$(1)) -$(eval mm_add_executable_oFromC:=$(addsuffix .o,$($(2).c))) -$(eval mm_add_executable_oFromCpp:=$(addsuffix .o,$($(2).cpp))) -$(eval $(mm_add_executable_infoAboutExecutable).o:=$(mm_add_executable_oFromC) $(mm_add_executable_oFromCpp)) -$(eval $(mm_add_executable_infoAboutExecutable).libraries:=$(filter $($(2).libraries),$(MM_LIBRARIES))) -$(eval $(mm_add_executable_infoAboutExecutable).staticlibraries:=$(filter $($(2).staticlibraries),$(MM_STATICLIBARIES))) -$(eval $(mm_add_executable_infoAboutExecutable).sharedlibraries:=$(filter $($(2).sharedlibraries),$(MM_SHAREDLIBRARIES))) -$(eval $(mm_add_executable_infoAboutExecutable).hAndHppFilepathPerLibrary:=$(call mm_get_filepath_per_h_and_hpp_from_libraries,$($(mm_add_executable_infoAboutExecutable).libraries))) -$(eval $(mm_add_executable_infoAboutExecutable).binaryfilepathPerStaticlibrary:=$(call mm_get_filepath_per_binary_from_staticlibraries,$($(mm_add_executable_infoAboutExecutable).staticlibraries) $($(mm_add_executable_infoAboutExecutable).libraries))) -$(eval $(mm_add_executable_infoAboutExecutable).binaryfilepathPerSharedlibrary:=$(call mm_get_filepath_per_binary_from_sharedlibraries,$($(mm_add_executable_infoAboutExecutable).sharedlibraries) $($(mm_add_executable_infoAboutExecutable).libraries))) -$(eval mm_add_executable_a:=$(patsubst lib%$(MM_STATICLIBRARY_EXTENSION),%,$(notdir $($(mm_add_executable_infoAboutExecutable).binaryfilepathPerStaticlibrary)))) -$(eval mm_add_executable_b:=$(patsubst lib%$(MM_SHAREDLIBRARY_EXTENSION),%,$(notdir $($(mm_add_executable_infoAboutExecutable).binaryfilepathPerSharedlibrary)))) -$(eval mm_add_executable_c:=$(mm_add_executable_a) $(mm_add_executable_b)) -$(eval $(mm_add_executable_infoAboutExecutable).lib:=$(mm_add_executable_c) $($(2).lib)) -$(eval mm_add_executable_d:=$($(mm_add_executable_infoAboutExecutable).binaryfilepathPerStaticlibrary) $($(mm_add_executable_infoAboutExecutable).binaryfilepathPerSharedlibrary)) -$(eval mm_add_executable_e:=$(sort $(dir $(mm_add_executable_d)))) -$(eval $(mm_add_executable_infoAboutExecutable).libFolders:=$(mm_add_executable_e) $($(2).libFolders)) -$(eval $(mm_add_executable_infoAboutExecutable).cc:=$(if $($(2).cpp),g++,gcc)) -$(eval $(mm_add_executable_infoAboutExecutable).gccOrG++:=$($(2).gccOrG++)) -$(eval mm_add_executable_f:=$(sort $(dir $($(mm_add_executable_infoAboutExecutable).hAndHppFilepathPerLibrary)))) -$(if $(mm_add_executable_oFromC),\ - $(call mm_add_o_from_c,$(0),$(mm_add_executable_f) $($(2).hAndHppFolders) $($(2).hFolders),$($(2).cGcc),$(mm_add_executable_oFromC))\ +$(eval $(0)_infoAboutExecutable:=$(lastword $(MM_INFO_PER_EXECUTABLE))) +$(eval $($(0)_infoAboutExecutable).name:=$(1)) +$(if $(OS),\ + $(eval $(0)_oFromC:=$(addsuffix .o,$($(2).c)))\ + $(eval $(0)_oFromCpp:=$(addsuffix .o,$($(2).cpp))),\ + $(eval $(0)_oFromC:=$(addsuffix .static.o,$($(2).c)))\ + $(eval $(0)_oFromCpp:=$(addsuffix .static.o,$($(2).cpp)))\ +) +$(eval $($(0)_infoAboutExecutable).o:=$($(0)_oFromC) $($(0)_oFromCpp)) +$(eval $($(0)_infoAboutExecutable).libraries:=$(filter $($(2).libraries),$(MM_LIBRARIES))) +$(eval $($(0)_infoAboutExecutable).staticlibraries:=$(filter $($(2).staticlibraries),$(MM_STATICLIBARIES))) +$(eval $($(0)_infoAboutExecutable).sharedlibraries:=$(filter $($(2).sharedlibraries),$(MM_SHAREDLIBRARIES))) +$(eval $($(0)_infoAboutExecutable).hAndHppFilepathPerLibrary:=$(call mm_get_filepath_per_h_and_hpp_from_libraries,$($($(0)_infoAboutExecutable).libraries))) +$(eval $($(0)_infoAboutExecutable).binaryfilepathPerStaticlibrary:=$(call mm_get_filepath_per_binary_from_staticlibraries,$($($(0)_infoAboutExecutable).staticlibraries) $($($(0)_infoAboutExecutable).libraries))) +$(eval $($(0)_infoAboutExecutable).binaryfilepathPerSharedlibrary:=$(call mm_get_filepath_per_binary_from_sharedlibraries,$($($(0)_infoAboutExecutable).sharedlibraries) $($($(0)_infoAboutExecutable).libraries))) +$(eval $(0)_a:=$(patsubst lib%$(MM_STATICLIBRARY_EXTENSION),%,$(notdir $($($(0)_infoAboutExecutable).binaryfilepathPerStaticlibrary)))) +$(eval $(0)_b:=$(patsubst lib%$(MM_SHAREDLIBRARY_EXTENSION),%,$(notdir $($($(0)_infoAboutExecutable).binaryfilepathPerSharedlibrary)))) +$(eval $(0)_c:=$($(0)_a) $($(0)_b)) +$(eval $($(0)_infoAboutExecutable).lib:=$($(0)_c) $($(2).lib)) +$(eval $(0)_d:=$($($(0)_infoAboutExecutable).binaryfilepathPerStaticlibrary) $($($(0)_infoAboutExecutable).binaryfilepathPerSharedlibrary)) +$(eval $(0)_e:=$(sort $(dir $($(0)_d)))) +$(eval $($(0)_infoAboutExecutable).libFolders:=$($(0)_e) $($(2).libFolders)) +$(eval $($(0)_infoAboutExecutable).cc:=$(if $($(2).cpp),g++,gcc)) +$(eval $($(0)_infoAboutExecutable).gccOrG++:=$($(2).gccOrG++)) +$(eval $(0)_f:=$(sort $(dir $($($(0)_infoAboutExecutable).hAndHppFilepathPerLibrary)))) +$(if $($(0)_oFromC),\ + $(call mm_add_o_from_c,$(0),$($(0)_f) $($(2).hAndHppFolders) $($(2).hFolders),$($(2).cGcc),$($(0)_oFromC))\ ,) -$(if $(mm_add_executable_oFromCpp),\ - $(call mm_add_o_from_cpp,$(0),$(mm_add_executable_f) $($(2).hAndHppFolders) $($(2).hppFolders),$($(2).cppG++),$(mm_add_executable_oFromCpp))\ +$(if $($(0)_oFromCpp),\ + $(call mm_add_o_from_cpp,$(0),$($(0)_f) $($(2).hAndHppFolders) $($(2).hppFolders),$($(2).cppG++),$($(0)_oFromCpp))\ ,) -$(call mm_add_binary,$(1)$(MM_EXECUTABLE_EXTENSION),$(mm_add_executable_infoAboutExecutable).$(MM_OS)$(MM_EXECUTABLE_EXTENSION_OR_DOT)filepath) +$(call mm_add_binary,$(1)$(MM_EXECUTABLE_EXTENSION),$($(0)_infoAboutExecutable).$(MM_OS)$(MM_EXECUTABLE_EXTENSION_OR_DOT)filepath) $(if $(OS),,\ $(if $(filter EMMAdditionalexecutablefiletypes_Portable,$($(2).additionalfiletypes)),\ $(call mm_add_binary,$(1).AppImage,$(2).linux.AppImagefilepath)\ @@ -1227,16 +1243,16 @@ $(if $(filter undefined,$(origin MM_SAFETY)),,\ $(call mm_check_add_test_parameters_t,$(0),$(2))\ ) $(eval MM_INFO_PER_TEST+=MM_INFO_PER_TEST.$(words $(MM_INFO_PER_TEST))) -$(eval mm_add_test_infoAboutTest:=$(lastword $(MM_INFO_PER_TEST))) -$(eval $(mm_add_test_infoAboutTest).name:=$(1)) -$(foreach mm_add_test_executable,$($(2).executables),\ - $(foreach mm_add_test_infoAboutExecutable,$(MM_INFO_PER_EXECUTABLE),\ - $(if $(filter $(mm_add_test_executable),$($(mm_add_test_infoAboutExecutable).name)),\ - $(eval $(mm_add_test_infoAboutTest).filepathPerExecutable+=$($(mm_add_test_infoAboutExecutable).$(MM_OS)$(MM_EXECUTABLE_EXTENSION_OR_DOT)filepath))\ +$(eval $(0)_infoAboutTest:=$(lastword $(MM_INFO_PER_TEST))) +$(eval $($(0)_infoAboutTest).name:=$(1)) +$(foreach $(0)_executable,$($(2).executables),\ + $(foreach $(0)_infoAboutExecutable,$(MM_INFO_PER_EXECUTABLE),\ + $(if $(filter $($(0)_executable),$($($(0)_infoAboutExecutable).name)),\ + $(eval $($(0)_infoAboutTest).filepathPerExecutable+=$($($(0)_infoAboutExecutable).$(MM_OS)$(MM_EXECUTABLE_EXTENSION_OR_DOT)filepath))\ ,)\ )\ ) -$(eval $(mm_add_test_infoAboutTest).scripts:=$($(2).scripts)) +$(eval $($(0)_infoAboutTest).scripts:=$($(2).scripts)) endef #****************************************************************************** @@ -1301,9 +1317,9 @@ endef # NOTE: $(1) == infoAboutSpvasmFromGlsl define mm_add_spvasm_from_glsl_target= -$(eval mm_add_spvasm_from_glsl_target_a:=$(strip $(call mm_switch,$($(1).type),EMMShadertype_Vertex EMMShadertype_Pixel,vert frag))) +$(eval $(0)_a:=$(strip $(call mm_switch,$($(1).type),EMMShadertype_Vertex EMMShadertype_Pixel,vert frag))) .makefile-mini/$($(1).spvasm):.makefile-mini/%.spvasm:%.glsl | $(call mm_get_binarypartfolderpath_from_binarypart,$($(1).spvasm)) - glslangValidator $($(1).glslangValidator) --quiet -o $(MM_CLI_DEV_NULL) --spirv-dis -V -S $(mm_add_spvasm_from_glsl_target_a) $$< > $$@ + glslangValidator $($(1).glslangValidator) --quiet -o $(MM_CLI_DEV_NULL) --spirv-dis -V -S $($(0)_a) $$< > $$@ endef # NOTE: ^ # -o $(MM_CLI_DEV_NULL) is to work around glslangValidator always.. @@ -1352,13 +1368,13 @@ endef # NOTE: $(1) == infoAboutLibrary define mm_add_local_staticlibrary_targets= -$(eval mm_add_staticlibrary_targets_filepathPerLocalStaticO:=$(addprefix .makefile-mini/,$($(1).localStaticO))) -.makefile-mini/$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath).nm:$(mm_add_staticlibrary_targets_filepathPerLocalStaticO) +$(eval $(0)_filepathPerLocalStaticO:=$(addprefix .makefile-mini/,$($(1).localStaticO))) +.makefile-mini/$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath).nm:$($(0)_filepathPerLocalStaticO) nm -j -g --defined-only $$^ > $$@ -$(eval mm_add_staticlibrary_targets_filepathPerStaticO:=$(addprefix .makefile-mini/,$($(1).staticO))) -.makefile-mini/$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath).o:.makefile-mini/$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath).nm $(mm_add_staticlibrary_targets_filepathPerStaticO) - ld -r -o $$@ $(mm_add_staticlibrary_targets_filepathPerStaticO) +$(eval $(0)_filepathPerStaticO:=$(addprefix .makefile-mini/,$($(1).staticO))) +.makefile-mini/$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath).o:.makefile-mini/$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath).nm $($(0)_filepathPerStaticO) + ld -r -o $$@ $($(0)_filepathPerStaticO) objcopy --localize-symbols $$< $$@ $($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath): .makefile-mini/$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath).o $($(1).hAndHppFilepathPerOtherLibrary) @@ -1372,9 +1388,9 @@ endef # NOTE: $(1) == infoAboutLibrary define mm_add_staticlibrary_target= -$(eval mm_add_staticlibrary_target_staticO:=$(addprefix .makefile-mini/,$($(1).staticO))) -$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath): $(mm_add_staticlibrary_target_staticO) $($(1).hAndHppFilepathPerOtherLibrary) - ar rcs $$@ $(mm_add_staticlibrary_target_staticO) +$(eval $(0)_staticO:=$(addprefix .makefile-mini/,$($(1).staticO))) +$($(1).$(MM_OS)$(MM_STATICLIBRARY_EXTENSION)filepath): $($(0)_staticO) $($(1).hAndHppFilepathPerOtherLibrary) + ar rcs $$@ $($(0)_staticO) endef # NOTE: $(1) == infoAboutLibrary @@ -1384,9 +1400,9 @@ endef # NOTE: $(1) == infoAboutLibrary define mm_add_sharedlibrary_target= -$(eval mm_add_sharedlibrary_target_filepathPerSharedO:=$(addprefix .makefile-mini/,$($(1).sharedO))) -$($(1).$(MM_OS)$(MM_SHAREDLIBRARY_EXTENSION)filepath): $(mm_add_sharedlibrary_target_filepathPerSharedO) $($(1).hAndHppFilepathPerOtherLibrary) - $($(1).cc) -shared -o $$@ $(mm_add_sharedlibrary_target_filepathPerSharedO) +$(eval $(0)_filepathPerSharedO:=$(addprefix .makefile-mini/,$($(1).sharedO))) +$($(1).$(MM_OS)$(MM_SHAREDLIBRARY_EXTENSION)filepath): $($(0)_filepathPerSharedO) $($(1).hAndHppFilepathPerOtherLibrary) + $($(1).cc) -shared -o $$@ $($(0)_filepathPerSharedO) endef # NOTE: $(1) == infoAboutLibrary @@ -1403,9 +1419,9 @@ endif # NOTE: $(1) == infoAboutExecutable define mm_add_executable_targets= -$(eval mm_add_executable_targets_filepathPerO:=$(addprefix .makefile-mini/,$($(1).o))) -$($(1).$(MM_OS)$(MM_EXECUTABLE_EXTENSION_OR_DOT)filepath): $(mm_add_executable_targets_filepathPerO) $($(1).hAndHppFilepathPerLibrary) $($(1).binaryfilepathPerStaticlibrary) $($(1).binaryfilepathPerSharedlibrary) - $($(1).cc) $($(1).gccOrG++) -o $$@ $(mm_add_executable_targets_filepathPerO) $(addprefix -L,$($(1).libFolders)) $(addprefix -l,$($(1).lib)) +$(eval $(0)_filepathPerO:=$(addprefix .makefile-mini/,$($(1).o))) +$($(1).$(MM_OS)$(MM_EXECUTABLE_EXTENSION_OR_DOT)filepath): $($(0)_filepathPerO) $($(1).hAndHppFilepathPerLibrary) $($(1).binaryfilepathPerStaticlibrary) $($(1).binaryfilepathPerSharedlibrary) + $($(1).cc) $($(1).gccOrG++) -o $$@ $($(0)_filepathPerO) $(addprefix -L,$($(1).libFolders)) $(addprefix -l,$($(1).lib)) endef # TODO: ^ # .h prerequisites should be order only such that $$^ here still works @@ -1426,7 +1442,7 @@ $(1): endef define mm_add_folders_targets= -$(foreach mm_add_folders_targets_binarypartfolderpathpart,$(MM_FOLDERPATHPART_PER_BINARYPART),$(call mm_add_folder_target,.makefile-mini/$(mm_add_folders_targets_binarypartfolderpathpart))) +$(foreach $(0)_binarypartfolderpathpart,$(MM_FOLDERPATHPART_PER_BINARYPART),$(call mm_add_folder_target,.makefile-mini/$($(0)_binarypartfolderpathpart))) endef # NOTE: ^ # "subst /,\" because mm_cli_mkdir parameter $(1) is non cli @@ -1434,23 +1450,24 @@ endef define mm_add_test_target= .PHONY: test test: $(MM_FILEPATH_PER_BINARY) - $(foreach mm_add_test_target_infoAboutTest,$(MM_INFO_PER_TEST),$\ - $(foreach mm_add_test_target_executablefilepath,$($(mm_add_test_target_infoAboutTest).filepathPerExecutable),$\ - $(MM_NEWLINE) $(if $(findstring /,$(mm_add_test_target_executablefilepath)),,.$(MM_FOLDER_SEPARATOR))$(mm_add_test_target_executablefilepath)$\ + $(foreach $(0)_infoAboutTest,$(MM_INFO_PER_TEST),$\ + $(foreach $(0)_executablefilepath,$($($(0)_infoAboutTest).filepathPerExecutable),$\ + $(eval $(0)_a:=$(if $(findstring /,$($(0)_executablefilepath)),,.$(MM_FOLDER_SEPARATOR))$($(0)_executablefilepath))$\ + $(MM_NEWLINE) @$(if $(OS),,export LD_LIBRARY_PATH=$$$$LD_LIBRARY_PATH:./:.makefile-mini/; )$($(0)_a);echo $($(0)_a)$\ )$\ - $(foreach mm_add_test_target_script,$($(mm_add_test_target_infoAboutTest).scripts),$\ - $(MM_NEWLINE) $(if $(findstring /,$(mm_add_test_target_executablefilepath)),,.$(MM_FOLDER_SEPARATOR))$(mm_add_test_target_script)$(MM_SCRIPT_EXTENSION)"$\ + $(foreach $(0)_script,$($($(0)_infoAboutTest).scripts),$\ + $(MM_NEWLINE) $(if $(findstring /,$($(0)_executablefilepath)),,.$(MM_FOLDER_SEPARATOR))$($(0)_script)$(MM_SCRIPT_EXTENSION)$\ )$\ ) endef # NOTE: ^ # I tried.. -# cmd /c "start /b $(mm_add_test_target_script).bat" +# cmd /c "start /b $($(0)_script).bat" # .. which caused powershell to keep cmd.exe open after make returned.. # .. thus having manually call exit,.. # .. https://stackoverflow.com/a/41411671 # Start-Job -ScriptBlock { Set-Location $using:pwd; Invoke-Expression.. -# .. .\$args } -ArgumentList "$(mm_add_test_target_script).bat" +# .. .\$args } -ArgumentList "$($(0)_script).bat" # .. was the closest to working solution I found, but it broke the.. # .. timeout command that I used to test whether scripts where ran in.. # .. parallel, https://stackoverflow.com/a/74843981 @@ -1458,6 +1475,15 @@ endef # Hence for now.. executables and scripts are not run in parallel and.. # .. .executables and .scripts is only for grouping tests (for.. # .. convenience perhaps?) +# NOTE: ^ +# make automatically adds environment variables as Makefile variables.. +# .. (hence $(LD_LIBRARY_PATH) works) and runs each line using a new.. +# .. shell (separate c stdlib system function call?), hence export.. +# .. LD_LIBRARY_PATH=<..> on same line as running executable here +# currently hidden that makefile-mini does this for clearer output +# TODO: this solution won't work if a test executable uses any external.. +# .. sharedlibrary/runs any executable that requires an external.. +# .. sharedlibrary define mm_add_releasezip_target= $(MM_PROJECTNAME).$(MM_OS).zip: $(MM_RELEASEZIP) @@ -1494,10 +1520,10 @@ endef define mm_add_clean_target= .PHONY: clean clean: - $(foreach mm_add_clean_target_binarypart,$(MM_BINARYPARTS),$(MM_NEWLINE) $(call mm_cli_rm,.makefile-mini/$(mm_add_clean_target_binarypart))) - $(foreach mm_add_clean_target_binarypartfolderpathpart,$(MM_FOLDERPATHPART_PER_BINARYPART),$(MM_NEWLINE) $(call mm_cli_rmdir,.makefile-mini/$(mm_add_clean_target_binarypartfolderpathpart))) - $(foreach mm_add_clean_target_binaryfilepath,$(MM_FILEPATH_PER_BINARY),$(MM_NEWLINE) $(call mm_cli_rm,$(mm_add_clean_target_binaryfilepath))) - $(foreach mm_add_clean_target_release,$(MM_RELEASE),$(MM_NEWLINE) $(call mm_cli_rm,$(mm_add_clean_target_release))) + $(foreach $(0)_binarypart,$(MM_BINARYPARTS),$(MM_NEWLINE) $(call mm_cli_rm,.makefile-mini/$($(0)_binarypart))) + $(foreach $(0)_binarypartfolderpathpart,$(MM_FOLDERPATHPART_PER_BINARYPART),$(MM_NEWLINE) $(call mm_cli_rmdir,.makefile-mini/$($(0)_binarypartfolderpathpart))) + $(foreach $(0)_binaryfilepath,$(MM_FILEPATH_PER_BINARY),$(MM_NEWLINE) $(call mm_cli_rm,$($(0)_binaryfilepath))) + $(foreach $(0)_release,$(MM_RELEASE),$(MM_NEWLINE) $(call mm_cli_rm,$($(0)_release))) endef # NOTE: ^ # $(MM_NEWLINE)$(call <...>) @@ -1520,28 +1546,28 @@ $(eval $(call mm_add_default_target)) $(eval $(call mm_add_folders_targets)) -$(foreach mm_add_makefile_infoAboutSpvasmFromGlsl,$(MM_INFO_PER_SPVASM_FROM_GLSL),$\ -$(eval $(call mm_add_spvasm_from_glsl_target,$(mm_add_makefile_infoAboutSpvasmFromGlsl)))$\ +$(foreach $(0)_infoAboutSpvasmFromGlsl,$(MM_INFO_PER_SPVASM_FROM_GLSL),$\ +$(eval $(call mm_add_spvasm_from_glsl_target,$($(0)_infoAboutSpvasmFromGlsl)))$\ ) -$(foreach mm_add_makefile_infoAboutShader,$(MM_INFO_PER_SHADER),$\ -$(eval $(call mm_add_shader_target,$(mm_add_makefile_infoAboutShader)))$\ +$(foreach $(0)_infoAboutShader,$(MM_INFO_PER_SHADER),$\ +$(eval $(call mm_add_shader_target,$($(0)_infoAboutShader)))$\ ) -$(foreach mm_add_makefile_infoAboutOFromC,$(MM_INFO_PER_O_FROM_C),$\ -$(eval $(call mm_add_o_from_c_target,$(mm_add_makefile_infoAboutOFromC)))$\ +$(foreach $(0)_infoAboutOFromC,$(MM_INFO_PER_O_FROM_C),$\ +$(eval $(call mm_add_o_from_c_target,$($(0)_infoAboutOFromC)))$\ ) -$(foreach mm_add_makefile_infoAboutOFromCpp,$(MM_INFO_PER_O_FROM_CPP),$\ -$(eval $(call mm_add_o_from_cpp_target,$(mm_add_makefile_infoAboutOFromCpp)))$\ +$(foreach $(0)_infoAboutOFromCpp,$(MM_INFO_PER_O_FROM_CPP),$\ +$(eval $(call mm_add_o_from_cpp_target,$($(0)_infoAboutOFromCpp)))$\ ) -$(foreach mm_add_makefile_infoAboutLibrary,$(MM_INFO_PER_LIBRARY),$\ -$(eval $(call mm_add_library_targets,$(mm_add_makefile_infoAboutLibrary)))$\ +$(foreach $(0)_infoAboutLibrary,$(MM_INFO_PER_LIBRARY),$\ +$(eval $(call mm_add_library_targets,$($(0)_infoAboutLibrary)))$\ ) -$(foreach mm_add_makefile_infoAboutExecutable,$(MM_INFO_PER_EXECUTABLE),$\ -$(eval $(call mm_add_executable_targets,$(mm_add_makefile_infoAboutExecutable)))$\ +$(foreach $(0)_infoAboutExecutable,$(MM_INFO_PER_EXECUTABLE),$\ +$(eval $(call mm_add_executable_targets,$($(0)_infoAboutExecutable)))$\ ) $(eval $(call mm_add_test_target))