Makefile.in
author Zhenqiang Chen <zhenqiang.chen@linaro.org>
Fri Nov 18 11:32:50 2011 +0800 (2011-11-18)
branch1.13
changeset 2841 64fe22ca6e6f
parent 2631 32c6a336482d
child 2834 0a0410dd0cb0
permissions -rw-r--r--
cc/gcc: Apply CT_CC_GCC_DISABLE_PCH to do_cc_core.

Otherwise, users have to input --disable-libstdcxx-pch option
when building bare-metal CANADIAN C++ compiler.

Reviewed-by: Michael Hope
Signed-off-by: Zhenqiang Chen <zhenqiang.chen@linaro.org>
(transplanted from e3e1c9d45bddfbfb433ee9d583faf42fa31f50c0)
     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 VERSION:= @@VERSION@@
    42 BINDIR := @@BINDIR@@
    43 LIBDIR := @@LIBDIR@@
    44 DOCDIR := @@DOCDIR@@
    45 MANDIR := @@MANDIR@@
    46 PROG_PFX:=@@PROG_PFX@@
    47 PROG_SFX:=@@PROG_SFX@@
    48 PROG_SED:=@@PROG_SED@@
    49 DATE   := @@DATE@@
    50 LOCAL  := @@LOCAL@@
    51 
    52 # Paths found by ./configure
    53 install   := @@install@@
    54 bash      := @@bash@@
    55 grep      := @@grep@@
    56 make      := @@make@@
    57 sed       := @@sed@@
    58 libtool   := @@libtool@@
    59 libtoolize:= @@libtoolize@@
    60 objcopy   := @@objcopy@@
    61 objdump   := @@objdump@@
    62 readelf   := @@readelf@@
    63 patch     := @@patch@@
    64 
    65 # config options to push down to kconfig
    66 KCONFIG:= @@KCONFIG@@
    67 
    68 ###############################################################################
    69 # Non-configure variables
    70 MAN_SECTION := 1
    71 MAN_SUBDIR := /man$(MAN_SECTION)
    72 
    73 PROG_NAME := $(shell echo '$(PROG_PFX)ct-ng$(PROG_SFX)' |sed -e '$(PROG_SED)' )
    74 
    75 ###############################################################################
    76 # Sanity checks
    77 
    78 # Check if Makefile is up to date:
    79 Makefile: Makefile.in
    80 	@echo "$< did changed: you must re-run './configure'"
    81 	@false
    82 
    83 # If installing with DESTDIR, check it's an absolute path
    84 ifneq ($(strip $(DESTDIR)),)
    85   ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
    86     $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
    87   endif
    88 endif
    89 
    90 ###############################################################################
    91 # Global make rules
    92 
    93 # If any extra MAKEFLAGS were added, re-run ourselves
    94 # See top of file for an explanation of why this is needed...
    95 ifneq ($(strip $(CT_MAKEFLAGS)),)
    96 
    97 # Somehow, the new auto-completion for make in the recent distributions
    98 # trigger a behavior where our Makefile calls itself recursively, in a
    99 # never-ending loop (except on lack of ressources, swap, PIDs...)
   100 # Avoid this situation by cutting the recursion short at the first
   101 # level.
   102 # This has the side effect of only showing the real targets, and hiding our
   103 # internal ones. :-)
   104 ifneq ($(MAKELEVEL),0)
   105 $(error Recursion detected, bailing out...)
   106 endif
   107 
   108 MAKEFLAGS += $(CT_MAKEFLAGS)
   109 build install clean distclean uninstall:
   110 	@$(MAKE) $@
   111 
   112 else
   113 # There were no additional MAKEFLAGS to add, do the job
   114 
   115 TARGETS := bin lib doc man
   116 
   117 build: $(patsubst %,build-%,$(TARGETS))
   118 
   119 install: build real-install
   120 
   121 clean: $(patsubst %,clean-%,$(TARGETS))
   122 
   123 distclean: clean
   124 	@echo "  RM     'Makefile'"
   125 	@rm -f Makefile
   126 
   127 uninstall: real-uninstall
   128 
   129 ###############################################################################
   130 # Specific make rules
   131 
   132 #--------------------------------------
   133 # Build rules
   134 
   135 build-bin: $(PROG_NAME) scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh
   136 	@chmod 755 $^
   137 
   138 build-lib: paths.mk config/configure.in
   139 
   140 build-doc:
   141 
   142 build-man: docs/$(PROG_NAME).1.gz
   143 
   144 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
   145 	@echo "  GZIP   '$@'"
   146 	@gzip -c9 $< >$@
   147 
   148 define sed_it
   149 	@echo "  SED    '$@'"
   150 	@$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;'        \
   151 	           -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;'        \
   152 	           -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;'        \
   153 	           -e 's,@@CT_MANDIR@@,$(MANDIR),g;'        \
   154 	           -e 's,@@CT_PROG_PFX@@,$(PROG_PFX),g;'    \
   155 	           -e 's,@@CT_PROG_SFX@@,$(PROG_SFX),g;'    \
   156 	           -e 's,@@CT_PROG_SED@@,$(PROG_SED),g;'    \
   157 	           -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;'  \
   158 	           -e 's,@@CT_VERSION@@,$(VERSION),g;'	    \
   159 	           -e 's,@@CT_DATE@@,$(DATE),g;'            \
   160 	           -e 's,@@CT_make@@,$(make),g;'            \
   161 	           -e 's,@@CT_bash@@,$(bash),g;'            \
   162 	           $< >$@
   163 endef
   164 
   165 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
   166 	$(call sed_it)
   167 
   168 $(PROG_NAME): ct-ng.in Makefile
   169 	$(call sed_it)
   170 
   171 %: %.in Makefile
   172 	$(call sed_it)
   173 
   174 # We create a script fragment that is parseable from inside a Makefile,
   175 # but also from inside a shell script, hence the reason why we don't
   176 # use := to set variables, although that will incur a (very small)
   177 # penalty from the Makefile that includes it (due to re-evaluation at
   178 # each call).
   179 paths.mk: FORCE
   180 	@echo "  GEN    '$@'"
   181 	@(echo "export install=$(install)"; \
   182 	  echo "export bash=$(bash)";       \
   183 	  echo "export grep=$(grep)";       \
   184 	  echo "export make=$(make)";       \
   185 	  echo "export sed=$(sed)";         \
   186 	  echo "export libtool=$(libtool)"; \
   187 	  echo "export libtoolize=$(libtoolize)"; \
   188 	  echo "export objcopy=$(objcopy)"; \
   189 	  echo "export objdump=$(objdump)"; \
   190 	  echo "export readelf=$(readelf)"; \
   191 	  echo "export patch=$(patch)";     \
   192 	 ) >paths.mk
   193 
   194 config/configure.in: FORCE
   195 	@echo "  GEN    '$@'"
   196 	@{  printf "# Generated file, do not edit\n";            \
   197 	    printf "# Default values as found by ./configure\n"; \
   198 	    for var in $(KCONFIG); do                            \
   199 	        printf "\n";                                     \
   200 	        printf "config CONFIGURE_$${var%%=*}\n";         \
   201 	        if [ "$${var#*=}" = "y" ]; then                  \
   202 	            printf "    def_bool y\n";                   \
   203 	        else                                             \
   204 	            printf "    bool\n";                         \
   205 	        fi;                                              \
   206 	    done;                                                \
   207 	 } >$@
   208 
   209 FORCE:
   210 
   211 #--------------------------------------
   212 # Clean rules
   213 
   214 clean-bin:
   215 	@echo "  RM     '$(PROG_NAME)'"
   216 	@rm -f $(PROG_NAME)
   217 	@echo "  RM     'scripts/crosstool-NG.sh'"
   218 	@rm -f scripts/crosstool-NG.sh
   219 	@echo "  RM     'scripts/saveSample.sh'"
   220 	@rm -f scripts/saveSample.sh
   221 	@echo "  RM     'scripts/showTuple.sh'"
   222 	@rm -f scripts/showTuple.sh
   223 
   224 clean-lib:
   225 	@echo "  RM     'paths.mk'"
   226 	@rm -f paths.mk
   227 	@echo "  RM     'config/configure.in'"
   228 	@rm -f config/configure.in
   229 
   230 clean-doc:
   231 
   232 clean-man:
   233 	@echo "  RM     'docs/$(PROG_NAME).1'"
   234 	@rm -f docs/$(PROG_NAME).1
   235 	@echo "  RM     'docs/$(PROG_NAME).1.gz'"
   236 	@rm -f docs/$(PROG_NAME).1.gz
   237 
   238 #--------------------------------------
   239 # Check for --local setup
   240 
   241 ifeq ($(strip $(LOCAL)),y)
   242 
   243 real-install:
   244 	@true
   245 
   246 real-uninstall:
   247 	@true
   248 
   249 else
   250 
   251 #--------------------------------------
   252 # Install rules
   253 
   254 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
   255 
   256 install-bin: $(DESTDIR)$(BINDIR)
   257 	@echo "  INST    '$(PROG_NAME)'"
   258 	@$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(BINDIR)/$(PROG_NAME)"
   259 
   260 # If one is hacking crosstool-NG, the patch set might change between any two
   261 # installations of the same VERSION, thus the patches must be removed prior
   262 # to being installed. It is simpler to remove the whole lib/ directory, as it
   263 # is the goal of the install-lib rule to install the lib/ directory...
   264 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
   265 
   266 LIB_SUB_DIR := config contrib kconfig patches scripts
   267 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(LIBDIR)
   268 	@echo "  INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
   269 	@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
   270 	 |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
   271 
   272 # Huh? It seems we need at least one command to make this rule kick-in.
   273 install-lib-%: install-lib-%-copy; @true
   274 
   275 # Huh? that one does not inherit the -opy dependency, above...
   276 install-lib-scripts: install-lib-scripts-copy
   277 	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
   278 	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
   279 	@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
   280 
   281 install-lib-main: $(DESTDIR)$(LIBDIR) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
   282 	@echo "  INST    'steps.mk'"
   283 	@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
   284 	@echo "  INST    'paths.mk'"
   285 	@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
   286 
   287 # Samples need a little love:
   288 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   289 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
   290 	@echo "  INSTDIR 'samples/'"
   291 	@for samp_dir in samples/*/; do                                         \
   292 	     mkdir -p "$(DESTDIR)$(LIBDIR)/$${samp_dir}";                       \
   293 	     $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;'             \
   294 	               -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;'   \
   295 	            $${samp_dir}/crosstool.config                               \
   296 	            >"$(DESTDIR)$(LIBDIR)/$${samp_dir}/crosstool.config";       \
   297 	     $(install) -m 644 "$${samp_dir}/reported.by"                       \
   298 	                       "$(DESTDIR)$(LIBDIR)/$${samp_dir}";              \
   299 	     for libc_cfg in "$${samp_dir}/"*libc*.config; do                   \
   300 	         [ -f "$${libc_cfg}" ] || continue;                             \
   301 	         $(install) -m 644 "$${libc_cfg}"                               \
   302 	                           "$(DESTDIR)$(LIBDIR)/$${samp_dir}";          \
   303 	     done;                                                              \
   304 	 done
   305 	@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(LIBDIR)/samples/samples.mk"
   306 
   307 install-doc: $(DESTDIR)$(DOCDIR)
   308 	@echo "  INST    'docs/*.txt'"
   309 	@for doc_file in docs/*.txt; do                              \
   310 	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
   311 	 done
   312 
   313 install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)
   314 	@echo "  INST    '$(PROG_NAME).1.gz'"
   315 	@$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)"
   316 
   317 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)):
   318 	@echo "  MKDIR   '$@/'"
   319 	@$(install) -m 755 -d "$@"
   320 
   321 install-post:
   322 	@echo
   323 	@echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
   324 	@echo "your bash completion directory (usually /etc/bash_completion.d)"
   325 
   326 #--------------------------------------
   327 # Uninstall rules
   328 
   329 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
   330 
   331 uninstall-bin:
   332 	@echo "  RM      '$(DESTDIR)$(BINDIR)/$(PROG_NAME)'"
   333 	@rm -f "$(DESTDIR)$(BINDIR)/$(PROG_NAME)"
   334 
   335 uninstall-lib:
   336 	@echo "  RMDIR   '$(DESTDIR)$(LIBDIR)/'"
   337 	@rm -rf "$(DESTDIR)$(LIBDIR)"
   338 
   339 uninstall-doc:
   340 	@echo "  RMDIR   '$(DESTDIR)$(DOCDIR)/'"
   341 	@rm -rf "$(DESTDIR)$(DOCDIR)"
   342 
   343 uninstall-man:
   344 	@echo "  RM      '$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
   345 	@rm -f "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
   346 
   347 endif # Not --local
   348 
   349 endif # No extra MAKEFLAGS were added
   350 
   351 .PHONY: build $(patsubst %,build-%,$(TARGETS)) install