#!/bin/sh # This is designed to compile a single package to a single binary # so it makes some assumptions about things to simplify config # to output a single binary (in a tarball) just use -o file # use --docker to output a tarball for input to docker build - set -e proc usage { echo "Usage: -o file" exit 1 } test $Argc = 0 && usage while [ $# -gt 0 ] { setvar flag = "$1" match $flag { with -o test $Argc -eq 1 && usage setvar out = "$2" mkdir -p $(dirname $2) shift with -l* setvar LIBS = ""$LIBS $1"" shift with * echo "Unknown option $1" exit 1 } shift } test -z $out && usage setvar package = $(basename "$out") setvar dir = ""/src/$package"" mkdir -p $dir # untar input tar xf - -C $dir shell { cd $dir setvar CFILES = $(find . -name '*.c') cc -static -O2 -Wall -Werror -o ../../$out $CFILES $LIBS } tar cf - $out exit 0