Makefile.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Apr 20 21:10:03 2009 +0000 (2009-04-20)
changeset 1299 3448ac3f1a5d
parent 1297 7439f29a0476
child 1336 bc8b9381f637
permissions -rw-r--r--
There's no longer any reason to require GNU awk:
- the only part that required it (socks proxy settings) is gone,
- all remaining awk scripts are POSIXly correct (or should be).

-------- diffstat follows --------
/trunk/configure | 5 2 3 0 ++---
/trunk/Makefile.in | 2 0 2 0 --
/trunk/scripts/build/kernel/linux.sh | 2 1 1 0 +-
/trunk/scripts/build/internals.sh | 1 0 1 0 -
/trunk/scripts/build/mpfr.sh | 2 1 1 0 +-
/trunk/scripts/functions | 4 2 2 0 ++--
/trunk/scripts/saveSample.sh.in | 4 2 2 0 ++--
7 files changed, 8 insertions(+), 12 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 sed    := @@sed@@
    55 
    56 ###############################################################################
    57 # Sanity checks
    58 
    59 # Check if Makefile is up to date:
    60 Makefile: Makefile.in
    61 	@echo "$< did changed: you must re-run './configure'"
    62 	@false
    63 
    64 # If installing with DESTDIR, check it's an absolute path
    65 ifneq ($(strip $(DESTDIR)),)
    66   ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
    67     $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
    68   endif
    69 endif
    70 
    71 ###############################################################################
    72 # Global make rules
    73 
    74 # If any extra MAKEFLAGS were added, re-run ourselves
    75 # See top of file for an explanation of why this is needed...
    76 ifneq ($(strip $(CT_MAKEFLAGS)),)
    77 
    78 MAKEFLAGS += $(CT_MAKEFLAGS)
    79 build install clean distclean uninstall:
    80 	@$(MAKE) $@
    81 
    82 else
    83 # There were no additional MAKEFLAGS to add, do the job
    84 
    85 TARGETS := bin lib doc man
    86 
    87 build: $(patsubst %,build-%,$(TARGETS))
    88 
    89 install: build real-install
    90 
    91 clean: $(patsubst %,clean-%,$(TARGETS))
    92 
    93 distclean: clean
    94 	@echo "  RM     'Makefile'"
    95 	@rm -f Makefile
    96 
    97 uninstall: real-uninstall
    98 
    99 ###############################################################################
   100 # Specific make rules
   101 
   102 #--------------------------------------
   103 # Build rules
   104 
   105 build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh
   106 	@chmod 755 $^
   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 sed=$(sed)";         \
   142 	 ) >paths.mk
   143 
   144 #--------------------------------------
   145 # Clean rules
   146 
   147 clean-bin:
   148 	@echo "  RM     'ct-ng'"
   149 	@rm -f ct-ng
   150 	@echo "  RM     'script/crosstool-NG.sh'"
   151 	@rm -f scripts/crosstool-NG.sh
   152 	@echo "  RM     'script/saveSample.sh'"
   153 	@rm -f scripts/saveSample.sh
   154 
   155 clean-lib:
   156 	@echo "  RM     'paths.mk'"
   157 	@rm -f paths.mk
   158 
   159 clean-doc:
   160 
   161 clean-man:
   162 	@echo "  RM     'docs/ct-ng.1'"
   163 	@rm -f docs/ct-ng.1
   164 	@echo "  RM     'docs/ct-ng.1.gz'"
   165 	@rm -f docs/ct-ng.1.gz
   166 
   167 #--------------------------------------
   168 # Check for --local setup
   169 
   170 ifeq ($(strip $(LOCAL)),y)
   171 
   172 real-install:
   173 	@true
   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 --exclude='*.sh.in' $${src_dir}    \
   199 	     |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -);                     \
   200 	 done
   201 	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
   202 	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
   203 	@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
   204 	@echo "  INST   'steps.mk'"
   205 	@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
   206 	@echo "  INST   'paths.mk'"
   207 	@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
   208 
   209 # Samples need a little love:
   210 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   211 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
   212 	@echo "  INST   'samples/'"
   213 	@tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
   214 	@for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do                    \
   215 	     $(sed) -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file};           \
   216 	     $(sed) -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file}; \
   217 	 done
   218 
   219 install-doc: $(DESTDIR)$(DOCDIR)
   220 	@for doc_file in docs/CREDITS docs/overview.txt; do             \
   221 	     echo "  INST   '$${doc_file}'";                            \
   222 	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
   223 	 done
   224 
   225 install-man: $(DESTDIR)$(MANDIR)
   226 	@echo "  INST   'ct-ng.1.gz'"
   227 	@$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
   228 
   229 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
   230 	@echo "  MKDIR  '$@'"
   231 	@$(install) -m 755 -d "$@"
   232 
   233 
   234 #--------------------------------------
   235 # Uninstall rules
   236 
   237 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
   238 
   239 uninstall-bin:
   240 	@echo "  RM     '$(DESTDIR)$(BINDIR)/ct-ng'"
   241 	@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
   242 
   243 uninstall-lib:
   244 	@echo "  RMDIR  '$(DESTDIR)$(LIBDIR)/'"
   245 	@rm -rf "$(DESTDIR)$(LIBDIR)"
   246 
   247 uninstall-doc:
   248 	@echo "  RMDIR  '$(DESTDIR)$(DOCDIR)/'"
   249 	@rm -rf "$(DESTDIR)$(DOCDIR)"
   250 
   251 uninstall-man:
   252 	@echo "  RM     '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
   253 	@rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}
   254 
   255 endif # Not --local
   256 
   257 endif # No extra MAKEFLAGS were added