Makefile.in
author "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Tue May 31 20:39:42 2011 +0200 (2011-05-31)
changeset 2488 58a28561f1bc
parent 2424 28092887b486
child 2505 f87f02b00cc7
permissions -rw-r--r--
binutils: use the PKGVERSION and BUGURL options

This patch makes binutils benefit from the TOOLCHAIN_PKGVERSION and
TOOLCHAIN_BUGURL options.

Signed-off-by: "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
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@182
    46
DATE   := @@DATE@@
yann@285
    47
LOCAL  := @@LOCAL@@
yann@1141
    48
yann@1141
    49
# Paths found by ./configure
yann@1153
    50
install:= @@install@@
yann@1153
    51
bash   := @@bash@@
yann@1153
    52
grep   := @@grep@@
yann@1153
    53
make   := @@make@@
yann@1153
    54
sed    := @@sed@@
titus@1962
    55
libtool:= @@libtool@@
titus@1962
    56
objcopy:= @@objcopy@@
titus@1962
    57
objdump:= @@objdump@@
titus@1962
    58
readelf:= @@readelf@@
titus@1962
    59
patch  := @@patch@@
yann@1109
    60
yann@2481
    61
# config options to push down to kconfig
yann@2481
    62
KCONFIG:= @@KCONFIG@@
yann@2481
    63
yann@1109
    64
###############################################################################
yann@2026
    65
# Non-configure variables
yann@2026
    66
MAN_SECTION := 1
yann@2026
    67
MAN_SUBDIR := /man$(MAN_SECTION)
yann@2026
    68
yann@2026
    69
###############################################################################
yann@1109
    70
# Sanity checks
yann@1109
    71
yann@1109
    72
# Check if Makefile is up to date:
yann@1109
    73
Makefile: Makefile.in
yann@1109
    74
	@echo "$< did changed: you must re-run './configure'"
yann@1109
    75
	@false
yann@1109
    76
yann@1109
    77
# If installing with DESTDIR, check it's an absolute path
yann@1109
    78
ifneq ($(strip $(DESTDIR)),)
yann@1109
    79
  ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
yann@1109
    80
    $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
yann@1109
    81
  endif
yann@1109
    82
endif
yann@182
    83
yann@182
    84
###############################################################################
yann@182
    85
# Global make rules
yann@182
    86
yann@1156
    87
# If any extra MAKEFLAGS were added, re-run ourselves
yann@1156
    88
# See top of file for an explanation of why this is needed...
yann@1156
    89
ifneq ($(strip $(CT_MAKEFLAGS)),)
yann@1156
    90
yann@1156
    91
MAKEFLAGS += $(CT_MAKEFLAGS)
yann@1156
    92
build install clean distclean uninstall:
yann@1156
    93
	@$(MAKE) $@
yann@1156
    94
yann@1156
    95
else
yann@1156
    96
# There were no additional MAKEFLAGS to add, do the job
yann@1156
    97
yann@555
    98
TARGETS := bin lib doc man
yann@182
    99
yann@555
   100
build: $(patsubst %,build-%,$(TARGETS))
yann@182
   101
yann@1101
   102
install: build real-install
yann@555
   103
yann@555
   104
clean: $(patsubst %,clean-%,$(TARGETS))
yann@182
   105
yann@182
   106
distclean: clean
yann@554
   107
	@echo "  RM     'Makefile'"
yann@182
   108
	@rm -f Makefile
yann@182
   109
yann@1048
   110
uninstall: real-uninstall
yann@182
   111
yann@182
   112
###############################################################################
yann@182
   113
# Specific make rules
yann@182
   114
yann@182
   115
#--------------------------------------
yann@182
   116
# Build rules
yann@182
   117
yann@1336
   118
build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh
yann@1297
   119
	@chmod 755 $^
yann@182
   120
yann@2481
   121
build-lib: paths.mk config/configure.in
yann@182
   122
yann@555
   123
build-doc:
yann@555
   124
yann@309
   125
build-man: docs/ct-ng.1.gz
yann@309
   126
yann@309
   127
docs/ct-ng.1.gz: docs/ct-ng.1
yann@554
   128
	@echo "  GZIP   '$@'"
yann@317
   129
	@gzip -c9 $< >$@
yann@182
   130
yann@470
   131
%: %.in Makefile
yann@554
   132
	@echo "  SED    '$@'"
yann@1153
   133
	@$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;'    \
yann@1153
   134
	           -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;'    \
yann@1153
   135
	           -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;'    \
yann@1153
   136
	           -e 's,@@CT_MANDIR@@,$(MANDIR),g;'    \
