Makefile.in
author Cody P Schafer <dev@codyps.com>
Sun May 11 23:31:54 2014 +0200 (2014-05-11)
changeset 3319 283cebef7061
parent 3223 58ca31386bfb
permissions -rw-r--r--
cc/gcc: add 4.9.0

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