Two important changes to the Windows build:

1) cvtres is no longer used directly. MSDN says to send the .res files to link.exe; that runs cvtres for us (at least it seems to, accoring to Google results for error LNK1158). It'll also avoid some of the weird warnings in cvtres, like CVT4001.

2) (and more important, but it depended on 1) Command-line switches are now passed using - instead of /. This is because some versions of MinGW are buggy and treat anything that starts with a / as a MSYS filename that needs to be converted to a Windows pathname.

Update #16.
This commit is contained in:
Pietro Gagliardi 2016-01-19 16:40:00 -05:00
parent 5fd3a6fbab
commit a3344f0341
4 changed files with 39 additions and 27 deletions

View File

@ -31,10 +31,10 @@ endif
# parameters # parameters
export OS export OS
# TODO CC, CXX, RC, CVTRES, LD # TODO CC, CXX, RC, LD
export CFLAGS export CFLAGS
export CXXFLAGS export CXXFLAGS
# TODO RCFLAGS, CVTRESFLAGS # TODO RCFLAGS
export LDFLAGS export LDFLAGS
export NODEBUG export NODEBUG
export EXAMPLE export EXAMPLE

View File

@ -71,8 +71,6 @@ $(OBJDIR)/%.m.o: $$(subst _,/,%).m $(HFILES) | $(OBJDIR)
@$(CC) -o $@ -c $< $(CFLAGS) @$(CC) -o $@ -c $< $(CFLAGS)
@echo ====== Compiled $< @echo ====== Compiled $<
# TODO split into $(RC) and $(CVTRES) forms
# with binutils windres can either go straight to a .o file or in the normal two steps
$(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR) $(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR)
@$(RC) $(RCFLAGS) $< $@ @$(RC) $(RCFLAGS) $< $@
@echo ====== Compiled $< @echo ====== Compiled $<

View File

@ -1,5 +1,19 @@
# 16 october 2015 # 16 october 2015
# 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
# TODO subsystem version # TODO subsystem version
# TODO silence compiler non-diagnostics (/nologo is not enough) # TODO silence compiler non-diagnostics (/nologo is not enough)
@ -13,27 +27,27 @@
# TODO /analyze requires us to write annotations everywhere # TODO /analyze requires us to write annotations everywhere
# TODO undecided flags from qo? # TODO undecided flags from qo?
CFLAGS += \ CFLAGS += \
/W4 \ -W4 \
/wd4100 \ -wd4100 \
/TC \ -TC \
/bigobj /nologo \ -bigobj -nologo \
/RTC1 /RTCc /RTCs /RTCu -RTC1 -RTCc -RTCs -RTCu
CXXFLAGS += \ CXXFLAGS += \
/W4 \ -W4 \
/wd4100 \ -wd4100 \
/TP \ -TP \
/bigobj /nologo \ -bigobj -nologo \
/RTC1 /RTCc /RTCs /RTCu -RTC1 -RTCc -RTCs -RTCu
# TODO warnings on undefined symbols # TODO warnings on undefined symbols
LDFLAGS += \ LDFLAGS += \
/largeaddressaware /nologo /incremental:no -largeaddressaware -nologo -incremental:no
ifneq ($(NODEBUG),1) ifneq ($(NODEBUG),1)
CFLAGS += /Zi CFLAGS += -Zi
CXXFLAGS += /Zi CXXFLAGS += -Zi
LDFLAGS += /debug LDFLAGS += -debug
endif endif
# Build rules. # Build rules.
@ -48,10 +62,10 @@ OFILES := $(OFILES:%=$(OBJDIR)/%.o)
OUT = $(OUTDIR)/$(NAME)$(SUFFIX) OUT = $(OUTDIR)/$(NAME)$(SUFFIX)
# TODO use $(CC), $(CXX), $(LD), $(RC), and $(CVTRES) # TODO use $(CC), $(CXX), $(LD), and s$(RC)
$(OUT): $(OFILES) | $(OUTDIR) $(OUT): $(OFILES) | $(OUTDIR)
@link /out:$(OUT) $(OFILES) $(LDFLAGS) @link -out:$(OUT) $(OFILES) $(LDFLAGS)
@echo ====== Linked $(OUT) @echo ====== Linked $(OUT)
.SECONDEXPANSION: .SECONDEXPANSION:
@ -59,23 +73,23 @@ $(OUT): $(OFILES) | $(OUTDIR)
# TODO can we put /Fd$@.pdb in a variable? # TODO can we put /Fd$@.pdb in a variable?
$(OBJDIR)/%.c.o: $$(subst _,/,%).c $(HFILES) | $(OBJDIR) $(OBJDIR)/%.c.o: $$(subst _,/,%).c $(HFILES) | $(OBJDIR)
ifeq ($(NODEBUG),1) ifeq ($(NODEBUG),1)
@cl /Fo:$@ /c $< $(CFLAGS) @cl -Fo:$@ -c $< $(CFLAGS)
else else
@cl /Fo:$@ /c $< $(CFLAGS) /Fd$@.pdb @cl -Fo:$@ -c $< $(CFLAGS) -Fd$@.pdb
endif endif
@echo ====== Compiled $< @echo ====== Compiled $<
$(OBJDIR)/%.cpp.o: $$(subst _,/,%).cpp $(HFILES) | $(OBJDIR) $(OBJDIR)/%.cpp.o: $$(subst _,/,%).cpp $(HFILES) | $(OBJDIR)
ifeq ($(NODEBUG),1) ifeq ($(NODEBUG),1)
@cl /Fo:$@ /c $< $(CXXFLAGS) @cl -Fo:$@ -c $< $(CXXFLAGS)
else else
@cl /Fo:$@ /c $< $(CXXFLAGS) /Fd$@.pdb @cl -Fo:$@ -c $< $(CXXFLAGS) -Fd$@.pdb
endif endif
@echo ====== Compiled $< @echo ====== Compiled $<
# note: don't run cvtres directly; the linker does that for us
$(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR) $(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR)
@rc /nologo /v /fo $@.res $< @rc -nologo -v -fo $@ $<
@cvtres /nologo /out:$@ $@.res
@echo ====== Compiled $< @echo ====== Compiled $<
$(OBJDIR) $(OUTDIR): $(OBJDIR) $(OUTDIR):

View File

@ -62,7 +62,7 @@ LDFLAGS += \
# flags for building a shared library # flags for building a shared library
LDFLAGS += \ LDFLAGS += \
/dll -dll
# TODO flags for warning on undefined symbols # TODO flags for warning on undefined symbols