aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-10-13 00:05:05 +0200
committerThomas Voss <mail@thomasvoss.com> 2022-10-13 00:05:05 +0200
commit9c6917a866bd7736001b88e10f20e0e35ec7e977 (patch)
tree60e5b59e6b9c57d334fb7f81cefcf46c7a7dd47e
parent7118692e506f9698a77c7cceea3b1dd47bb4b99a (diff)
Move from make(1) to tup(1)
-rw-r--r--.gitignore5
-rw-r--r--Makefile32
-rw-r--r--Tupfile.ini8
-rw-r--r--src/Tupfile12
4 files changed, 34 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore
index c96aa38..865f7fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.aspell.en.prepl
-*.[ao]
-*.so
man/*.bak
+src/*
+!src/*.[ch]
+!src/Tupfile
diff --git a/Makefile b/Makefile
index c9e54d4..788670a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,31 +1,21 @@
.POSIX:
-CFLAGS = -std=c11 -pipe -O3 -Wall -Wextra -Werror -pedantic
-PREFIX = /usr
-MANDIR = ${PREFIX}/share/man
+PREFIX = /usr
+DPREFIX = ${DESTDIR}${PREFIX}
+MANDIR = ${DPREFIX}/share/man
-sources = liblux.o lux.h
-outputs = liblux.so liblux.a
-
-all: ${outputs}
-
-liblux.o: liblux.c
-
-liblux.a: ${sources}
- ${AR} ${ARFLAGS} $@ liblux.o
-
-liblux.so: ${sources}
- ${CC} ${CFLAGS} -o $@ -fPIC -shared liblux.o
+all:
+ @echo "run `tup` to build the library" >&2
install:
- mkdir -p ${PREFIX}/include ${PREFIX}/lib ${MANDIR}/man0 ${MANDIR}/man3
- cp ${outputs} ${PREFIX}/lib
- cp lux.h ${PREFIX}/include
- cp man/*.0 ${MANDIR}/man0
- cp man/*.3 ${MANDIR}/man3
+ mkdir -p ${DPREFIX}/include ${DPREFIX}/lib ${DMANDIR}/man0 ${DMANDIR}/man3
+ cp src/liblux.a src/liblux.so ${DPREFIX}/lib
+ cp src/lux.h ${DPREFIX}/include
+ cp man/*.0 ${DMANDIR}/man0
+ cp man/*.3 ${DMANDIR}/man3
file=/usr/share/groff/site-tmac/mdoc.local; \
grep '^\.ds doc-str-Lb-liblux' $$file > /dev/null || \
cat man/Lb-desc.tmac >> $$file
clean:
- rm -f ${outputs} liblux.o
+ rm -rf .tup/ src/*.[ao] src/*.so
diff --git a/Tupfile.ini b/Tupfile.ini
new file mode 100644
index 0000000..8700219
--- /dev/null
+++ b/Tupfile.ini
@@ -0,0 +1,8 @@
+Run `tup` to compile everything:
+
+ $ tup
+ [ tup ] [0.002s] Scanning filesystem...
+ [ tup ] [0.005s] Reading in new environment variables...
+ [ tup ] [0.007s] Parsing Tupfiles...
+ ...
+ $
diff --git a/src/Tupfile b/src/Tupfile
new file mode 100644
index 0000000..ac7f050
--- /dev/null
+++ b/src/Tupfile
@@ -0,0 +1,12 @@
+import CFLAGS=
+CFLAGS += -Wall -Wextra -Wpedantic -Werror
+CFLAGS += -march=native -mtune=native
+CFLAGS += -fomit-frame-pointer -O3
+CFLAGS += -pipe
+
+import CC=cc
+import AR=ar
+
+: foreach *.c |> ^ CC %f^ $(CC) $(CFLAGS) -c %f |> %B.o
+: *.o |> ^ AR %f^ $(AR) crs %o %f |> liblux.a
+: *.o |> ^ CC %f^ $(CC) $(CFLAGS) -fPIC -shared -o %o %f |> liblux.so