Makefile.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Apr 15 00:22:42 2011 +0200 (2011-04-15)
changeset 2544 751c3f735ada
parent 2481 30644208c955
child 2577 6fc224df66e8
permissions -rw-r--r--
scripts/internals: do not remove lib{32,64}/ symlinks after build

During the build, we create lib{32,64}/ symlinks out of the sysroot.
In some cases (eg. mingw32 target), these symlinks are still required
when running the toolchain. For other combinations, the symlinks are
without incidence, so they can be safely kept after the build.

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@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@2505
    91
# Somehow, the new auto-completion for make in the recent distributions
yann@2505
    92
# trigger a behavior where our Makefile calls itself recursively, in a
yann@2505
    93
# never-ending loop (except on lack of ressources, swap, PIDs...)
yann@2505
    94
# Avoid this situation by cutting the recursion short at the first
yann@2505
    95
# level.
yann@2505
    96
# This has the side effect of only showing the real targets, and hiding our
yann@2505
    97
# internal ones. :-)
yann@2505
    98
ifneq ($(MAKELEVEL),0)
yann@2505
    99
$(error Recursion detected, bailing out...)
yann@2505
   100
endif
yann@2505
   101
yann@1156
   102
MAKEFLAGS += $(CT_MAKEFLAGS)
yann@1156
   103
build install clean distclean uninstall:
yann@1156
   104
	@$(MAKE) $@
yann@1156
   105
yann@1156
   106
else
yann@1156
   107
# There were no additional MAKEFLAGS to add, do the job
yann@1156
   108
yann@555
   109
TARGETS := bin lib doc man
yann@182
   110
yann@555
   111
build: $(patsubst %,build-%,$(TARGETS))
yann@182
   112
yann@1101
   113
install: build real-install
yann@555
   114
yann@555
   115
clean: $(patsubst %,clean-%,$(TARGETS))
yann@182
   116
yann@182
   117
distclean: clean
yann@554
   118
	@echo "  RM     'Makefile'"
yann@182
   119
	@rm -f Makefile
yann@182
   120
yann@1048
   121
uninstall: real-uninstall
yann@182
   122
yann@182
   123
###############################################################################
yann@182
   124
# Specific make rules
yann@182
   125
yann@182
   126
#--------------------------------------
yann@182
   127
# Build rules
yann@182
   128
yann@1336
   129
build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh
yann@1297
   130
	@chmod 755 $^
yann@182
   131
yann@2481
   132
build-lib: paths.mk config/configure.in
yann@182
   133
yann@555
   134
build-doc:
yann@555
   135
yann@309
   136
build-man: docs/ct-ng.1.gz
yann@309
   137
yann@309
   138
docs/ct-ng.1.gz: docs/ct-ng.1
yann@554
   139
	@echo "  GZIP   '$@'"
yann@317
   140
	@gzip -c9 $< >$@
yann@182
   141
yann@470
   142
%: %.in Makefile
yann@554
   143
	@echo "  SED    '$@'"
yann@1153
   144
	@$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;'    \
yann@1153
   145
	           -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;'    \
yann@1153
   146
	           -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;'    \
yann@1153
   147
	           -e 's,@@CT_MANDIR@@,$(MANDIR),g;'    \
yann@1153
   148
	           -e 's,@@CT_VERSION@@,$(VERSION),g;'	\
yann@1153
   149
	           -e 's,@@CT_DATE@@,$(DATE),g;'        \
yann@1153
   150
	           -e 's,@@CT_make@@,$(make),g;'        \
yann@1156
   151
	           -e 's,@@CT_bash@@,$(bash),g;'        \
yann@1153
   152
	           $@.in >$@
yann@1153
   153
yann@1153
   154
# We create a script fragment that is parseable from inside a Makefile,
yann@1153
   155
# but also from inside a shell script, hence the reason why we don't
fr@1643
   156
# use := to set variables, although that will incur a (very small)
yann@1153
   157
# penalty from the Makefile that includes it (due to re-evaluation at
yann@1153
   158
# each call).
yann@2481
   159
paths.mk: FORCE
yann@1153
   160
	@echo "  GEN    '$@'"
