-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile.msvc
70 lines (52 loc) · 2.44 KB
/
Makefile.msvc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#While this uses MSVC, it still requires GNU make.
#This is because Microsoft's method, nmake, does not support functions; just plain variables.
all: minir_dummy
CC = cl
CFLAGS = /Oy /Oi /Os /Ox /D_CRT_SECURE_NO_WARNINGS /Dmain="__cdecl main" /WX /wd4700
CXX = cl
CXXFLAGS = $(CFLAGS)
LD = link
LFLAGS =
OBJSUFFIX =
#Native toolchain, aka not cross compiler. Used because parts of minir are autogenerated, and the generator is also written in C++.
#The generated file doesn't change between platforms.
NATCXX = $(CXX)
NATCXXFLAGS = /nologo /Imsvc /Dstrtoll=strtol /Dstrcasecmp=stricmp /Dstrncasecmp=strnicmp $(CXXFLAGS)
NATLD = $(LD)
NATLFLAGS = $(LFLAGS)
MSLIB = kernel32.lib shell32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib dinput8.lib
OUTNAME = minir.exe
TESTSRC = memory.cpp
TESTSEPSRC = test-*.cpp window-*.cpp
OBJS = $(patsubst %.cpp,obj/%$(OBJSUFFIX).obj,$(wildcard *.cpp)) $(EXTRAOBJ) obj/miniz$(OBJSUFFIX).obj obj/minir.res obj/dxguid$(OBJSUFFIX).obj
TESTOBJS = $(patsubst %.cpp,obj/%.obj,$(wildcard $(TESTSRC))) $(patsubst %.cpp,obj/%-test.obj,$(wildcard $(TESTSEPSRC))) $(EXTRAOBJ)
TRUE_CFLAGS = $(CFLAGS) /nologo /Imsvc
TRUE_CXXFLAGS = $(CXXFLAGS) /nologo /Imsvc /Dstrtoll=strtol /Dstrcasecmp=stricmp /Dstrncasecmp=strnicmp
TRUE_LFLAGS = $(LFLAGS) $(MSLIB) /nologo /subsystem:windows /entry:mainCRTStartup
#$(CC) $(TRUE_CFLAGS) -DTEST -DNO_ICON test*.c window*.c $(TRUE_LFLAGS) -otest $(RESOBJ)
test: $(TESTOBJS)
$(LD) $+ $(TRUE_LFLAGS) /Fo$@
#On Windows, cleaning up the object directory is expected to be done with 'del /q obj\*' in a batch script.
obj:
mkdir obj
obj/miniz$(OBJSUFFIX).obj: miniz.c | obj
$(CC) $(TRUE_CFLAGS) /c /Tp $< /Fo$@
obj/config$(OBJSUFFIX).obj: config.cpp obj/generated.cpp | obj
obj/main$(OBJSUFFIX).obj: main.cpp obj/generated.cpp minir.h | obj
obj/%$(OBJSUFFIX).obj: %.cpp | obj obj/generated.cpp
$(CXX) $(TRUE_CXXFLAGS) /c /Tp $< /Fo$@
obj/%-test.o: %.cpp | obj obj/generated.cpp
$(CXX) $(TRUE_CXXFLAGS) /c /Tp $< /Fo$@ /DTEST /DNO_ICON
obj/minir.res: ico/*
rc /nologo ico/minir.rc
move ico\minir.res obj
obj/dxguid$(OBJSUFFIX).obj: msvc/dxguid.c | obj
$(CC) $(TRUE_CFLAGS) /c /Tp $< /Fo$@
obj/generated.cpp: obj/rescompile.exe minir.cfg.tmpl
obj/rescompile.exe
obj/rescompile.exe: rescompile.cpp miniz.c | obj
$(NATCXX) $(NATCXXFLAGS) $(NATLFLAGS) /DRESCOMPILE /Tprescompile.cpp /Tcminiz.c /Feobj/rescompile.exe
del miniz.obj rescompile.obj
$(OUTNAME): $(OBJS)
$(LD) $(TRUE_LFLAGS) $+ /out:$@
minir_dummy: $(OUTNAME)