diff --git a/notwa-util/Dockerfile b/notwa-util/Dockerfile index 0dc599a..4de20c4 100644 --- a/notwa-util/Dockerfile +++ b/notwa-util/Dockerfile @@ -3,7 +3,7 @@ FROM alpine:3.16 as partial # need this for acquire (.tar.xz files): RUN apk add --no-cache xz -COPY --chmod=0755 acquire cosmocc dedupe quickconf shed \ +COPY --chmod=0755 acquire cosmocc dedupe ofc quickconf shed \ /usr/local/bin/ RUN ln -s /usr/local/bin /nu WORKDIR /media/common diff --git a/notwa-util/ofc b/notwa-util/ofc new file mode 100755 index 0000000..2433c3e --- /dev/null +++ b/notwa-util/ofc @@ -0,0 +1,12 @@ +#!/usr/bin/env sh +: "${CC:=cc}" "${LDFLAGS=-Wl,--gc-sections}" "${CFLAGS=-Os -g -Wall -Wextra \ +-Wwrite-strings -Wformat=2 -Wno-unused -ffunction-sections -fdata-sections}" \ + && compile() { "$CC" $CFLAGS $CPPFLAGS -c -o "$n$obj" "$c" ;} \ + && link() { "$CC" $LDFLAGS -o "$n$dbg" "$n$obj" $LIBS ;} \ + && finish() { "${STRIP:-strip}" "$n$dbg" -o "$n$exe" ;} \ + && obj=.o dbg=.dbg exe= \ + && if [ cosmocc = "${CC##*/}" ]; then dbg=.com.dbg exe=.com \ + && finish() { "${OBJCOPY:-objcopy}" -S -O binary "$n$dbg" "$n$exe" ;} \ + ;fi \ + && for c in "$@"; do n="${c%.*}" && compile && link && finish || exit; done \ +;