ct-ng.in
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Thu Nov 22 19:43:26 2012 +0100 (2012-11-22)
branch1.17
changeset 3130 8db540910974
parent 2881 eb19492e3386
permissions -rw-r--r--
scripts/functions: fix debug-shell

Properly catch resuming the build when continuing past the
failed command.

The 'case ;;&' construct is a bash4ism. Get rid of it.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
(transplanted from 2af20cfd210bac338ec18d774458c84fd585ef07)
yann@1141
     1
#!@@CT_make@@ -rf
yann@182
     2
# Makefile for crosstool-NG.
yann@2908
     3
# Copyright 2006 Yann E. MORIN <yann.morin.1998@free.fr>
yann@182
     4
yann@182
     5
# Don't print directory as we descend into them
yann@411
     6
# Don't use built-in rules, we know what we're doing
yann@289
     7
MAKEFLAGS += --no-print-directory --no-builtin-rules
yann@182
     8
yann@1155
     9
# Don't go parallel
yann@1155
    10
.NOTPARALLEL:
yann@411
    11
yann@1144
    12
# This is where ct-ng is:
yann@1144
    13
export CT_NG:=$(lastword $(MAKEFILE_LIST))
yann@1144
    14
# and this is where we're working in:
yann@1144
    15
export CT_TOP_DIR:=$(shell pwd)
yann@1144
    16
yann@1144
    17
# Paths and values set by ./configure
yann@372
    18
# Don't bother to change it other than with a new ./configure!
yann@182
    19
export CT_LIB_DIR:=@@CT_LIBDIR@@
yann@182
    20
export CT_DOC_DIR:=@@CT_DOCDIR@@
yann@182
    21
yann@197
    22
# This is crosstool-NG version string
yann@543
    23
export CT_VERSION:=@@CT_VERSION@@
yann@182
    24
yann@1155
    25
# Paths found by ./configure
yann@1155
    26
include $(CT_LIB_DIR)/paths.mk
yann@953
    27
yann@1155
    28
# Some distributions (eg. Ubuntu) thought it wise to point /bin/sh to
yann@1155
    29
# a truly POSIX-conforming shell, ash in this case. This is not so good
yann@1155
    30
# as we, smart (haha!) developers (as smart we ourselves think we are),
yann@1155
    31
# got used to bashisms, and are enclined to easiness... So force use of
yann@1155
    32
# bash.
yann@1155
    33
export SHELL=$(bash)
yann@1155
    34
yann@1667
    35
# GREP_OPTIONS=--color=always will break the generated .in files
yann@1667
    36
# We do not need any GREP_OPTIONS anyway, so set it to empty.
yann@1667
    37
export GREP_OPTIONS=
yann@1667
    38
yann@1155
    39
# Make the restart/stop steps availabe to scripts/crostool-NG.sh
yann@334
    40
export CT_STOP:=$(STOP)
yann@334
    41
export CT_RESTART:=$(RESTART)
yann@182
    42
yann@954
    43
SILENT=@
yann@954
    44
ECHO=echo
yann@954
    45
ifeq ($(strip $(origin V)),command line)
yann@940
    46
  ifeq ($(strip $(V)),0)
yann@940
    47
    SILENT=@
yann@940
    48
    ECHO=:
yann@940
    49
  else
yann@940
    50
    ifeq ($(strip $(V)),1)
yann@940
    51
      SILENT=
yann@940
    52
      ECHO=:
yann@953
    53
    else
yann@953
    54
      ifeq ($(strip $(V)),2)
yann@953
    55
        SILENT=
yann@953
    56
        ECHO=echo
yann@954
    57
      endif # V == 2
yann@954
    58
    endif # V== 1
yann@954
    59
  endif # V == 0
yann@954
    60
endif # origin V
yann@1008
    61
export V SILENT ECHO
yann@940
    62
yann@1618
    63
all: help
yann@1618
    64
yann@182
    65
.PHONY: $(PHONY)
yann@182
    66
PHONY += all
yann@1618
    67
FORCE:
yann@182
    68
yann@182
    69
# Help system
yann@229
    70
help:: help-head help-config help-samples help-build help-clean help-distrib help-env help-tail
yann@182
    71
yann@544
    72
help-head:: version
yann@544
    73
	@echo  'See below for a list of available actions, listed by category:'
yann@182
    74
yann@182
    75
help-config::
yann@182
    76
	@echo
yann@197
    77
	@echo  'Configuration actions:'
yann@182
    78
yann@182
    79
help-samples::
yann@182
    80
	@echo
yann@1024
    81
	@echo  'Preconfigured toolchains (#: force number of // jobs):'
yann@182
    82
yann@182
    83
help-build::
yann@182
    84
	@echo
yann@333
    85
	@echo  'Build actions (#: force number of // jobs):'
yann@182
    86
yann@229
    87
help-clean::
yann@229
    88
	@echo
yann@229
    89
	@echo  'Clean actions:'
yann@229
    90
yann@182
    91
help-distrib::
yann@182
    92
	@echo
yann@197
    93
	@echo  'Distribution actions:'