yann@1153
   137
	           -e 's,@@CT_VERSION@@,$(VERSION),g;'	\
yann@1153
   138
	           -e 's,@@CT_DATE@@,$(DATE),g;'        \
yann@1153
   139
	           -e 's,@@CT_make@@,$(make),g;'        \
yann@1156
   140
	           -e 's,@@CT_bash@@,$(bash),g;'        \
yann@1153
   141
	           $@.in >$@
yann@1153
   142
yann@1153
   143
# We create a script fragment that is parseable from inside a Makefile,
yann@1153
   144
# but also from inside a shell script, hence the reason why we don't
fr@1643
   145
# use := to set variables, although that will incur a (very small)
yann@1153
   146
# penalty from the Makefile that includes it (due to re-evaluation at
yann@1153
   147
# each call).
yann@2481
   148
paths.mk: FORCE
yann@1153
   149
	@echo "  GEN    '$@'"
yann@1153
   150
	@(echo "export install=$(install)"; \
yann@1153
   151
	  echo "export bash=$(bash)";       \
yann@1153
   152
	  echo "export grep=$(grep)";       \
yann@1153
   153
	  echo "export make=$(make)";       \
yann@1153
   154
	  echo "export sed=$(sed)";         \
titus@1962
   155
	  echo "export libtool=$(libtool)"; \
titus@1962
   156
	  echo "export objcopy=$(objcopy)"; \
titus@1962
   157
	  echo "export objdump=$(objdump)"; \
titus@1962
   158
	  echo "export readelf=$(readelf)"; \
titus@1962
   159
	  echo "export patch=$(patch)";     \
yann@1153
   160
	 ) >paths.mk
yann@182
   161
yann@2481
   162
config/configure.in: FORCE
yann@2481
   163
	@echo "  GEN    '$@'"
yann@2481
   164
	@{  printf "# Generated file, do not edit\n";            \
yann@2481
   165
	    printf "# Default values as found by ./configure\n"; \
yann@2481
   166
	    for var in $(KCONFIG); do                            \
yann@2481
   167
	        printf "\n";                                     \
yann@2481
   168
	        printf "config CONFIGURE_$${var%%=*}\n";         \
yann@2481
   169
	        printf "    bool\n";                             \
yann@2481
   170
	        if [ "$${var#*=}" = "y" ]; then                  \
yann@2481
   171
	            printf "    default y\n";                    \
yann@2481
   172
	        fi;                                              \
yann@2481
   173
	    done;                                                \
yann@2481
   174
	 } >$@
yann@2481
   175
yann@2481
   176
FORCE:
yann@2481
   177
yann@182
   178
#--------------------------------------
yann@182
   179
# Clean rules
yann@182
   180
yann@182
   181
clean-bin:
yann@554
   182
	@echo "  RM     'ct-ng'"
yann@182
   183
	@rm -f ct-ng
yann@1339
   184
	@echo "  RM     'scripts/crosstool-NG.sh'"
yann@1158
   185
	@rm -f scripts/crosstool-NG.sh
yann@1339
   186
	@echo "  RM     'scripts/saveSample.sh'"
yann@1186
   187
	@rm -f scripts/saveSample.sh
yann@1339
   188
	@echo "  RM     'scripts/showTuple.sh'"
yann@1336
   189
	@rm -f scripts/showTuple.sh
yann@182
   190
yann@182
   191
clean-lib:
yann@1154
   192
	@echo "  RM     'paths.mk'"
yann@1154
   193
	@rm -f paths.mk
yann@2481
   194
	@echo "  RM     'config/configure.in'"
yann@2481
   195
	@rm -f config/configure.in
yann@182
   196
yann@182
   197
clean-doc:
yann@555
   198
yann@555
   199
clean-man:
yann@554
   200
	@echo "  RM     'docs/ct-ng.1'"
yann@318
   201
	@rm -f docs/ct-ng.1
yann@554
   202
	@echo "  RM     'docs/ct-ng.1.gz'"
yann@318
   203
	@rm -f docs/ct-ng.1.gz
yann@182
   204
yann@182
   205
#--------------------------------------
yann@554
   206
# Check for --local setup
yann@182
   207
yann@1297
   208
ifeq ($(strip $(LOCAL)),y)
yann@1048
   209
yann@1101
   210
real-install:
yann@1297
   211
	@true
yann@1048
   212
yann@1048
   213
real-uninstall:
yann@1048
   214
	@true
yann@1048
   215
yann@1048
   216
else
yann@285
   217
yann@554
   218
#--------------------------------------
yann@554
   219
# Install rules
yann@554
   220
yann@1876
   221
real-install: $(patsubst %,install-%,$(TARGETS)) install-post
yann@1048
   222
