summaryrefslogtreecommitdiff
path: root/solenv/gbuild
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-02-24 10:02:43 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2014-02-25 08:58:15 +0100
commit8491c5c4f1a4e01796dab8ce41904cf6593bd038 (patch)
tree9ccdc76a8a1c9fd1df63020060adc5b0b73de0ba /solenv/gbuild
parent5673bac9a7403d19bafbb28f2608be7f38dbb4df (diff)
gbuild: one command for C/C++ objects
Change-Id: I835bd56123acfbfb53e0d3d86e5d66b929b3181f
Diffstat (limited to 'solenv/gbuild')
-rw-r--r--solenv/gbuild/LinkTarget.mk52
-rw-r--r--solenv/gbuild/platform/com_GCC_class.mk75
-rw-r--r--solenv/gbuild/platform/com_GCC_defs.mk5
-rw-r--r--solenv/gbuild/platform/com_MSC_class.mk34
-rw-r--r--solenv/gbuild/platform/com_MSC_defs.mk5
-rw-r--r--solenv/gbuild/platform/solaris.mk2
6 files changed, 36 insertions, 137 deletions
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index b7cd9c80cce8..773aa3f60ca5 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -27,6 +27,15 @@
# OBJCXXFLAGS
# LDFLAGS
+# defined by platform
+# gb_AsmObject_get_source (.asm on Windows, .s elsewhere)
+# gb_AsmObject__command
+# gb_CObject__command_pattern
+# gb_LinkTarget_CXXFLAGS
+# gb_LinkTarget_LDFLAGS
+# gb_LinkTarget_INCLUDE
+# gb_YaccTarget__command(grammar-file, stem-for-message, source-target, include-target)
+
# enable if: no "-TARGET" defined AND [module is enabled OR "TARGET" defined]
gb_LinkTarget__debug_enabled = \
$(and $(if $(filter -$(1),$(ENABLE_DEBUGINFO_FOR)),,$(true)),\
@@ -120,15 +129,14 @@ endif
# CObject class
gb_CObject_get_source = $(1)/$(2).c
-# defined by platform
-# gb_CObject__command
ifneq ($(COMPILER_PLUGIN_TOOL),)
$(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
$(call gb_CObject__tool_command,$*,$<)
else
$(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%)
- $(call gb_CObject__command,$@,$*,$<,$(call gb_CObject_get_dep_target,$*))
+ $(call gb_Output_announce,$*.c,$(true),C ,3)
+ $(call gb_CObject__command_pattern,$@,$(T_CFLAGS) $(T_CFLAGS_APPEND),$<,$(call gb_CObject_get_dep_target,$*))
endif
# Note: if the *Object_dep_target does not exist it will be created by
@@ -143,8 +151,6 @@ endif
# CxxObject class
gb_CxxObject_get_source = $(1)/$(2).cxx
-# defined by platform
-# gb_CxxObject__command
# Only enable PCH if the PCH_CXXFLAGS and the PCH_DEFS (from the linktarget)
# are the same as the T_CXXFLAGS and DEFS we want to use for this object. This
@@ -174,8 +180,9 @@ $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%)
$(call gb_CxxObject__tool_command,$*,$<)
else
$(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%)
+ $(call gb_Output_announce,$*.cxx,$(true),CXX,3)
$(eval $(gb_CxxObject__set_pchflags))
- $(call gb_CxxObject__command,$@,$*,$<,$(call gb_CxxObject_get_dep_target,$*))
+ $(call gb_CObject__command_pattern,$@,$(T_CXXFLAGS) $(T_CXXFLAGS_APPEND),$<,$(call gb_CxxObject_get_dep_target,$*))
endif
ifeq ($(gb_FULLDEPS),$(true))
@@ -195,12 +202,11 @@ endif
# GenCObject class
gb_GenCObject_get_source = $(WORKDIR)/$(1).c
-# defined by platform
-# gb_CObject__command
$(call gb_GenCObject_get_target,%) :
+ $(call gb_Output_announce,$*.c,$(true),C ,3)
test -f $(call gb_GenCObject_get_source,$*) || (echo "Missing generated source file $(call gb_GenCObject_get_source,$*)" && false)
- $(call gb_CObject__command,$@,$*,$(call gb_GenCObject_get_source,$*),$(call gb_GenCObject_get_dep_target,$*))
+ $(call gb_CObject__command_pattern,$@,$(T_CFLAGS) $(T_CFLAGS_APPEND),$(call gb_GenCObject_get_source,$*),$(call gb_GenCObject_get_dep_target,$*))
ifeq ($(gb_FULLDEPS),$(true))
$(call gb_GenCObject_get_dep_target,%) :
@@ -212,13 +218,12 @@ endif
# GenCxxObject class
gb_GenCxxObject_get_source = $(WORKDIR)/$(1).$(gb_LinkTarget_CXX_SUFFIX_$(call gb_LinkTarget__get_workdir_linktargetname,$(2)))
-# defined by platform
-# gb_CxxObject__command
$(call gb_GenCxxObject_get_target,%) :
+ $(call gb_Output_announce,$*.cxx,$(true),CXX,3)
test -f $(GEN_CXX_SOURCE) || (echo "Missing generated source file $(GEN_CXX_SOURCE)" && false)
$(eval $(gb_CxxObject__set_pchflags))
- $(call gb_CxxObject__command,$@,$*,$(GEN_CXX_SOURCE),$(call gb_GenCxxObject_get_dep_target,$*))
+ $(call gb_CObject__command_pattern,$@,$(T_CXXFLAGS) $(T_CXXFLAGS_APPEND),$(GEN_CXX_SOURCE),$(call gb_GenCxxObject_get_dep_target,$*))
ifeq ($(gb_FULLDEPS),$(true))
$(call gb_GenCxxObject_get_dep_target,%) :
@@ -236,8 +241,6 @@ endif
# tries to use it.
gb_YaccTarget_get_source = $(1)/$(2).y
-# defined by platform
-# gb_YaccTarget__command(grammar-file, stem-for-message, source-target, include-target)
.PHONY : $(call gb_YaccTarget_get_clean_target,%)
$(call gb_YaccTarget_get_clean_target,%) :
@@ -293,8 +296,6 @@ endef
#
gb_ObjCxxObject_get_source = $(1)/$(2).mm
-# defined by platform
-# gb_ObjCxxObject__command
ifneq ($(COMPILER_PLUGIN_TOOL),)
$(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
@@ -302,7 +303,8 @@ $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDI
else
$(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%)
- $(call gb_ObjCxxObject__command,$@,$*,$<,$(call gb_ObjCxxObject_get_dep_target,$*))
+ $(call gb_Output_announce,$*.mm,$(true),OCX,3)
+ $(call gb_CObject__command_pattern,$@,$(T_OBJCXXFLAGS) $(T_OBJCXXFLAGS_APPEND),$<,$(call gb_ObjCxxObject_get_dep_target,$*))
ifeq ($(gb_FULLDEPS),$(true))
$(call gb_ObjCxxObject_get_dep_target,%) :
@@ -316,8 +318,6 @@ endif
#
gb_ObjCObject_get_source = $(1)/$(2).m
-# defined by platform
-# gb_ObjCObject__command
ifneq ($(COMPILER_PLUGIN_TOOL),)
$(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
@@ -325,7 +325,8 @@ $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%
else
$(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%)
- $(call gb_ObjCObject__command,$@,$*,$<,$(call gb_ObjCObject_get_dep_target,$*))
+ $(call gb_Output_announce,$*.m,$(true),OCC,3)
+ $(call gb_CObject__command_pattern,$@,$(T_OBJCFLAGS) $(T_OBJCFLAGS_APPEND),$<,$(call gb_ObjCObject_get_dep_target,$*))
ifeq ($(gb_FULLDEPS),$(true))
$(call gb_ObjCObject_get_dep_target,%) :
@@ -337,10 +338,6 @@ endif
# AsmObject class
-# defined by platform
-# gb_AsmObject_get_source (.asm on Windows, .s elsewhere)
-# gb_AsmObject__command
-
$(call gb_AsmObject_get_target,%) : $(call gb_AsmObject_get_source,$(SRCDIR),%)
$(call gb_AsmObject__command,$@,$*,$<,$(call gb_AsmObject_get_dep_target,$*))
@@ -365,11 +362,6 @@ define gb_LinkTarget_rtl_defs
$(if $(filter-out sal salhelper cppu cppuhelper odk, $(gb_Module_CURRENTMODULE_NAME)), -DRTL_USING)
endef
-# defined by platform
-# gb_LinkTarget_CXXFLAGS
-# gb_LinkTarget_LDFLAGS
-# gb_LinkTarget_INCLUDE
-
.PHONY : $(WORKDIR)/Clean/LinkTarget/%
$(WORKDIR)/Clean/LinkTarget/% :
$(call gb_Output_announce,$*,$(false),LNK,4)
@@ -1142,7 +1134,7 @@ endef
# call gb_LinkTarget_add_x64_generated_cobjects,linktarget,sourcefiles,cflags,linktargetmakefilename
define gb_LinkTarget_add_x64_generated_cobjects
$(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
-$(foreach obj,$(2),$(eval $(call gb_GenCObject_get_target,$(obj)) : COBJECT_X64 := YES))
+$(foreach obj,$(2),$(eval $(call gb_GenCObject_get_target,$(obj)) : CXXOBJECT_X64 := YES))
endef
# call gb_LinkTarget_add_generated_cxxobjects,linktarget,sourcefiles,cxxflags,linktargetmakefilename
diff --git a/solenv/gbuild/platform/com_GCC_class.mk b/solenv/gbuild/platform/com_GCC_class.mk
index 2308af817905..c8cd30a2420a 100644
--- a/solenv/gbuild/platform/com_GCC_class.mk
+++ b/solenv/gbuild/platform/com_GCC_class.mk
@@ -42,24 +42,24 @@ endef
# CObject class
-# $(call gb_CObject__command,object,relative-source,source,dep-file)
-define gb_CObject__command
-$(call gb_Output_announce,$(2).c,$(true),C ,3)
+# $(call gb_CObject__command_pattern,object,flags,source,dep-file)
+define gb_CObject__command_pattern
$(call gb_Helper_abbreviate_dirs,\
mkdir -p $(dir $(1)) $(dir $(4)) && cd $(SRCDIR) && \
$(if $(COMPILER_PLUGINS),$(gb_COMPILER_PLUGINS_SETUP)) \
- $(gb_CC) \
+ $(if $(filter %.c %.m,$(3)), $(gb_CC), $(gb_CXX)) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),,$(gb_CFLAGS_WERROR)) \
$(if $(COMPILER_PLUGINS),$(gb_COMPILER_PLUGINS)) \
- $(T_CFLAGS) $(T_CFLAGS_APPEND) \
+ $(2) \
-c $(3) \
-o $(1) \
$(call gb_cxx_dep_generation_options,$(1),$(4)) \
-I$(dir $(3)) \
$(INCLUDE) \
+ $(PCHFLAGS) \
$(call gb_cxx_dep_copy,$(4)) \
)
endef
@@ -83,31 +83,6 @@ $(call gb_Helper_abbreviate_dirs,\
)
endef
-# CxxObject class
-
-# $(call gb_CxxObject__command,object,relative-source,source,dep-file)
-define gb_CxxObject__command
-$(call gb_Output_announce,$(2).cxx,$(true),CXX,3)
-$(call gb_Helper_abbreviate_dirs,\
- mkdir -p $(dir $(1)) $(dir $(4)) && cd $(SRCDIR) && \
- $(if $(COMPILER_PLUGINS),$(gb_COMPILER_PLUGINS_SETUP)) \
- $(gb_CXX) \
- $(DEFS) \
- $(gb_LTOFLAGS) \
- $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
- $(if $(WARNINGS_NOT_ERRORS),,$(gb_CXXFLAGS_WERROR)) \
- $(if $(COMPILER_PLUGINS),$(gb_COMPILER_PLUGINS)) \
- $(T_CXXFLAGS) $(T_CXXFLAGS_APPEND) \
- -c $(3) \
- -o $(1) \
- $(call gb_cxx_dep_generation_options,$(1),$(4)) \
- -I$(dir $(3)) \
- $(INCLUDE) \
- $(PCHFLAGS) \
- $(call gb_cxx_dep_copy,$(4)) \
- )
-endef
-
# Used to run a compiler plugin tool.
# $(call gb_CxxObject__tool_command,relative-source,source)
define gb_CxxObject__tool_command
@@ -118,7 +93,7 @@ $(call gb_Helper_abbreviate_dirs,\
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
- $(if $(WARNINGS_NOT_ERRORS),,$(gb_CXXFLAGS_WERROR)) \
+ $(if $(WARNINGS_NOT_ERRORS),,$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_CXXFLAGS) $(T_CXXFLAGS_APPEND) \
-c $(2) \
@@ -127,44 +102,6 @@ $(call gb_Helper_abbreviate_dirs,\
)
endef
-# ObjCxxObject class
-
-define gb_ObjCxxObject__command
-$(call gb_Output_announce,$(2).mm,$(true),OCX,3)
-$(call gb_Helper_abbreviate_dirs,\
- mkdir -p $(dir $(1)) $(dir $(4)) && \
- $(gb_CXX) \
- $(DEFS) \
- $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
- $(if $(WARNINGS_NOT_ERRORS),,$(gb_CXXFLAGS_WERROR)) \
- $(T_OBJCXXFLAGS) $(T_OBJCXXFLAGS_APPEND) \
- -c $(3) \
- -o $(1) \
- -MMD -MT $(1) \
- -MP -MF $(4) \
- -I$(dir $(3)) \
- $(INCLUDE))
-endef
-
-# ObjCObject class
-
-define gb_ObjCObject__command
-$(call gb_Output_announce,$(2).m,$(true),OCC,3)
-$(call gb_Helper_abbreviate_dirs,\
- mkdir -p $(dir $(1)) $(dir $(4)) && \
- $(gb_CC) \
- $(DEFS) \
- $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
- $(if $(WARNINGS_NOT_ERRORS),,$(gb_CFLAGS_WERROR)) \
- $(T_OBJCFLAGS) $(T_OBJCFLAGS_APPEND) \
- -c $(3) \
- -o $(1) \
- -MMD -MT $(1) \
- -MP -MF $(4) \
- -I$(dir $(3)) \
- $(INCLUDE))
-endef
-
define gb_SrsPartTarget__command_dep
$(call gb_Helper_abbreviate_dirs,\
mkdir -p $(dir $(call gb_SrsPartTarget_get_dep_target,$(1))) && cd $(SRCDIR) && \
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk
index e4c105cf15e2..986ef39d3bc5 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -92,10 +92,7 @@ gb_CXXFLAGS_COMMON += -fvisibility-inlines-hidden
endif
endif
-ifneq ($(ENABLE_WERROR),)
-gb_CFLAGS_WERROR := -Werror
-gb_CXXFLAGS_WERROR := -Werror
-endif
+gb_CFLAGS_WERROR := $(if $(ENABLE_WERROR),-Werror)
ifneq ($(MERGELIBS),)
gb_CFLAGS_COMMON += -DLIBO_MERGELIBS
diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk
index 3341e358b790..e0fa5b554f32 100644
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -34,41 +34,18 @@ endef
# CObject class
-# $(call gb_CObject__command,object,relative-source,source,dep-file)
-define gb_CObject__command
-$(call gb_Output_announce,$(2).c,$(true),C ,3)
+# $(call gb_CObject__command_pattern,object,flags,source,dep-file)
+define gb_CObject__command_pattern
$(call gb_Helper_abbreviate_dirs,\
mkdir -p $(dir $(1)) $(dir $(4)) && \
unset INCLUDE && \
- $(if $(filter YES,$(COBJECT_X64)), $(CXX_X64_BINARY), $(gb_CC)) \
+ $(if $(filter YES,$(CXXOBJECT_X64)), $(CXX_X64_BINARY), \
+ $(if $(filter %.c,$(3)), $(gb_CC), $(gb_CXX))) \
$(DEFS) \
$(gb_LTOFLAGS) \
- $(T_CFLAGS) $(T_CFLAGS_APPEND) \
+ $(2) \
$(if $(WARNINGS_NOT_ERRORS),,$(gb_CFLAGS_WERROR)) \
-Fd$(PDBFILE) \
- $(gb_COMPILERDEPFLAGS) \
- -I$(dir $(3)) \
- $(INCLUDE) \
- $(if $(filter YES,$(COBJECT_X64)), -U_X86_ -D_AMD64_,) \
- -c $(3) \
- -Fo$(1)) $(call gb_create_deps,$(4),$(1),$(3))
-endef
-
-
-# CxxObject class
-
-# $(call gb_CxxObject__command,object,relative-source,source,dep-file)
-define gb_CxxObject__command
-$(call gb_Output_announce,$(2).cxx,$(true),CXX,3)
-$(call gb_Helper_abbreviate_dirs,\
- mkdir -p $(dir $(1)) $(dir $(4)) && \
- unset INCLUDE && \
- $(if $(filter YES,$(CXXOBJECT_X64)), $(CXX_X64_BINARY), $(gb_CXX)) \
- $(DEFS) \
- $(gb_LTOFLAGS) \
- $(T_CXXFLAGS) $(T_CXXFLAGS_APPEND) \
- $(if $(WARNINGS_NOT_ERRORS),,$(gb_CXXFLAGS_WERROR)) \
- -Fd$(PDBFILE) \
$(PCHFLAGS) \
$(gb_COMPILERDEPFLAGS) \
-I$(dir $(3)) \
@@ -78,7 +55,6 @@ $(call gb_Helper_abbreviate_dirs,\
-Fo$(1)) $(call gb_create_deps,$(4),$(1),$(3))
endef
-
# PrecompiledHeader class
# Note: MSVC has a race condition when dealing with .pdb files, that can result in error C1033 when
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk
index 9f050e940000..0779b02d6e6f 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -244,10 +244,7 @@ gb_PCHWARNINGS = \
gb_STDLIBS := \
advapi32.lib \
-ifneq ($(ENABLE_WERROR),)
-gb_CFLAGS_WERROR := -WX
-gb_CXXFLAGS_WERROR := -WX
-endif
+gb_CFLAGS_WERROR := $(if $(ENABLE_WERROR),-WX)
ifneq ($(MERGELIBS),)
gb_CFLAGS += -DLIBO_MERGELIBS
diff --git a/solenv/gbuild/platform/solaris.mk b/solenv/gbuild/platform/solaris.mk
index 68e50202bc44..7f1ce40018d5 100644
--- a/solenv/gbuild/platform/solaris.mk
+++ b/solenv/gbuild/platform/solaris.mk
@@ -149,7 +149,7 @@ gb_LinkTarget__RPATHS := \
NONE:\dORIGIN/../Library \
gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR)
-gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR)
+gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CFLAGS_WERROR)
ifeq ($(gb_SYMBOL),$(true))
gb_LinkTarget_CXXFLAGS += -ggdb2