X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/341377103dfdc83d2d52e33d78672366db0efe93..5b1805652b70bcf8f56c827e09b18fbf5a77bea6:/omk/rules/linux/Makefile.rules diff --git a/omk/rules/linux/Makefile.rules b/omk/rules/linux/Makefile.rules index 406e45d..2a634d1 100644 --- a/omk/rules/linux/Makefile.rules +++ b/omk/rules/linux/Makefile.rules @@ -1,10 +1,10 @@ # Makefile.rules - OCERA make framework common project rules -*- makefile-gmake -*- #OMK:base.omk # -# (C) Copyright 2003 by Pavel Pisa - OCERA team member -# (C) Copyright 2006 by Michal Sojka - Czech Technical University, FEE, DCE +# (C) Copyright 2003, 2006, 2007, 2008, 2009 by Pavel Pisa - OCERA team member +# (C) Copyright 2006, 2007, 2008, 2009, 2010 by Michal Sojka - Czech Technical University, FEE, DCE # # Homepage: http://rtime.felk.cvut.cz/omk/ -# Version: 0.1-88-g324e3bf +# Version: 0.2-12-g881199c # # The OMK build system is distributed under the GNU General Public # License. See file COPYING for details. @@ -63,12 +63,6 @@ # QTDIR .. where QT resides OMK_RULES_TYPE=linux #OMK:Makefile.rules.linux@ #OMK:base.omk@Makefile.rules.linux -# We need to ensure definition of sources directory first -ifndef SOURCES_DIR -# Only shell built-in pwd understands -L -SOURCES_DIR := $(shell ( pwd -L ) ) -endif - # If we are not called by OMK leaf Makefile... ifndef MAKERULES_DIR MAKERULES_DIR := $(abspath $(dir $(filter %Makefile.rules,$(MAKEFILE_LIST)))) @@ -81,6 +75,15 @@ ifndef OUTPUT_DIR OUTPUT_DIR := $(MAKERULES_DIR) endif +# We need to ensure definition of sources directory first +ifndef SOURCES_DIR +# Only shell built-in pwd understands -L +SOURCES_DIR := $(shell ( pwd -L ) ) +INVOCATION_DIR := $(SOURCES_DIR:$(OUTPUT_DIR)%=%) +INVOCATION_DIR := $(INVOCATION_DIR:/%=%) +INVOCATION_DIR := $(INVOCATION_DIR:\\%=%) +endif + .PHONY: all default check-make-ver omkize ifdef W @@ -142,7 +145,7 @@ endif #$(CONFIG_FILE_OK) CONFIG_FILES ?= $(wildcard $(CONFIG_FILE)-default) $(wildcard $(OUTPUT_DIR)/config.target) $(wildcard $(CONFIG_FILE)) -export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR +export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR INVOCATION_DIR export CONFIG_FILE CONFIG_FILES OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT # OMK_SERIALIZE_INCLUDED has to be exported to submakes because passes # must to be serialized only in the toplevel make. @@ -243,11 +246,14 @@ endif pass = $(strip $(1)) +unexport SUBDIRS + # Call a pass in a subdirectory # Usage: $(call omk_pass_subdir_template,,,) define omk_pass_subdir_template .PHONY: $(pass)-$(3)-subdir $(pass)-submakes: $(pass)-$(3)-subdir +$(pass)-$(3)-subdir: MAKEOVERRIDES:=$(filter-out SUBDIRS=%,$(MAKEOVERRIDES)) $(pass)-$(3)-subdir: @$(call mkdir_def,$(2)/$(3)) +@$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(3) $(NO_PRINT_DIRECTORY) \ @@ -463,6 +469,7 @@ LIB_CPPFLAGS += $(CPPFLAGS) LIB_CFLAGS += $(CFLAGS) ifeq ($(TARGET_OS),win32) + EXE_SUFFIX = .exe SOLIB_EXT = dll else SOLIB_EXT = so @@ -568,6 +575,7 @@ $(2): $(1) $$(GEN_HEADERS) fi endef +NM ?= nm # Syntax: $(call CMETRIC_o_h_template,,) define CMETRIC_o_h_template @@ -576,15 +584,22 @@ $(2): $(1) $(Q)if [ -n `dirname $$@` ] ; then \ if [ ! -e `dirname $$@` ] ; then \ mkdir -p `dirname $$@` ; fi ; fi - $(Q)echo >$$@ '/* Automatically generated from $$< */' - $(Q)echo >>$$@ '/* Conditionals to control compilation */' - $(Q)set -o pipefail ; $(NM) $$< \ + $(Q)echo >$$@.tmp '/* Automatically generated from $$< */' + $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */' +# Bellow, the tricks with redirection are for shells without set -o pipefail +# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html) + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ - | sort >>$$@ - $(Q)echo >>$$@ '/* Defines from the values defined to symbols */' - $(Q)set -o pipefail ; $(NM) $$< \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */' + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ - | sort >>$$@ + | sort >>$$@.tmp` && exit $$$$status + $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */' + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\ + | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)mv $$@.tmp $$@ endef @@ -1244,7 +1259,7 @@ define qt_project_template # FIXME: Handle multiple .pro files correctly $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile: $(SOURCES_DIR)/$(1) $(Q)mkdir -p $$(dir $$(@)) && cd $$(dir $$(@)) && \ - $(QTDIR:%=%/bin/)qmake \ + $(if $(QMAKE),$(QMAKE),$(QTDIR:%=%/bin/)qmake) \ TOP_DIR=$(OUTPUT_DIR) \ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir $(1)) \ $(QTDIR:%=QTDIR=%) CC=$(CC) CXX=$(CXX) \