Fix basic makefile using unspecified behavior

This commit is contained in:
rexy712 2021-04-19 12:49:51 -07:00
parent c3759e2802
commit 9a56b99f27

View File

@ -11,7 +11,7 @@
#You should have received a copy of the GNU General Public License #You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#Copyright 2018-2020 rexy712 #Copyright 2018-2021 rexy712
#Makefile to generate a single executable from all sources in SOURCE_DIRS that end in EXT #Makefile to generate a single executable from all sources in SOURCE_DIRS that end in EXT
@ -72,7 +72,7 @@ endif #windows
all:: all::
#main target #main target
all:: | flags-update $(MAIN_EXECUTABLE) all:: $(MAIN_EXECUTABLE)
#postrun targets #postrun targets
all:: all::
@ -162,25 +162,23 @@ define \n
endef endef
.PHONY: cflags-update
cflags-update:
ifeq ($(SAVEFLAGS),1) ifeq ($(SAVEFLAGS),1)
ifneq ($(subst -MF"$(DEPDIR)/",-MF"$(DEPDIR)/cflags-update",$(ALL_COMPILEFLAGS)),$(OLD_COMPILEFLAGS)) ifneq ($(subst -MF"$(DEPDIR)/",-MF"$(DEPDIR)/$(CFLAGS_TMPFILE)",$(ALL_COMPILEFLAGS)),$(OLD_COMPILEFLAGS))
.PHONY: $(CFLAGS_TMPFILE)
$(CFLAGS_TMPFILE):
$(file >$(CFLAGS_TMPFILE),$(ALL_COMPILEFLAGS)) $(file >$(CFLAGS_TMPFILE),$(ALL_COMPILEFLAGS))
endif else
$(CFLAGS_TMPFILE): cflags-update $(CFLAGS_TMPFILE):
endif
.PHONY: ldflags-update
ldflags-update:
ifeq ($(SAVEFLAGS),1)
ifneq ($(ALL_LINKFLAGS),$(OLD_LINKFLAGS))
$(file >$(LDFLAGS_TMPFILE),$(ALL_LINKFLAGS))
endif
$(LDFLAGS_TMPFILE): ldflags-update
endif endif
.PHONY: flags-update ifneq ($(ALL_LINKFLAGS),$(OLD_LINKFLAGS))
flags-update: cflags-update ldflags-update .PHONY: $(LDFLAGS_TMPFILE)
$(LDFLAGS_TMPFILE):
$(file >$(LDFLAGS_TMPFILE),$(ALL_LINKFLAGS))
else
$(LDFLAGS_TMPFILE):
endif
endif
#Link executable #Link executable
$(MAIN_EXECUTABLE): $(OBJECTS) $(LDFLAGS_TMPFILE) $(MAIN_EXECUTABLE): $(OBJECTS) $(LDFLAGS_TMPFILE)