Makefile.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Aug 02 18:28:10 2011 +0200 (2011-08-02)
changeset 2590 b64cfb67944e
parent 2505 f87f02b00cc7
child 2620 d9c5b3b75864
child 2637 97cc0c987a1a
permissions -rw-r--r--
scripts/functions: svn retrieval first tries the mirror for tarballs

The svn download helper looks for the local tarballs dir to see if it
can find a pre-downloaded tarball, and if it does not find it, does
the actual fetch to upstream via svn.

In the process, it does not even try to get a tarball from the local
mirror, which can be useful if the mirror has been pre-populated
manually (or with a previously downloaded tree).

Fake a tarball get with the standard tarball-download helper, but
without specifying any upstream URL, which makes the helper directly
try the LAN mirror.

Of course, if no mirror is specified, no URL wil be available, and
the standard svn retrieval will kick in.

Reported-by: ANDY KENNEDY <ANDY.KENNEDY@adtran.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     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 # Somehow, the new auto-completion for make in the recent distributions
    92 # trigger a behavior where our Makefile calls itself recursively, in a
    93 # never-ending loop (except on lack of ressources, swap, PIDs...)
    94 # Avoid this situation by cutting the recursion short at the first
    95 # level.
    96 # This has the side effect of only showing the real targets, and hiding our
    97 # internal ones. :-)
    98 ifneq ($(MAKELEVEL),0)
    99 $(error Recursion detected, bailing out...)
   100 endif
   101 
   102 MAKEFLAGS += $(CT_MAKEFLAGS)
   103 build install clean distclean uninstall:
   104 	@$(MAKE) $@
   105 
   106 else
   107 # There were no additional MAKEFLAGS to add, do the job
   108 
   109 TARGETS := bin lib doc man
   110 
   111 build: $(patsubst %,build-%,$(TARGETS))
   112 
   113 install: build real-install
   114 
   115 clean: $(patsubst %,clean-%,$(TARGETS))
   116 
   117 distclean: clean
   118 	@echo "  RM     'Makefile'"
   119 	@rm -f Makefile
   120 
   121 uninstall: real-uninstall
   122 
   123 ###############################################################################
   124 # Specific make rules
   125 
   126 #--------------------------------------
   127 # Build rules
   128 
   129 build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh
   130 	@chmod 755 $^
   131 
   132 build-lib: paths.mk config/configure.in
   133 
   134 build-doc:
   135 
   136 build-man: docs/ct-ng.1.gz
   137 
   138 docs/ct-ng.1.gz: docs/ct-ng.1
   139 	@echo "  GZIP   '$@'"
   140 	@gzip -c9 $< >$@
   141 
   142 %: %.in Makefile
   143 	@echo "  SED    '$@'"
   144 	@$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;'    \
   145 	           -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;'    \
   146 	           -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;'    \
   147 	           -e 's,@@CT_MANDIR@@,$(MANDIR),g;'    \
   148 	           -e 's,@@CT_VERSION@@,$(VERSION),g;'	\
   149 	           -e 's,@@CT_DATE@@,$(DATE),g;'        \
   150 	           -e 's,@@CT_make@@,$(make),g;'        \
   151 	           -e 's,@@CT_bash@@,$(bash),g;'        \
   152 	           $@.in >$@
   153 
   154 # We create a script fragment that is parseable from inside a Makefile,
   155 # but also from inside a shell script, hence the reason why we don't
   156 # use := to set variables, although that will incur a (very small)
   157 # penalty from the Makefile that includes it (due to re-evaluation at
   158 # each call).
   159 paths.mk: FORCE
   160 	@echo "  GEN    '$@'"
   161 	@(echo "export install=$(install)"; \
   162 	  echo "export bash=$(bash)";       \
   163 	  echo "export grep=$(grep)";       \
   164 	  echo "export make=$(make)";       \
   165 	  echo "export sed=$(sed)";         \
   166 	  echo "export libtool=$(libtool)"; \
   167 	  echo "export objcopy=$(objcopy)"; \
   168 	  echo "export objdump=$(objdump)"; \
   169 	  echo "export readelf=$(readelf)"; \
   170 	  echo "export patch=$(patch)";     \
   171 	 ) >paths.mk
   172 
   173 config/configure.in: FORCE
   174 	@echo "  GEN    '$@'"
   175 	@{  printf "# Generated file, do not edit\n";            \
   176 	    printf "# Default values as found by ./configure\n"; \
   177 	    for var in $(KCONFIG); do                            \
   178 	        printf "\n";                                     \
   179 	        printf "config CONFIGURE_$${var%%=*}\n";         \
   180 	        printf "    bool\n";                             \
   181 	        if [ "$${var#*=}" = "y" ]; then                  \
   182 	            printf "    default y\n";                    \
   183 	        fi;                                              \
   184 	    done;                                                \
   185 	 } >$@
   186 
   187 FORCE:
   188 
   189 #--------------------------------------
   190 # Clean rules
   191 
   192 clean-bin:
   193 	@echo "  RM     'ct-ng'"
   194 	@rm -f ct-ng
   195 	@echo "  RM     'scripts/crosstool-NG.sh'"
   196 	@rm -f scripts/crosstool-NG.sh
   197 	@echo "  RM     'scripts/saveSample.sh'"
   198 	@rm -f scripts/saveSample.sh
   199 	@echo "  RM     'scripts/showTuple.sh'"
   200 	@rm -f scripts/showTuple.sh
   201 
   202 clean-lib:
   203 	@echo "  RM     'paths.mk'"
   204 	@rm -f paths.mk
   205 	@echo "  RM     'config/configure.in'"
   206 	@rm -f config/configure.in
   207 
   208 clean-doc:
   209 
   210 clean-man:
   211 	@echo "  RM     'docs/ct-ng.1'"
   212 	@rm -f docs/ct-ng.1
   213 	@echo "  RM     'docs/ct-ng.1.gz'"
   214 	@rm -f docs/ct-ng.1.gz
   215 
   216 #--------------------------------------
   217 # Check for --local setup
   218 
   219 ifeq ($(strip $(LOCAL)),y)
   220 
   221 real-install:
   222 	@true
   223 
   224 real-uninstall:
   225 	@true
   226 
   227 else
   228 
   229 #--------------------------------------
   230 # Install rules
   231 
   232 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
   233 
   234 install-bin: $(DESTDIR)$(BINDIR)
   235 	@echo "  INST    'ct-ng'"
   236 	@$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
   237 
   238 # If one is hacking crosstool-NG, the patch set might change between any two
   239 # installations of the same VERSION, thus the patches must be removed prior
   240 # to being installed. It is simpler to remove the whole lib/ directory, as it
   241 # is the goal of the install-lib rule to install the lib/ directory...
   242 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
   243 
   244 LIB_SUB_DIR := config contrib kconfig patches scripts
   245 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(LIBDIR)
   246 	@echo "  INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
   247 	@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
   248 	 |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
   249 
   250 # Huh? It seems we need at least one command to make this rule kick-in.
   251 install-lib-%: install-lib-%-copy; @true
   252 
   253 # Huh? that one does not inherit the -opy dependency, above...
   254 install-lib-scripts: install-lib-scripts-copy
   255 	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
   256 	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
   257 	@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
   258 
   259 install-lib-main: $(DESTDIR)$(LIBDIR) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
   260 	@echo "  INST    'steps.mk'"
   261 	@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
   262 	@echo "  INST    'paths.mk'"
   263 	@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
   264 
   265 # Samples need a little love:
   266 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   267 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
   268 	@echo "  INSTDIR 'samples/'"
   269 	@for samp_dir in samples/*/; do                                         \
   270 	     mkdir -p "$(DESTDIR)$(LIBDIR)/$${samp_dir}";                       \
   271 	     $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;'             \
   272 	               -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;'   \
   273 	            $${samp_dir}/crosstool.config                               \
   274 	            >"$(DESTDIR)$(LIBDIR)/$${samp_dir}/crosstool.config";       \
   275 	     $(install) -m 644 "$${samp_dir}/reported.by"                       \
   276 	                       "$(DESTDIR)$(LIBDIR)/$${samp_dir}";              \
   277 	     for libc_cfg in "$${samp_dir}/"*libc*.config; do                   \
   278 	         [ -f "$${libc_cfg}" ] || continue;                             \
   279 	         $(install) -m 644 "$${libc_cfg}"                               \
   280 	                           "$(DESTDIR)$(LIBDIR)/$${samp_dir}";          \
   281 	     done;                                                              \
   282 	 done
   283 	@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(LIBDIR)/samples/samples.mk"
   284 
   285 install-doc: $(DESTDIR)$(DOCDIR)
   286 	@echo "  INST    'docs/*.txt'"
   287 	@for doc_file in docs/*.txt; do                              \
   288 	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
   289 	 done
   290 
   291 install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)
   292 	@echo "  INST    'ct-ng.1.gz'"
   293 	@$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)"
   294 
   295 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)):
   296 	@echo "  MKDIR   '$@/'"
   297 	@$(install) -m 755 -d "$@"
   298 
   299 install-post:
   300 	@echo
   301 	@echo "For auto-completion, do not forget to install 'ct-ng.comp' into"
   302 	@echo "your bash completion directory (usually /etc/bash_completion.d)"
   303 
   304 #--------------------------------------
   305 # Uninstall rules
   306 
   307 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
   308 
   309 uninstall-bin:
   310 	@echo "  RM      '$(DESTDIR)$(BINDIR)/ct-ng'"
   311 	@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
   312 
   313 uninstall-lib:
   314 	@echo "  RMDIR   '$(DESTDIR)$(LIBDIR)/'"
   315 	@rm -rf "$(DESTDIR)$(LIBDIR)"
   316 
   317 uninstall-doc:
   318 	@echo "  RMDIR   '$(DESTDIR)$(DOCDIR)/'"
   319 	@rm -rf "$(DESTDIR)$(DOCDIR)"
   320 
   321 uninstall-man:
   322 	@echo "  RM      '$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1.gz'"
   323 	@rm -f "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1"{,.gz}
   324 
   325 endif # Not --local
   326 
   327 endif # No extra MAKEFLAGS were added