]> git.ozlabs.org Git - petitboot/blobdiff - docker/build-pb
docker: Allow CC and make command to be customised
[petitboot] / docker / build-pb
index ad08ef9e3cd586e5addd320fffc21df1944b8260..62295509f20b28b093e24bff939159c872b11041 100755 (executable)
@@ -12,21 +12,26 @@ usage () {
        echo "${name} - Builds the petitboot programs using a pb-builder container." >&2
        echo "Usage: ${name} [flags]" >&2
        echo "Option flags:" >&2
-       echo "  -c --check       - Run 'make check'." >&2
-       echo "  -d --dry-run     - Do not run docker commands." >&2
-       echo "  -h --help        - Show this help and exit." >&2
-       echo "  -i --interactive - Run an interactive pb-builder container." >&2
-       echo "  -t --tag         - Print Docker tag to stdout and exit." >&2
-       echo "  -v --verbose     - Verbose execution." >&2
+       echo "  -c --check              - Run 'make check'." >&2
+       echo "  -d --dry-run            - Do not run docker commands." >&2
+       echo "  -h --help               - Show this help and exit." >&2
+       echo "  -i --interactive        - Run an interactive pb-builder container." >&2
+       echo "  -m --make-command       - Set a specific command to be called for 'make'.">&2
+       echo "  -o --configure-opts     - Extra arguments for configure." >&2
+       echo "  -t --tag                - Print Docker tag to stdout and exit." >&2
+       echo "  -v --verbose            - Verbose execution." >&2
        echo "Environment:" >&2
-       echo "  DOCKER_TAG       - Default: '${DOCKER_TAG}'" >&2
+       echo "  DOCKER_TAG              - Default: '${DOCKER_TAG}'" >&2
+       echo "  CFLAGS                  - Default: '${CFLAGS}'" >&2
+       echo "  LDFLAGS                 - Default: '${LDFLAGS}'" >&2
+       echo "  CC                      - Default: '${CC}'" >&2
        echo "Examples:" >&2
        echo "  ${name} -vc"
        echo "  ${name} -v"
 }
 
-short_opts="cdhitv"
-long_opts="check,dry-run,help,interactive,tag,verbose"
+short_opts="cdhim:o:tv"
+long_opts="check,dry-run,help,interactive,make-command:,configure-opts:,tag,verbose"
 
 opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${name}" -- "$@")
 
@@ -55,6 +60,16 @@ while true ; do
                interactive=1
                shift
                ;;
+       -m | --make-command)
+               shift
+               makecmd=${1}
+               shift
+               ;;
+       -o | --configure-opts)
+               shift
+               configure_opts=${1}
+               shift
+               ;;
        -t | --tag)
                tag=1
                shift
@@ -97,7 +112,7 @@ docker_user_args="-u $(id -u):$(id -g)"
 
 if [[ -n "${interactive}" ]]; then
        cd "${TOP_DIR}"
-       docker_args="${docker_base_args}"
+       docker_args="${docker_base_args} --privileged"
        run_cmd "docker run -it ${docker_args} ${DOCKER_TAG} /bin/bash"
        exit
 fi
@@ -112,8 +127,14 @@ else
        docker_extra="true"
 fi
 
+if [[ -z "${makecmd}" ]]; then
+       makecmd="make"
+fi
+
+flags="CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} CC=${CC}"
+
 cd "${TOP_DIR}"
 docker_args="${docker_base_args} ${docker_user_args}"
 run_cmd "docker run ${docker_args} ${DOCKER_TAG} /bin/bash \
        -e ${bash_debug} \
-       -c './bootstrap && ./configure --with-ncurses && make && ${docker_extra}'"
+       -c './bootstrap && ${flags} ./configure ${configure_opts[@]} && ${makecmd} && ${docker_extra}'"