-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile.win
173 lines (145 loc) · 3.77 KB
/
Makefile.win
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
cc=cl
link=link
LIBS=$(lib)
#Include the sources
!if exists ("sources")
! include "sources"
!endif
#Default values for reserved Marcos
#USECRT, default to YES
!if !DEFINED(USE_MSVCRT) ||"$(USE_MSVCRT)" == ""
USE_MSVCRT=YES
!endif
#UMTYPE default to console
!if !DEFINED(UMTYPE) || "$(UMTYPE)" == ""
UMTYPE=console
!endif
#USE_UNICODE, default to YES
!if !DEFINED(USE_UNICODE) || "$(USE_UNICODE)" == ""
USE_UNICODE=YES
!endif
#UMENTRY, default to wmain
!if !DEFINED(UMENTRY) || "$(UMENTRY)" == ""
! if "$(USE_UNICODE)" == "YES"
UMENTRY=wmain
! else
UMENTRY=main
! endif
!endif
#TARGETNAME, we don't allow TARGETNAME is undefined or is null
!if !DEFINED(TARGETNAME) || "$(TARGETNAME)" == ""
!error Unknown target name!
!endif
!if !DEFINED(TARGETPATH) || "$(TARGETPATH)" == ""
TARGETPATH=obj
!endif
#TARGETTYPE, default to exe
!if !DEFINED(TARGETTYPE) || "$(TARGETTYPE)" == ""
TARGETTYPE=exe
!endif
!ifdef DEBUG
cflags=$(cflags) /D_DEBUG /Zi /Od
TARGETPATH=debug\$(TARGETPATH)
BIN_DIR=debug
!else
cflags=$(cflags) /Od
TARGETPATH=release\$(TARGETPATH)
BIN_DIR=release
!endif
!if "$(USE_UNICODE)" == "YES"
cflags=$(cflags) /D_UNICODE /DUNICODE
!endif
TARGETPATH=$(TARGETPATH)\$(CPU)
#generate directories
!if !EXIST("$(TARGETPATH)")
! if ![-mkdir "$(TARGETPATH)"]
! endif
!endif
#create objs list file
!if EXIST("$(TARGETPATH)\m_objs")
! if [del "$(TARGETPATH)\m_objs"]
! endif
!endif
!if ![-echo OBJS=\>>"$(TARGETPATH)\m_objs"]
! if ![-for %i in ($(SOURCES)) do (echo %~dpni.obj\>>"$(TARGETPATH)\m_objs")]
! include "$(TARGETPATH)\m_objs"
! endif
!endif
#create src list file
!if EXIST("$(TARGETPATH)\m_src")
! if [del "$(TARGETPATH)\m_src"]
! endif
!endif
!if ![-for %i in ($(SOURCES)) do (echo %~dpni.obj:%i >> "$(TARGETPATH)\m_src")]
! include "$(TARGETPATH)\m_src"
!endif
!if "$(USE_MSVCRT)" == "NO"
! ifdef DEBUG
cflags=$(cflags) /MTd
! else
cflags=$(cflags) /MT
! endif
!else
! ifdef DEBUG
cflags=$(cflags) /MDd
! else
cflags=$(cflags) /MD
! endif
!endif
TARGETPDB=$(TARGETNAME).pdb
#always enable debug for linking
LINKFLAGS=$(LINKFLAGS) /DEBUG
!if "$(UMTYPE)" == "console"
LINKFLAGS=$(LINKFLAGS) $(conlflags) /pdb:"$(TARGETPATH)\$(TARGETPDB)"
USE_LIBS=$(USE_LIBS) $(conlibs)
!elseif "$(UMTYPE)" == "windows"
LINKFLAGS=$(LINKFLAGS) $(guilflags) /pdb:"$(TARGETPATH)\$(TARGETPDB)"
USE_LIBS=$(USE_LIBS) $(guilibs)
!elseif "$(UMTYPE)" == "dll"
LINKFLAGS=$(LINKFLAGS) $(dlllflags) /pdb:"$(TARGETPATH)\$(TARGETPDB)"
USE_LIBS=$(USE_LIBS) $(conlibs)
TARGETTYPE=dll
!else
link=lib.exe
TARGETTYPE=lib
LINKFLAGS=
!endif
!if "$(UMTYPE)" != "lib"
! ifndef DEBUG
LINKFLAGS=$(LINKFLAGS) /PDBSTRIPPED:"$(TARGETPATH)\$(TARGETNAME).pri"
! endif
!endif
!if "$(TARGETTYPE)" == "exe"
_TARGETNAME=$(TARGETNAME).exe
!elseif "$(TARGETTYPE)" == "dll"
_TARGETNAME=$(TARGETNAME).dll
!elseif "$(TARGETTYPE)" == "lib"
_TARGETNAME=$(TARGETNAME).lib
!endif
!if "$(INCLUDES)" != ""
cflags=$(cflags) /I"$(INCLUDES)"
!endif
!if DEFINED(LIBS) && "$(LIBS)" != ""
LINKFLAGS=$(LINKFLAGS) /LIBPATH:"$(LIBS)"
!endif
all:$(_TARGETNAME)
$(_TARGETNAME):$(OBJS)
$(link) $(LINKFLAGS) /out:"$(_TARGETNAME)" $(USE_LIBS) $**
@for %i in ($(SOURCES)) do (move /Y %~dpni.obj "$(TARGETPATH)\%~ni.obj")
@-copy /Y *.pdb "$(TARGETPATH)\"
@-del /Q *.pdb
@-copy /Y *.ilk "$(TARGETPATH)\"
@-del /Q *.ilk
@copy /Y $(_TARGETNAME) "$(TARGETPATH)\$(_TARGETNAME)"
@del /Q $(_TARGETNAME)
.c.obj:
$(cc) /c $(cflags) /Fo$@ $<
.cpp.obj:
$(cc) /c $(cflags) /Fo$@ /EHac $<
.cxx.obj:
$(cc) /c $(cflags) /Fo$@ /EHac $<
clean:
@rd /s /q "$(BIN_DIR)"
@del *.obj
@del *.pdb
@echo successfully clean up!