Makefile.in
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Fri Jan 13 12:24:55 2012 +0100 (2012-01-13)
changeset 2837 db26e387b70b
parent 2834 0a0410dd0cb0
child 2838 822af73497bf
permissions -rw-r--r--
cc/gcc: update Linaro GCC revisions to 2012.01

Update Linaro GCC with the latest available revisions.

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            := @EGREP@
    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: paths.mk             \
   155            config/configure.in
   156 
   157 build-lib-kconfig:
   158 	@$(MAKE) -C kconfig
   159 
   160 build-doc:
   161 
   162 build-man: docs/$(PROG_NAME).1.gz
   163 
   164 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
   165 	@echo "  GZIP   '$@'"
   166 	@gzip -c9 $< >$@
   167 
   168 define sed_it
   169 	@echo "  SED    '$@'"
   170 	@$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;'        \
   171 	           -e 's,@@CT_LIBDIR@@,$(libdir),g;'        \
   172 	           -e 's,@@CT_DOCDIR@@,$(docdir),g;'        \
   173 	           -e 's,@@CT_MANDIR@@,$(mandir),g;'        \
   174 	           -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;'  \
   175 	           -e 's,@@CT_VERSION@@,$(VERSION),g;'	    \
   176 	           -e 's,@@CT_DATE@@,$(DATE),g;'            \
   177 	           -e 's,@@CT_make@@,$(make),g;'            \
   178 	           -e 's,@@CT_bash@@,$(bash),g;'            \
   179 	           $< >$@
   180 endef
   181 
   182 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
   183 	$(call sed_it)
   184 
   185 $(PROG_NAME): ct-ng.in Makefile
   186 	$(call sed_it)
   187 
   188 %: %.in Makefile
   189 	$(call sed_it)
   190 
   191 # We create a script fragment that is parseable from inside a Makefile,
   192 # but also from inside a shell script, hence the reason why we don't
   193 # use := to set variables, although that will incur a (very small)
   194 # penalty from the Makefile that includes it (due to re-evaluation at
   195 # each call).
   196 paths.mk: FORCE
   197 	@echo "  GEN    '$@'"
   198 	@(echo "export install=$(install)"; \
   199 	  echo "export bash=$(bash)";       \
   200 	  echo "export grep=$(grep)";       \
   201 	  echo "export make=$(make)";       \
   202 	  echo "export sed=$(sed)";         \
   203 	  echo "export libtool=$(libtool)"; \
   204 	  echo "export libtoolize=$(libtoolize)"; \
   205 	  echo "export objcopy=$(objcopy)"; \
   206 	  echo "export objdump=$(objdump)"; \
   207 	  echo "export readelf=$(readelf)"; \
   208 	  echo "export patch=$(patch)";     \
   209 	 ) >paths.mk
   210 
   211 config/configure.in: FORCE
   212 	@echo "  GEN    '$@'"
   213 	@{  printf "# Generated file, do not edit\n";            \
   214 	    printf "# Default values as found by ./configure\n"; \
   215 	    for var in $(KCONFIG); do                            \
   216 	        printf "\n";                                     \
   217 	        printf "config CONFIGURE_$${var%%=*}\n";         \
   218 	        if [ "$${var#*=}" = "y" ]; then                  \
   219 	            printf "    def_bool y\n";                   \
   220 	        else                                             \
   221 	            printf "    bool\n";                         \
   222 	        fi;                                              \
   223 	    done;                                                \
   224 	 } >$@
   225 
   226 FORCE:
   227 
   228 #--------------------------------------
   229 # Clean rules
   230 
   231 clean-bin:
   232 	@echo "  RM     '$(PROG_NAME)'"
   233 	@rm -f $(PROG_NAME)
   234 	@echo "  RM     'scripts/crosstool-NG.sh'"
   235 	@rm -f scripts/crosstool-NG.sh
   236 	@echo "  RM     'scripts/saveSample.sh'"
   237 	@rm -f scripts/saveSample.sh
   238 	@echo "  RM     'scripts/showTuple.sh'"
   239 	@rm -f scripts/showTuple.sh
   240 
   241 clean-lib:
   242 	@echo "  RM     'paths.mk'"
   243 	@rm -f paths.mk
   244 	@echo "  RM     'config/configure.in'"
   245 	@rm -f config/configure.in
   246 
   247 clean-lib-kconfig:
   248 	@$(MAKE) -C kconfig clean
   249 
   250 clean-doc:
   251 
   252 clean-man:
   253 	@echo "  RM     'docs/$(PROG_NAME).1'"
   254 	@rm -f docs/$(PROG_NAME).1
   255 	@echo "  RM     'docs/$(PROG_NAME).1.gz'"
   256 	@rm -f docs/$(PROG_NAME).1.gz
   257 
   258 #--------------------------------------
   259 # Check for --local setup
   260 
   261 ifeq ($(strip $(LOCAL)),yes)
   262 
   263 real-install:
   264 	@true
   265 
   266 real-uninstall:
   267 	@true
   268 
   269 else
   270 
   271 #--------------------------------------
   272 # Install rules
   273 
   274 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
   275 
   276 install-bin: $(DESTDIR)$(bindir)
   277 	@echo "  INST    '$(PROG_NAME)'"
   278 	@$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
   279 
   280 # If one is hacking crosstool-NG, the patch set might change between any two
   281 # installations of the same VERSION, thus the patches must be removed prior
   282 # to being installed. It is simpler to remove the whole lib/ directory, as it
   283 # is the goal of the install-lib rule to install the lib/ directory...
   284 install-lib: uninstall-lib          \
   285              $(DESTDIR)$(libdir)    \
   286              install-lib-main       \
   287              install-lib-samples
   288 
   289 LIB_SUB_DIR := config contrib patches scripts
   290 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
   291 	@echo "  INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
   292 	@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
   293 	 |(cd "$(DESTDIR)$(libdir)"; tar xf -)
   294 
   295 # Huh? It seems we need at least one command to make this rule kick-in.
   296 install-lib-%: install-lib-%-copy; @true
   297 
   298 # Huh? that one does not inherit the -opy dependency, above...
   299 install-lib-scripts: install-lib-scripts-copy
   300 	@chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
   301 	@chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
   302 	@rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
   303 
   304 install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
   305 	@echo "  INST    'steps.mk'"
   306 	@$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
   307 	@echo "  INST    'paths.mk'"
   308 	@$(install) -m 644 paths.mk "$(DESTDIR)$(libdir)/paths.mk"
   309 
   310 # Samples need a little love:
   311 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   312 install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
   313 	@echo "  INSTDIR 'samples/'"
   314 	@for samp_dir in samples/*/; do                                         \
   315 	     mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}";                       \
   316 	     $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;'             \
   317 	               -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;'   \
   318 	            $${samp_dir}/crosstool.config                               \
   319 	            >"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config";       \
   320 	     $(install) -m 644 "$${samp_dir}/reported.by"                       \
   321 	                       "$(DESTDIR)$(libdir)/$${samp_dir}";              \
   322 	     for libc_cfg in "$${samp_dir}/"*libc*.config; do                   \
   323 	         [ -f "$${libc_cfg}" ] || continue;                             \
   324 	         $(install) -m 644 "$${libc_cfg}"                               \
   325 	                           "$(DESTDIR)$(libdir)/$${samp_dir}";          \
   326 	     done;                                                              \
   327 	 done
   328 	@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
   329 
   330 KCONFIG_FILES := conf mconf nconf kconfig.mk
   331 install-lib-kconfig: $(DESTDIR)$(libdir) install-lib-main
   332 	@echo "  INST    'kconfig/'"
   333 	@for f in $(KCONFIG_FILES); do                                      \
   334 	    install -D "kconfig/$${f}" "$(DESTDIR)$(libdir)/kconfig/$${f}"; \
   335 	 done
   336 
   337 install-doc: $(DESTDIR)$(docdir)
   338 	@echo "  INST    'docs/*.txt'"
   339 	@for doc_file in docs/*.txt; do                              \
   340 	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
   341 	 done
   342 
   343 install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
   344 	@echo "  INST    '$(PROG_NAME).1.gz'"
   345 	@$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
   346 
   347 $(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
   348 	@echo "  MKDIR   '$@/'"
   349 	@$(install) -m 755 -d "$@"
   350 
   351 install-post:
   352 	@echo
   353 	@echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
   354 	@echo "your bash completion directory (usually /etc/bash_completion.d)"
   355 
   356 #--------------------------------------
   357 # Uninstall rules
   358 
   359 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
   360 
   361 uninstall-bin:
   362 	@echo "  RM      '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
   363 	@rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
   364 
   365 uninstall-lib:
   366 	@echo "  RMDIR   '$(DESTDIR)$(libdir)/'"
   367 	@rm -rf "$(DESTDIR)$(libdir)"
   368 
   369 uninstall-doc:
   370 	@echo "  RMDIR   '$(DESTDIR)$(docdir)/'"
   371 	@rm -rf "$(DESTDIR)$(docdir)"
   372 
   373 uninstall-man:
   374 	@echo "  RM      '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
   375 	@rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
   376 
   377 endif # Not --local
   378 
   379 endif # No extra MAKEFLAGS were added
   380 
   381 .PHONY: build $(patsubst %,build-%,$(TARGETS)) install