2015-11-08 06:37:25 +00:00
|
|
|
# Copyright (c) 2011-2015 Ryan Prichard
|
2012-03-23 10:11:34 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2015-11-07 04:08:24 +00:00
|
|
|
# Use make -n to see the actual command-lines make would run.
|
|
|
|
|
2016-02-26 10:21:22 +00:00
|
|
|
# The default "make install" prefix is /usr/local. Pass PREFIX=<path> on the
|
|
|
|
# command-line to override the default.
|
|
|
|
|
2016-02-29 09:27:26 +00:00
|
|
|
.SECONDEXPANSION :
|
|
|
|
|
2016-04-05 07:20:06 +00:00
|
|
|
.PHONY : default
|
2015-11-07 04:08:24 +00:00
|
|
|
default : all
|
|
|
|
|
2016-02-26 10:21:22 +00:00
|
|
|
PREFIX := /usr/local
|
2016-04-05 07:36:06 +00:00
|
|
|
UNIX_ADAPTER_EXE := winpty.exe
|
2016-02-26 10:21:22 +00:00
|
|
|
MINGW_ENABLE_CXX11_FLAG := -std=c++11
|
2016-02-29 10:33:42 +00:00
|
|
|
USE_PCH := 1
|
2016-02-26 10:21:22 +00:00
|
|
|
|
|
|
|
COMMON_CXXFLAGS :=
|
|
|
|
UNIX_CXXFLAGS :=
|
|
|
|
MINGW_CXXFLAGS :=
|
|
|
|
MINGW_LDFLAGS :=
|
|
|
|
UNIX_LDFLAGS :=
|
2015-11-07 04:08:24 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2016-02-26 10:21:22 +00:00
|
|
|
VERSION_TXT_CONTENT := $(shell cat VERSION.txt | tr -d '\r\n')
|
2015-11-08 03:19:03 +00:00
|
|
|
COMMON_CXXFLAGS += \
|
2016-02-26 10:21:22 +00:00
|
|
|
-DWINPTY_VERSION=$(VERSION_TXT_CONTENT) \
|
2015-11-08 03:19:03 +00:00
|
|
|
-DWINPTY_VERSION_SUFFIX=$(VERSION_SUFFIX) \
|
|
|
|
-DWINPTY_COMMIT_HASH=$(COMMIT_HASH) \
|
2015-11-07 04:08:24 +00:00
|
|
|
-MMD -Wall \
|
|
|
|
-DUNICODE \
|
|
|
|
-D_UNICODE \
|
2015-11-08 03:19:03 +00:00
|
|
|
-D_WIN32_WINNT=0x0501
|
|
|
|
|
|
|
|
UNIX_CXXFLAGS += \
|
|
|
|
$(COMMON_CXXFLAGS)
|
|
|
|
|
|
|
|
MINGW_CXXFLAGS += \
|
|
|
|
$(COMMON_CXXFLAGS) \
|
2016-02-26 07:20:31 +00:00
|
|
|
-O2 \
|
|
|
|
$(MINGW_ENABLE_CXX11_FLAG)
|
2012-07-11 18:50:51 +00:00
|
|
|
|
2015-11-07 04:08:24 +00:00
|
|
|
MINGW_LDFLAGS += -static -static-libgcc -static-libstdc++
|
|
|
|
UNIX_LDFLAGS += $(UNIX_LDFLAGS_STATIC)
|
2012-01-22 01:30:41 +00:00
|
|
|
|
2016-02-29 10:33:42 +00:00
|
|
|
ifeq "$(USE_PCH)" "1"
|
|
|
|
MINGW_CXXFLAGS += -include build/mingw/PrecompiledHeader.h
|
|
|
|
PCH_DEP := build/mingw/PrecompiledHeader.h.gch
|
|
|
|
else
|
|
|
|
PCH_DEP :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-02-29 09:27:26 +00:00
|
|
|
define def_unix_target
|
|
|
|
build/$1/%.o : src/%.cc VERSION.txt | $$$$(@D)/.mkdir
|
|
|
|
$$(info Compiling $$<)
|
|
|
|
@$$(UNIX_CXX) $$(UNIX_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
|
|
|
|
endef
|
|
|
|
|
|
|
|
define def_mingw_target
|
2016-02-29 10:33:42 +00:00
|
|
|
build/$1/%.o : src/%.cc VERSION.txt $$(PCH_DEP) | $$$$(@D)/.mkdir
|
2016-02-29 09:27:26 +00:00
|
|
|
$$(info Compiling $$<)
|
|
|
|
@$$(MINGW_CXX) $$(MINGW_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
|
|
|
|
endef
|
|
|
|
|
2015-11-29 09:50:06 +00:00
|
|
|
include src/subdir.mk
|
2015-11-07 04:08:24 +00:00
|
|
|
|
2016-04-05 07:20:06 +00:00
|
|
|
.PHONY : all
|
2015-11-07 04:08:24 +00:00
|
|
|
all : $(ALL_TARGETS)
|
|
|
|
|
2016-04-05 07:20:06 +00:00
|
|
|
.PHONY : tests
|
2015-11-07 04:08:24 +00:00
|
|
|
tests : $(TEST_PROGRAMS)
|
2015-08-23 23:02:23 +00:00
|
|
|
|
2016-04-05 07:20:06 +00:00
|
|
|
.PHONY : install-bin
|
|
|
|
install-bin : all
|
2012-07-11 18:50:51 +00:00
|
|
|
mkdir -p $(PREFIX)/bin
|
2015-11-07 04:08:24 +00:00
|
|
|
install -m 755 -p -s build/$(UNIX_ADAPTER_EXE) $(PREFIX)/bin
|
2015-10-15 21:47:00 +00:00
|
|
|
install -m 755 -p -s build/winpty.dll $(PREFIX)/bin
|
|
|
|
install -m 755 -p -s build/winpty-agent.exe $(PREFIX)/bin
|
2016-04-05 07:20:06 +00:00
|
|
|
|
|
|
|
.PHONY : install-debugserver
|
|
|
|
install-debugserver : all
|
|
|
|
mkdir -p $(PREFIX)/bin
|
2015-10-15 21:47:00 +00:00
|
|
|
install -m 755 -p -s build/winpty-debugserver.exe $(PREFIX)/bin
|
2012-07-11 18:50:51 +00:00
|
|
|
|
2016-04-05 07:20:06 +00:00
|
|
|
.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
|
|
|
|
|
|
|
|
.PHONY : install
|
|
|
|
install : \
|
|
|
|
install-bin \
|
|
|
|
install-debugserver \
|
|
|
|
install-lib \
|
|
|
|
install-doc \
|
|
|
|
install-include
|
|
|
|
|
|
|
|
.PHONY : clean
|
2012-01-22 01:30:41 +00:00
|
|
|
clean :
|
2015-11-07 04:08:24 +00:00
|
|
|
rm -fr build
|
2012-04-17 16:50:19 +00:00
|
|
|
|
2016-04-05 07:20:06 +00:00
|
|
|
.PHONY : clean-msvs
|
2016-02-29 08:59:35 +00:00
|
|
|
clean-msvs :
|
|
|
|
rm -fr src/Default src/Release src/.vs
|
|
|
|
rm -f src/*.vcxproj src/*.vcxproj.filters src/*.sln src/*.sdf
|
|
|
|
|
2016-04-05 07:20:06 +00:00
|
|
|
.PHONY : distclean
|
2012-04-17 16:50:19 +00:00
|
|
|
distclean : clean
|
2015-11-07 04:08:24 +00:00
|
|
|
rm -f config.mk
|
|
|
|
|
2016-02-26 10:21:22 +00:00
|
|
|
.PRECIOUS : %.mkdir
|
|
|
|
%.mkdir :
|
2016-04-06 23:53:31 +00:00
|
|
|
$(info Creating directory $(dir $@))
|
2016-02-26 10:21:22 +00:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@touch $@
|
2016-02-29 08:58:30 +00:00
|
|
|
|
|
|
|
src/%.h :
|
|
|
|
@echo "Missing header file $@ (stale dependency file?)"
|