yann@1153
   161
	@(echo "export install=$(install)"; \
yann@1153
   162
	  echo "export bash=$(bash)";       \
yann@1153
   163
	  echo "export grep=$(grep)";       \
yann@1153
   164
	  echo "export make=$(make)";       \
yann@1153
   165
	  echo "export sed=$(sed)";         \
titus@1962
   166
	  echo "export libtool=$(libtool)"; \
titus@1962
   167
	  echo "export objcopy=$(objcopy)"; \
titus@1962
   168
	  echo "export objdump=$(objdump)"; \
titus@1962
   169
	  echo "export readelf=$(readelf)"; \
titus@1962
   170
	  echo "export patch=$(patch)";     \
yann@1153
   171
	 ) >paths.mk
yann@182
   172
yann@2481
   173
config/configure.in: FORCE
yann@2481
   174
	@echo "  GEN    '$@'"
yann@2481
   175
	@{  printf "# Generated file, do not edit\n";            \
yann@2481
   176
	    printf "# Default values as found by ./configure\n"; \
yann@2481
   177
	    for var in $(KCONFIG); do                            \
yann@2481
   178
	        printf "\n";                                     \
yann@2481
   179
	        printf "config CONFIGURE_$${var%%=*}\n";         \
yann@2481
   180
	        printf "    bool\n";                             \
yann@2481
   181
	        if [ "$${var#*=}" = "y" ]; then                  \
yann@2481
   182
	            printf "    default y\n";                    \
yann@2481
   183
	        fi;                                              \
yann@2481
   184
	    done;                                                \
yann@2481
   185
	 } >$@
yann@2481
   186
yann@2481
   187
FORCE:
yann@2481
   188
yann@182
   189
#--------------------------------------
yann@182
   190
# Clean rules
yann@182
   191
yann@182
   192
clean-bin:
yann@554
   193
	@echo "  RM     'ct-ng'"
yann@182
   194
	@rm -f ct-ng
yann@1339
   195
	@echo "  RM     'scripts/crosstool-NG.sh'"
yann@1158
   196
	@rm -f scripts/crosstool-NG.sh
yann@1339
   197
	@echo "  RM     'scripts/saveSample.sh'"
yann@1186
   198
	@rm -f scripts/saveSample.sh
yann@1339
   199
	@echo "  RM     'scripts/showTuple.sh'"
yann@1336
   200
	@rm -f scripts/showTuple.sh
yann@182
   201
yann@182
   202
clean-lib:
yann@1154
   203
	@echo "  RM     'paths.mk'"
yann@1154
   204
	@rm -f paths.mk
yann@2481
   205
	@echo "  RM     'config/configure.in'"
yann@2481
   206
	@rm -f config/configure.in
yann@182
   207
yann@182
   208
clean-doc:
yann@555
   209
yann@555
   210
clean-man:
yann@554
   211
	@echo "  RM     'docs/ct-ng.1'"
yann@318
   212
	@rm -f docs/ct-ng.1
yann@554
   213
	@echo "  RM     'docs/ct-ng.1.gz'"
yann@318
   214
	@rm -f docs/ct-ng.1.gz
yann@182
   215
yann@182
   216
#--------------------------------------
yann@554
   217
# Check for --local setup
yann@182
   218
yann@1297
   219
ifeq ($(strip $(LOCAL)),y)
yann@1048
   220
yann@1101
   221
real-install:
yann@1297
   222
	@true
yann@1048
   223
yann@1048
   224
real-uninstall:
yann@1048
   225
	@true
yann@1048
   226
yann@1048
   227
else
yann@285
   228
yann@554
   229
#--------------------------------------
yann@554
   230
# Install rules
yann@554
   231
yann@1876
   232
real-install: $(patsubst %,install-%,$(TARGETS)) install-post
yann@1048
   233
yann@1047
   234
install-bin: $(DESTDIR)$(BINDIR)
yann@1994
   235
	@echo "  INST    'ct-ng'"
yann@1153
   236
	@$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
yann@182
   237
yann@555
   238
# If one is hacking crosstool-NG, the patch set might change between any two
yann@555
   239
# installations of the same VERSION, thus the patches must be removed prior
yann@555
   240
# to being installed. It is simpler to remove the whole lib/ directory, as it
yann@555
   241
