Makefile.in
author "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Tue May 31 20:12:35 2011 +0200 (2011-05-31)
changeset 2487 481cd34691f0
parent 2424 28092887b486
child 2505 f87f02b00cc7
permissions -rw-r--r--
gcc: promote PKGVERSION and BUGURL options to toolchain level

This patch promotes the PKGVERSION and BUGURL options to toolchain level so that
all toolchain components supporting them can benefit from them.

These options are passed to configure through --with-pkgversion and
--with-bugurl.

They are supported by binutils 2.18+, gcc 4.3+, eglibc 2.9+ and gdb 7.0+.

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