-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
175 lines (133 loc) · 8.79 KB
/
Makefile
File metadata and controls
175 lines (133 loc) · 8.79 KB
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
#MIT License
#Copyright (c) 2023 Jared Loewenthal
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#Makefile to create the Windows Lossless Screen Record program executable
#designed to be run by MinGW-w64's make (mingw32-make.exe)
#Can only currently be run on Windows and expects the following programs
#to be on the System PATH:
# MinGW-w64 Binaries (bin folder in downloadable: https://winlibs.com/)
# FASM.exe from flatassembler for Windows: https://flatassembler.net/
# glslangValidator.exe from the Vulkan SDK: https://vulkan.lunarg.com/
#The default target is for Windows
default_target: WindowsExecutables
#create directories when needed
./bin/:
cmd /c mkdir .\bin
./bin/obj/:
cmd /c mkdir .\bin\obj
./bin/lib/:
cmd /c mkdir .\bin\lib
./bin/spv/:
cmd /c mkdir .\bin\spv
#Common Compiler (gcc) arguments
CompilerArguments = -std=c11 -O2 -m64 -mabi=ms -ffreestanding -fno-exceptions -fno-unwind-tables
# -ffreestanding
CompilerWarnings = -Wall
# -Wextra -Wwrite-strings -pedantic -g3 More Warnings in the future
./bin/obj/compatibility.o: ./src/compatibility.c ./src/compatibility.h | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/compatibility.o ./src/compatibility.c
#-O1 to counter the automatic memset insert until functions get converted to assembly
# generate elf output format in future
./bin/obj/compatibilityAssembly.o: ./src/compatibilityAssembly.asm | ./bin/obj/
FASM ./src/compatibilityAssembly.asm ./bin/obj/compatibilityAssembly.o
./bin/obj/compatibilityWin32.o: ./src/compatibilityWin32.c ./src/compatibility.h | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/compatibilityWin32.o ./src/compatibilityWin32.c
#-fstack-usage to output stack usage per function so that it can be adjusted to be lower than 4096 bytes
./bin/obj/compatibilityWin32Graphics.o: ./src/compatibilityWin32Graphics.c ./src/compatibility.h ./src/math.h | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/compatibilityWin32Graphics.o ./src/compatibilityWin32Graphics.c
./bin/obj/compatibilityWin32Network.o: ./src/compatibilityWin32Network.c ./src/compatibility.h ./src/math.h | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/compatibilityWin32Network.o ./src/compatibilityWin32Network.c
CompatibilityWindowsObjects = ./bin/obj/compatibility.o ./bin/obj/compatibilityAssembly.o ./bin/obj/compatibilityWin32.o ./bin/obj/compatibilityWin32Graphics.o ./bin/obj/compatibilityWin32Network.o
./bin/lib/compatibilityWin32.a: $(CompatibilityWindowsObjects) | ./bin/lib/
ar cr ./bin/lib/compatibilityWin32.a $(CompatibilityWindowsObjects)
./bin/obj/math.o: ./src/math.c ./src/math.h | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/math.o ./src/math.c
./bin/obj/mathAssembly.o: ./src/mathAssembly.asm | ./bin/obj/
FASM ./src/mathAssembly.asm ./bin/obj/mathAssembly.o
./bin/obj/log2.o: ./src/log2.c ./src/math.h | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/log2.o ./src/log2.c
./bin/obj/exp2.o: ./src/exp2.c ./src/math.h | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/exp2.o ./src/exp2.c
MathObjects = ./bin/obj/math.o ./bin/obj/mathAssembly.o ./bin/obj/log2.o ./bin/obj/exp2.o
./bin/lib/math.a: $(MathObjects) | ./bin/lib/
ar cr ./bin/lib/math.a $(MathObjects)
ProgramEntry = ./src/compatibility.h ./src/programStrings.h ./src/programEntry.h
./bin/obj/desktopDuplicationWindow.o: ./src/desktopDuplicationWindow.c $(ProgramEntry) | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/desktopDuplicationWindow.o ./src/desktopDuplicationWindow.c
./bin/obj/losslessScreenRecord.o: ./src/losslessScreenRecord.c $(ProgramEntry) ./src/math.h | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/losslessScreenRecord.o ./src/losslessScreenRecord.c
./bin/obj/bitstreamFrameExtract.o: ./src/bitstreamFrameExtract.c $(ProgramEntry) | ./bin/obj/
gcc $(CompilerArguments) $(CompilerWarnings) -c -o ./bin/obj/bitstreamFrameExtract.o ./src/bitstreamFrameExtract.c
./bin/CreateStringsData.exe: ./src/createStringsData.c ./src/elf.h | ./bin
gcc $(CompilerArguments) $(CompilerWarnings) -s -o ./bin/CreateStringsData.exe ./src/createStringsData.c
./bin/obj/stringsData.o: ./bin/CreateStringsData.exe ./src/en-us.txt | ./bin/obj/
./bin/CreateStringsData.exe ./bin/obj/stringsData.o ./src/en-us.txt
./bin/spv/shader.spv: ./src/shader.comp.glsl | ./bin/spv/
glslangValidator ./src/shader.comp.glsl -V -o ./bin/spv/shader.spv \
-g0 --target-env vulkan1.1
#-Os Optimize for size to try
./bin/CreateElfObjectFromFiles.exe: ./src/createElfObjectFromFiles.c ./src/elf.h | ./bin
gcc $(CompilerArguments) $(CompilerWarnings) -s -o ./bin/CreateElfObjectFromFiles.exe ./src/createElfObjectFromFiles.c
./bin/obj/binData.o: ./bin/CreateElfObjectFromFiles.exe ./bin/spv/shader.spv
./bin/CreateElfObjectFromFiles.exe ./bin/obj/binData.o ./bin/spv/shader.spv
./bin/obj/win32Resource.o: ./src/win32Resource.rc ./src/win32AppManifest.xml | ./bin/obj/
windres -o ./bin/obj/win32Resource.o -i ./src/win32Resource.rc -O coff
./bin/CheckLosslessSRGBtoYUV.exe: ./src/checkLosslessSRGBtoYUV.c ./src/math.h ./bin/obj/mathAssembly.o
gcc $(CompilerArguments) $(CompilerWarnings) -s -o ./bin/CheckLosslessSRGBtoYUV.exe ./src/checkLosslessSRGBtoYUV.c ./bin/obj/mathAssembly.o
CheckLossless: ./bin/CheckLosslessSRGBtoYUV.exe
./bin/CheckLosslessSRGBtoYUV.exe
LocalLibraryDirectory = -L./lib/
LocalLibraries = -l:vulkan-1.lib
# vulkan-1.lib is needed for Vulkan ("Middleman" Compute Pipeline)
# -l:cuda.lib & -l:nvencodeapi.lib was needed for NVIDIA Encoding (the libraries are now loaded during runtime if needed)
WindowsLibraryDirectory = -LC:/Windows/System32
# should maybe point to mingw library directory here in future
Libraries = -l:kernel32.dll -l:user32.dll -l:dxgi.dll -l:d3d11.dll -l:ws2_32.dll
# kernel32.dll is needed for the basic Window OS API interface
# dxgi.dll & d3d11.dll is needed for Windows Desktop Duplication
# ws2_32.dll is needed for Windows networking (sockets)
LinkerLibraries = $(LocalLibraryDirectory) $(LocalLibraries) $(WindowsLibraryDirectory) $(Libraries)
#gccLibraryDirectory = -LC:/mingw64/lib/gcc/x86_64-w64-mingw32/13.1.0
#gccLibraries = -lgcc
#needed for gcc automatic windows function stack correction (when a function uses more than 4096 bytes / a page for the stack)
#TempLibraries = $(gccLibraryDirectory) $(gccLibraries)
WindowsLinkingObjects = ./bin/lib/compatibilityWin32.a ./bin/lib/math.a ./bin/obj/stringsData.o ./bin/obj/win32Resource.o
WindowsLibraries = -lkernel32 -luser32 -ldxgi -ld3d11 -lws2_32
./bin/DesktopDuplicationWindow.exe: ./bin/obj/desktopDuplicationWindow.o $(WindowsLinkingObjects)
ld -o ./bin/DesktopDuplicationWindow.exe -eprogramEntry -s --gc-sections --subsystem console \
./bin/obj/desktopDuplicationWindow.o $(WindowsLinkingObjects) \
$(LinkerLibraries)
#$(TempLibraries)
#gcc -Wall -m64 -mconsole -O2 -s -nostartfiles -Wl,-eprogramEntry -Wl,--gc-sections \
#-o ./bin/VulkanWindowDuplication.exe ./bin/obj/desktopDuplicationWindow.o $(WindowsLinkingObjects) \
#$(LocalLibraryDirectory) $(LocalLibraries) $(WindowsLibraries)
./bin/LosslessScreenRecord.exe: ./bin/obj/losslessScreenRecord.o $(WindowsLinkingObjects) ./bin/obj/binData.o
ld -o ./bin/LosslessScreenRecord.exe -eprogramEntry -s --gc-sections --subsystem console \
./bin/obj/losslessScreenRecord.o $(WindowsLinkingObjects) ./bin/obj/binData.o \
$(LinkerLibraries)
#$(TempLibraries)
./bin/BitstreamFrameExtract.exe: ./bin/obj/bitstreamFrameExtract.o $(WindowsLinkingObjects)
ld -o ./bin/BitstreamFrameExtract.exe -eprogramEntry -s --gc-sections --subsystem console \
./bin/obj/bitstreamFrameExtract.o $(WindowsLinkingObjects) \
$(LinkerLibraries)
#$(TempLibraries)
WindowsExecutables: ./bin/DesktopDuplicationWindow.exe ./bin/LosslessScreenRecord.exe ./bin/BitstreamFrameExtract.exe
WindowsClean:
cmd /c rmdir /s /q .\bin