# is the goal of the install-lib rule to install the lib/ directory...
yann@1047
   242
install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
yann@182
   243
yann@1994
   244
LIB_SUB_DIR := config contrib kconfig patches scripts
yann@1994
   245
$(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(LIBDIR)
yann@1994
   246
	@echo "  INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
yann@1994
   247
	@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
yann@1994
   248
	 |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
yann@1994
   249
yann@1994
   250
# Huh? It seems we need at least one command to make this rule kick-in.
yann@1994
   251
install-lib-%: install-lib-%-copy; @true
yann@1994
   252
yann@1994
   253
# Huh? that one does not inherit the -opy dependency, above...
yann@1994
   254
install-lib-scripts: install-lib-scripts-copy
yann@1184
   255
	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
yann@1186
   256
	@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
yann@1101
   257
	@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
yann@1994
   258
yann@1994
   259
install-lib-main: $(DESTDIR)$(LIBDIR) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
yann@1994
   260
	@echo "  INST    'steps.mk'"
yann@1153
   261
	@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
yann@1994
   262
	@echo "  INST    'paths.mk'"
yann@1153
   263
	@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
yann@182
   264
yann@182
   265
# Samples need a little love:
yann@425
   266
#  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
yann@1047
   267
install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
yann@1994
   268
	@echo "  INSTDIR 'samples/'"
yann@2422
   269
	@for samp_file in samples/*/crosstool.config; do                        \
yann@2422
   270
	     mkdir -p "$(DESTDIR)$(LIBDIR)/$${samp_file%/*}";                   \
yann@2422
   271
	     $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;'             \
yann@2422
   272
	               -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;'   \
yann@2422
   273
	            $${samp_file}                                               \
yann@2422
   274
	            >"$(DESTDIR)$(LIBDIR)/$${samp_file}";                       \
yann@182
   275
	 done
yann@2424
   276
	@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(LIBDIR)/samples/samples.mk"
yann@182
   277
yann@1047
   278
install-doc: $(DESTDIR)$(DOCDIR)
yann@2076
   279
	@echo "  INST    'docs/*.txt'"
yann@2076
   280
	@for doc_file in docs/*.txt; do                              \
yann@1153
   281
	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
yann@182
   282
	 done
yann@249
   283
yann@2026
   284
install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)
yann@1994
   285
	@echo "  INST    'ct-ng.1.gz'"
yann@2026
   286
	@$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)"
yann@182
   287
yann@2026
   288
$(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)):
yann@1994
   289
	@echo "  MKDIR   '$@/'"
yann@1153
   290
	@$(install) -m 755 -d "$@"
yann@182
   291
yann@1876
   292
install-post:
yann@1876
   293
	@echo
yann@1994
   294
	@echo "For auto-completion, do not forget to install 'ct-ng.comp' into"
yann@1994
   295
	@echo "your bash completion directory (usually /etc/bash_completion.d)"
yann@182
   296
yann@182
   297
#--------------------------------------
yann@182
   298
# Uninstall rules
yann@182
   299
yann@1048
   300
real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
yann@1048
   301
yann@554
   302
uninstall-bin:
yann@1994
   303
	@echo "  RM      '$(DESTDIR)$(BINDIR)/ct-ng'"
yann@1047
   304
	@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
yann@182
   305
yann@554
   306
uninstall-lib:
yann@1994
   307
	@echo "  RMDIR   '$(DESTDIR)$(LIBDIR)/'"
yann@1047
   308
	@rm -rf "$(DESTDIR)$(LIBDIR)"
yann@298
   309
yann@554
   310
uninstall-doc:
yann@1994
   311
	@echo "  RMDIR   '$(DESTDIR)$(DOCDIR)/'"
yann@1047
   312
	@rm -rf "$(DESTDIR)$(DOCDIR)"
yann@554
   313
yann@554
   314
uninstall-man:
yann@2423
   315
	@echo "  RM      '$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1.gz'"
yann@2423
   316
	@rm -f "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1"{,.gz}
yann@1048
   317
yann@1048
   318
endif # Not --local
yann@1156
   319
yann@1156
   320
endif # No extra MAKEFLAGS were added