Commit e9704966 authored by Jeremy Kerr's avatar Jeremy Kerr

tools/create-ccan-tree: Add --build-type=TYPE

Replace the --exclude-configurator argument with a
single --build-type=TYPE argument, allowing future expansion of build
system types (and allowing source-tree-only creation). We currently
support:

 * 'make' (just the Makefile, equivalent to --exclude-configurator)
 * 'make+config' (current default)
Signed-off-by: default avatarJeremy Kerr <jeremy.kerr@canonical.com>
parent 70a438e8
...@@ -7,18 +7,18 @@ usage() { ...@@ -7,18 +7,18 @@ usage() {
Usage: $progname [options] <outdir> <depends>... Usage: $progname [options] <outdir> <depends>...
options: options:
-a, --copy-all copy all files in module tree (not just -a, --copy-all copy all files in module tree (not just sources
sources required for build) required for build)
-c, --exclude-configurator exclude configurator. config.h must be -b, --build-type=TYPE generate build infrastructure of TYPE
supplied by another method (eg, autotools) (one of 'make', 'make+config')
EOF EOF
} }
# parse options, setting the following flags # parse options, setting the following flags
copy_all= copy_all=
exclude_configurator= build_type=
opts=$(getopt -o ac --long copy-all,exclude-configurator -n $progname -- "$@") opts=$(getopt -o ab: --long copy-all,build-type: -n $progname -- "$@")
if [ $? != 0 ] if [ $? != 0 ]
then then
...@@ -35,9 +35,9 @@ do ...@@ -35,9 +35,9 @@ do
copy_all=1 copy_all=1
shift shift
;; ;;
-c|--exclude-configurator) -b|--build-type)
exclude_configurator=1 build_type="$2"
shift shift 2
;; ;;
--) --)
shift shift
...@@ -58,6 +58,15 @@ then ...@@ -58,6 +58,15 @@ then
exit 1 exit 1
fi fi
# check --build-type argument sanity
case "$build_type" in
''|'make'|'make+config')
;;
*)
echo "Invalid build type '$build_type'" >&2
exit 1
esac
srcdir=$(dirname $0)/../ srcdir=$(dirname $0)/../
outdir="$1" outdir="$1"
shift shift
...@@ -151,26 +160,30 @@ do ...@@ -151,26 +160,30 @@ do
cp "$license_src" "$license_dest" cp "$license_src" "$license_dest"
done done
# add ccan Makefile
echo "Adding build infrastructure" echo "Adding build infrastructure"
cp "$srcdir/Makefile-ccan" "$tmpdir/"
# add top-level Makefile makefile="$tmpdir/Makefile"
top_makefile="$tmpdir/Makefile" if [ "$build_type" = "make" -o "$build_type" = "make+config" ]
cat > "$top_makefile" << EOF then
# add ccan Makefile
cp "$srcdir/Makefile-ccan" "$tmpdir/"
# add top-level Makefile
cat > "$makefile" << EOF
all: libccan.a all: libccan.a
include Makefile-ccan include Makefile-ccan
EOF EOF
fi
# optionally add configurator, and relevant parts to top-level Makefile # optionally add configurator, and relevant parts to top-level Makefile
if [ -z "$exclude_configurator" ] if [ "$build_type" = "make+config" ]
then then
echo "Adding configurator" echo "Adding configurator"
mkdir -p "$tmpdir/tools/configurator" mkdir -p "$tmpdir/tools/configurator"
cp -a "$srcdir/tools/configurator" "$tmpdir/tools/" cp -a "$srcdir/tools/configurator" "$tmpdir/tools/"
cat >> "$top_makefile" <<EOF cat >> "$makefile" <<EOF
tools/configurator/configurator: tools/configurator/configurator.c tools/configurator/configurator: tools/configurator/configurator.c
config.h: tools/configurator/configurator Makefile Makefile-ccan config.h: tools/configurator/configurator Makefile Makefile-ccan
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment