forked from neosmart/msvcrt.lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (52 loc) · 2.2 KB
/
Makefile
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
# Compile with nmake from a VS Dev Command Prompt
# Requires some basic posix utilities (sed, echo, cat)
# RunInBash aliased to `$` is required. WSL must be installed.
.PHONY: all
all: x86/msvcrt.lib x64/msvcrt.lib zip
GetFileVersionInfo.exe: GetFileVersionInfo/GetFileVersionInfo.c
cl.exe -DUNICODE -W4 -D_UNICODE $? /link mincore.lib /out:$@
x64:
mkdir x64
x86:
mkdir x86
x64/msvcrt.exports: x64
dumpbin.exe /EXPORTS C:\\Windows\\System32\\msvcrt.dll > x64/msvcrt.exports
x86/msvcrt.exports: x86
dumpbin.exe /EXPORTS C:\\Windows\\syswow64\\msvcrt.dll > x86/msvcrt.exports
x64/msvcrt.funcs: x64/msvcrt.exports
$$ sed -r "s/.*?(:?[A-F0-9]+ ){2}/\t/;tx;d;:x" ./x64/msvcrt.exports > ./x64/msvcrt.funcs
x86/msvcrt.funcs: x86/msvcrt.exports
$$ sed -r "s/.*?(:?[A-F0-9]+ ){2}/\t/;tx;d;:x" ./x86/msvcrt.exports > ./x86/msvcrt.funcs
x64/msvcrt.def: x64/msvcrt.funcs
echo EXPORTS > ./x64/msvcrt.def
cat x64/msvcrt.funcs >> ./x64/msvcrt.def
x86/msvcrt.def: x86/msvcrt.funcs
echo EXPORTS > x86/msvcrt.def
cat x86/msvcrt.funcs >> x86/msvcrt.def
x64/msvcrt.lib: x64/msvcrt.def
lib.exe /MACHINE:X64 /def:x64/msvcrt.def /out:x64/msvcrt.lib
x86/msvcrt.lib: x86/msvcrt.def
lib.exe /MACHINE:X86 /def:x86/msvcrt.def /out:x86/msvcrt.lib
.PHONY: zip
version.txt: GetFileVersionInfo.exe x64/msvcrt.lib
.\\GetFileVersionInfo.exe %windir%\\system32\\ntoskrnl.exe > version.txt
readme.txt: Makefile GetFileVersionInfo.exe
$$ printf "msvcrt.lib by Mahmoud Al-Qudsi <[email protected]>\r\nCopyright NeoSmart Technologies %%d\r\nhttps://github.com/neosmart/msvcrt.lib\r\n\r\nBuilt against Windows %%s and msvcrt.dll %%s\r\n" "$$(date +%%Y)" "$$(./GetFileVersionInfo.exe user32.dll | dos2unix)" "$$(./GetFileVersionInfo.exe msvcrt.dll | dos2unix)" > $@
zip: x86/msvcrt.lib x64/msvcrt.lib releases version.txt readme.txt
# get Windows version number
# ver.bat | grep -o -P "\d+.\d+.\d+" > version.txt
# for /f does not support piping
$$ zip ./msvcrt.zip ./readme.txt ./x86/msvcrt.lib ./x64/msvcrt.lib
for /f "tokens=* USEBACKQ" %i IN (`cat version.txt`) DO ( \
move msvcrt.zip releases/msvcrt_%i.zip \
)
releases:
mkdir -p ./releases
clean:
rm -f *.exe
rm -f *.exp
rm -f *.obj
rm -f *.zip
rm -f version.txt
rm -rf x64
rm -rf x86