Makefile.in
author Titus von Boxberg <titus@v9g.de>
Mon Aug 22 09:38:19 2011 +0200 (2011-08-22)
branch1.12
changeset 2638 18d05b18e242
parent 2577 6fc224df66e8
permissions -rw-r--r--
libc/uClibc: portability fixes to install_headers

Add patch files for uClibc-0.9.30:
extra/scripts/install_headers.sh: find must be called with path.
extra/scripts/unifdef.c: getline is declared in <stdio.h>, use different name.

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