installed pty
[VSoRC/.git] / node_modules / node-pty / deps / winpty / Makefile
1 # Copyright (c) 2011-2015 Ryan Prichard
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 # IN THE SOFTWARE.
20
21 # Use make -n to see the actual command-lines make would run.
22
23 # The default "make install" prefix is /usr/local.  Pass PREFIX=<path> on the
24 # command-line to override the default.
25
26 .SECONDEXPANSION :
27
28 .PHONY : default
29 default : all
30
31 PREFIX := /usr/local
32 UNIX_ADAPTER_EXE := winpty.exe
33 MINGW_ENABLE_CXX11_FLAG := -std=c++11
34 USE_PCH := 1
35
36 COMMON_CXXFLAGS :=
37 UNIX_CXXFLAGS :=
38 MINGW_CXXFLAGS :=
39 MINGW_LDFLAGS :=
40 UNIX_LDFLAGS :=
41
42 # Include config.mk but complain if it hasn't been created yet.
43 ifeq "$(wildcard config.mk)" ""
44     $(error config.mk does not exist.  Please run ./configure)
45 endif
46 include config.mk
47
48 COMMON_CXXFLAGS += \
49         -MMD -Wall \
50         -DUNICODE \
51         -D_UNICODE \
52         -D_WIN32_WINNT=0x0501 \
53         -Ibuild/gen
54
55 UNIX_CXXFLAGS += \
56         $(COMMON_CXXFLAGS)
57
58 MINGW_CXXFLAGS += \
59         $(COMMON_CXXFLAGS) \
60         -O2 \
61         $(MINGW_ENABLE_CXX11_FLAG)
62
63 MINGW_LDFLAGS += -static -static-libgcc -static-libstdc++
64 UNIX_LDFLAGS += $(UNIX_LDFLAGS_STATIC)
65
66 ifeq "$(USE_PCH)" "1"
67 MINGW_CXXFLAGS += -include build/mingw/PrecompiledHeader.h
68 PCH_DEP := build/mingw/PrecompiledHeader.h.gch
69 else
70 PCH_DEP :=
71 endif
72
73 build/gen/GenVersion.h : VERSION.txt $(COMMIT_HASH_DEP) | $$(@D)/.mkdir
74         $(info Updating build/gen/GenVersion.h)
75         @echo "const char GenVersion_Version[] = \"$(shell cat VERSION.txt | tr -d '\r\n')\";" > build/gen/GenVersion.h
76         @echo "const char GenVersion_Commit[] = \"$(COMMIT_HASH)\";" >> build/gen/GenVersion.h
77
78 build/mingw/PrecompiledHeader.h : src/shared/PrecompiledHeader.h | $$(@D)/.mkdir
79         $(info Copying $< to $@)
80         @cp $< $@
81
82 build/mingw/PrecompiledHeader.h.gch : build/mingw/PrecompiledHeader.h | $$(@D)/.mkdir
83         $(info Compiling $<)
84         @$(MINGW_CXX) $(MINGW_CXXFLAGS) -c -o $@ $<
85
86 -include build/mingw/PrecompiledHeader.h.d
87
88 define def_unix_target
89 build/$1/%.o : src/%.cc | $$$$(@D)/.mkdir
90         $$(info Compiling $$<)
91         @$$(UNIX_CXX) $$(UNIX_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
92 endef
93
94 define def_mingw_target
95 build/$1/%.o : src/%.cc $$(PCH_DEP) | $$$$(@D)/.mkdir
96         $$(info Compiling $$<)
97         @$$(MINGW_CXX) $$(MINGW_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
98 endef
99
100 include src/subdir.mk
101
102 .PHONY : all
103 all : $(ALL_TARGETS)
104
105 .PHONY : tests
106 tests : $(TEST_PROGRAMS)
107
108 .PHONY : install-bin
109 install-bin : all
110         mkdir -p $(PREFIX)/bin
111         install -m 755 -p -s build/$(UNIX_ADAPTER_EXE) $(PREFIX)/bin
112         install -m 755 -p -s build/winpty.dll $(PREFIX)/bin
113         install -m 755 -p -s build/winpty-agent.exe $(PREFIX)/bin
114
115 .PHONY : install-debugserver
116 install-debugserver : all
117         mkdir -p $(PREFIX)/bin
118         install -m 755 -p -s build/winpty-debugserver.exe $(PREFIX)/bin
119
120 .PHONY : install-lib
121 install-lib : all
122         mkdir -p $(PREFIX)/lib
123         install -m 644 -p build/winpty.lib $(PREFIX)/lib
124
125 .PHONY : install-doc
126 install-doc :
127         mkdir -p $(PREFIX)/share/doc/winpty
128         install -m 644 -p LICENSE $(PREFIX)/share/doc/winpty
129         install -m 644 -p README.md $(PREFIX)/share/doc/winpty
130         install -m 644 -p RELEASES.md $(PREFIX)/share/doc/winpty
131
132 .PHONY : install-include
133 install-include :
134         mkdir -p $(PREFIX)/include/winpty
135         install -m 644 -p src/include/winpty.h $(PREFIX)/include/winpty
136         install -m 644 -p src/include/winpty_constants.h $(PREFIX)/include/winpty
137
138 .PHONY : install
139 install : \
140         install-bin \
141         install-debugserver \
142         install-lib \
143         install-doc \
144         install-include
145
146 .PHONY : clean
147 clean :
148         rm -fr build
149
150 .PHONY : clean-msvc
151 clean-msvc :
152         rm -fr src/Default src/Release src/.vs src/gen
153         rm -f src/*.vcxproj src/*.vcxproj.filters src/*.sln src/*.sdf
154
155 .PHONY : distclean
156 distclean : clean
157         rm -f config.mk
158
159 .PRECIOUS : %.mkdir
160 %.mkdir :
161         $(info Creating directory $(dir $@))
162         @mkdir -p $(dir $@)
163         @touch $@
164
165 src/%.h :
166         @echo "Missing header file $@ (stale dependency file?)"