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