host_vc.mk revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
1# Copyright (c) 2012 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5# 6# GNU Make based build file. For details on GNU Make see: 7# http://www.gnu.org/software/make/manual/make.html 8# 9# 10 11 12# 13# Macros for TOOLS 14# 15# We use the C++ compiler for everything and then use the -Wl,-as-needed flag 16# in the linker to drop libc++ unless it's actually needed. 17# 18HOST_CC?=cl.exe /nologo 19HOST_CXX?=cl.exe /nologo /EHsc 20HOST_LINK?=link.exe /nologo 21HOST_LIB?=lib.exe /nologo 22 23ifeq (,$(findstring cl.exe,$(shell $(WHICH) cl.exe))) 24$(warning To skip the host build use:) 25$(warning "make NO_HOST_BUILDS=1") 26$(error Unable to find cl.exe in PATH while building Windows host build) 27endif 28 29 30ifeq ('Debug','$(CONFIG)') 31WIN_OPT_FLAGS?=/Od /MTd /Z7 32else 33WIN_OPT_FLAGS?=/O2 /MT /Z7 34endif 35 36WIN_FLAGS?=-D WIN32 -D _WIN32 -D PTW32_STATIC_LIB 37 38 39# 40# Individual Macros 41# 42# $1 = Source Name 43# $2 = Compile Flags 44# 45define C_COMPILER_RULE 46$(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp 47 $(call LOG,CC,$$@,$(HOST_CC) /Fo$$@ /c $$< $(WIN_OPT_FLAGS) $(2) $(WIN_FLAGS)) 48endef 49 50define CXX_COMPILER_RULE 51$(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp 52 $(call LOG,CXX,$$@,$(HOST_CXX) /Fo$$@ -c $$< $(WIN_OPT_FLAGS) $(2) $(WIN_FLAGS)) 53endef 54 55 56# $1 = Source Name 57# $2 = POSIX Compile Flags (unused) 58# $3 = VC Compile Flags 59# 60define COMPILE_RULE 61ifeq ($(suffix $(1)),.c) 62$(call C_COMPILER_RULE,$(1),$(3) $(foreach inc,$(INC_PATHS),/I$(inc))) 63else 64$(call CXX_COMPILER_RULE,$(1),$(3) $(foreach inc,$(INC_PATHS),/I$(inc))) 65endif 66endef 67 68 69# 70# LIB Macro 71# 72# $1 = Target Name 73# $2 = List of Sources 74# 75# 76define LIB_RULE 77$(STAMPDIR)/$(1).stamp : $(NACL_SDK_ROOT)/lib/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib 78 @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp 79 80all:$(NACL_SDK_ROOT)/lib/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib 81$(NACL_SDK_ROOT)/lib/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib : $(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o) 82 $(MKDIR) -p $$(dir $$@) 83 $(call LOG,LIB,$$@,$(HOST_LIB) /OUT:$$@ $$^ $(WIN_LDFLAGS)) 84endef 85 86 87# 88# Link Macro 89# 90# $1 = Target Name 91# $2 = List of inputs 92# $3 = List of libs 93# $4 = List of deps 94# $5 = List of lib dirs 95# $6 = Other Linker Args 96# 97define LINKER_RULE 98all: $(1) 99$(1) : $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) 100 $(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)) 101endef 102 103 104# 105# Link Macro 106# 107# $1 = Target Name 108# $2 = List of Sources 109# $3 = List of LIBS 110# $4 = List of DEPS 111# $5 = POSIX Linker Switches 112# $6 = VC Linker Switches 113# 114define LINK_RULE 115$(call LINKER_RULE,$(OUTDIR)/$(1)$(HOST_EXT),$(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o),$(3),$(4),$(LIB_PATHS),$(6)) 116endef 117 118all : $(LIB_LIST) $(DEPS_LIST) 119