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
export OS
# TODO CC, CXX, RC, CVTRES, LD
# TODO CC, CXX, RC, LD
export CFLAGS
export CXXFLAGS
# TODO RCFLAGS, CVTRESFLAGS
# TODO RCFLAGS
export LDFLAGS
export NODEBUG
export EXAMPLE

View File

@ -71,8 +71,6 @@ $(OBJDIR)/%.m.o: $$(subst _,/,%).m $(HFILES) | $(OBJDIR)
@$(CC) -o $@ -c $< $(CFLAGS)
@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)
@$(RC) $(RCFLAGS) $< $@
@echo ====== Compiled $<

View File

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

View File

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