forked from rprichard/winpty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
166 lines (134 loc) · 4.61 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
# Copyright (c) 2011-2015 Ryan Prichard
#
# 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.
# Use make -n to see the actual command-lines make would run.
# The default "make install" prefix is /usr/local. Pass PREFIX=<path> on the
# command-line to override the default.
.SECONDEXPANSION :
.PHONY : default
default : all
PREFIX := /usr/local
UNIX_ADAPTER_EXE := winpty.exe
MINGW_ENABLE_CXX11_FLAG := -std=c++11
USE_PCH := 1
COMMON_CXXFLAGS :=
UNIX_CXXFLAGS :=
MINGW_CXXFLAGS :=
MINGW_LDFLAGS :=
UNIX_LDFLAGS :=
# Include config.mk but complain if it hasn't been created yet.
ifeq "$(wildcard config.mk)" ""
$(error config.mk does not exist. Please run ./configure)
endif
include config.mk
COMMON_CXXFLAGS += \
-MMD -Wall \
-DUNICODE \
-D_UNICODE \
-D_WIN32_WINNT=0x0501 \
-Ibuild/gen
UNIX_CXXFLAGS += \
$(COMMON_CXXFLAGS)
MINGW_CXXFLAGS += \
$(COMMON_CXXFLAGS) \
-O2 \
$(MINGW_ENABLE_CXX11_FLAG)
MINGW_LDFLAGS += -static -static-libgcc -static-libstdc++
UNIX_LDFLAGS += $(UNIX_LDFLAGS_STATIC)
ifeq "$(USE_PCH)" "1"
MINGW_CXXFLAGS += -include build/mingw/PrecompiledHeader.h
PCH_DEP := build/mingw/PrecompiledHeader.h.gch
else
PCH_DEP :=
endif
build/gen/GenVersion.h : VERSION.txt $(COMMIT_HASH_DEP) | $$(@D)/.mkdir
$(info Updating build/gen/GenVersion.h)
@echo "const char GenVersion_Version[] = \"$(shell cat VERSION.txt | tr -d '\r\n')\";" > build/gen/GenVersion.h
@echo "const char GenVersion_Commit[] = \"$(COMMIT_HASH)\";" >> build/gen/GenVersion.h
build/mingw/PrecompiledHeader.h : src/shared/PrecompiledHeader.h | $$(@D)/.mkdir
$(info Copying $< to $@)
@cp $< $@
build/mingw/PrecompiledHeader.h.gch : build/mingw/PrecompiledHeader.h | $$(@D)/.mkdir
$(info Compiling $<)
@$(MINGW_CXX) $(MINGW_CXXFLAGS) -c -o $@ $<
-include build/mingw/PrecompiledHeader.h.d
define def_unix_target
build/$1/%.o : src/%.cc | $$$$(@D)/.mkdir
$$(info Compiling $$<)
@$$(UNIX_CXX) $$(UNIX_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
endef
define def_mingw_target
build/$1/%.o : src/%.cc $$(PCH_DEP) | $$$$(@D)/.mkdir
$$(info Compiling $$<)
@$$(MINGW_CXX) $$(MINGW_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
endef
include src/subdir.mk
.PHONY : all
all : $(ALL_TARGETS)
.PHONY : tests
tests : $(TEST_PROGRAMS)
.PHONY : install-bin
install-bin : all
mkdir -p $(PREFIX)/bin
install -m 755 -p -s build/$(UNIX_ADAPTER_EXE) $(PREFIX)/bin
install -m 755 -p -s build/winpty.dll $(PREFIX)/bin
install -m 755 -p -s build/winpty-agent.exe $(PREFIX)/bin
.PHONY : install-debugserver
install-debugserver : all
mkdir -p $(PREFIX)/bin
install -m 755 -p -s build/winpty-debugserver.exe $(PREFIX)/bin
.PHONY : install-lib
install-lib : all
mkdir -p $(PREFIX)/lib
install -m 644 -p build/winpty.lib $(PREFIX)/lib
.PHONY : install-doc
install-doc :
mkdir -p $(PREFIX)/share/doc/winpty
install -m 644 -p LICENSE $(PREFIX)/share/doc/winpty
install -m 644 -p README.md $(PREFIX)/share/doc/winpty
install -m 644 -p RELEASES.md $(PREFIX)/share/doc/winpty
.PHONY : install-include
install-include :
mkdir -p $(PREFIX)/include/winpty
install -m 644 -p src/include/winpty.h $(PREFIX)/include/winpty
install -m 644 -p src/include/winpty_constants.h $(PREFIX)/include/winpty
.PHONY : install
install : \
install-bin \
install-debugserver \
install-lib \
install-doc \
install-include
.PHONY : clean
clean :
rm -fr build
.PHONY : clean-msvc
clean-msvc :
rm -fr src/Default src/Release src/.vs src/gen
rm -f src/*.vcxproj src/*.vcxproj.filters src/*.sln src/*.sdf
.PHONY : distclean
distclean : clean
rm -f config.mk
.PRECIOUS : %.mkdir
%.mkdir :
$(info Creating directory $(dir $@))
@mkdir -p $(dir $@)
@touch $@
src/%.h :
@echo "Missing header file $@ (stale dependency file?)"