$(target_debug_FLAGS0) and $(target_debug_FLAGS1) shuold be the same (ando also $(target_opt_FLAGS0) and $(target_opt_FLAGS1).
it seems that ifneq ($$(strip $$($(1)_VAR1)),) $(1)_$(2)_FLAGS0 += $$($(1)_VAR1) endif
doesn't work. It never add $$($(1)_VAR1) to $(1)_$(2)_FLAGS0, as if $$($(1)_VAR1) was empty, but is is not, infact it is assigned to $(1)_$(2)_FLAGS1