Makefile.in
author Johannes Stezenbach <js@sig21.net>
Fri Jul 09 15:53:49 2010 +0200 (2010-07-09)
changeset 2012 aefc8799ef0c
parent 1993 6641889d5603
child 2026 a8a4d5c97738
permissions -rw-r--r--
binutils/binutils: add binutils-2.20.1

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