host_vc.mk revision 868fa2fe829687343ffae624259930155e16dbd8
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# GNU Make based build file.  For details on GNU Make see:
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#   http://www.gnu.org/software/make/manual/make.html
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# Macros for TOOLS
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# We use the C++ compiler for everything and then use the -Wl,-as-needed flag
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# in the linker to drop libc++ unless it's actually needed.
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)HOST_CC ?= cl.exe /nologo
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)HOST_CXX ?= cl.exe /nologo /EHsc
2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)HOST_LINK ?= link.exe /nologo
2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)HOST_LIB ?= lib.exe /nologo
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)ifeq (,$(findstring cl.exe,$(shell $(WHICH) cl.exe)))
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(warning To skip the host build use:)
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(warning "make NO_HOST_BUILDS=1")
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(error Unable to find cl.exe in PATH while building Windows host build)
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endif
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)ifeq ($(CONFIG),Release)
3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)WIN_OPT_FLAGS ?= /O2 /MT /Z7
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)else
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)WIN_OPT_FLAGS ?= /Od /MTd /Z7 -DNACL_SDK_DEBUG
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endif
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)WIN_FLAGS ?= -DWIN32 -D_WIN32 -DPTW32_STATIC_LIB
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# Individual Macros
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $1 = Source Name
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $2 = Compile Flags
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)define C_COMPILER_RULE
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	$(call LOG,CC,$$@,$(HOST_CC) /Fo$$@ /c $$< $(WIN_OPT_FLAGS) $(2) $(WIN_FLAGS))
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endef
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)define CXX_COMPILER_RULE
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	$(call LOG,CXX,$$@,$(HOST_CXX) /Fo$$@ -c $$< $(WIN_OPT_FLAGS) $(2) $(WIN_FLAGS))
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endef
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $1 = Source Name
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $2 = POSIX Compile Flags (unused)
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $3 = VC Compile Flags
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)define COMPILE_RULE
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)ifeq ($(suffix $(1)),.c)
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(call C_COMPILER_RULE,$(1),$(3) $(foreach inc,$(INC_PATHS),/I$(inc)))
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)else
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(call CXX_COMPILER_RULE,$(1),$(3) $(foreach inc,$(INC_PATHS),/I$(inc)))
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endif
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endef
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# LIB Macro
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $1 = Target Name
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $2 = List of Sources
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)define LIB_RULE
77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)$(STAMPDIR)/$(1).stamp : $(LIBDIR)/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	@echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)all:$(LIBDIR)/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib
81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)$(LIBDIR)/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib : $(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o)
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	$(MKDIR) -p $$(dir $$@)
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	$(call LOG,LIB,$$@,$(HOST_LIB) /OUT:$$@ $$^ $(WIN_LDFLAGS))
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endef
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# Link Macro
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $1 = Target Name
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $2 = List of inputs
922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $3 = List of libs
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $4 = List of deps
942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $5 = List of lib dirs
952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $6 = Other Linker Args
962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)define LINKER_RULE
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)all: $(1)
992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(1) : $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	$(call LOG,LINK,$$@,$(HOST_LINK) /DLL /OUT:$(1) /PDB:$(1).pdb $(2) /DEBUG $(foreach path,$(5),/LIBPATH:$(path)/$(OSNAME)_x86_32_host/$(CONFIG)) $(foreach lib,$(3),$(lib).lib) $(6))
1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endef
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# Link Macro
1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $1 = Target Name
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $2 = List of Sources
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $3 = List of LIBS
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $4 = List of DEPS
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $5 = POSIX Linker Switches
1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# $6 = VC Linker Switches
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)define LINK_RULE
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)$(call LINKER_RULE,$(OUTDIR)/$(1)$(HOST_EXT),$(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o),$(3),$(4),$(LIB_PATHS),$(6))
1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)endef
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
118c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
119c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#
120c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)# Strip Macro
121c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)# This is a nop (copy) since visual studio already keeps debug info
122c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)# separate from the binaries
123c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#
124c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)# $1 = Target Name
125c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)# $2 = Input Name
126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#
127c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)define STRIP_RULE
128c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)all: $(OUTDIR)/$(1)$(HOST_EXT)
129c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)$(OUTDIR)/$(1)$(HOST_EXT): $(OUTDIR)/$(2)$(HOST_EXT)
130c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)	$(call LOG,COPY,$$@,$(CP) $$^ $$@)
131c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)endef
132c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)all : $(LIB_LIST) $(DEPS_LIST)
134