yann@182
    94
yann@182
    95
help-env::
yann@182
    96
	@echo
js@2881
    97
	@echo  'Environment variables (see @@CT_DOCDIR@@/0 - Table of content.txt):'
yann@182
    98
yann@182
    99
help-tail::
yann@182
   100
	@echo
yann@2076
   101
	@echo  'Use action "menuconfig" to configure your toolchain'
yann@932
   102
	@echo  'Use action "build" to build your toolchain'
yann@932
   103
	@echo  'Use action "version" to see the version'
yann@2621
   104
	@echo  'See "man 1 $(notdir $(CT_NG))" for some help as well'
yann@182
   105
yann@182
   106
help-build::
yann@1024
   107
	@echo  '  build[.#]          - Build the currently configured toolchain'
yann@229
   108
yann@229
   109
help-clean::
yann@333
   110
	@echo  '  clean              - Remove generated files'
yann@333
   111
	@echo  '  distclean          - Remove generated files, configuration and build directories'
yann@182
   112
yann@945
   113
include $(CT_LIB_DIR)/config/config.mk
yann@261
   114
include $(CT_LIB_DIR)/kconfig/kconfig.mk
yann@333
   115
include $(CT_LIB_DIR)/steps.mk
yann@261
   116
include $(CT_LIB_DIR)/samples/samples.mk
yann@1101
   117
include $(CT_LIB_DIR)/scripts/scripts.mk
yann@182
   118
yann@1336
   119
help-config::
yann@1336
   120
	@echo  '  show-tuple         - Print the tuple of the currently configured toolchain'
yann@1336
   121
yann@182
   122
help-distrib::
yann@333
   123
	@echo  '  tarball            - Build a tarball of the configured toolchain'
yann@182
   124
yann@182
   125
help-env::
yann@1876
   126
	@echo  '  V=0|1|2            - 0 => show only human-readable messages (default)'
yann@1876
   127
	@echo  '                       1 => show only the commands being executed'
yann@1876
   128
	@echo  '                       2 => show both'
yann@182
   129
yann@940
   130
# End help system
yann@940
   131
yann@182
   132
.config:
yann@1336
   133
	@echo "There is no existing .config file!"
yann@1336
   134
	@echo "You need to either run 'menuconfig',"
yann@1336
   135
	@echo "or configure an existing sample."
yann@182
   136
	@false
yann@182
   137
yann@2468
   138
.config.2: .config
yann@2468
   139
	$(SILENT)$(sed) -r -e 's/^([^=]+_ARRAY)="(.*)"$$/\1=( \2 )/;'   \
yann@2468
   140
	                   -e '/^[^=]+_ARRAY=/s/\\(.)/\1/g;'            \
yann@2468
   141
	                $< >$@
yann@2468
   142
yann@2468
   143
show-tuple: .config.2
yann@1336
   144
	$(SILENT)$(bash) $(CT_LIB_DIR)/scripts/showTuple.sh
yann@1336
   145
yann@182
   146
# Actual build
yann@2468
   147
build: .config.2
yann@1143
   148
	$(SILENT)$(CT_LIB_DIR)/scripts/crosstool-NG.sh
yann@182
   149
yann@372
   150
build.%:
yann@1155
   151
	$(SILENT)$(MAKE) -rf $(CT_NG) $(shell echo "$(@)" |$(sed) -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
yann@333
   152
yann@182
   153
PHONY += tarball
yann@214
   154
#tarball:
yann@214
   155
#	@$(CT_LIB_DIR)/scripts/tarball.sh
yann@182
   156
tarball:
yann@940
   157
	@echo 'Tarball creation disabled for now... Sorry.'
yann@214
   158
	@true
yann@182
   159
yann@268
   160
PHONY += version
yann@268
   161
version:
yann@273
   162
	@echo 'This is crosstool-NG version $(CT_VERSION)'
yann@675
   163
	@echo
yann@2908
   164
	@echo 'Copyright (C) 2008  Yann E. MORIN <yann.morin.1998@free.fr>'
yann@675
   165
	@echo 'This is free software; see the source for copying conditions.'
yann@675
   166
	@echo 'There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A'
yann@675
   167
	@echo 'PARTICULAR PURPOSE.'
yann@931
   168
	@echo
yann@268
   169
yann@182
   170
PHONY += clean
yann@182
   171
clean::
yann@953
   172
	@$(ECHO) "  CLEAN log"
yann@2339
   173
	$(SILENT)rm -f build.log .config.* ..config*
yann@182
   174
yann@182
   175
PHONY += distclean
yann@182
   176
distclean:: clean
yann@953
   177
	@$(ECHO) "  CLEAN .config"
yann@953
   178
	$(SILENT)rm -f .config .config.* ..config*
yann@2134
   179
	@$(ECHO) "  CLEAN build dir"
yann@2137
   180
	$(SILENT)[ ! -d targets ] || chmod -R u+w targets
yann@2137
   181
	$(SILENT)[ ! -d .build  ] || chmod -R u+w .build
yann@2134
   182
	$(SILENT)rm -rf targets .build