1 # Copyright (c) 2011-2015 Ryan Prichard
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:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
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
21 # Use make -n to see the actual command-lines make would run.
23 # The default "make install" prefix is /usr/local. Pass PREFIX=<path> on the
24 # command-line to override the default.
32 UNIX_ADAPTER_EXE := winpty.exe
33 MINGW_ENABLE_CXX11_FLAG := -std=c++11
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)
52 -D_WIN32_WINNT=0x0501 \
61 $(MINGW_ENABLE_CXX11_FLAG)
63 MINGW_LDFLAGS += -static -static-libgcc -static-libstdc++
64 UNIX_LDFLAGS += $(UNIX_LDFLAGS_STATIC)
67 MINGW_CXXFLAGS += -include build/mingw/PrecompiledHeader.h
68 PCH_DEP := build/mingw/PrecompiledHeader.h.gch
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
78 build/mingw/PrecompiledHeader.h : src/shared/PrecompiledHeader.h | $$(@D)/.mkdir
79 $(info Copying $< to $@)
82 build/mingw/PrecompiledHeader.h.gch : build/mingw/PrecompiledHeader.h | $$(@D)/.mkdir
84 @$(MINGW_CXX) $(MINGW_CXXFLAGS) -c -o $@ $<
86 -include build/mingw/PrecompiledHeader.h.d
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 $$@ $$<
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 $$@ $$<
100 include src/subdir.mk
106 tests : $(TEST_PROGRAMS)
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
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
122 mkdir -p $(PREFIX)/lib
123 install -m 644 -p build/winpty.lib $(PREFIX)/lib
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
132 .PHONY : 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
141 install-debugserver \
152 rm -fr src/Default src/Release src/.vs src/gen
153 rm -f src/*.vcxproj src/*.vcxproj.filters src/*.sln src/*.sdf
161 $(info Creating directory $(dir $@))
166 @echo "Missing header file $@ (stale dependency file?)"