-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathmakefile.vc
164 lines (135 loc) · 4.1 KB
/
makefile.vc
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
# VC makefile for ANSICON.
# Jason Hood, 15 November, 2010.
#
# Tested with:
# * Visual Studio 6.0 (VC6);
# * Visual C++ 2003 Toolkit (VC7);
# * Platform SDK for Windows Server 2003 R2 (VC8 64-bit);
# * Visual Studio 2008 Express SP1 (VC9);
# * Visual Studio 2010 Professional (VC10).
#
# Note that the 64-bit version still requires a 32-bit compiler.
#
# 22 & 23 November, 2012:
# determine if the PSDK is used automatically;
# use AC0000[00] (AnsiCon) as the base address;
# twiddle stuff around to support VC6 (with 2003 PSDK) for the 32-bit version;
# determine BITS automatically.
#
# 18 July, 2013:
# hide the commands (use V=1 to show them).
#
# 30 April, 8 to 11 May 2018:
# use a batch rule (even if this project is too small to make a difference);
# add /nologo to RFLAGS if rc supports it;
# explicitly link the exe with MSVCRT.DLL.
#BITS = 32
#BITS = 64
!IFNDEF BITS
!IF "$(CPU)" == "AMD64" || "$(PLATFORM)" == "x64" || "$(PLATFORM)" == "X64"
BITS = 64
!ELSE
BITS = 32
!ENDIF
!ENDIF
!IF $(BITS) == 32
DIR = x86
!ELSE
!IF $(BITS) == 64
DIR = x64
!ELSE
!ERROR BITS should be defined to 32 or 64.
!ENDIF
!ENDIF
# Disable security checks, but VC6 & 7 don't have /GS-.
!IF "$(_NMAKE_VER)" != "7.00.8882" || $(BITS) == 64
NOSECCHK = /GS-
!ENDIF
# 2008 (SDK v6) and earlier rc do not have /nologo.
!IF [cmd /d /c exit $(_NMAKE_VER)] <= 9
RFLAGS =
!ENDIF
# Link with MSVCRT.LIB by default.
!IFNDEF SHARE
SHARE = /MD
CRT = $(DIR)\acrt.lib
LINK = /entry:main /nod
# The 2003 Toolkit has chkstk in libc, but the rest have it as itself.
!IF "$(_NMAKE_VER)" == "7.00.8882" && $(BITS) == 32 && !DEFINED(MSVCDIR)
LIBS = libc.lib
!ELSE
LIBS = chkstk.obj
!ENDIF
!ENDIF
!IFNDEF RFLAGS
RFLAGS = /nologo
!ENDIF
!IF $(BITS) == 64
RFLAGS = $(RFLAGS) /D_WIN64
!ENDIF
CFLAGS = /nologo /W3 /O2 $(NOSECCHK) /D_CRT_SECURE_NO_WARNINGS
LIBS = $(LIBS) kernel32.lib advapi32.lib
# Identify ansicon.exe using "ANSI" as a version number.
LINK = /link /version:20033.18771 $(LINK) /fixed
X86OBJS = x86\injdll.obj x86\procrva.obj x86\proctype.obj x86\util.obj
X64OBJS = x64\injdll.obj x64\procrva.obj x64\proctype.obj x64\util.obj
X6432OBJS = x86\injdll.obj x86\procrva.obj x64\proctype32.obj x86\util.obj
!IF !DEFINED(V)
V = 0
!ENDIF
!IF $(V) == 0
CCmsg = @
RCmsg = @echo $<&
LDmsg = @echo $@&
!ENDIF
{}.c{$(DIR)}.obj::
$(CCmsg)$(CC) /c $(CFLAGS) /Fo$(DIR)\ $<
{}.rc{$(DIR)}.res:
$(RCmsg)$(RC) $(RFLAGS) /fo$@ $<
all: ansicon$(BITS)
ansicon32: x86 x86\ANSI32.dll x86\ansicon.exe x64 x64\ANSI32.dll
ansicon64: x64 x64\ANSI64.dll x64\ansicon.exe
x86:
mkdir x86
x86\ansicon.exe: x86\ansicon.obj x86\ansi32.lib $(CRT) x86\ansicon.res
$(LDmsg)$(CC) /nologo $(SHARE) /Fe$@ $** $(LIBS) $(LINK) /filealign:512
!IF "$(_NMAKE_VER)" == "9.00.30729.01"
@del [email protected]
!ENDIF
x86\ANSI32.dll: x86\ANSI.obj $(X86OBJS) x86\ansi.res
$(LDmsg)$(CC) /nologo /LD /Fe$@ $** kernel32.lib /link \
/base:0xAC0000 /entry:DllMain /filealign:512
x64:
mkdir x64
x64\ansicon.exe: x64\ansicon.obj x64\ansi64.lib $(CRT) x64\ansicon.res
$(LDmsg)$(CC) /nologo $(SHARE) /Fe$@ $** $(LIBS) $(LINK)
x64\ANSI64.dll: x64\ANSI.obj $(X64OBJS) x64\ansi.res
$(LDmsg)$(CC) /nologo /LD /Fe$@ $** kernel32.lib /link \
/base:0xAC000000 /entry:DllMain
x64\ANSI32.dll: x64\ANSI32.obj $(X6432OBJS) x86\ansi.res
$(LDmsg)$(CC) /nologo /LD /Fe$@ $** kernel32.lib /link \
/base:0xAC0000 /entry:DllMain /filealign:512 \
/largeaddressaware
ansicon.c: ansicon.h version.h
ansicon.rc: version.h
ANSI.c: ansicon.h version.h
ANSI.rc: version.h
util.c: ansicon.h version.h
injdll.c: ansicon.h
proctype.c: ansicon.h
procrva.c: ansicon.h
$(DIR)\ansicon.obj:
$(CCmsg)$(CC) /c $(CFLAGS) $(SHARE) /Fo$@ $?
x64\ANSI32.obj: ANSI.c
$(CCmsg)$(CC) /DW32ON64 /c $(CFLAGS) /Fo$@ $?
x64\proctype32.obj: proctype.c
$(CCmsg)$(CC) /DW32ON64 /c $(CFLAGS) /Fo$@ $?
x86\acrt.lib: acrt.def
$(LDmsg)link /lib /nologo /def:acrt.def /machine:ix86 /name:msvcrt /out:$@
x64\acrt.lib: acrt.def
$(LDmsg)link /lib /nologo /def:acrt.def /machine:amd64 /name:msvcrt /out:$@
clean:
-del $(DIR)\*.obj $(DIR)\*.res $(DIR)\*.lib $(DIR)\*.exp
!IF $(BITS) == 32
-del x64\ansi32.obj x64\proctype32.obj
!ENDIF