samples/Makefile
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 01 19:04:20 2007 +0000 (2007-07-01)
changeset 182 223c84ec2d90
parent 179 ba6e7292f7bf
child 189 654627ec680e
permissions -rw-r--r--
Merge the build system to trunk: ct-ng is now installable:
- ./configure --prefix=/some/place
- make
- make install
- export PATH="${PATH}:/some/place/bin"
- ct-ng <action>
     1 # Makefile to manage samples
     2 
     3 # Build the list of available samples
     4 CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
     5 CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config)))
     6 
     7 CT_SAMPLES := $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES)
     8 
     9 help-config::
    10 	@echo  '  saveconfig     - Save current config as a preconfigured target'
    11 
    12 help-samples::
    13 	@$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
    14 
    15 help-build::
    16 	@echo  '  regtest        - Regtest-build all samples'
    17 
    18 # How we do build one sample
    19 PHONY += $(CT_SAMPLES)
    20 $(CT_SAMPLES):
    21 	@$(MAKE) -f $(CT_MAKEFILE) $(patsubst %,%_copy_config,$(@)) oldconfig
    22 
    23 $(patsubst %,%_copy_config,$(CT_SAMPLES)):
    24 	@if [ -f $(CT_TOP_DIR)/samples/$(patsubst %_copy_config,%,$(@))/crosstool.config ]; then                    \
    25 	      cp "$(CT_TOP_DIR)/samples/$(patsubst %_copy_config,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    26 	 else                                                                                                       \
    27 	      cp "$(CT_LIB_DIR)/samples/$(patsubst %_copy_config,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    28 	 fi
    29 
    30 # And now for building all samples one after the other
    31 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    32 # work because we want to save the samples as well.
    33 # Also, we don't want to see anylog at all, save for the elapsed time, and we
    34 # want to save the log file in a specific place
    35 # Furthermore, force the location where the toolchain will be installed.
    36 # Finaly, we can't use 'make sample-name' as we need to provide default values
    37 # if the options set has changed, but oldconfig does not like when stdin is
    38 # not a terminal (eg. it is a pipe).
    39 PHONY += regtest
    40 regtest:
    41 	@for samp in $(CT_SAMPLES); do                                                                          \
    42 	     echo -e "\rBuilding sample \"$${samp}\""                                                       &&  \
    43 	     $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) $${samp}_copy_config                                &&  \
    44 	     yes "" |$(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) defoldconfig >/dev/null 2>&1                &&  \
    45 	     sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config  &&  \
    46 	     sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    47 	     sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    48 	     sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    49 	     sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    50 	     sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    51 	     yes "" |$(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) defoldconfig >/dev/null 2>&1                &&  \
    52 	     $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE)                                                     &&  \
    53 	     echo -e "\rMaking tarball for sample \"$${samp}\""                                             &&  \
    54 	     $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) tarball                                             ;   \
    55 	     echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
    56 	     $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) distclean                                           ;   \
    57 	 done
    58 
    59 saveconfig:
    60 	$(CT_LIB_DIR)/scripts/saveSample.sh