Makefile.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Jan 29 22:09:55 2009 +0000 (2009-01-29)
changeset 1176 8508ec77df4c
parent 1156 b8e4a98bbdf3
child 1184 a4e9bf8c9448
permissions -rw-r--r--
If compiling the Java frontend, we'll require a native gcj, but only in this case.

/trunk/scripts/crosstool-NG.sh.in | 8 7 1 0 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
     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 	@echo "  RM     'script/crosstool-NG.sh'"
   152 	@rm -f scripts/crosstool-NG.sh
   153 
   154 clean-lib:
   155 	@echo "  RM     'paths.mk'"
   156 	@rm -f paths.mk
   157 
   158 clean-doc:
   159 
   160 clean-man:
   161 	@echo "  RM     'docs/ct-ng.1'"
   162 	@rm -f docs/ct-ng.1
   163 	@echo "  RM     'docs/ct-ng.1.gz'"
   164 	@rm -f docs/ct-ng.1.gz
   165 
   166 #--------------------------------------
   167 # Check for --local setup
   168 
   169 ifeq ($(strip $(LOCAL)),1)
   170 
   171 real-install:
   172 	@echo "  CHMOD  'ct-ng'"
   173 	@chmod a+x ct-ng
   174 	@echo "  CHMOD  'scripts/crosstool-NG.sh'"
   175 	@chmod a+x scripts/crosstool-NG.sh
   176 
   177 real-uninstall:
   178 	@true
   179 
   180 else
   181 
   182 #--------------------------------------
   183 # Install rules
   184 
   185 real-install: $(patsubst %,install-%,$(TARGETS))
   186 
   187 install-bin: $(DESTDIR)$(BINDIR)
   188 	@echo "  INST   'ct-ng'"
   189 	@$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
   190 
   191 # If one is hacking crosstool-NG, the patch set might change between any two
   192 # installations of the same VERSION, thus the patches must be removed prior
   193 # to being installed. It is simpler to remove the whole lib/ directory, as it
   194 # is the goal of the install-lib rule to install the lib/ directory...
   195 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
   196 
   197 install-lib-main: $(DESTDIR)$(LIBDIR)
   198 	@for src_dir in config kconfig patches scripts; do                              \
   199 	     echo "  INST   '$${src_dir}/'";                                            \
   200 	     tar cf - --exclude=.svn $${src_dir} |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
   201 	 done
   202 	@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
   203 	@echo "  INST   'steps.mk'"
   204 	@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
   205 	@echo "  INST   'paths.mk'"
   206 	@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
   207 
   208 # Samples need a little love:
   209 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   210 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
   211 	@echo "  INST   'samples/'"
   212 	@tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
   213 	@for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do                    \
   214 	     $(sed) -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file};           \
   215 	     $(sed) -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file}; \
   216 	 done
   217 
   218 install-doc: $(DESTDIR)$(DOCDIR)
   219 	@for doc_file in docs/CREDITS docs/overview.txt; do             \
   220 	     echo "  INST   '$${doc_file}'";                            \
   221 	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
   222 	 done
   223 
   224 install-man: $(DESTDIR)$(MANDIR)
   225 	@echo "  INST   'ct-ng.1.gz'"
   226 	@$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
   227 
   228 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
   229 	@echo "  MKDIR  '$@'"
   230 	@$(install) -m 755 -d "$@"
   231 
   232 
   233 #--------------------------------------
   234 # Uninstall rules
   235 
   236 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
   237 
   238 uninstall-bin:
   239 	@echo "  RM     '$(DESTDIR)$(BINDIR)/ct-ng'"
   240 	@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
   241 
   242 uninstall-lib:
   243 	@echo "  RMDIR  '$(DESTDIR)$(LIBDIR)/'"
   244 	@rm -rf "$(DESTDIR)$(LIBDIR)"
   245 
   246 uninstall-doc:
   247 	@echo "  RMDIR  '$(DESTDIR)$(DOCDIR)/'"
   248 	@rm -rf "$(DESTDIR)$(DOCDIR)"
   249 
   250 uninstall-man:
   251 	@echo "  RM     '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
   252 	@rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}
   253 
   254 endif # Not --local
   255 
   256 endif # No extra MAKEFLAGS were added