Compile each target's source files separately from other targets.

The gyp file already worked this way, but now the Makefile does too.

The motivation is to let the shared source files have different error
handling behavior (e.g. assert/ASSERT/stderr-print/abort/exception) in
winpty.dll and the other targets.
This commit is contained in:
Ryan Prichard 2016-02-29 03:27:26 -06:00
parent bce511725a
commit fd270915c1
7 changed files with 54 additions and 40 deletions

View File

@ -23,6 +23,8 @@
# The default "make install" prefix is /usr/local. Pass PREFIX=<path> on the
# command-line to override the default.
.SECONDEXPANSION :
default : all
PREFIX := /usr/local
@ -62,6 +64,18 @@ MINGW_CXXFLAGS += \
MINGW_LDFLAGS += -static -static-libgcc -static-libstdc++
UNIX_LDFLAGS += $(UNIX_LDFLAGS_STATIC)
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
build/$1/%.o : src/%.cc VERSION.txt | $$$$(@D)/.mkdir
$$(info Compiling $$<)
@$$(MINGW_CXX) $$(MINGW_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
endef
include src/subdir.mk
all : $(ALL_TARGETS)
@ -86,15 +100,6 @@ distclean : clean
rm -f config.mk
.PHONY : default all tests install clean clean-msvs distclean
.SECONDEXPANSION :
build/mingw/%.o : src/%.cc VERSION.txt | $$(@D)/.mkdir
$(info Compiling $<)
@$(MINGW_CXX) $(MINGW_CXXFLAGS) -I src/include -c -o $@ $<
build/unix/%.o : src/%.cc VERSION.txt | $$(@D)/.mkdir
$(info Compiling $<)
@$(UNIX_CXX) $(UNIX_CXXFLAGS) -I src/include -c -o $@ $<
.PRECIOUS : %.mkdir
%.mkdir :

View File

@ -20,26 +20,28 @@
ALL_TARGETS += build/winpty-agent.exe
$(eval $(call def_mingw_target,agent,))
AGENT_OBJECTS = \
build/mingw/agent/Agent.o \
build/mingw/agent/ConsoleFont.o \
build/mingw/agent/ConsoleInput.o \
build/mingw/agent/ConsoleLine.o \
build/mingw/agent/Coord.o \
build/mingw/agent/DebugShowInput.o \
build/mingw/agent/DefaultInputMap.o \
build/mingw/agent/EventLoop.o \
build/mingw/agent/InputMap.o \
build/mingw/agent/LargeConsoleRead.o \
build/mingw/agent/NamedPipe.o \
build/mingw/agent/SmallRect.o \
build/mingw/agent/Terminal.o \
build/mingw/agent/Win32Console.o \
build/mingw/agent/main.o \
build/mingw/shared/DebugClient.o \
build/mingw/shared/WinptyAssert.o \
build/mingw/shared/WinptyVersion.o \
build/mingw/shared/winpty_wcsnlen.o
build/agent/agent/Agent.o \
build/agent/agent/ConsoleFont.o \
build/agent/agent/ConsoleInput.o \
build/agent/agent/ConsoleLine.o \
build/agent/agent/Coord.o \
build/agent/agent/DebugShowInput.o \
build/agent/agent/DefaultInputMap.o \
build/agent/agent/EventLoop.o \
build/agent/agent/InputMap.o \
build/agent/agent/LargeConsoleRead.o \
build/agent/agent/NamedPipe.o \
build/agent/agent/SmallRect.o \
build/agent/agent/Terminal.o \
build/agent/agent/Win32Console.o \
build/agent/agent/main.o \
build/agent/shared/DebugClient.o \
build/agent/shared/WinptyAssert.o \
build/agent/shared/WinptyVersion.o \
build/agent/shared/winpty_wcsnlen.o
build/winpty-agent.exe : $(AGENT_OBJECTS)
$(info Linking $@)

View File

@ -20,8 +20,10 @@
ALL_TARGETS += build/winpty-debugserver.exe
$(eval $(call def_mingw_target,debugserver,))
DEBUGSERVER_OBJECTS = \
build/mingw/debugserver/DebugServer.o
build/debugserver/debugserver/DebugServer.o
build/winpty-debugserver.exe : $(DEBUGSERVER_OBJECTS)
$(info Linking $@)

View File

@ -20,9 +20,11 @@
ALL_TARGETS += build/winpty.dll
$(eval $(call def_mingw_target,libwinpty,-DCOMPILING_WINPTY_DLL))
LIBWINPTY_OBJECTS = \
build/mingw/libwinpty/winpty.o \
build/mingw/shared/DebugClient.o
build/libwinpty/libwinpty/winpty.o \
build/libwinpty/shared/DebugClient.o
build/winpty.dll : $(LIBWINPTY_OBJECTS)
$(info Linking $@)

View File

@ -18,8 +18,6 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
#define COMPILING_WINPTY_DLL
#include <winpty.h>
#include <windows.h>
#include <assert.h>

View File

@ -20,14 +20,16 @@
ALL_TARGETS += build/$(UNIX_ADAPTER_EXE)
$(eval $(call def_unix_target,unix-adapter,))
UNIX_ADAPTER_OBJECTS = \
build/unix/unix-adapter/InputHandler.o \
build/unix/unix-adapter/OutputHandler.o \
build/unix/unix-adapter/Util.o \
build/unix/unix-adapter/WakeupFd.o \
build/unix/unix-adapter/main.o \
build/unix/shared/DebugClient.o \
build/unix/shared/WinptyVersion.o
build/unix-adapter/unix-adapter/InputHandler.o \
build/unix-adapter/unix-adapter/OutputHandler.o \
build/unix-adapter/unix-adapter/Util.o \
build/unix-adapter/unix-adapter/WakeupFd.o \
build/unix-adapter/unix-adapter/main.o \
build/unix-adapter/shared/DebugClient.o \
build/unix-adapter/shared/WinptyVersion.o
build/$(UNIX_ADAPTER_EXE) : $(UNIX_ADAPTER_OBJECTS) build/winpty.dll
$(info Linking $@)

View File

@ -91,6 +91,9 @@
'include_dirs' : [
'include',
],
'defines' : [
'COMPILING_WINPTY_DLL',
],
'libraries' : [
'-luser32',
],