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.
6 # GNU Make based build file. For details on GNU Make see:
7 # http://www.gnu.org/software/make/manual/make.html
14 # We use the C++ compiler for everything and then use the -Wl,-as-needed flag
15 # in the linker to drop libc++ unless it's actually needed.
17 HOST_CC ?
= cl.exe
/nologo
18 HOST_CXX ?
= cl.exe
/nologo
/EHsc
19 HOST_LINK ?
= link.exe
/nologo
20 HOST_LIB ?
= lib.exe
/nologo
22 ifeq (,$(findstring cl.exe
,$(shell $(WHICH
) cl.exe
)))
23 $(warning To skip the host build use
:)
24 $(warning
"make NO_HOST_BUILDS=1")
25 $(error Unable to find cl.exe in PATH while building Windows host build
)
29 ifeq ($(CONFIG
),Release
)
30 WIN_OPT_FLAGS ?
= /O2
/MT
/Z7
-DNDEBUG
32 WIN_OPT_FLAGS ?
= /Od
/MTd
/Z7
-DNACL_SDK_DEBUG
35 WIN_FLAGS ?
= -DWIN32
-D_WIN32
-DPTW32_STATIC_LIB
44 define C_COMPILER_RULE
45 $(call SRC_TO_OBJ
,$(1)): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
46 $(call LOG
,CC
,$$@
,$(HOST_CC
) /Fo
$$@
/c
$$< $(WIN_OPT_FLAGS
) $(2) $(WIN_FLAGS
))
49 define CXX_COMPILER_RULE
50 $(call SRC_TO_OBJ
,$(1)): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
51 $(call LOG
,CXX
,$$@
,$(HOST_CXX
) /Fo
$$@
-c
$$< $(WIN_OPT_FLAGS
) $(2) $(WIN_FLAGS
))
56 # $2 = POSIX Compile Flags (unused)
57 # $3 = VC Compile Flags
60 ifeq ($(suffix $(1)),.c
)
61 $(call C_COMPILER_RULE
,$(1),$(3) $(foreach inc
,$(INC_PATHS
),/I
$(inc
)))
63 $(call CXX_COMPILER_RULE
,$(1),$(3) $(foreach inc
,$(INC_PATHS
),/I
$(inc
)))
72 # $2 = List of Sources
76 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(OSNAME
)_x86_32_host
/$(CONFIG
)/$(1).lib
77 @echo
"TOUCHED $$@" > $(STAMPDIR
)/$(1).stamp
79 all:$(LIBDIR
)/$(OSNAME
)_x86_32_host
/$(CONFIG
)/$(1).lib
80 $(LIBDIR
)/$(OSNAME
)_x86_32_host
/$(CONFIG
)/$(1).lib
: $(foreach src
,$(2),$(OUTDIR
)/$(basename $(src
)).o
)
81 $(MKDIR
) -p
$$(dir $$@
)
82 $(call LOG
,LIB
,$$@
,$(HOST_LIB
) /OUT
:$$@
$$^
$(WIN_LDFLAGS
))
93 # $5 = List of lib dirs
94 # $6 = Other Linker Args
98 $(1): $(2) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
99 $(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))
107 # $2 = List of Sources
110 # $5 = POSIX Linker Switches
111 # $6 = VC Linker Switches
114 $(call LINKER_RULE
,$(OUTDIR
)/$(1)$(HOST_EXT
),$(foreach src
,$(2),$(OUTDIR
)/$(basename $(src
)).o
),$(3),$(4),$(LIB_PATHS
),$(6))
120 # This is a nop (copy) since visual studio already keeps debug info
121 # separate from the binaries
127 all: $(OUTDIR
)/$(1)$(HOST_EXT
)
128 $(OUTDIR
)/$(1)$(HOST_EXT
): $(OUTDIR
)/$(2)$(HOST_EXT
)
129 $(call LOG
,COPY
,$$@
,$(CP
) $$^
$$@
)
132 all: $(LIB_LIST
) $(DEPS_LIST
)