2015-12-11 18:49:14 -06:00
|
|
|
# 16 october 2015
|
|
|
|
|
2016-01-19 15:40:00 -06:00
|
|
|
# IMPORTANT
|
|
|
|
# Do NOT use / for command-line options here!
|
|
|
|
# This breaks on GNU makes that come with some versions of
|
|
|
|
# MinGW because they mangle things that start with /, thinking that
|
|
|
|
# those arguments are Unix paths that need to be converted to
|
|
|
|
# Windows paths. This cannot be turned off. -_-'
|
|
|
|
# MSDN says cl, rc, and link all accept - instead of /, so we're good.
|
|
|
|
# See also:
|
|
|
|
# - https://github.com/andlabs/libui/issues/16
|
|
|
|
# - http://www.mingw.org/wiki/Posix_path_conversion
|
|
|
|
# - http://www.mingw.org/wiki/FAQ
|
|
|
|
# - http://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line
|
|
|
|
# - http://stackoverflow.com/questions/28533664/how-to-prevent-msys-to-convert-the-file-path-for-an-external-program
|
|
|
|
|
2015-12-11 18:49:14 -06:00
|
|
|
# TODO subsystem version
|
|
|
|
|
|
|
|
# TODO silence compiler non-diagnostics (/nologo is not enough)
|
|
|
|
|
|
|
|
# Global flags.
|
|
|
|
|
|
|
|
# TODO /Wall does too much
|
|
|
|
# TODO -Wno-switch equivalent
|
|
|
|
# TODO /sdl turns C4996 into an ERROR
|
|
|
|
# TODO loads of warnings in the system header files
|
|
|
|
# TODO /analyze requires us to write annotations everywhere
|
|
|
|
# TODO undecided flags from qo?
|
|
|
|
CFLAGS += \
|
2016-01-19 15:40:00 -06:00
|
|
|
-W4 \
|
|
|
|
-wd4100 \
|
|
|
|
-TC \
|
|
|
|
-bigobj -nologo \
|
|
|
|
-RTC1 -RTCc -RTCs -RTCu
|
2015-12-11 18:49:14 -06:00
|
|
|
|
|
|
|
CXXFLAGS += \
|
2016-01-19 15:40:00 -06:00
|
|
|
-W4 \
|
|
|
|
-wd4100 \
|
|
|
|
-TP \
|
|
|
|
-bigobj -nologo \
|
|
|
|
-RTC1 -RTCc -RTCs -RTCu
|
2015-12-11 18:49:14 -06:00
|
|
|
|
|
|
|
# TODO warnings on undefined symbols
|
|
|
|
LDFLAGS += \
|
2016-01-19 15:40:00 -06:00
|
|
|
-largeaddressaware -nologo -incremental:no
|
2015-12-11 18:49:14 -06:00
|
|
|
|
|
|
|
ifneq ($(NODEBUG),1)
|
2016-01-19 15:40:00 -06:00
|
|
|
CFLAGS += -Zi
|
|
|
|
CXXFLAGS += -Zi
|
|
|
|
LDFLAGS += -debug
|
2015-12-11 18:49:14 -06:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Build rules.
|
|
|
|
|
|
|
|
OFILES = \
|
|
|
|
$(subst /,_,$(CFILES)) \
|
|
|
|
$(subst /,_,$(CXXFILES)) \
|
|
|
|
$(subst /,_,$(MFILES)) \
|
|
|
|
$(subst /,_,$(RCFILES))
|
|
|
|
|
|
|
|
OFILES := $(OFILES:%=$(OBJDIR)/%.o)
|
|
|
|
|
|
|
|
OUT = $(OUTDIR)/$(NAME)$(SUFFIX)
|
|
|
|
|
2016-01-19 15:40:00 -06:00
|
|
|
# TODO use $(CC), $(CXX), $(LD), and s$(RC)
|
2015-12-11 18:49:14 -06:00
|
|
|
|
|
|
|
$(OUT): $(OFILES) | $(OUTDIR)
|
2016-01-19 15:40:00 -06:00
|
|
|
@link -out:$(OUT) $(OFILES) $(LDFLAGS)
|
2015-12-11 18:49:14 -06:00
|
|
|
@echo ====== Linked $(OUT)
|
|
|
|
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
|
|
|
# TODO can we put /Fd$@.pdb in a variable?
|
|
|
|
$(OBJDIR)/%.c.o: $$(subst _,/,%).c $(HFILES) | $(OBJDIR)
|
|
|
|
ifeq ($(NODEBUG),1)
|
2016-01-19 15:40:00 -06:00
|
|
|
@cl -Fo:$@ -c $< $(CFLAGS)
|
2015-12-11 18:49:14 -06:00
|
|
|
else
|
2016-01-19 15:40:00 -06:00
|
|
|
@cl -Fo:$@ -c $< $(CFLAGS) -Fd$@.pdb
|
2015-12-11 18:49:14 -06:00
|
|
|
endif
|
|
|
|
@echo ====== Compiled $<
|
|
|
|
|
2015-12-22 19:01:53 -06:00
|
|
|
$(OBJDIR)/%.cpp.o: $$(subst _,/,%).cpp $(HFILES) | $(OBJDIR)
|
2015-12-11 18:49:14 -06:00
|
|
|
ifeq ($(NODEBUG),1)
|
2016-01-19 15:40:00 -06:00
|
|
|
@cl -Fo:$@ -c $< $(CXXFLAGS)
|
2015-12-11 18:49:14 -06:00
|
|
|
else
|
2016-01-19 15:40:00 -06:00
|
|
|
@cl -Fo:$@ -c $< $(CXXFLAGS) -Fd$@.pdb
|
2015-12-11 18:49:14 -06:00
|
|
|
endif
|
|
|
|
@echo ====== Compiled $<
|
|
|
|
|
2016-01-19 15:40:00 -06:00
|
|
|
# note: don't run cvtres directly; the linker does that for us
|
2015-12-11 18:49:14 -06:00
|
|
|
$(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR)
|
2016-01-19 15:40:00 -06:00
|
|
|
@rc -nologo -v -fo $@ $<
|
2015-12-11 18:49:14 -06:00
|
|
|
@echo ====== Compiled $<
|
|
|
|
|
|
|
|
$(OBJDIR) $(OUTDIR):
|
|
|
|
@mkdir $@
|