yann@1047
   223
install-bin: $(DESTDIR)$(BINDIR)
yann@1994
   224
	@echo "  INST    'ct-ng'"
yann@1153
   225
	@$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
yann@182
   226
yann@555
   227
# If one is hacking crosstool-NG, the patch set might change between any two
yann@555
   228
# installations of the same VERSION, thus the patches must be removed prior
yann@555
   229
# to being installed. It is simpler to remove the whole lib/ directory, as it
yann@555
   230
# is the goal of the install-lib rule to install the lib/ directory...
yann@1047
   231
install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
yann@182
   232
yann@1994
   233
LIB_SUB_DIR := config contrib kconfig patches scripts
yann@1994
   234
$(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(LIBDIR)
yann@1994
   235
	@echo "  INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
yann@1994
   236
	@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
yann@1994
   237
	 |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
yann@1994
   238
yann@1994
   239
# Huh? It seems we need at least one command to make this rule kick-in.
yann@1994
   240
install-lib-%: install-lib-%-copy; @true
yann@1994
   241
yann@1994
   242
# Huh? that one does not inherit the -opy dependency, above...
yann@1994
   243
install-lib-scripts: install-lib-scripts-copy
yann@1184
   244
	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
yann@1186
   245
	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
yann@1101
   246
	@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
yann@1994
   247
yann@1994
   248
install-lib-main: $(DESTDIR)$(LIBDIR) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
yann@1994
   249
	@echo "  INST    'steps.mk'"
yann@1153
   250
	@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
yann@1994
   251
	@echo "  INST    'paths.mk'"
yann@1153
   252
	@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
yann@182
   253
yann@182
   254
# Samples need a little love:
yann@425
   255
#  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
yann@1047
   256
install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
yann@1994
   257
	@echo "  INSTDIR 'samples/'"
yann@2422
   258
	@for samp_file in samples/*/crosstool.config; do                        \
yann@2422
   259
	     mkdir -p "$(DESTDIR)$(LIBDIR)/$${samp_file%/*}";                   \
yann@2422
   260
	     $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;'             \
yann@2422
   261
	               -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;'   \
yann@2422
   262
	            $${samp_file}                                               \
yann@2422
   263
	            >"$(DESTDIR)$(LIBDIR)/$${samp_file}";                       \
yann@182
   264
	 done
yann@2424
   265
	@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(LIBDIR)/samples/samples.mk"
yann@182
   266
yann@1047
   267
install-doc: $(DESTDIR)$(DOCDIR)
yann@2076
   268
	@echo "  INST    'docs/*.txt'"
yann@2076
   269
	@for doc_file in docs/*.txt; do                              \
yann@1153
   270
	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
yann@182
   271
	 done
yann@249
   272
yann@2026
   273
install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)
yann@1994
   274
	@echo "  INST    'ct-ng.1.gz'"
yann@2026
   275
	@$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)"
yann@182
   276
yann@2026
   277
$(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)):
yann@1994
   278
	@echo "  MKDIR   '$@/'"
yann@1153
   279
	@$(install) -m 755 -d "$@"
yann@182
   280
yann@1876
   281
install-post:
yann@1876
   282
	@echo
yann@1994
   283
	@echo "For auto-completion, do not forget to install 'ct-ng.comp' into"
yann@1994
   284
	@echo "your bash completion directory (usually /etc/bash_completion.d)"
yann@182
   285
yann@182
   286
#--------------------------------------
yann@182
   287
# Uninstall rules
yann@182
   288
yann@1048
   289
real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
yann@1048
   290
yann@554
   291
uninstall-bin:
yann@1994
   292
	@echo "  RM      '$(DESTDIR)$(BINDIR)/ct-ng'"
yann@1047
   293
	@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
yann@182
   294
yann@554
   295
uninstall-lib:
yann@1994
   296
	@echo "  RMDIR   '$(DESTDIR)$(LIBDIR)/'"
yann@1047
   297
	@rm -rf "$(DESTDIR)$(LIBDIR)"
yann@298
   298
yann@554
   299
uninstall-doc:
yann@1994
   300
	@echo "  RMDIR   '$(DESTDIR)$(DOCDIR)/'"
yann@1047
   301
	@rm -rf "$(DESTDIR)$(DOCDIR)"
yann@554
   302
yann@554
   303
uninstall-man:
yann@2423
   304
	@echo "  RM      '$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1.gz'"
yann@2423
   305
	@rm -f "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1"{,.gz}
yann@1048
   306
yann@1048
   307
endif # Not --local
yann@1156
   308
yann@1156
   309
endif # No extra MAKEFLAGS were added