Makefile.in
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Mon Apr 16 15:25:36 2012 +0200 (2012-04-16)
changeset 2941 13e40098fffc
parent 2838 822af73497bf
child 2999 4ccfca658d9b
permissions -rw-r--r--
cc/gcc: update Linaro GCC revisions to 2012.04

Update Linaro GCC with the latest available revisions.

The 4.7 revision is also released, but the infrastructure is not yet ready for
it in CT-NG.

Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
     1 # Makefile.in for building crosstool-NG
     2 # This file serves as source for the ./configure operation
     3 
     4 # This series of test is here because GNU make 3.81 will *not* use MAKEFLAGS
     5 # to set additional flags in the current Makfile ( see:
     6 # http://savannah.gnu.org/bugs/?20501 ), although the make manual says it
     7 # should ( see: http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion )
     8 # so we have to work it around by calling ourselves back if needed
     9 
    10 # So why do we need not to use the built rules and variables? Because we
    11 # need to generate scripts/crosstool-NG.sh from scripts/crosstool-NG.sh.in
    12 # and there is a built-in implicit rule '%.sh:' that has neither a pre-requisite
    13 # nor a command associated, and that built-in implicit rule takes precedence
    14 # over our non-built-in implicit rule '%: %.in', below.
    15 
    16 # CT_MAKEFLAGS will be used later, below...
    17 
    18 # Do not print directories as we descend into them
    19 ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),)
    20 CT_MAKEFLAGS += --no-print-directory
    21 endif
    22 
    23 # Use neither builtin rules, nor builtin variables
    24 # Note: dual test, because if -R and -r are given on the command line
    25 # (who knows?), MAKEFLAGS contains 'Rr' instead of '-Rr', while adding
    26 # '-Rr' to MAKEFLAGS adds it literaly ( and does not add 'Rr' )
    27 ifeq ($(filter Rr,$(MAKEFLAGS)),)
    28 ifeq ($(filter -Rr,$(MAKEFLAGS)),)
    29 CT_MAKEFLAGS += -Rr
    30 endif # No -Rr
    31 endif # No Rr
    32 
    33 # Remove any suffix rules
    34 .SUFFIXES:
    35 
    36 all: Makefile build
    37 
    38 ###############################################################################
    39 # Configuration variables
    40 
    41 # Stuff found by ./configure
    42 export DATE            := @DATE@
    43 export LOCAL           := @enable_local@
    44 export PROG_SED        := @program_transform_name@
    45 export PACKAGE_TARNAME := @PACKAGE_TARNAME@
    46 export VERSION         := @PACKAGE_VERSION@
    47 export prefix          := @prefix@
    48 export exec_prefix     := @exec_prefix@
    49 export bindir          := @bindir@
    50 export libdir          := @libdir@@sublibdir@
    51 export docdir          := @docdir@@subdocdir@
    52 export mandir          := @mandir@
    53 export datarootdir     := @datarootdir@
    54 export install         := @INSTALL@
    55 export bash            := @_BASH@
    56 export grep            := @GREP@
    57 export make            := @MAKE@
    58 export sed             := @SED@
    59 export libtool         := @LIBTOOL@
    60 export libtoolize      := @LIBTOOLIZE@
    61 export objcopy         := @OBJCOPY@
    62 export objdump         := @OBJDUMP@
    63 export readelf         := @READELF@
    64 export patch           := @PATCH@
    65 export CC              := @CC@
    66 export CPP             := @CPP@
    67 export CPPFLAGS        := @CPPFLAGS@
    68 export CFLAGS          := @CFLAGS@
    69 export LDFLAGS         := @LDFLAGS@
    70 export LIBS            := @LIBS@
    71 export curses_hdr      := @ac_ct_curses_hdr@
    72 export gettext         := @gettext@
    73 
    74 # config options to push down to kconfig
    75 KCONFIG:= @kconfig_options@
    76 
    77 ###############################################################################
    78 # Non-configure variables
    79 MAN_SECTION := 1
    80 MAN_SUBDIR := /man$(MAN_SECTION)
    81 
    82 PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' )
    83 
    84 ###############################################################################
    85 # Sanity checks
    86 
    87 # Check if Makefile is up to date:
    88 Makefile: Makefile.in
    89 	@echo "$< did changed: you must re-run './configure'"
    90 	@false
    91 
    92 # If installing with DESTDIR, check it's an absolute path
    93 ifneq ($(strip $(DESTDIR)),)
    94   ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
    95     $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
    96   endif
    97 endif
    98 
    99 ###############################################################################
   100 # Global make rules
   101 
   102 # If any extra MAKEFLAGS were added, re-run ourselves
   103 # See top of file for an explanation of why this is needed...
   104 ifneq ($(strip $(CT_MAKEFLAGS)),)
   105 
   106 # Somehow, the new auto-completion for make in the recent distributions
   107 # trigger a behavior where our Makefile calls itself recursively, in a
   108 # never-ending loop (except on lack of ressources, swap, PIDs...)
   109 # Avoid this situation by cutting the recursion short at the first
   110 # level.
   111 # This has the side effect of only showing the real targets, and hiding our
   112 # internal ones. :-)
   113 ifneq ($(MAKELEVEL),0)
   114 $(error Recursion detected, bailing out...)
   115 endif
   116 
   117 MAKEFLAGS += $(CT_MAKEFLAGS)
   118 build install clean distclean mrproper uninstall:
   119 	@$(MAKE) $@
   120 
   121 else
   122 # There were no additional MAKEFLAGS to add, do the job
   123 
   124 TARGETS := bin lib lib-kconfig doc man
   125 
   126 build: $(patsubst %,build-%,$(TARGETS))
   127 
   128 install: build real-install
   129 
   130 clean: $(patsubst %,clean-%,$(TARGETS))
   131 
   132 distclean: clean
   133 	@echo "  RM     'Makefile'"
   134 	@rm -f Makefile
   135 
   136 mrproper: distclean
   137 	@echo "  RM     'autostuff'"
   138 	@ rm -rf autom4te.cache config.log config.status configure
   139 
   140 uninstall: real-uninstall
   141 
   142 ###############################################################################
   143 # Specific make rules
   144 
   145 #--------------------------------------
   146 # Build rules
   147 
   148 build-bin: $(PROG_NAME)             \
   149            scripts/crosstool-NG.sh  \
   150            scripts/saveSample.sh    \
   151            scripts/showTuple.sh
   152 	@chmod 755 $^
   153 
   154 build-lib: config/configure.in  \
   155            paths.mk             \
   156            paths.sh
   157 
   158 build-lib-kconfig:
   159 	@$(MAKE) -C kconfig
   160 
   161 build-doc:
   162 
   163 build-man: docs/$(PROG_NAME).1.gz
   164 
   165 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
   166 	@echo "  GZIP   '$@'"
   167 	@gzip -c9 $< >$@
   168 
   169 define sed_it
   170 	@echo "  SED    '$@'"
   171 	@$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;'        \
   172 	           -e 's,@@CT_LIBDIR@@,$(libdir),g;'        \
   173 	           -e 's,@@CT_DOCDIR@@,$(docdir),g;'        \
   174 	           -e 's,@@CT_MANDIR@@,$(mandir),g;'        \
   175 	           -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;'  \
   176 	           -e 's,@@CT_VERSION@@,$(VERSION),g;'	    \
   177 	           -e 's,@@CT_DATE@@,$(DATE),g;'            \
   178 	           -e 's,@@CT_make@@,$(make),g;'            \
   179 	           -e 's,@@CT_bash@@,$(bash),g;'            \
   180 	           $< >$@
   181 endef
   182 
   183 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
   184 	$(call sed_it)
   185 
   186 $(PROG_NAME): ct-ng.in Makefile
   187 	$(call sed_it)
   188 
   189 %: %.in Makefile
   190 	$(call sed_it)
   191 
   192 # We create a script fragment that is parseable from inside a Makefile,
   193 # and one from inside a shell script
   194 paths.mk: FORCE
   195 	@echo "  GEN    '$@'"
   196 	@(echo 'export install=$(install)';         \
   197 	  echo 'export bash=$(bash)';               \
   198 	  echo 'export grep=$(grep)';               \
   199 	  echo 'export make=$(make)';               \
   200 	  echo 'export sed=$(sed)';                 \
   201 	  echo 'export libtool=$(libtool)';         \
   202 	  echo 'export libtoolize=$(libtoolize)';   \
   203 	  echo 'export objcopy=$(objcopy)';         \
   204 	  echo 'export objdump=$(objdump)';         \
   205 	  echo 'export readelf=$(readelf)';         \
   206 	  echo 'export patch=$(patch)';             \
   207 	 ) >$@
   208 
   209 paths.sh: FORCE
   210 	@echo "  GEN    '$@'"
   211 	@(echo 'export install="$(install)"';       \
   212 	  echo 'export bash="$(bash)"';             \
   213 	  echo 'export grep="$(grep)"';             \
   214 	  echo 'export make="$(make)"';             \
   215 	  echo 'export sed="$(sed)"';               \
   216 	  echo 'export libtool="$(libtool)"';       \
   217 	  echo 'export libtoolize="$(libtoolize)"'; \
   218 	  echo 'export objcopy="$(objcopy)"';       \
   219 	  echo 'export objdump="$(objdump)"';       \
   220 	  echo 'export readelf="$(readelf)"';       \
   221 	  echo 'export patch="$(patch)"';           \
   222 	 ) >$@
   223 
   224 config/configure.in: FORCE
   225 	@echo "  GEN    '$@'"
   226 	@{  printf "# Generated file, do not edit\n";            \
   227 	    printf "# Default values as found by ./configure\n"; \
   228 	    for var in $(KCONFIG); do                            \
   229 	        printf "\n";                                     \
   230 	        printf "config CONFIGURE_$${var%%=*}\n";         \
   231 	        if [ "$${var#*=}" = "y" ]; then                  \
   232 	            printf "    def_bool y\n";                   \
   233 	        else                                             \
   234 	            printf "    bool\n";                         \
   235 	        fi;                                              \
   236 	    done;                                                \
   237 	 } >$@
   238 
   239 FORCE:
   240 
   241 #--------------------------------------
   242 # Clean rules
   243 
   244 clean-bin:
   245 	@echo "  RM     '$(PROG_NAME)'"
   246 	@rm -f $(PROG_NAME)
   247 	@echo "  RM     'scripts/crosstool-NG.sh'"
   248 	@rm -f scripts/crosstool-NG.sh
   249 	@echo "  RM     'scripts/saveSample.sh'"
   250 	@rm -f scripts/saveSample.sh
   251 	@echo "  RM     'scripts/showTuple.sh'"
   252 	@rm -f scripts/showTuple.sh
   253 
   254 clean-lib:
   255 	@echo "  RM     'paths'"
   256 	@rm -f paths.mk paths.sh
   257 	@echo "  RM     'config/configure.in'"
   258 	@rm -f config/configure.in
   259 
   260 clean-lib-kconfig:
   261 	@$(MAKE) -C kconfig clean
   262 
   263 clean-doc:
   264 
   265 clean-man:
   266 	@echo "  RM     'docs/$(PROG_NAME).1'"
   267 	@rm -f docs/$(PROG_NAME).1
   268 	@echo "  RM     'docs/$(PROG_NAME).1.gz'"
   269 	@rm -f docs/$(PROG_NAME).1.gz
   270 
   271 #--------------------------------------
   272 # Check for --local setup
   273 
   274 ifeq ($(strip $(LOCAL)),yes)
   275 
   276 real-install:
   277 	@true
   278 
   279 real-uninstall:
   280 	@true
   281 
   282 else
   283 
   284 #--------------------------------------
   285 # Install rules
   286 
   287 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
   288 
   289 install-bin: $(DESTDIR)$(bindir)
   290 	@echo "  INST    '$(PROG_NAME)'"
   291 	@$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
   292 
   293 # If one is hacking crosstool-NG, the patch set might change between any two
   294 # installations of the same VERSION, thus the patches must be removed prior
   295 # to being installed. It is simpler to remove the whole lib/ directory, as it
   296 # is the goal of the install-lib rule to install the lib/ directory...
   297 install-lib: uninstall-lib          \
   298              $(DESTDIR)$(libdir)    \
   299              install-lib-main       \
   300              install-lib-samples
   301 
   302 LIB_SUB_DIR := config contrib patches scripts
   303 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
   304 	@echo "  INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
   305 	@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
   306 	 |(cd "$(DESTDIR)$(libdir)"; tar xf -)
   307 
   308 # Huh? It seems we need at least one command to make this rule kick-in.
   309 install-lib-%: install-lib-%-copy; @true
   310 
   311 # Huh? that one does not inherit the -opy dependency, above...
   312 install-lib-scripts: install-lib-scripts-copy
   313 	@chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
   314 	@chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
   315 	@rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
   316 
   317 install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
   318 	@echo "  INST    'steps.mk'"
   319 	@$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
   320 	@echo "  INST    'paths'"
   321 	@$(install) -m 644 paths.mk paths.sh "$(DESTDIR)$(libdir)"
   322 
   323 # Samples need a little love:
   324 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   325 install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
   326 	@echo "  INSTDIR 'samples/'"
   327 	@for samp_dir in samples/*/; do                                         \
   328 	     mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}";                       \
   329 	     $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;'             \
   330 	               -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;'   \
   331 	            $${samp_dir}/crosstool.config                               \
   332 	            >"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config";       \
   333 	     $(install) -m 644 "$${samp_dir}/reported.by"                       \
   334 	                       "$(DESTDIR)$(libdir)/$${samp_dir}";              \
   335 	     for libc_cfg in "$${samp_dir}/"*libc*.config; do                   \
   336 	         [ -f "$${libc_cfg}" ] || continue;                             \
   337 	         $(install) -m 644 "$${libc_cfg}"                               \
   338 	                           "$(DESTDIR)$(libdir)/$${samp_dir}";          \
   339 	     done;                                                              \
   340 	 done
   341 	@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
   342 
   343 KCONFIG_FILES := conf mconf nconf kconfig.mk
   344 install-lib-kconfig: $(DESTDIR)$(libdir) install-lib-main
   345 	@echo "  INST    'kconfig/'"
   346 	@for f in $(KCONFIG_FILES); do                                      \
   347 	    install -D "kconfig/$${f}" "$(DESTDIR)$(libdir)/kconfig/$${f}"; \
   348 	 done
   349 
   350 install-doc: $(DESTDIR)$(docdir)
   351 	@echo "  INST    'docs/*.txt'"
   352 	@for doc_file in docs/*.txt; do                              \
   353 	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
   354 	 done
   355 
   356 install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
   357 	@echo "  INST    '$(PROG_NAME).1.gz'"
   358 	@$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
   359 
   360 $(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
   361 	@echo "  MKDIR   '$@/'"
   362 	@$(install) -m 755 -d "$@"
   363 
   364 install-post:
   365 	@echo
   366 	@echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
   367 	@echo "your bash completion directory (usually /etc/bash_completion.d)"
   368 
   369 #--------------------------------------
   370 # Uninstall rules
   371 
   372 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
   373 
   374 uninstall-bin:
   375 	@echo "  RM      '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
   376 	@rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
   377 
   378 uninstall-lib:
   379 	@echo "  RMDIR   '$(DESTDIR)$(libdir)/'"
   380 	@rm -rf "$(DESTDIR)$(libdir)"
   381 
   382 uninstall-doc:
   383 	@echo "  RMDIR   '$(DESTDIR)$(docdir)/'"
   384 	@rm -rf "$(DESTDIR)$(docdir)"
   385 
   386 uninstall-man:
   387 	@echo "  RM      '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
   388 	@rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
   389 
   390 endif # Not --local
   391 
   392 endif # No extra MAKEFLAGS were added
   393 
   394 .PHONY: build $(patsubst %,build-%,$(TARGETS)) install