mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-18 20:37:56 +00:00
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>
This commit is contained in:
parent
c3c8a70767
commit
c8e39d6d29
@ -1,6 +1,10 @@
|
||||
syntax: glob
|
||||
|
||||
# Generated files
|
||||
configure
|
||||
autom4te.cache
|
||||
config.log
|
||||
config.status
|
||||
Makefile
|
||||
*ct-ng*
|
||||
docs/*ct-ng*.1
|
||||
|
130
Makefile.in
130
Makefile.in
@ -38,39 +38,40 @@ all: Makefile build
|
||||
###############################################################################
|
||||
# Configuration variables
|
||||
|
||||
VERSION:= @@VERSION@@
|
||||
BINDIR := @@BINDIR@@
|
||||
LIBDIR := @@LIBDIR@@
|
||||
DOCDIR := @@DOCDIR@@
|
||||
MANDIR := @@MANDIR@@
|
||||
PROG_PFX:=@@PROG_PFX@@
|
||||
PROG_SFX:=@@PROG_SFX@@
|
||||
PROG_SED:=@@PROG_SED@@
|
||||
DATE := @@DATE@@
|
||||
LOCAL := @@LOCAL@@
|
||||
|
||||
# Paths found by ./configure
|
||||
install := @@install@@
|
||||
bash := @@bash@@
|
||||
grep := @@grep@@
|
||||
make := @@make@@
|
||||
sed := @@sed@@
|
||||
libtool := @@libtool@@
|
||||
libtoolize:= @@libtoolize@@
|
||||
objcopy := @@objcopy@@
|
||||
objdump := @@objdump@@
|
||||
readelf := @@readelf@@
|
||||
patch := @@patch@@
|
||||
# Stuff found by ./configure
|
||||
DATE := @DATE@
|
||||
LOCAL := @enable_local@
|
||||
PROG_SED := @program_transform_name@
|
||||
PACKAGE_TARNAME := @PACKAGE_TARNAME@
|
||||
VERSION := @PACKAGE_VERSION@
|
||||
prefix := @prefix@
|
||||
exec_prefix := @exec_prefix@
|
||||
bindir := @bindir@
|
||||
libdir := @libdir@@sublibdir@
|
||||
docdir := @docdir@@subdocdir@
|
||||
datarootdir := @datarootdir@
|
||||
mandir := @mandir@
|
||||
install := @INSTALL@
|
||||
bash := @_BASH@
|
||||
grep := @EGREP@
|
||||
make := @MAKE@
|
||||
sed := @SED@
|
||||
libtool := @LIBTOOL@
|
||||
libtoolize := @LIBTOOLIZE@
|
||||
objcopy := @OBJCOPY@
|
||||
objdump := @OBJDUMP@
|
||||
readelf := @READELF@
|
||||
patch := @PATCH@
|
||||
|
||||
# config options to push down to kconfig
|
||||
KCONFIG:= @@KCONFIG@@
|
||||
KCONFIG:= @kconfig_options@
|
||||
|
||||
###############################################################################
|
||||
# Non-configure variables
|
||||
MAN_SECTION := 1
|
||||
MAN_SUBDIR := /man$(MAN_SECTION)
|
||||
|
||||
PROG_NAME := $(shell echo '$(PROG_PFX)ct-ng$(PROG_SFX)' |sed -e '$(PROG_SED)' )
|
||||
PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' )
|
||||
|
||||
###############################################################################
|
||||
# Sanity checks
|
||||
@ -106,7 +107,7 @@ $(error Recursion detected, bailing out...)
|
||||
endif
|
||||
|
||||
MAKEFLAGS += $(CT_MAKEFLAGS)
|
||||
build install clean distclean uninstall:
|
||||
build install clean distclean mrproper uninstall:
|
||||
@$(MAKE) $@
|
||||
|
||||
else
|
||||
@ -124,6 +125,10 @@ distclean: clean
|
||||
@echo " RM 'Makefile'"
|
||||
@rm -f Makefile
|
||||
|
||||
mrproper: distclean
|
||||
@echo " RM 'autostuff'"
|
||||
@ rm -rf autom4te.cache config.log config.status configure
|
||||
|
||||
uninstall: real-uninstall
|
||||
|
||||
###############################################################################
|
||||
@ -147,13 +152,10 @@ docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
|
||||
|
||||
define sed_it
|
||||
@echo " SED '$@'"
|
||||
@$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;' \
|
||||
-e 's,@@CT_LIBDIR@@,$(LIBDIR),g;' \
|
||||
-e 's,@@CT_DOCDIR@@,$(DOCDIR),g;' \
|
||||
-e 's,@@CT_MANDIR@@,$(MANDIR),g;' \
|
||||
-e 's,@@CT_PROG_PFX@@,$(PROG_PFX),g;' \
|
||||
-e 's,@@CT_PROG_SFX@@,$(PROG_SFX),g;' \
|
||||
-e 's,@@CT_PROG_SED@@,$(PROG_SED),g;' \
|
||||
@$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;' \
|
||||
-e 's,@@CT_LIBDIR@@,$(libdir),g;' \
|
||||
-e 's,@@CT_DOCDIR@@,$(docdir),g;' \
|
||||
-e 's,@@CT_MANDIR@@,$(mandir),g;' \
|
||||
-e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;' \
|
||||
-e 's,@@CT_VERSION@@,$(VERSION),g;' \
|
||||
-e 's,@@CT_DATE@@,$(DATE),g;' \
|
||||
@ -238,7 +240,7 @@ clean-man:
|
||||
#--------------------------------------
|
||||
# Check for --local setup
|
||||
|
||||
ifeq ($(strip $(LOCAL)),y)
|
||||
ifeq ($(strip $(LOCAL)),yes)
|
||||
|
||||
real-install:
|
||||
@true
|
||||
@ -253,68 +255,68 @@ else
|
||||
|
||||
real-install: $(patsubst %,install-%,$(TARGETS)) install-post
|
||||
|
||||
install-bin: $(DESTDIR)$(BINDIR)
|
||||
install-bin: $(DESTDIR)$(bindir)
|
||||
@echo " INST '$(PROG_NAME)'"
|
||||
@$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(BINDIR)/$(PROG_NAME)"
|
||||
@$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
|
||||
|
||||
# If one is hacking crosstool-NG, the patch set might change between any two
|
||||
# installations of the same VERSION, thus the patches must be removed prior
|
||||
# to being installed. It is simpler to remove the whole lib/ directory, as it
|
||||
# is the goal of the install-lib rule to install the lib/ directory...
|
||||
install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
|
||||
install-lib: uninstall-lib $(DESTDIR)$(libdir) install-lib-main install-lib-samples
|
||||
|
||||
LIB_SUB_DIR := config contrib kconfig patches scripts
|
||||
$(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(LIBDIR)
|
||||
$(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
|
||||
@echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
|
||||
@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
|
||||
|(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
|
||||
|(cd "$(DESTDIR)$(libdir)"; tar xf -)
|
||||
|
||||
# Huh? It seems we need at least one command to make this rule kick-in.
|
||||
install-lib-%: install-lib-%-copy; @true
|
||||
|
||||
# Huh? that one does not inherit the -opy dependency, above...
|
||||
install-lib-scripts: install-lib-scripts-copy
|
||||
@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
|
||||
@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
|
||||
@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
|
||||
@chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
|
||||
@chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
|
||||
@rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
|
||||
|
||||
install-lib-main: $(DESTDIR)$(LIBDIR) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
|
||||
install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
|
||||
@echo " INST 'steps.mk'"
|
||||
@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
|
||||
@$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
|
||||
@echo " INST 'paths.mk'"
|
||||
@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
|
||||
@$(install) -m 644 paths.mk "$(DESTDIR)$(libdir)/paths.mk"
|
||||
|
||||
# Samples need a little love:
|
||||
# - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
|
||||
install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
|
||||
install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
|
||||
@echo " INSTDIR 'samples/'"
|
||||
@for samp_dir in samples/*/; do \
|
||||
mkdir -p "$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \
|
||||
mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}"; \
|
||||
$(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \
|
||||
-e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \
|
||||
$${samp_dir}/crosstool.config \
|
||||
>"$(DESTDIR)$(LIBDIR)/$${samp_dir}/crosstool.config"; \
|
||||
>"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config"; \
|
||||
$(install) -m 644 "$${samp_dir}/reported.by" \
|
||||
"$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \
|
||||
"$(DESTDIR)$(libdir)/$${samp_dir}"; \
|
||||
for libc_cfg in "$${samp_dir}/"*libc*.config; do \
|
||||
[ -f "$${libc_cfg}" ] || continue; \
|
||||
$(install) -m 644 "$${libc_cfg}" \
|
||||
"$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \
|
||||
"$(DESTDIR)$(libdir)/$${samp_dir}"; \
|
||||
done; \
|
||||
done
|
||||
@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(LIBDIR)/samples/samples.mk"
|
||||
@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
|
||||
|
||||
install-doc: $(DESTDIR)$(DOCDIR)
|
||||
install-doc: $(DESTDIR)$(docdir)
|
||||
@echo " INST 'docs/*.txt'"
|
||||
@for doc_file in docs/*.txt; do \
|
||||
$(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
|
||||
$(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
|
||||
done
|
||||
|
||||
install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)
|
||||
install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
|
||||
@echo " INST '$(PROG_NAME).1.gz'"
|
||||
@$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)"
|
||||
@$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
|
||||
|
||||
$(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)):
|
||||
$(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
|
||||
@echo " MKDIR '$@/'"
|
||||
@$(install) -m 755 -d "$@"
|
||||
|
||||
@ -329,20 +331,20 @@ install-post:
|
||||
real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
|
||||
|
||||
uninstall-bin:
|
||||
@echo " RM '$(DESTDIR)$(BINDIR)/$(PROG_NAME)'"
|
||||
@rm -f "$(DESTDIR)$(BINDIR)/$(PROG_NAME)"
|
||||
@echo " RM '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
|
||||
@rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
|
||||
|
||||
uninstall-lib:
|
||||
@echo " RMDIR '$(DESTDIR)$(LIBDIR)/'"
|
||||
@rm -rf "$(DESTDIR)$(LIBDIR)"
|
||||
@echo " RMDIR '$(DESTDIR)$(libdir)/'"
|
||||
@rm -rf "$(DESTDIR)$(libdir)"
|
||||
|
||||
uninstall-doc:
|
||||
@echo " RMDIR '$(DESTDIR)$(DOCDIR)/'"
|
||||
@rm -rf "$(DESTDIR)$(DOCDIR)"
|
||||
@echo " RMDIR '$(DESTDIR)$(docdir)/'"
|
||||
@rm -rf "$(DESTDIR)$(docdir)"
|
||||
|
||||
uninstall-man:
|
||||
@echo " RM '$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
|
||||
@rm -f "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
|
||||
@echo " RM '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
|
||||
@rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
|
||||
|
||||
endif # Not --local
|
||||
|
||||
|
6
README
6
README
@ -2,7 +2,11 @@ This is the README for crosstool-NG
|
||||
|
||||
Crosstool-NG follows the autoconf dance. So, to get you
|
||||
kick-started, just run:
|
||||
./configure --help
|
||||
./configure --help
|
||||
|
||||
If you are using a development snapshot, you'll have to
|
||||
create the configure script, first. Just run:
|
||||
./bootstrap
|
||||
|
||||
You will find the documentation in the directory 'docs'.
|
||||
Here is a quick overview of what you'll find there:
|
||||
|
7
bootstrap
Executable file
7
bootstrap
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
printf "Running autoconf...\n"
|
||||
autoconf -Wall --force
|
||||
|
||||
printf "Done. You may now run:\n ./configure\n"
|
645
configure
vendored
645
configure
vendored
@ -1,645 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
myname="${0##*/}"
|
||||
|
||||
VERSION=$( cat .version )
|
||||
DATE=$( date +%Y%m%d )
|
||||
|
||||
PREFIX_DEFAULT=/usr/local
|
||||
|
||||
BINDIR_set=
|
||||
LIBDIR_set=
|
||||
DOCDIR_set=
|
||||
MANDIR_set=
|
||||
PROG_PFX=
|
||||
PROG_SFX=
|
||||
PROG_SED=
|
||||
LOCAL_set=
|
||||
FORCE=
|
||||
|
||||
do_quit=
|
||||
|
||||
# Simply print the error message, and exit. Obvious, he?
|
||||
do_error() {
|
||||
printf "${myname}: ${@}\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Given an option string and the following argument,
|
||||
# echoes the value of the option.
|
||||
# If --var=val => echoes val and returns 0, meaning second arg was not consumed
|
||||
# If --var val => echoes val and returns non null, meaning second arg was used
|
||||
get_optval(){
|
||||
case "$1" in
|
||||
--*=?*)
|
||||
printf "${1#*=}"
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
printf "${2}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# The set_xxx functions will set the corresponding configuration variable
|
||||
# They return 0 if second arg was not consumed, and non-zero if it was consumed.
|
||||
set_prefix() {
|
||||
PREFIX="$( get_optval "$1" "$2" )"
|
||||
}
|
||||
set_bindir() {
|
||||
BINDIR_set=1
|
||||
BINDIR="$( get_optval "$1" "$2" )"
|
||||
}
|
||||
set_libdir() {
|
||||
LIBDIR_set=1
|
||||
LIBDIR="$( get_optval "$1" "$2" )"
|
||||
}
|
||||
set_docdir() {
|
||||
DOCDIR_set=1
|
||||
DOCDIR="$( get_optval "$1" "$2" )"
|
||||
}
|
||||
set_mandir() {
|
||||
MANDIR_set=1
|
||||
MANDIR="$( get_optval "$1" "$2" )"
|
||||
}
|
||||
set_program_prefix() {
|
||||
PROG_PFX="$( get_optval "$1" "$2" )"
|
||||
}
|
||||
set_program_suffix() {
|
||||
PROG_SFX="$( get_optval "$1" "$2" )"
|
||||
}
|
||||
set_program_transform_name() {
|
||||
PROG_SED="$( get_optval "$1" "$2" )"
|
||||
}
|
||||
set_tool() {
|
||||
local var_name="${1%%=*}"
|
||||
var_name="${var_name#--with-}"
|
||||
eval ${var_name}="\$( get_optval "$1" "$2" )"
|
||||
}
|
||||
|
||||
# var_list is a list of variables, each one holding a path to a
|
||||
# tool, either detected by ./configure, or specified by the user.
|
||||
var_list=""
|
||||
kconfig_list=""
|
||||
|
||||
# This function adds a variable name to the above list of variable names.
|
||||
# $1: the name of the variable to add to the list
|
||||
add_to_var_list() {
|
||||
local v
|
||||
for v in ${var_list}; do
|
||||
[ "${v}" = "${1}" ] && return 0
|
||||
done
|
||||
var_list="${var_list} ${1}"
|
||||
}
|
||||
add_to_kconfig_list() {
|
||||
local k
|
||||
for k in ${kconfig_list}; do
|
||||
[ "${k}" = "${1}" ] && return 0
|
||||
done
|
||||
kconfig_list="${kconfig_list} ${1}"
|
||||
}
|
||||
|
||||
# A function to test for required tools/headers/libraries
|
||||
# Return 0 (true) if found, !0 (false) if not found
|
||||
#
|
||||
# $*: [prog|inc|lib]=<name[ name...]>
|
||||
# the name(s) of tool(s) to test for
|
||||
# mandatory
|
||||
# eg: prog=bash prog="curl wget"
|
||||
# $*: var=<var_name>
|
||||
# the name of the variable to test and set
|
||||
# optional
|
||||
# eg: var=bash if ${bash} is set and non-null, use that,
|
||||
# else check for bash and set bash=$(which bash)
|
||||
# $*: ver=<regexp>
|
||||
# for each 'prog', test if $(prog --version) matches 'regexp'
|
||||
# optional
|
||||
# eg: ver='^GNU bash, version [34]\.'
|
||||
# $*: lib_exts=<extension[ extension...]>
|
||||
# the list of allowed library extension
|
||||
# mandatory
|
||||
# eg: lib_exts="so dylib" lib_exts="so dylib a"
|
||||
# $*: err=<error_message>
|
||||
# the error message to print if tool is missing
|
||||
# optional, defaults to: '${prog}: none found'
|
||||
# eg: err="'bash' 3.x or above was not found"
|
||||
# Note: err may be printed by caller, not us
|
||||
# $*: kconfig=<var_name>
|
||||
# the name of a variable to pass down to kconfig if
|
||||
# the prog/inc/lib was found
|
||||
# optional, defaults to none
|
||||
# eg: kconfig=has_libncurses
|
||||
# $*: skip=[y|n|]
|
||||
# if set to 'y', skip the test, but still register the
|
||||
# kconfig and var variables; if 'n' or empty, do the
|
||||
# test.
|
||||
# optional, default to 'n'
|
||||
# eg: skip="${static_link_ko}"
|
||||
check_for() {
|
||||
local lib_exts
|
||||
local skip
|
||||
local val
|
||||
local item
|
||||
local where
|
||||
local status
|
||||
local ext
|
||||
|
||||
# Note: prog/inc/lib and var/kconfig/ver/err are set here,
|
||||
# but declared by the caller (because it needs it)
|
||||
for item in "${@}"; do
|
||||
case "${item}" in
|
||||
prog=*|inc=*|lib=*|var=*|ver=*|err=*|kconfig=*|lib_exts=*|skip=*)
|
||||
eval ${item%%=*}=\"${item#*=}\"
|
||||
;;
|
||||
*) do_error "check_for: incorrect parameters: '${item}'";;
|
||||
esac
|
||||
done
|
||||
|
||||
case "${prog}:${inc}:${lib}" in
|
||||
?*:?*:|?*::?*|:?*:?*|?*:?*:?*)
|
||||
if [ -n "${var}" ]; then
|
||||
do_error "check_for: the use of var is not compatible with passing several of [prog|inc|lib] at once"
|
||||
fi
|
||||
;;
|
||||
::) do_error "check_for: [prog|inc|lib] is mandatory";;
|
||||
esac
|
||||
|
||||
if [ -n "${var}" ]; then
|
||||
add_to_var_list "${var}"
|
||||
fi
|
||||
if [ -n "${kconfig}" ]; then
|
||||
add_to_kconfig_list "${kconfig}"
|
||||
fi
|
||||
|
||||
if [ "${skip}" = "y" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -n "${prog}" ]; then
|
||||
for item in ${prog}; do
|
||||
printf "Checking for '${item}'... "
|
||||
if [ -n "${var}" ]; then
|
||||
eval val="\${${var}}"
|
||||
if [ -n "${val}" ]; then
|
||||
status="${val} (cached)\n"
|
||||
where="${val}"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
where="$( which "${item}" 2>/dev/null )"
|
||||
if [ -z "${where}" ]; then
|
||||
printf "no\n"
|
||||
continue
|
||||
elif [ -n "${ver}" ]; then
|
||||
str=$( LC_ALL=C "${where}" --version 2>&1 \
|
||||
|grep -E "${ver}" \
|
||||
|head -n 1
|
||||
)
|
||||
if [ -z "${str}" ]; then
|
||||
printf "no\n"
|
||||
unset where
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
status="${where}"
|
||||
break
|
||||
done
|
||||
if [ -z "${status}" ]; then
|
||||
return 1
|
||||
fi
|
||||
printf "${status}\n"
|
||||
unset status
|
||||
fi
|
||||
|
||||
if [ -n "${inc}" ]; then
|
||||
for item in ${inc}; do
|
||||
printf "Checking for '${item}'... "
|
||||
if printf "#include \"${item}\"" |gcc -x c -c - -o /dev/null >/dev/null 2>&1; then
|
||||
where="${item}"
|
||||
status=yes
|
||||
break;
|
||||
fi
|
||||
printf "no\n"
|
||||
done
|
||||
if [ -z "${status}" ]; then
|
||||
return 1
|
||||
fi
|
||||
printf "${status}\n"
|
||||
unset status
|
||||
fi
|
||||
|
||||
if [ -n "${lib}" ]; then
|
||||
if [ -z "${lib_exts}" ]; then
|
||||
do_error "check_for: no library extension specified for '${lib}'"
|
||||
fi
|
||||
for item in ${lib}; do
|
||||
for ext in ${lib_exts}; do
|
||||
printf "Checking for '${item}.${ext}'... "
|
||||
where="$( gcc -print-file-name="${item}.${ext}" )"
|
||||
if [ "${where}" != "${item}.${ext}" ]; then
|
||||
where="$( readlink "${where}" )"
|
||||
status=yes
|
||||
break 2;
|
||||
fi
|
||||
printf "no\n"
|
||||
done
|
||||
done
|
||||
if [ -z "${status}" ]; then
|
||||
return 1
|
||||
fi
|
||||
printf "${status}\n"
|
||||
unset status
|
||||
fi
|
||||
|
||||
if [ -n "${var}" ]; then
|
||||
eval ${var}='"'"${where}"'"'
|
||||
fi
|
||||
if [ -n "${kconfig}" ]; then
|
||||
eval ${kconfig}=y
|
||||
fi
|
||||
}
|
||||
|
||||
# This function checks for a tool, and aborts if not found
|
||||
# See check_for(), above, for how to call has_or_abort
|
||||
has_or_abort() {
|
||||
# We declare these 6 variables here, although they are
|
||||
# set in check_for(), called below
|
||||
local prog inc lib
|
||||
local var ver err kconfig
|
||||
|
||||
if ! check_for "$@"; then
|
||||
printf " * A mandatory dependency is missing, or version mis-match:\n"
|
||||
printf " * - ${err:-${prog}${inc}${lib}: none found}\n"
|
||||
if [ -n "${var}" ]; then
|
||||
printf " * --> You can give the path to this tool using: --with-${var}=PATH\n"
|
||||
fi
|
||||
printf "\n"
|
||||
# Bail out if --force is not specified
|
||||
[ -z "${FORCE}" ] && do_error "Bailing out..."
|
||||
printf "<* *>\n"
|
||||
printf "<* FORCE in action: *>\n"
|
||||
printf "<* Continuing despite missing pre-requisite *>\n"
|
||||
printf "<* Prepare for breakage *>\n"
|
||||
printf "<* *>\n"
|
||||
printf "\n"
|
||||
fi
|
||||
}
|
||||
|
||||
# This function checks for a tool, and warns if not found
|
||||
# See check_for(), above, for how to call has_or_abort
|
||||
# Note: if err is not set, then no error message is printed
|
||||
has_or_warn() {
|
||||
# We declare these 6 variables here, although they are
|
||||
# set in check_for(), called below
|
||||
local prog inc lib
|
||||
local var ver err kconfig
|
||||
|
||||
if ! check_for "$@"; then
|
||||
printf " * An optional dependency is missing, some features will be disabled"
|
||||
printf "${err:+:\n * - ${err}}\n"
|
||||
if [ -n "${var}" ]; then
|
||||
printf " * --> You can give the path to this tool using: --with-${var}=PATH\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
do_help() {
|
||||
cat <<__EOF__
|
||||
\`configure' configures crosstool-NG-${VERSION} to adapt to many kind of systems.
|
||||
|
||||
USAGE: ./configure [OPTION]...
|
||||
|
||||
Defaults for the options are specified in brackets.
|
||||
|
||||
Configuration:
|
||||
-h, --help display this help and exit
|
||||
--force force configure to continue, even in case
|
||||
some pre-requisites are missing
|
||||
|
||||
Installation directories:
|
||||
--prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
|
||||
--local don't install, and use current directory
|
||||
|
||||
By default, \`make install' will install all the files in
|
||||
\`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc. You can specify
|
||||
an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
|
||||
for instance \`--prefix=\${HOME}'.
|
||||
|
||||
For better control, use the options below.
|
||||
Note: options marked as \`ignored' are recognised, but not acted upon, as
|
||||
they make no sense for crosstool-NG, or they are not implemented yet.
|
||||
|
||||
Fine tuning of the installation directories:
|
||||
--bindir=DIR user executables [PREFIX/bin]
|
||||
--libdir=DIR object code libraries [PREFIX/lib]
|
||||
--docdir=DIR info documentation [PREFIX/share/doc]
|
||||
--mandir=DIR man documentation [PREFIX/share/man]
|
||||
--infodir=DIR info documentation [DATAROOTDIR/info] (ignored)
|
||||
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
|
||||
(ignored)
|
||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] (ignored)
|
||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var] (ignored)
|
||||
|
||||
Program names:
|
||||
--program-prefix=PREFIX prepend PREFIX to installed program names
|
||||
--program-suffix=SUFFIX append SUFFIX to installed program names
|
||||
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
|
||||
|
||||
System types:
|
||||
--build=BUILD configure for building on BUILD [guessed] (ignored)
|
||||
--host=HOST cross-compile to build programs to run on HOST [BUILD]
|
||||
(ignored)
|
||||
|
||||
Optional Features:
|
||||
--enable-shared[=PKGS] build shared libraries [default=yes] (ignored)
|
||||
--enable-static[=PKGS] build static libraries [default=yes] (ignored)
|
||||
|
||||
Optional Packages:
|
||||
--with-install=PATH Specify the full PATH to GNU install
|
||||
--with-make=PATH Specify the full PATH to GNU make >= 3.80
|
||||
--with-grep=PATH Specify the full PATH to GNU grep
|
||||
--with-sed=PATH Specify the full PATH to GNU sed
|
||||
--with-bash=PATH Specify the full PATH to bash >= 3.0
|
||||
__EOF__
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Set user's options
|
||||
|
||||
while [ $# -ne 0 ]; do
|
||||
case "$1" in
|
||||
--local) LOCAL_set="y"; shift;;
|
||||
--prefix*) set_prefix "$1" "$2" && shift || shift 2;;
|
||||
--bindir*) set_bindir "$1" "$2" && shift || shift 2;;
|
||||
--libdir*) set_libdir "$1" "$2" && shift || shift 2;;
|
||||
--docdir*) set_docdir "$1" "$2" && shift || shift 2;;
|
||||
--mandir*) set_mandir "$1" "$2" && shift || shift 2;;
|
||||
--with-*) set_tool "$1" "$2" && shift || shift 2;;
|
||||
--program-prefix=*|--program-prefix)
|
||||
set_program_prefix "$1" "$2" && shift || shift 2
|
||||
;;
|
||||
--program-suffix=*|--program-suffix)
|
||||
set_program_suffix "$1" "$2" && shift || shift 2
|
||||
;;
|
||||
--program-transform-name=*|--program-transform-name)
|
||||
set_program_transform_name "$1" "$2" && shift || shift 2
|
||||
;;
|
||||
--force) FORCE=1; shift;;
|
||||
--help|-h) do_help; exit 0;;
|
||||
# Skip, auto-stuff compatibility
|
||||
--build=*|--host=*|--infodir=*|--datadir=*|--sysconfdir=*|--localstatedir=*) shift;;
|
||||
--build|--host|--infodir|--datadir|--sysconfdir|--localstatedir) shift 2;;
|
||||
--enable-shared|--disable-shared|--enable-static|--disable-static) shift;;
|
||||
*) printf "Unrecognised option: '${1}'\n"; do_help; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Use defaults
|
||||
[ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
|
||||
|
||||
# Special case when installing locally
|
||||
if [ "${LOCAL_set}" = "y" ]; then
|
||||
set_prefix "" "$( pwd )"
|
||||
set_bindir "" "$( pwd )"
|
||||
set_libdir "" "$( pwd )"
|
||||
set_docdir "" "$( pwd )/docs"
|
||||
set_mandir "" "$( pwd )/docs"
|
||||
set_program_prefix "" ""
|
||||
set_program_suffix "" ""
|
||||
set_program_transform_name "" ""
|
||||
fi
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Some sanity checks, now
|
||||
|
||||
# We check for grep and sed manually, because they are used in check_for()
|
||||
printf "Checking for 'grep'... "
|
||||
if [ -n "${grep}" ]; then
|
||||
printf "${grep} (cached)\n"
|
||||
else
|
||||
grep="$( which grep 2>/dev/null )"
|
||||
if [ -z "${grep}" ]; then
|
||||
printf "not found\n"
|
||||
else
|
||||
printf "${grep}\n"
|
||||
printf "Checking whether '${grep}' supports -E... "
|
||||
if echo 'foo' |"${grep}" -E 'foo' >/dev/null 2>&1; then
|
||||
printf "yes\n"
|
||||
else
|
||||
printf "no\n"
|
||||
grep=
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -z "${grep}" ]; then
|
||||
printf "Either you are missing entirely the needed tool,\n"
|
||||
printf "or the version you have is too old.\n"
|
||||
printf "You can give the path to this tool using: --with-grep=PATH\n"
|
||||
do_error "Bailing out..."
|
||||
fi
|
||||
add_to_var_list grep
|
||||
|
||||
printf "Checking for 'sed'... "
|
||||
if [ -n "${sed}" ]; then
|
||||
printf "${sed} (cached)\n"
|
||||
else
|
||||
sed="$( which sed 2>/dev/null )"
|
||||
if [ -z "${sed}" ]; then
|
||||
printf "not found\n"
|
||||
else
|
||||
printf "${sed}\n"
|
||||
printf "Checking whether '${sed}' supports -i and -e... "
|
||||
touch .ct-ng.sed.test
|
||||
if "${sed}" -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
|
||||
printf "yes\n"
|
||||
else
|
||||
printf "no\n"
|
||||
sed=
|
||||
fi
|
||||
rm -f .ct-ng.sed.test
|
||||
fi
|
||||
fi
|
||||
if [ -z "${sed}" ]; then
|
||||
printf "Either you are missing entirely the needed tool,\n"
|
||||
printf "or the version you have is too old.\n"
|
||||
printf "You can give the path to this tool using: --with-sed=PATH\n"
|
||||
do_error "Bailing out..."
|
||||
fi
|
||||
add_to_var_list sed
|
||||
|
||||
# The regular list of tools we can now easily check for
|
||||
has_or_abort prog=bash \
|
||||
var=bash \
|
||||
ver='^GNU bash, version (3\.[1-9]|4)' \
|
||||
err="'bash' 3.1 or above was not found"
|
||||
has_or_abort prog=cut
|
||||
has_or_abort prog=install var=install
|
||||
has_or_abort prog=make \
|
||||
var=make \
|
||||
ver='^GNU Make (3.[89][[:digit:]]|[4-9])' \
|
||||
err="GNU 'make' 3.80 or above was not found"
|
||||
has_or_abort prog=gcc
|
||||
has_or_abort prog="awk gawk" ver='^GNU Awk' err="GNU 'awk' was not found"
|
||||
has_or_abort prog=bison
|
||||
has_or_abort prog=flex
|
||||
has_or_abort prog=makeinfo
|
||||
has_or_abort prog=automake \
|
||||
ver='\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)' \
|
||||
err="'automake' 1.10 or above was not found"
|
||||
has_or_abort prog=libtool \
|
||||
var=libtool \
|
||||
ver='\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)' \
|
||||
err="'libtool' 1.5.26 or above was not found"
|
||||
has_or_abort prog=libtoolize \
|
||||
var=libtoolize \
|
||||
ver='\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)' \
|
||||
err="'libtoolize' 1.5.26 or above was not found"
|
||||
has_or_abort prog=stat
|
||||
has_or_abort prog=wget
|
||||
has_or_abort prog=patch
|
||||
has_or_abort prog=tar
|
||||
has_or_abort prog=gzip
|
||||
has_or_abort prog=bzip2
|
||||
has_or_warn prog=xz \
|
||||
kconfig=has_xzutils \
|
||||
err="xz-compressed tarballs will not be used"
|
||||
has_or_warn prog=lzma \
|
||||
kconfig=has_lzma \
|
||||
skip="${has_xzutils}" \
|
||||
err="lzma-compressed tarballs will not be used"
|
||||
has_or_abort prog=readlink
|
||||
has_or_abort prog=objcopy var=objcopy
|
||||
has_or_abort prog=objdump var=objdump
|
||||
has_or_abort prog=readelf var=readelf
|
||||
has_or_abort prog=patch var=patch
|
||||
has_or_warn prog=cvs \
|
||||
kconfig=has_cvs \
|
||||
err="it will not be possible to use newlib cvs snapshots"
|
||||
has_or_warn prog=svn \
|
||||
kconfig=has_svn \
|
||||
err="subversion is required to download eglibc"
|
||||
|
||||
# Library checks
|
||||
libs_exts="so dylib a"
|
||||
|
||||
ncurses_hdrs="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h"
|
||||
ncurses_libs="libncursesw libncurses libcurses"
|
||||
has_or_abort lib="${ncurses_libs}" \
|
||||
lib_exts="${libs_exts}" \
|
||||
inc="${ncurses_hdrs}" \
|
||||
err="The 'ncurses' library is needed fo the menuconfig frontend"
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Compute the version string
|
||||
|
||||
# If this version is n hg clone, try to get the revision number
|
||||
# If we can't get the revision number, use date
|
||||
printf "\nComputing version string... "
|
||||
|
||||
# Pass the version to the version helper script, if present, to compute
|
||||
# a local version string, if needed.
|
||||
if [ -f version.sh -a -x version.sh ]; then
|
||||
V="$( ./version.sh "${VERSION}" 2>/dev/null |head -n 1 )"
|
||||
fi
|
||||
|
||||
# If the script returns an empty string, revert to using the version
|
||||
# we just computed, above.
|
||||
if [ -n "${V}" ]; then
|
||||
VERSION="${V}"
|
||||
else
|
||||
case "${VERSION}" in
|
||||
*+hg|hg)
|
||||
rev_id="$( hg log -r . --template '{branch}-{node|short}\n' \
|
||||
2>/dev/null \
|
||||
|| true \
|
||||
)"
|
||||
VERSION="${VERSION}+${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Arrange to have no / in the directory name, no need to create an
|
||||
# arbitrarily deep directory structure
|
||||
VERSION="$( printf "${VERSION}" |"${sed}" -r -e 's:/+:_:g;' )"
|
||||
|
||||
printf "${VERSION}\n"
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Compute and check install paths
|
||||
|
||||
# Now we have the version string, we can build up the paths
|
||||
[ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
|
||||
[ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib"
|
||||
[ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc"
|
||||
[ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man"
|
||||
|
||||
# Install support files in our own sub-dir, so as not to mangle (system)
|
||||
# files and dirs, but only if not --local
|
||||
if [ -z "${LOCAL_set}" ]; then
|
||||
LIBDIR="${LIBDIR}/ct-ng-${VERSION}"
|
||||
DOCDIR="${DOCDIR}/ct-ng-${VERSION}"
|
||||
fi
|
||||
|
||||
# Check that install PATHs are absolute
|
||||
for p in BIN LIB DOC MAN; do
|
||||
var="${p}DIR"
|
||||
eval v='"${'"${var}"'}"'
|
||||
case "${v}" in
|
||||
/*) ;;
|
||||
*) do_error "'${var}' is not an absolute path: '${v}'";;
|
||||
esac
|
||||
done
|
||||
case "${PROG_PFX}" in
|
||||
*/*) do_error "program prefix '${PROG_PFX}' contains a '/'";;
|
||||
esac
|
||||
case "${PROG_SFX}" in
|
||||
*/*) do_error "program suffix '${PROG_SFX}' contains a '/'";;
|
||||
esac
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# That's all, folks!
|
||||
|
||||
printf "Building up Makefile... "
|
||||
var_sed="$( for var_name in ${var_list}; do
|
||||
eval echo 's,@@${var_name}@@,${'"${var_name}"'},g'
|
||||
done
|
||||
)"
|
||||
kconfig_sed="s/@@KCONFIG@@/$( for k_name in ${kconfig_list}; do
|
||||
eval printf \"${k_name}=\${${k_name}} \"
|
||||
done
|
||||
)/"
|
||||
"${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g" \
|
||||
-e "s,@@LIBDIR@@,${LIBDIR},g" \
|
||||
-e "s,@@DOCDIR@@,${DOCDIR},g" \
|
||||
-e "s,@@MANDIR@@,${MANDIR},g" \
|
||||
-e "s,@@PROG_PFX@@,${PROG_PFX},g" \
|
||||
-e "s,@@PROG_SFX@@,${PROG_SFX},g" \
|
||||
-e "s,@@PROG_SED@@,${PROG_SED},g" \
|
||||
-e "s,@@VERSION@@,${VERSION},g" \
|
||||
-e "s,@@DATE@@,${DATE},g" \
|
||||
-e "s,@@LOCAL@@,${LOCAL_set},g" \
|
||||
-e "${var_sed}" \
|
||||
-e "${kconfig_sed}" \
|
||||
Makefile.in \
|
||||
>Makefile
|
||||
echo "done"
|
||||
|
||||
cat <<__EOF__
|
||||
|
||||
crosstool-NG configured as follows:
|
||||
PREFIX='${PREFIX}'
|
||||
BINDIR='${BINDIR}'
|
||||
LIBDIR='${LIBDIR}'
|
||||
DOCDIR='${DOCDIR}'
|
||||
MANDIR='${MANDIR}'
|
||||
PROG_PFX='${PROG_PFX}'
|
||||
PROG_SFX='${PROG_SFX}'
|
||||
PROG_SED='${PROG_SED}'
|
||||
|
||||
Now run:
|
||||
make
|
||||
__EOF__
|
||||
if [ "${LOCAL_set}" != "y" ]; then
|
||||
printf " make install\n"
|
||||
fi
|
346
configure.ac
Normal file
346
configure.ac
Normal file
@ -0,0 +1,346 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.67])
|
||||
#AC_INIT([crosstool-NG], [hg], [crossgcc@sourceware.org])
|
||||
AC_INIT([crosstool-NG], [m4_esyscmd_s([cat .version])], [crossgcc@sourceware.org])
|
||||
AC_CONFIG_AUX_DIR([scripts])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# A few helper macros
|
||||
|
||||
# Check for required tool
|
||||
AC_DEFUN(
|
||||
[ACX_CHECK_TOOL_REQ],
|
||||
[AC_CHECK_TOOLS([$1], [$2])
|
||||
AS_IF(
|
||||
[test -z "$$1"],
|
||||
[AC_MSG_ERROR([missing required tool: $2])])
|
||||
])
|
||||
|
||||
# Check for required tool, set variable to full pathname
|
||||
AC_DEFUN(
|
||||
[ACX_PATH_TOOL_REQ],
|
||||
[ACX_CHECK_TOOL_REQ([$1], [$2])
|
||||
AS_CASE(
|
||||
[$$1],
|
||||
[/*],,
|
||||
[?*],[AC_MSG_CHECKING([for absolute path to $$1])
|
||||
$1=$(which $$1)
|
||||
AC_MSG_RESULT([$$1])])])
|
||||
|
||||
# Check for required program
|
||||
AC_DEFUN(
|
||||
[ACX_CHECK_PROGS_REQ],
|
||||
[AC_CHECK_PROGS([$1], [$2])
|
||||
AS_IF(
|
||||
[test -z "$$1"],
|
||||
[AC_MSG_ERROR([missing required tool: $2])])
|
||||
])
|
||||
|
||||
# Check for path to required program
|
||||
AC_DEFUN(
|
||||
[ACX_PATH_PROGS_REQ],
|
||||
[AC_PATH_PROGS([$1], [$2])
|
||||
AS_IF(
|
||||
[test -z "$$1"],
|
||||
[AC_MSG_ERROR([missing required tool: $2])])
|
||||
])
|
||||
|
||||
# Set the kconfig option
|
||||
AC_DEFUN(
|
||||
[ACX_SET_KCONFIG_OPTION],
|
||||
[AS_IF(
|
||||
[test -n "$$1"],
|
||||
[kconfig_options="$kconfig_options $1=y"],
|
||||
[kconfig_options="$kconfig_options $1"])
|
||||
])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Allow dummy --{en,dis}able-{static,shared}
|
||||
AC_ARG_ENABLE(
|
||||
[local],
|
||||
[AS_HELP_STRING(
|
||||
[--enable-local],
|
||||
[don't install, and use current directory])])
|
||||
AC_SUBST([enable_local], [${enable_local:-no}])
|
||||
AC_ARG_ENABLE(
|
||||
[shared],
|
||||
[AS_HELP_STRING(
|
||||
[--enable-shared],
|
||||
[build shared libraries (default=yes) (ignored)])])
|
||||
AC_ARG_ENABLE(
|
||||
[static],
|
||||
[AS_HELP_STRING(
|
||||
[--enable-static],
|
||||
[build static libraries (default=yes) (ignored)])])
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Check for --build and --host...
|
||||
AC_CANONICAL_BUILD
|
||||
AC_CANONICAL_HOST
|
||||
# ... but refuse --target
|
||||
AS_IF([test -n "$target_alias"],
|
||||
AC_MSG_ERROR([--target is not allowed]))
|
||||
|
||||
# Allow program name tranformation (--program-{prefix,suffix,transform-name})
|
||||
AC_ARG_PROGRAM
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Initial checks that are usually done first (I don't know why, that's
|
||||
# just what I seem to experience...)
|
||||
#---------------------------------------------------------------------
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_EGREP
|
||||
AC_CACHE_VAL([ac_cv_path_SED],
|
||||
[AC_ARG_WITH([sed],
|
||||
AS_HELP_STRING([--with-sed=PATH],
|
||||
[Specify the full PATH to sed]),
|
||||
[ac_cv_path_SED=$withval])])
|
||||
AC_PROG_SED
|
||||
AC_MSG_CHECKING([whether sed understands -r -i -e])
|
||||
touch .ct-ng.sed.test
|
||||
if ${SED} -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
|
||||
rm -f .ct-ng.sed.test
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
rm -f .ct-ng.sed.test
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR()
|
||||
fi
|
||||
AC_PROG_LN_S
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# A bunch of boring tests...
|
||||
#--------------------------------------------------------------------
|
||||
AC_PROG_CC
|
||||
AS_IF([test -z "$CC"],
|
||||
[AC_MSG_ERROR([no suitable compiler found])])
|
||||
AC_PROG_CPP
|
||||
AC_PROG_RANLIB
|
||||
ACX_PATH_TOOL_REQ([OBJCOPY], [objcopy])
|
||||
ACX_PATH_TOOL_REQ([OBJDUMP], [objdump])
|
||||
ACX_PATH_TOOL_REQ([READELF], [readelf])
|
||||
|
||||
ACX_CHECK_PROGS_REQ([bison], [bison])
|
||||
ACX_CHECK_PROGS_REQ([flex], [flex])
|
||||
ACX_CHECK_PROGS_REQ([awk], [gawk mawk nawk awk])
|
||||
ACX_CHECK_PROGS_REQ([makeinfo], [makeinfo])
|
||||
ACX_CHECK_PROGS_REQ([cut], [cut])
|
||||
ACX_CHECK_PROGS_REQ([stat], [stat])
|
||||
ACX_CHECK_PROGS_REQ([readlink], [readlink])
|
||||
ACX_CHECK_PROGS_REQ([curl], [curl])
|
||||
ACX_CHECK_PROGS_REQ([tar], [tar])
|
||||
ACX_CHECK_PROGS_REQ([gzip], [gzip])
|
||||
ACX_CHECK_PROGS_REQ([bzip2], [bzip2])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Still boring, but remember the path, now...
|
||||
#--------------------------------------------------------------------
|
||||
ACX_PATH_PROGS_REQ([PATCH], [patch])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# And a bunch of less boring tests...
|
||||
#--------------------------------------------------------------------
|
||||
# We need a bash that is >= 3.1
|
||||
AC_CACHE_VAL([ac_cv_path__BASH],
|
||||
[AC_ARG_WITH([bash],
|
||||
AS_HELP_STRING([--with-bash=PATH],
|
||||
[Specify the full PATH to bash >= 3.1]),
|
||||
[ac_cv_path__BASH=$withval])])
|
||||
AC_CACHE_CHECK([for bash >= 3.1], [ac_cv_path__BASH],
|
||||
[AC_PATH_PROGS_FEATURE_CHECK([_BASH], [bash],
|
||||
[[_BASH_ver=$($ac_path__BASH --version 2>&1 \
|
||||
|$EGREP '^GNU bash, version (3\.[1-9]|4)')
|
||||
test -n "$_BASH_ver" && ac_cv_path__BASH=$ac_path__BASH ac_path__BASH_found=:]],
|
||||
[AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([could not find bash >= 3.1])])])
|
||||
AC_SUBST([_BASH], [$ac_cv_path__BASH])
|
||||
|
||||
#----------------------------------------
|
||||
# Check for GNU make 3.80 or above
|
||||
AC_CACHE_VAL([ac_cv_path_MAKE],
|
||||
[AC_ARG_WITH([make],
|
||||
AS_HELP_STRING([--with-make=PATH],
|
||||
[Specify the full PATH to GNU make >= 3.80]),
|
||||
[ac_cv_path_MAKE=$withval])])
|
||||
AC_CACHE_CHECK([for GNU make >= 3.80], [ac_cv_path_MAKE],
|
||||
[AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake],
|
||||
[[MAKE_ver=$($ac_path_MAKE --version 2>&1 \
|
||||
|$EGREP '^GNU Make (3.[89][[:digit:]]|[4-9])')
|
||||
test -n "$MAKE_ver" && ac_cv_path_MAKE=$ac_path_MAKE ac_path_MAKE_found=:]],
|
||||
[AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([could not find GNU make >= 3.80])])])
|
||||
AC_SUBST([MAKE], [$ac_cv_path_MAKE])
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
#----------------------------------------
|
||||
# Check for libtool >= 1.5.26
|
||||
AC_CACHE_VAL([ac_cv_path_LIBTOOL],
|
||||
[AC_ARG_WITH([libtool],
|
||||
AS_HELP_STRING([--with-libtool=PATH],
|
||||
[Specify the full PATH to GNU libtool >= 1.5.26]),
|
||||
[ac_cv_path_LIBTOOL=$withval])])
|
||||
AC_CACHE_CHECK([for GNU libtool >= 1.5.26], [ac_cv_path_LIBTOOL],
|
||||
[AC_PATH_PROGS_FEATURE_CHECK([LIBTOOL], [libtool],
|
||||
[[LIBTOOL_ver=$($ac_path_LIBTOOL --version 2>&1 \
|
||||
|$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
|
||||
test -n "$LIBTOOL_ver" && ac_cv_path_LIBTOOL=$ac_path_LIBTOOL ac_path_LIBTOOL_found=:]],
|
||||
[AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([could not find GNU libtool >= 1.5.26])])])
|
||||
AC_SUBST([LIBTOOL], [$ac_cv_path_LIBTOOL])
|
||||
|
||||
#----------------------------------------
|
||||
# Check for libtoolize >= 1.5.26
|
||||
AC_CACHE_VAL([ac_cv_path_LIBTOOLIZE],
|
||||
[AC_ARG_WITH([libtoolize],
|
||||
AS_HELP_STRING([--with-libtoolize=PATH],
|
||||
[Specify the full PATH to GNU libtoolize >= 1.5.26]),
|
||||
[ac_cv_path_LIBTOOLIZE=$withval])])
|
||||
AC_CACHE_CHECK([for GNU libtoolize >= 1.5.26], [ac_cv_path_LIBTOOLIZE],
|
||||
[AC_PATH_PROGS_FEATURE_CHECK([LIBTOOLIZE], [libtool],
|
||||
[[LIBTOOLIZE_ver=$($ac_path_LIBTOOLIZE --version 2>&1 \
|
||||
|$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
|
||||
test -n "$LIBTOOLIZE_ver" && ac_cv_path_LIBTOOLIZE=$ac_path_LIBTOOLIZE ac_path_LIBTOOLIZE_found=:]],
|
||||
[AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([could not find GNU libtoolize >= 1.5.26])])])
|
||||
AC_SUBST([LIBTOOLIZE], [$ac_cv_path_LIBTOOLIZE])
|
||||
|
||||
#----------------------------------------
|
||||
# Check for automake >= 1.10
|
||||
AC_CACHE_VAL([ac_cv_path_automake],
|
||||
[AC_ARG_WITH([automake],
|
||||
AS_HELP_STRING([--with-automake=PATH],
|
||||
[Specify the full PATH to GNU automake >= 1.10]),
|
||||
[ac_cv_path_automake=$withval])])
|
||||
AC_CACHE_CHECK([for GNU automake >= 1.10], [ac_cv_path_automake],
|
||||
[AC_PATH_PROGS_FEATURE_CHECK([automake], [automake],
|
||||
[[automake_ver=$($ac_path_automake --version 2>&1 \
|
||||
|$EGREP '\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)')
|
||||
test -n "$automake_ver" && ac_cv_path_automake=$ac_path_automake ac_path_automake_found=:]],
|
||||
[AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([could not find GNU automake >= 1.10])])])
|
||||
AC_SUBST([automake], [$ac_cv_path_automake])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Boring again... But still a bit of work to do...
|
||||
#--------------------------------------------------------------------
|
||||
AC_SUBST([kconfig_options])
|
||||
|
||||
#----------------------------------------
|
||||
AC_CHECK_PROGS([xz], [xz])
|
||||
ACX_SET_KCONFIG_OPTION([xz])
|
||||
AS_IF(
|
||||
[test -z "$xz"],
|
||||
[AC_CHECK_PROGS([lzma], [lzma])])
|
||||
ACX_SET_KCONFIG_OPTION([lzma])
|
||||
|
||||
#----------------------------------------
|
||||
AC_CHECK_PROGS([cvs], [cvs])
|
||||
ACX_SET_KCONFIG_OPTION([cvs])
|
||||
|
||||
#----------------------------------------
|
||||
AC_CHECK_PROGS([svn], [svn])
|
||||
ACX_SET_KCONFIG_OPTION([svn])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Now, for some fun...
|
||||
#--------------------------------------------------------------------
|
||||
AC_C_INLINE
|
||||
AC_HEADER_STDC
|
||||
AC_FUNC_MALLOC
|
||||
AC_FUNC_REALLOC
|
||||
AC_FUNC_ALLOCA
|
||||
AC_CHECK_HEADERS(
|
||||
[ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h],
|
||||
[ac_ct_curses_hdr_found=yes; break])
|
||||
AS_IF(
|
||||
[test -z "$ac_ct_curses_hdr_found"],
|
||||
[AC_MSG_ERROR([could not find curses header, required for the kconfig frontends])])
|
||||
AC_SEARCH_LIBS(
|
||||
[initscr],
|
||||
[ncursesw ncurses curses],
|
||||
[ac_ct_curses_lib_found=yes; break])
|
||||
AS_IF(
|
||||
[test -z "$ac_ct_curses_lib_found"],
|
||||
[AC_MSG_ERROR([could not find curses library, required for the kconfig frontends])])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Lastly, take care of crosstool-NG internal values
|
||||
#--------------------------------------------------------------------
|
||||
# Hey! We need the date! :-)
|
||||
AC_SUBST(
|
||||
[DATE],
|
||||
[$(date +%Y%m%d)])
|
||||
|
||||
# Decorate the version string if needed
|
||||
AS_IF(
|
||||
[test -f version.sh -a -x version.sh],
|
||||
[V=$(./version.sh "${PACKAGE_VERSION}")])
|
||||
AS_IF(
|
||||
[test -n "${V}"],
|
||||
[PACKAGE_VERSION="${V}"],
|
||||
[AS_CASE(
|
||||
[${PACKAGE_VERSION}],
|
||||
[hg|*+hg],
|
||||
[rev_id="$( hg log -r . --template '{branch}-{node|short}\n' \
|
||||
2>/dev/null \
|
||||
|| true )"
|
||||
PACKAGE_VERSION="${PACKAGE_VERSION}@${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}"
|
||||
])])
|
||||
# Arrange to have no / in the directory name, no need to create an
|
||||
# arbitrarily deep directory structure
|
||||
[PACKAGE_VERSION="$( printf "${PACKAGE_VERSION}\n" |"${SED}" -r -e 's:/+:_:g;' )"]
|
||||
|
||||
# Handle the local case
|
||||
AC_SUBST([sublibdir])
|
||||
AC_SUBST([subdocdir])
|
||||
AS_IF(
|
||||
[test "x$enable_local" = "xyes"],
|
||||
[AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set])
|
||||
prefix=$(pwd)
|
||||
exec_prefix="$prefix"
|
||||
bindir="$prefix"
|
||||
libdir="$prefix"
|
||||
sublibdir=""
|
||||
docdir="$prefix""/docs"
|
||||
subdocdir=""
|
||||
datarootdir="$prefix"
|
||||
mandir="$docdir"],
|
||||
[sublibdir="/ct-ng.\${VERSION}"
|
||||
subdocdir="/ct-ng.\${VERSION}"])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Finally, generate the output file(s)
|
||||
#--------------------------------------------------------------------
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
|
||||
# AC_CONFIG_SRCDIR([kconfig/menu.c])
|
||||
# AC_CONFIG_HEADERS([config.h])
|
||||
#
|
||||
# # Checks for programs.
|
||||
#
|
||||
# # Checks for libraries.
|
||||
#
|
||||
# # Checks for header files.
|
||||
# AC_CHECK_HEADERS([fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h stddef.h stdlib.h string.h sys/time.h unistd.h])
|
||||
#
|
||||
# # Checks for typedefs, structures, and compiler characteristics.
|
||||
# AC_HEADER_STDBOOL
|
||||
# AC_TYPE_INT16_T
|
||||
# AC_TYPE_INT32_T
|
||||
# AC_TYPE_INT8_T
|
||||
# AC_TYPE_SIZE_T
|
||||
# AC_TYPE_UINT16_T
|
||||
# AC_TYPE_UINT32_T
|
||||
# AC_TYPE_UINT8_T
|
||||
#
|
||||
# # Checks for library functions.
|
||||
# AC_FUNC_MALLOC
|
||||
# AC_FUNC_REALLOC
|
||||
# AC_CHECK_FUNCS([bzero gettimeofday memmove memset mkdir regcomp setlocale strcasecmp strchr strcspn strdup strncasecmp strpbrk strrchr strspn strtol uname])
|
||||
#
|
||||
# AC_OUTPUT
|
@ -30,6 +30,8 @@ If you go for the install, then you just follow the classical, but yet easy
|
||||
|
||||
You can then get rid of crosstool-NG source. Next create a directory to serve
|
||||
as a working place, cd in there and run:
|
||||
mkdir work-dir
|
||||
cd work-dir
|
||||
ct-ng help
|
||||
|
||||
See below for complete usage.
|
||||
@ -39,8 +41,12 @@ The Hacker's way |
|
||||
-----------------+
|
||||
|
||||
If you go the hacker's way, then the usage is a bit different, although very
|
||||
simple:
|
||||
./configure --local
|
||||
simple. First, you need to generate the ./configure script from its autoconf
|
||||
template:
|
||||
./bootstrap
|
||||
|
||||
Then, you run ./configure for local execution of crosstool-NG:
|
||||
./configure --enable-local
|
||||
make
|
||||
|
||||
Now, *do not* remove crosstool-NG sources. They are needed to run crosstool-NG!
|
||||
|
520
scripts/install-sh
Executable file
520
scripts/install-sh
Executable file
@ -0,0 +1,520 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dst_arg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
-*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test -z "$d" && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
Loading…
Reference in New Issue
Block a user