forked from lsdev/litestep-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
233 lines (193 loc) · 7.02 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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#-----------------------------------------------------------------------------
# Makefile for MinGW
#
# To make a release build: make
# To make a debug build: make DEBUG=1
# To clean up a release build: make clean
# To clean up a debug build: make clean DEBUG=1
#
# While mingw32-make.exe will work with this makefile we suggest using
# GNU Make 3.81 available from http://gnuwin32.sourceforge.net/
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Tools and Flags
#-----------------------------------------------------------------------------
# C++ compiler
CXX = g++
#CXXWARNING = -Wall -Wextra -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wpacked -Wpadded -Wredundant-decls -Wunreachable-code -Winline -Wdisabled-optimization
CXXWARNING = -Wall
# C++ compiler flags
ifdef DEBUG
CXXFLAGS = $(CXXWARNING) -D_DEBUG -g
else
CXXFLAGS = -O2 $(CXXWARNING) -DNDEBUG
endif
# Linker flags
ifdef DEBUG
LDFLAGS =
else
LDFLAGS = -s
endif
# Resource compiler
RC = windres
# Resource compiler flags
RCFLAGS = -O coff
# dlltool
DLLTOOL = dlltool
# rm
RM = del /F
# md
MD = mkdir
ifeq ($(OS), Windows_NT)
NULL =
else
NULL = nul
endif
#-----------------------------------------------------------------------------
# Files and Paths
#-----------------------------------------------------------------------------
# Output directory
ifdef DEBUG
OUTPUT = Debug_MinGW
else
OUTPUT = Release_MinGW
endif
# Path to litestep.exe
EXE = $(OUTPUT)\litestep.exe
# Libraries that litestep.exe uses
EXELIBS = -ladvapi32 -lkernel32 -lmsvcp60 -lmsvcrt -lole32 -lshell32 -lshlwapi -luser32 -luuid -L$(OUTPUT) -llsapi.dll
EXEMAP = $(OUTPUT)\litestep.map
# Object files for litestep.exe
EXEOBJS = \
litestep\$(OUTPUT)\DataStore.o \
litestep\$(OUTPUT)\DDEService.o \
litestep\$(OUTPUT)\DDEStub.o \
litestep\$(OUTPUT)\DDEWorker.o \
litestep\$(OUTPUT)\FullscreenMonitor.o \
litestep\$(OUTPUT)\litestep.o \
litestep\$(OUTPUT)\MessageManager.o \
litestep\$(OUTPUT)\Module.o \
litestep\$(OUTPUT)\ModuleManager.o \
litestep\$(OUTPUT)\RecoveryMenu.o \
litestep\$(OUTPUT)\StartupRunner.o \
litestep\$(OUTPUT)\TrayNotifyIcon.o \
litestep\$(OUTPUT)\TrayService.o \
litestep\$(OUTPUT)\WinMain.o
EXERES = litestep\$(OUTPUT)\litestep.res
EXERESFILES = \
litestep\litestep.rc \
litestep\resource.h \
litestep\litestep.bmp \
litestep\litestep.ico
# Path to lsapi.dll
DLL = $(OUTPUT)\lsapi.dll
DLLEXP = $(OUTPUT)\lsapi.exp
# Path to lsapi.dll import library
DLLIMPLIB = $(OUTPUT)\liblsapi.dll.a
# Libraries that lsapi.dll uses
DLLLIBS = -ladvapi32 -lgdi32 -lkernel32 -lmsvcrt -lole32 -lshell32 -lshlwapi -luser32
DLLMAP = $(OUTPUT)\lsapi.map
# Object files for lsapi.dll
DLLOBJS = \
lsapi\$(OUTPUT)\aboutbox.o \
lsapi\$(OUTPUT)\BangCommand.o \
lsapi\$(OUTPUT)\BangManager.o \
lsapi\$(OUTPUT)\bangs.o \
lsapi\$(OUTPUT)\graphics.o \
lsapi\$(OUTPUT)\lsapi.o \
lsapi\$(OUTPUT)\lsapiInit.o \
lsapi\$(OUTPUT)\match.o \
lsapi\$(OUTPUT)\MathEvaluate.o \
lsapi\$(OUTPUT)\MathParser.o \
lsapi\$(OUTPUT)\MathScanner.o \
lsapi\$(OUTPUT)\MathToken.o \
lsapi\$(OUTPUT)\MathValue.o \
lsapi\$(OUTPUT)\picopng.o \
lsapi\$(OUTPUT)\png_support.o \
lsapi\$(OUTPUT)\settings.o \
lsapi\$(OUTPUT)\SettingsFileParser.o \
lsapi\$(OUTPUT)\SettingsIterator.o \
lsapi\$(OUTPUT)\SettingsManager.o \
lsapi\$(OUTPUT)\stubs.o
DLLRES = lsapi\$(OUTPUT)\lsapi.res
DLLRESFILES = \
lsapi\lsapi.rc \
lsapi\resource.h
# Object files for utility project
UTILOBJS = \
utility\$(OUTPUT)\debug.o \
utility\$(OUTPUT)\shellhlp.o
#-----------------------------------------------------------------------------
# Rules
#-----------------------------------------------------------------------------
# all targets (default)
.PHONY: all
all: setup $(DLL) $(EXE)
# litestep.exe
$(EXE): setup $(UTILOBJS) $(EXEOBJS) $(EXERES)
$(CXX) $(LDFLAGS) -Wl,--subsystem,windows,-Map,$(EXEMAP) -o $(EXE) $(UTILOBJS) $(EXEOBJS) $(EXERES) $(EXELIBS)
# lsapi.dll
$(DLL): setup $(UTILOBJS) $(DLLOBJS) $(DLLRES)
# The only reason that we must use dlltool, is to generate an export file and
# import library which contains the correct stdcall naming fixups.
$(DLLTOOL) --add-stdcall-underscore -e $(DLLEXP) -l $(DLLIMPLIB) -D $(DLL) $(UTILOBJS) $(DLLOBJS) $(DLLRES)
$(CXX) $(DLLEXP) $(LDFLAGS) -shared -Wl,--subsystem,windows,-Map,$(DLLMAP) -o $(DLL) $(UTILOBJS) $(DLLOBJS) $(DLLRES) $(DLLLIBS)
# Setup environment
.PHONY: setup
setup:
@-if not exist $(OUTPUT)\$(NULL) $(MD) $(OUTPUT)
@-if not exist litestep\$(OUTPUT)\$(NULL) $(MD) litestep\$(OUTPUT)
@-if not exist lsapi\$(OUTPUT)\$(NULL) $(MD) lsapi\$(OUTPUT)
@-if not exist utility\$(OUTPUT)\$(NULL) $(MD) utility\$(OUTPUT)
# Remove output files
.PHONY: clean
clean:
@echo Cleaning output files
@echo $(OUTPUT)\ ...
@-$(RM) $(EXE) $(EXEMAP) $(DLL) $(DLLMAP) $(DLLEXP) $(DLLIMPLIB)
@echo Cleaning intermediate files
@echo litestep\$(OUTPUT)\ ...
@-$(RM) litestep\$(OUTPUT)\*.o litestep\$(OUTPUT)\*.d $(EXERES)
@echo lsapi\$(OUTPUT)\ ...
@-$(RM) lsapi\$(OUTPUT)\*.o lsapi\$(OUTPUT)\*.d $(DLLRES)
@echo utility\$(OUTPUT)\ ...
@-$(RM) utility\$(OUTPUT)\*.o utility\$(OUTPUT)\*.d
@echo Done
# Resources for litestep.exe
$(EXERES): $(EXERESFILES)
$(RC) -Ilitestep $(RCFLAGS) -o $@ $<
# Resources for lsapi.dll
$(DLLRES): $(DLLRESFILES)
$(RC) -Ilsapi $(RCFLAGS) -o $@ $<
# Pattern rule to compile cpp files
#
# The sed mess does this with the auto-dependency (*.d) files:
# 1. strip line of colon and everything preceding it
# 2. strip whitespace from start of line
# 3. strip trailing whitespace and backslash from end of line
# 4. remove empty lines
# 5. if a space character is left anywhere in the line, replace it with a colon
# and a new line. (splits apart multiple file names into individual lines)
# 6. add a trailing colon at the end of the line.
#
# (note: for some reason sed does not like + matching. odd.)
#
# If for some reason you don't have sed, just delete those lines, and the only
# issue you'll run into is that if you ever get the error "No rule to make
# target <...>" then you'll have to run a 'make clean' to fix the issue.
#
utility\$(OUTPUT)\\%.o: utility\%.cpp
$(CXX) $(CXXFLAGS) -MMD -c -o $@ $<
@sed -e "s/^[^:]*://" -e "s/^ *//" -e "s/ *\\$$//" -e "/^$$/ d" -e "s/ */:\n/g" -e "s/$$/:/" < utility/$(OUTPUT)/$*.d >> utility/$(OUTPUT)/$*.d
lsapi\$(OUTPUT)\\%.o: lsapi\%.cpp
$(CXX) $(CXXFLAGS) -MMD -DLSAPI_PRIVATE -DLSAPI_INTERNAL -c -o $@ $<
@sed -e "s/^[^:]*://" -e "s/^ *//" -e "s/ *\\$$//" -e "/^$$/ d" -e "s/ */:\n/g" -e "s/$$/:/" < lsapi/$(OUTPUT)/$*.d >> lsapi/$(OUTPUT)/$*.d
litestep\$(OUTPUT)\\%.o: litestep\%.cpp
$(CXX) $(CXXFLAGS) -MMD -DLSAPI_PRIVATE -c -o $@ $<
@sed -e "s/^[^:]*://" -e "s/^ *//" -e "s/ *\\$$//" -e "/^$$/ d" -e "s/ */:\n/g" -e "s/$$/:/" < litestep/$(OUTPUT)/$*.d >> litestep/$(OUTPUT)/$*.d
#-----------------------------------------------------------------------------
# Dependencies
#-----------------------------------------------------------------------------
-include $(EXEOBJS:.o=.d)
-include $(DLLOBJS:.o=.d)
-include $(UTILOBJS:.o=.d)