Restructure project, Use build.sh
* I don't like makefiles... * Fix cast warning in countdown.c
This commit is contained in:
parent
76a7cf830e
commit
278cf4eff1
|
@ -3,3 +3,7 @@ a.out
|
|||
dist
|
||||
*.swp
|
||||
*.tgz
|
||||
djl-utils
|
||||
|
||||
bin
|
||||
dist
|
||||
|
|
62
Makefile
62
Makefile
|
@ -1,62 +0,0 @@
|
|||
VERSION = v0.0.1
|
||||
SRCDIR = src
|
||||
DISTDIR = dist
|
||||
DISTBIN = $(DISTDIR)/usr/bin
|
||||
DISTMAN = $(DISTDIR)/usr/share/man
|
||||
|
||||
all: djl-utils.deb
|
||||
|
||||
dist: bin DEBIAN.control
|
||||
bin: line sign pasta suptime countdown truthy stopwatch timestamp
|
||||
|
||||
distdir:
|
||||
mkdir -p $(DISTBIN)
|
||||
mkdir -p $(DISTMAN)/man1
|
||||
|
||||
line: $(SRCDIR)/line.c $(SRCDIR)/line.1 distdir
|
||||
cc -o $(DISTBIN)/line $(SRCDIR)/line.c
|
||||
cp $(SRCDIR)/line.1 $(DISTMAN)/man1/line.1
|
||||
|
||||
sign: $(SRCDIR)/sign $(SRCDIR)/sign.1 distdir
|
||||
cp $(SRCDIR)/sign $(DISTBIN)/sign
|
||||
cp $(SRCDIR)/sign.1 $(DISTMAN)/man1/sign.1
|
||||
|
||||
pasta: $(SRCDIR)/pasta distdir
|
||||
cp $(SRCDIR)/pasta $(DISTBIN)/pasta
|
||||
|
||||
truthy: $(SRCDIR)/truthy.c distdir
|
||||
cc -o $(DISTBIN)/truthy $(SRCDIR)/truthy.c
|
||||
|
||||
suptime: $(SRCDIR)/suptime.c $(SRCDIR)/suptime.1 distdir
|
||||
cc -o $(DISTBIN)/suptime $(SRCDIR)/suptime.c
|
||||
cp $(SRCDIR)/suptime.1 $(DISTMAN)/man1/suptime.1
|
||||
|
||||
countdown: $(SRCDIR)/countdown.c $(SRCDIR)/countdown.1 distdir
|
||||
cc -o $(DISTBIN)/countdown $(SRCDIR)/countdown.c
|
||||
cp $(SRCDIR)/countdown.1 $(DISTMAN)/man1/countdown.1
|
||||
|
||||
stopwatch: $(SRCDIR)/stopwatch.c $(SRCDIR)/stopwatch.1 distdir
|
||||
cc -o $(DISTBIN)/stopwatch $(SRCDIR)/stopwatch.c
|
||||
cp $(SRCDIR)/stopwatch.1 $(DISTMAN)/man1/stopwatch.1
|
||||
|
||||
timestamp: $(SRCDIR)/timestamp $(SRCDIR)/timestamp.1 distdir
|
||||
cp $(SRCDIR)/timestamp $(DISTBIN)
|
||||
cp $(SRCDIR)/timestamp.1 $(DISTMAN)/man1/timestamp.1
|
||||
|
||||
|
||||
DEBIAN.control: $(SRCDIR)/DEBIAN/control distdir
|
||||
rm -rf dist/DEBIAN
|
||||
cp -r $(SRCDIR)/DEBIAN dist/DEBIAN
|
||||
|
||||
djl-utils.deb: dist
|
||||
dpkg-deb -b dist
|
||||
mv dist.deb dist/djl-utils.deb
|
||||
|
||||
install: djl-utils.deb
|
||||
dpkg -i dist/djl-utils.deb
|
||||
|
||||
tarball:
|
||||
tar -czf $(VERSION).tgz LICENSE Makefile src/
|
||||
|
||||
clean:
|
||||
rm -rf dist
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
#build stuff
|
||||
|
||||
VERSION='0.0.2-1'
|
||||
|
||||
CFLAGS="-std=c99 -Wall -W -Wpointer-arith -Wbad-function-cast -Wpedantic -D_XOPEN_SOURCE=700"
|
||||
DEBDIR="dist/djl-utils"
|
||||
|
||||
commands="bin clean deb help"
|
||||
|
||||
prettyname() {
|
||||
basename "$1" | rev | cut -d'.' -f2 | rev
|
||||
}
|
||||
|
||||
help() {
|
||||
echo "$0 [$(echo "$commands" | tr ' ' '|')]" > /dev/stderr
|
||||
}
|
||||
|
||||
cbuild() {
|
||||
target="$1"
|
||||
targetdest="bin/$(prettyname "$target")"
|
||||
shift
|
||||
(set -x; cc $CFLAGS -o "$targetdest" "$target" "$@")
|
||||
}
|
||||
|
||||
fbuild() {
|
||||
target="$1"
|
||||
targetdest="bin/$(prettyname "$target")"
|
||||
(set -x; cp "$target" "$targetdest")
|
||||
}
|
||||
|
||||
bin() {
|
||||
[ ! -d bin ] && mkdir bin
|
||||
|
||||
for f in src/*.c; do
|
||||
cbuild "$f"
|
||||
done
|
||||
|
||||
for f in src/pasta src/sign src/timestamp; do
|
||||
fbuild "$f"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
deb() {
|
||||
bin
|
||||
[ -d "$DEBDIR" ] && rm -f "$DISTDIR"
|
||||
(set -x; mkdir -p "$DEBDIR/usr/bin"
|
||||
mkdir -p "$DEBDIR/usr/share/man"
|
||||
cp bin/* "$DEBDIR/usr/bin"
|
||||
cp doc/* "$DEBDIR/usr/share/man"
|
||||
cp -r pkgsrc/DEBIAN "$DEBDIR"
|
||||
sed -i "s/%VERSION%/$VERSION/g" "$DEBDIR/DEBIAN/control"
|
||||
dpkg-deb -b "$DEBDIR")
|
||||
}
|
||||
|
||||
clean() {
|
||||
(set -x; rm -rf dist bin)
|
||||
}
|
||||
|
||||
test -z "$1" && bin || $1
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
Package: djl-utils
|
||||
Version: 0.0.1
|
||||
Version: %VERSION%
|
||||
Section: custom
|
||||
Priority: optional
|
||||
Architecture: all
|
|
@ -47,7 +47,7 @@ int main(int argc, char* argv[]) {
|
|||
while (time) {
|
||||
/* Clear stdout, otherwise going from e.g. 10->9 leaves a trailing 0 */
|
||||
printf("\r ");
|
||||
printf("\r%d", time);
|
||||
printf("\r%d", (int)time);
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
time--;
|
||||
|
|
Loading…
Reference in New Issue