]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
Makefile.rules updatet. It is now possible to specify custom CFLAGS
authorsojka <sojka@78ed6b52-5822-0410-8084-884f26da6e90>
Tue, 24 Jul 2007 12:28:33 +0000 (12:28 +0000)
committersojka <sojka@78ed6b52-5822-0410-8084-884f26da6e90>
Tue, 24 Jul 2007 12:28:33 +0000 (12:28 +0000)
git-svn-id: svn+ssh://rtime.felk.cvut.cz/var/svn/eurobot/trunk/soft@482 78ed6b52-5822-0410-8084-884f26da6e90

build/_infrastructure/Makefile.rules

index 74554c430da81d469580dcc0671a665631448286..d2244fbcd48ea75782096a26b39fb4aeb915fd9e 100644 (file)
 # W                .. whole tree - if set to 1, make is always called from the top-level directory
 # SUBDIRS          .. list of subdirectories intended for make from actual directory
 # default_CONFIG   .. list of default config assignments CONFIG_XXX=y/n ...
-# LOCAL_CONFIG_H   .. name of local config.h file generated from values #OMK@config_h
-#                     of options defined in the current directory
-# config_include_HEADERS .. names of global config files (possibly
-#                     with subdirectories)
-# xxx_DEFINES      .. list of config directives to be included in
-#                     config header file of the name <somedir>/xxx.h
 # LN_HEADERS       .. if "y", header files are symbolicaly linked instead of copied. #OMK@include
 #                                                            #OMK@linux
 # input variables
 #
 # LINUX_DIR        .. location of Linux kernel sources
 # RTL_DIR          .. location of RT-Linux sources
+# CFLAGS           .. C compiler flags
+# CXXFLAGS         .. C++ compiler flags
+# LOCAL_CONFIG_H   .. name of local config.h file generated from values #OMK@config_h
+#                     of options defined in the current directory
+# config_include_HEADERS .. names of global config files (possibly
+#                     with subdirectories)
+# xxx_DEFINES      .. list of config directives to be included in
+#                     config header file of the name <somedir>/xxx.h
 # QT_SUBDIRS       .. subdirectories where to build QT applications using qmake #OMK@qt
 # QTDIR                   .. where QT resides
 -include $(MAKERULES_DIR)/OCERA_TOP_DIR                      #OMK@linux-setup
@@ -265,58 +267,6 @@ default-config-pass-local:
        @$(foreach x, $(default_CONFIG), echo $(x) | \
                sed -e 's/^.*=x$$/#\0/' >> "$(CONFIG_FILE)-default" ; )
 
-                                                             #OMK@config_h
-# Syntax: $(call BUILD_CONFIG_H_template,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
-define BUILD_CONFIG_H_template
-
-$(1) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
-       @$(QUIET_CMD_ECHO) "  CONFGEN $$(@:$(MAKERULES_DIR)/%=%)"
-       @if [ ! -d `dirname $(1).tmp` ] ; then \
-               mkdir `dirname $(1).tmp` ; fi
-       @echo "/* Automatically generated from */" > "$(1).tmp"
-       @echo "/* config file: $$< */" >> "$(1).tmp"
-       @echo "#ifndef $(3)" >> "$(1).tmp"
-       @echo "#define $(3)" >> "$(1).tmp"
-       @( $(foreach x, $(shell echo '$($(2))' | sed -e 's/\<\([^ =]*\)\(=[^ ]\+\|\)\>/\1/g' ), \
-               echo '$(x).$($(x))' ; ) echo ; ) | \
-               sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
-               sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
-                 >> "$(1).tmp"
-       @echo "#endif /*$(3)*/" >> "$(1).tmp"
-       @if cmp --quiet "$(1).tmp" "$(1)" ; then rm "$(1).tmp" ; \
-       else mv "$(1).tmp" "$(1)" ; \
-       echo Updated configuration "$(1)" ; fi
-
-endef
-
-ifdef LOCAL_CONFIG_H
-
-CFLAGS += -I.
-$(eval $(call BUILD_CONFIG_H_template,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
-
-endif
-
-# Special rules for configuration exported headers
-
-#FIXME: The directory for headers should not be specified here.
-$(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
-_$(basename $(notdir $(confh)))_H \
-)))
-
-# Add some hooks to standard passes
-include-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS))
-
-clean-local: clean-local-config-h
-
-clean-local-config-h:
-       @$(foreach confh,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\
-           if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \
-       )
-
-
-# Local Variables:
-# mode:makefile
-# End:
 ifeq ($(OMK_VERBOSE),1)                                      #OMK@include
 CPHEADER_FLAGS += -v
 LNHEADER_FLAGS += -v
@@ -357,12 +307,10 @@ endef
 #CONFIG_RTLINUX = y
 #OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
 
-#CFLAGS += -ggdb
-CFLAGS += -O2 
-CFLAGS += -Wall
-#CXXFLAGS += -ggdb
-CXXFLAGS += -O0
-CXXFLAGS += -Wall
+# Assign default values to CFLAGS variable. If the variable is defined
+# earlier (i.g. in config.omk), it is not overriden here.
+CFLAGS ?= -O2 -Wall
+CXXFLAGS ?= -O2 -Wall
 
 
 CPPFLAGS  += -I $(USER_INCLUDE_DIR)
@@ -989,6 +937,60 @@ ifndef OMIT_KERNEL_PASSES
 default: kernel-lib-pass kernel-pass
 endif
 
+# Local Variables:
+# mode:makefile
+# End:
+                                                             #OMK@config_h
+# Syntax: $(call BUILD_CONFIG_H_template,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
+define BUILD_CONFIG_H_template
+
+$(1) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+       @$(QUIET_CMD_ECHO) "  CONFGEN $$(@:$(MAKERULES_DIR)/%=%)"
+       @if [ ! -d `dirname $(1).tmp` ] ; then \
+               mkdir `dirname $(1).tmp` ; fi
+       @echo "/* Automatically generated from */" > "$(1).tmp"
+       @echo "/* config file: $$< */" >> "$(1).tmp"
+       @echo "#ifndef $(3)" >> "$(1).tmp"
+       @echo "#define $(3)" >> "$(1).tmp"
+       @( $(foreach x, $(shell echo '$($(2))' | sed -e 's/\<\([^ =]*\)\(=[^ ]\+\|\)\>/\1/g' ), \
+               echo '$(x).$($(x))' ; ) echo ; ) | \
+               sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
+               sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
+                 >> "$(1).tmp"
+       @echo "#endif /*$(3)*/" >> "$(1).tmp"
+       @if cmp --quiet "$(1).tmp" "$(1)" ; then rm "$(1).tmp" ; \
+       else mv "$(1).tmp" "$(1)" ; \
+       echo Updated configuration "$(1)" ; fi
+
+endef
+
+ifdef LOCAL_CONFIG_H
+
+# This must be declared after the default cflags are assigned!
+# Override is used to override command line assignemnt.
+override CFLAGS += -I.
+$(eval $(call BUILD_CONFIG_H_template,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
+
+endif
+
+# Special rules for configuration exported headers
+
+#FIXME: The directory for headers should not be specified here.
+$(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
+_$(basename $(notdir $(confh)))_H \
+)))
+
+# Add some hooks to standard passes
+include-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS))
+
+clean-local: clean-local-config-h
+
+clean-local-config-h:
+       @$(foreach confh,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\
+           if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \
+       )
+
+
 # Local Variables:
 # mode:makefile
 # End: