Makefile.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 26 22:43:08 2009 +0000 (2009-01-26)
changeset 1156 b8e4a98bbdf3
parent 1154 0f15f05af399
child 1158 4e0970ec62a0
permissions -rw-r--r--
Finally used the discovered paths from ./configure in scripts/crosstool-NG.sh:
- fix Makefile to really, really not used built-in rules and variables
- have scripts/crosstool-NG.sh generated from scripts/crosstool-NG.sh.in
- create a bin-overide directory ( in ${CT_WORK_DIR}/bin ) that contains shell wrappers to the actual discovered tools

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