-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
140 lines (121 loc) · 4.35 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
# Usage:
# make BUILD=COMPILER HOST=OS_TYPE
# Makes SnK HotkeySuite binary
# make clean
# Cleans directory of executables
# make upx
# Pack executables with upx
# make install
# Makes installer, requires compiled SnK binary residing in adjacent directory (../snk)
# Under MSYS 1.0 fails because of posix path conversion - use mingw32-make for this target
# make UPSTREAM_INC=PATH
# Change include path for clang++ 3.6.2 and g++ 4.7.2 (default is /c/cygwin/usr/i686-w64-mingw32/sys-root/mingw/include/)
# make DEBUG=LEVEL
# Makes debug build (currently only level 1 supported)
# Conditionals
ifeq (,$(if $(filter-out upx install clean,$(MAKECMDGOALS)),,$(MAKECMDGOALS)))
ifeq (,$(and $(filter $(BUILD),MinGW-w64 MinGW-w64_pthreads Clang_362),$(filter $(HOST),x86-64 x86)))
$(info Compiler and/or OS type is invalid! Please correctly set BUILD and HOST variables.)
$(info Possible BUILD values: MinGW-w64, MinGW-w64_pthreads, Clang_362)
$(info Possible HOST values: x86-64, x86)
$(error BUILD/HOST is invalid)
endif
endif
# Common section
RM=rm -f
UPX=upx
CFLAGS=-std=c++11 -D_WIN32_WINNT=0x0600 -DUNICODE -D_UNICODE
LDFLAGS=-static-libgcc -static-libstdc++ -lole32 -loleaut32 -lgdi32 -lcomdlg32 -Wl,--enable-stdcall-fixup
UPSTREAM_INC=/c/cygwin/usr/i686-w64-mingw32/sys-root/mingw/include/
SRC=Suite.cpp SuiteCommon.cpp SuiteExterns.cpp SuiteExternalRelations.cpp SuiteMain.cpp TaskbarNotificationAreaIcon.cpp HotkeyEngine.cpp SuiteHotkeyFunctions.cpp AsmHotkeyFunctions.S SuiteSettings.cpp SuiteAboutDialog.cpp SuiteBindingDialog.cpp Res.rc
OBJ=$(patsubst %.S,%.o,$(patsubst %.cpp,%.o,$(patsubst %.rc,%.o,$(SRC))))
TARGET=HotkeySuite.exe
MAKENSIS=makensis.exe /V2
NSISSRC=SuiteInstaller.nsi
NSISTARGET=SnKHotkeySuiteSetup*.exe
# Debug specific common section
ifdef DEBUG
CFLAGS+=-DDEBUG=$(DEBUG) -g
LDFLAGS+=-g
else
CFLAGS+=-O2
LDFLAGS+=-O2 -s
endif
# Compiler/OS specific sections
# N.B.:
# i386 is minimum system requirement for Windows 95, maximum arch for apps is pentium2 (OS doesn't handle SSE instructions without patch)
# i486 is minimum system requirement for Windows NT4, maximum arch for apps is pentium2 (OS doesn't handle SSE instructions)
# pentium is minimum system requirement for Windows 2000
# Current MinGW-w64 with Win32 threads
# MinGW-w64 minimum supported target 32-bit Windows version is Windows 2000
# pentiumpro is MinGW-w64 default arch for 32-bit compiler
ifeq ($(BUILD),MinGW-w64)
LDFLAGS+=-mwindows -municode
ifeq ($(HOST),x86-64)
CC=x86_64-w64-mingw32-g++
WINDRES=x86_64-w64-mingw32-windres
MAKENSISFLAGS=/DINST64
NSISTARGET=SnKHotkeySuiteSetup64.exe
endif
ifeq ($(HOST),x86)
CC=i686-w64-mingw32-g++
WINDRES=i686-w64-mingw32-windres
NSISTARGET=SnKHotkeySuiteSetup32.exe
endif
endif
# Current MinGW-w64 with POSIX threads
# MinGW-w64 minimum supported target 32-bit Windows version is Windows 2000
# pentiumpro is MinGW-w64 default arch for 32-bit compiler
ifeq ($(BUILD),MinGW-w64_pthreads)
LDFLAGS+=-static -lpthread -mwindows -municode
ifeq ($(HOST),x86-64)
CC=x86_64-w64-mingw32-g++
WINDRES=x86_64-w64-mingw32-windres
MAKENSISFLAGS=/DINST64
NSISTARGET=SnKHotkeySuiteSetup64.exe
endif
ifeq ($(HOST),x86)
CC=i686-w64-mingw32-g++
WINDRES=i686-w64-mingw32-windres
NSISTARGET=SnKHotkeySuiteSetup32.exe
endif
endif
# Clang 3.6.2 with includes from current MinGW-w64
# pentium4 is Clang 3.6.2 default arch
# Clang uses libraries from MinGW 4.7.2
# i386 is MinGW 4.7.2 default arch
ifeq ($(BUILD),Clang_362)
CC=clang++
WINDRES=windres
INC=-I$(UPSTREAM_INC)
CFLAGS+=-target i486-pc-windows-gnu -march=i486 -Wno-ignored-attributes -Wno-deprecated-register -Wno-inconsistent-dllimport -Wno-missing-declarations -Wno-unknown-attributes -DUMDF_USING_NTSTATUS -DOBSOLETE_WWINMAIN
LDFLAGS+=-Wl,--subsystem,windows
ifndef DEBUG
CFLAGS+=-Wno-unused-value -Wno-macro-redefined -Wno-ignored-pragmas
endif
ifeq ($(HOST),x86-64)
$(error not implemented)
endif
ifeq ($(HOST),x86)
NSISTARGET=SnKHotkeySuiteSetup32.exe
endif
endif
.PHONY: all exe clean upx install
.INTERMEDIATE: $(OBJ)
all: exe
exe: $(SRC) $(TARGET)
install: $(NSISSRC) $(NSISTARGET)
$(NSISTARGET): $(NSISSRC)
$(MAKENSIS) $(MAKENSISFLAGS) $<
$(TARGET): $(OBJ)
$(CC) -o $@ $(OBJ) $(LDFLAGS)
%.o: %.cpp
$(CC) -c -o $@ $< $(CFLAGS) $(INC)
%.o: %.S
$(CC) -c -o $@ $< $(CFLAGS) $(INC)
%.o: %.rc
$(WINDRES) $< $@ $(filter -D% -U% -I%,$(CFLAGS)) $(INC)
upx:
$(UPX) $(TARGET) ||:
clean:
$(RM) $(TARGET) $(NSISTARGET) $(OBJ) ||: