]> git.ozlabs.org Git - ccan/commitdiff
tools/create-ccan-tree: Add --build-type=TYPE
authorJeremy Kerr <jeremy.kerr@canonical.com>
Thu, 24 May 2012 01:48:00 +0000 (09:48 +0800)
committerJeremy Kerr <jeremy.kerr@canonical.com>
Mon, 28 May 2012 13:48:51 +0000 (21:48 +0800)
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: Jeremy Kerr <jeremy.kerr@canonical.com>
tools/create-ccan-tree

index 88644b78651b267281e4abab2a375693f262caec..ccfee7c664cdcf3bae592844552a2e291e314ab7 100755 (executable)
@@ -7,18 +7,18 @@ usage() {
 Usage: $progname [options] <outdir> <depends>...
 
 options:
-  -a, --copy-all              copy all files in module tree (not just
-                              sources required for build)
-  -c, --exclude-configurator  exclude configurator. config.h must be
-                              supplied by another method (eg, autotools)
+  -a, --copy-all         copy all files in module tree (not just sources
+                        required for build)
+  -b, --build-type=TYPE  generate build infrastructure of TYPE
+                         (one of 'make', 'make+config')
 EOF
 }
 
 # parse options, setting the following flags
 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 ]
 then
@@ -35,9 +35,9 @@ do
                        copy_all=1
                        shift
                        ;;
-               -c|--exclude-configurator)
-                       exclude_configurator=1
-                       shift
+               -b|--build-type)
+                       build_type="$2"
+                       shift 2
                        ;;
                --)
                        shift
@@ -58,6 +58,15 @@ then
        exit 1
 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)/../
 outdir="$1"
 shift
@@ -151,26 +160,30 @@ do
        cp "$license_src" "$license_dest"
 done
 
-# add ccan Makefile
 echo "Adding build infrastructure"
-cp "$srcdir/Makefile-ccan" "$tmpdir/"
 
-# add top-level Makefile
-top_makefile="$tmpdir/Makefile"
-cat > "$top_makefile" << EOF
+makefile="$tmpdir/Makefile"
+if [ "$build_type" = "make" -o "$build_type" = "make+config" ]
+then
+       # add ccan Makefile
+       cp "$srcdir/Makefile-ccan" "$tmpdir/"
+
+       # add top-level Makefile
+       cat > "$makefile" << EOF
 all: libccan.a
 
 include Makefile-ccan
 EOF
+fi
 
 # optionally add configurator, and relevant parts to top-level Makefile
-if [ -z "$exclude_configurator" ]
+if [ "$build_type" = "make+config" ]
 then
        echo "Adding configurator"
        mkdir -p "$tmpdir/tools/configurator"
        cp -a "$srcdir/tools/configurator" "$tmpdir/tools/"
 
-       cat >> "$top_makefile" <<EOF
+       cat >> "$makefile" <<EOF
 tools/configurator/configurator: tools/configurator/configurator.c
 
 config.h: tools/configurator/configurator Makefile Makefile-ccan