Makefile.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Nov 07 22:28:40 2011 +0100 (2011-11-07)
changeset 2834 0a0410dd0cb0
parent 2694 2c01a02334ea
child 2835 0a2fa748727e
permissions -rw-r--r--
configure: use autoconf to generate configure

Create configure.ac, an autoconf script to generate ./configure
This will be needed by a subsequent patch to properly handle
--build and --host, and more tests, when the kconfig stuff will
be installed pre-built.

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 # Stuff found by ./configure
    42 DATE            := @DATE@
    43 LOCAL           := @enable_local@
    44 PROG_SED        := @program_transform_name@
    45 PACKAGE_TARNAME := @PACKAGE_TARNAME@
    46 VERSION         := @PACKAGE_VERSION@
    47 prefix          := @prefix@
    48 exec_prefix     := @exec_prefix@
    49 bindir          := @bindir@
    50 libdir          := @libdir@@sublibdir@
    51 docdir          := @docdir@@subdocdir@
    52 datarootdir     := @datarootdir@
    53 mandir          := @mandir@
    54 install         := @INSTALL@
    55 bash            := @_BASH@
    56 grep            := @EGREP@
    57 make            := @MAKE@
    58 sed             := @SED@
    59 libtool         := @LIBTOOL@
    60 libtoolize      := @LIBTOOLIZE@
    61 objcopy         := @OBJCOPY@
    62 objdump         := @OBJDUMP@
    63 readelf         := @READELF@
    64 patch           := @PATCH@
    65 
    66 # config options to push down to kconfig
    67 KCONFIG:= @kconfig_options@
    68 
    69 ###############################################################################
    70 # Non-configure variables
    71 MAN_SECTION := 1
    72 MAN_SUBDIR := /man$(MAN_SECTION)
    73 
    74 PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' )
    75 
    76 ###############################################################################
    77 # Sanity checks
    78 
    79 # Check if Makefile is up to date:
    80 Makefile: Makefile.in
    81 	@echo "$< did changed: you must re-run './configure'"
    82 	@false
    83 
    84 # If installing with DESTDIR, check it's an absolute path
    85 ifneq ($(strip $(DESTDIR)),)
    86   ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
    87     $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
    88   endif
    89 endif
    90 
    91 ###############################################################################
    92 # Global make rules
    93 
    94 # If any extra MAKEFLAGS were added, re-run ourselves
    95 # See top of file for an explanation of why this is needed...
    96 ifneq ($(strip $(CT_MAKEFLAGS)),)
    97 
    98 # Somehow, the new auto-completion for make in the recent distributions
    99 # trigger a behavior where our Makefile calls itself recursively, in a
   100 # never-ending loop (except on lack of ressources, swap, PIDs...)
   101 # Avoid this situation by cutting the recursion short at the first
   102 # level.
   103 # This has the side effect of only showing the real targets, and hiding our
   104 # internal ones. :-)
   105 ifneq ($(MAKELEVEL),0)
   106 $(error Recursion detected, bailing out...)
   107 endif
   108 
   109 MAKEFLAGS += $(CT_MAKEFLAGS)
   110 build install clean distclean mrproper uninstall:
   111 	@$(MAKE) $@
   112 
   113 else
   114 # There were no additional MAKEFLAGS to add, do the job
   115 
   116 TARGETS := bin lib doc man
   117 
   118 build: $(patsubst %,build-%,$(TARGETS))
   119 
   120 install: build real-install
   121 
   122 clean: $(patsubst %,clean-%,$(TARGETS))
   123 
   124 distclean: clean
   125 	@echo "  RM     'Makefile'"
   126 	@rm -f Makefile
   127 
   128 mrproper: distclean
   129 	@echo "  RM     'autostuff'"
   130 	@ rm -rf autom4te.cache config.log config.status configure
   131 
   132 uninstall: real-uninstall
   133 
   134 ###############################################################################
   135 # Specific make rules
   136 
   137 #--------------------------------------
   138 # Build rules
   139 
   140 build-bin: $(PROG_NAME) scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh
   141 	@chmod 755 $^
   142 
   143 build-lib: paths.mk config/configure.in
   144 
   145 build-doc:
   146 
   147 build-man: docs/$(PROG_NAME).1.gz
   148 
   149 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
   150 	@echo "  GZIP   '$@'"
   151 	@gzip -c9 $< >$@
   152 
   153 define sed_it
   154 	@echo "  SED    '$@'"
   155 	@$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;'        \
   156 	           -e 's,@@CT_LIBDIR@@,$(libdir),g;'        \
   157 	           -e 's,@@CT_DOCDIR@@,$(docdir),g;'        \
   158 	           -e 's,@@CT_MANDIR@@,$(mandir),g;'        \
   159 	           -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;'  \
   160 	           -e 's,@@CT_VERSION@@,$(VERSION),g;'	    \
   161 	           -e 's,@@CT_DATE@@,$(DATE),g;'            \
   162 	           -e 's,@@CT_make@@,$(make),g;'            \
   163 	           -e 's,@@CT_bash@@,$(bash),g;'            \
   164 	           $< >$@
   165 endef
   166 
   167 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
   168 	$(call sed_it)
   169 
   170 $(PROG_NAME): ct-ng.in Makefile
   171 	$(call sed_it)
   172 
   173 %: %.in Makefile
   174 	$(call sed_it)
   175 
   176 # We create a script fragment that is parseable from inside a Makefile,
   177 # but also from inside a shell script, hence the reason why we don't
   178 # use := to set variables, although that will incur a (very small)
   179 # penalty from the Makefile that includes it (due to re-evaluation at
   180 # each call).
   181 paths.mk: FORCE
   182 	@echo "  GEN    '$@'"
   183 	@(echo "export install=$(install)"; \
   184 	  echo "export bash=$(bash)";       \
   185 	  echo "export grep=$(grep)";       \
   186 	  echo "export make=$(make)";       \
   187 	  echo "export sed=$(sed)";         \
   188 	  echo "export libtool=$(libtool)"; \
   189 	  echo "export libtoolize=$(libtoolize)"; \
   190 	  echo "export objcopy=$(objcopy)"; \
   191 	  echo "export objdump=$(objdump)"; \
   192 	  echo "export readelf=$(readelf)"; \
   193 	  echo "export patch=$(patch)";     \
   194 	 ) >paths.mk
   195 
   196 config/configure.in: FORCE
   197 	@echo "  GEN    '$@'"
   198 	@{  printf "# Generated file, do not edit\n";            \
   199 	    printf "# Default values as found by ./configure\n"; \
   200 	    for var in $(KCONFIG); do                            \
   201 	        printf "\n";                                     \
   202 	        printf "config CONFIGURE_$${var%%=*}\n";         \
   203 	        if [ "$${var#*=}" = "y" ]; then                  \
   204 	            printf "    def_bool y\n";                   \
   205 	        else                                             \
   206 	            printf "    bool\n";                         \
   207 	        fi;                                              \
   208 	    done;                                                \
   209 	 } >$@
   210 
   211 FORCE:
   212 
   213 #--------------------------------------
   214 # Clean rules
   215 
   216 clean-bin:
   217 	@echo "  RM     '$(PROG_NAME)'"
   218 	@rm -f $(PROG_NAME)
   219 	@echo "  RM     'scripts/crosstool-NG.sh'"
   220 	@rm -f scripts/crosstool-NG.sh
   221 	@echo "  RM     'scripts/saveSample.sh'"
   222 	@rm -f scripts/saveSample.sh
   223 	@echo "  RM     'scripts/showTuple.sh'"
   224 	@rm -f scripts/showTuple.sh
   225 
   226 clean-lib:
   227 	@echo "  RM     'paths.mk'"
   228 	@rm -f paths.mk
   229 	@echo "  RM     'config/configure.in'"
   230 	@rm -f config/configure.in
   231 
   232 clean-doc:
   233 
   234 clean-man:
   235 	@echo "  RM     'docs/$(PROG_NAME).1'"
   236 	@rm -f docs/$(PROG_NAME).1
   237 	@echo "  RM     'docs/$(PROG_NAME).1.gz'"
   238 	@rm -f docs/$(PROG_NAME).1.gz
   239 
   240 #--------------------------------------
   241 # Check for --local setup
   242 
   243 ifeq ($(strip $(LOCAL)),yes)
   244 
   245 real-install:
   246 	@true
   247 
   248 real-uninstall:
   249 	@true
   250 
   251 else
   252 
   253 #--------------------------------------
   254 # Install rules
   255 
   256 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
   257 
   258 install-bin: $(DESTDIR)$(bindir)
   259 	@echo "  INST    '$(PROG_NAME)'"
   260 	@$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
   261 
   262 # If one is hacking crosstool-NG, the patch set might change between any two
   263 # installations of the same VERSION, thus the patches must be removed prior
   264 # to being installed. It is simpler to remove the whole lib/ directory, as it
   265 # is the goal of the install-lib rule to install the lib/ directory...
   266 install-lib: uninstall-lib $(DESTDIR)$(libdir) install-lib-main install-lib-samples
   267 
   268 LIB_SUB_DIR := config contrib kconfig patches scripts
   269 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
   270 	@echo "  INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
   271 	@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
   272 	 |(cd "$(DESTDIR)$(libdir)"; tar xf -)
   273 
   274 # Huh? It seems we need at least one command to make this rule kick-in.
   275 install-lib-%: install-lib-%-copy; @true
   276 
   277 # Huh? that one does not inherit the -opy dependency, above...
   278 install-lib-scripts: install-lib-scripts-copy
   279 	@chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
   280 	@chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
   281 	@rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
   282 
   283 install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
   284 	@echo "  INST    'steps.mk'"
   285 	@$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
   286 	@echo "  INST    'paths.mk'"
   287 	@$(install) -m 644 paths.mk "$(DESTDIR)$(libdir)/paths.mk"
   288 
   289 # Samples need a little love:
   290 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   291 install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
   292 	@echo "  INSTDIR 'samples/'"
   293 	@for samp_dir in samples/*/; do                                         \
   294 	     mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}";                       \
   295 	     $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;'             \
   296 	               -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;'   \
   297 	            $${samp_dir}/crosstool.config                               \
   298 	            >"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config";       \
   299 	     $(install) -m 644 "$${samp_dir}/reported.by"                       \
   300 	                       "$(DESTDIR)$(libdir)/$${samp_dir}";              \
   301 	     for libc_cfg in "$${samp_dir}/"*libc*.config; do                   \
   302 	         [ -f "$${libc_cfg}" ] || continue;                             \
   303 	         $(install) -m 644 "$${libc_cfg}"                               \
   304 	                           "$(DESTDIR)$(libdir)/$${samp_dir}";          \
   305 	     done;                                                              \
   306 	 done
   307 	@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
   308 
   309 install-doc: $(DESTDIR)$(docdir)
   310 	@echo "  INST    'docs/*.txt'"
   311 	@for doc_file in docs/*.txt; do                              \
   312 	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
   313 	 done
   314 
   315 install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
   316 	@echo "  INST    '$(PROG_NAME).1.gz'"
   317 	@$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
   318 
   319 $(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
   320 	@echo "  MKDIR   '$@/'"
   321 	@$(install) -m 755 -d "$@"
   322 
   323 install-post:
   324 	@echo
   325 	@echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
   326 	@echo "your bash completion directory (usually /etc/bash_completion.d)"
   327 
   328 #--------------------------------------
   329 # Uninstall rules
   330 
   331 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
   332 
   333 uninstall-bin:
   334 	@echo "  RM      '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
   335 	@rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
   336 
   337 uninstall-lib:
   338 	@echo "  RMDIR   '$(DESTDIR)$(libdir)/'"
   339 	@rm -rf "$(DESTDIR)$(libdir)"
   340 
   341 uninstall-doc:
   342 	@echo "  RMDIR   '$(DESTDIR)$(docdir)/'"
   343 	@rm -rf "$(DESTDIR)$(docdir)"
   344 
   345 uninstall-man:
   346 	@echo "  RM      '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
   347 	@rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
   348 
   349 endif # Not --local
   350 
   351 endif # No extra MAKEFLAGS were added
   352 
   353 .PHONY: build $(patsubst %,build-%,$(TARGETS)) install