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