ap

An audio player suited to my tastes
Log | Files | Refs | README | LICENSE

commit 335cf5562928434589900fd148a958196d69016b
parent e7d4a70714211562320383e83eef334af33b3bfb
Author: Jacob R. Edwards <n/a>
Date:   Tue, 22 Feb 2022 17:47:37 -0800

Switch to the make(1) build system

The old mkfiles had some flaws, and while improving them I decided
to use make(1) instead; I find some things easier with it (though
some are harder), and it's included with every (good) UNIX system.

Variables like cc and cflags were replaced with their conventional
equivilents (in this case, CC and CFLAGS) so user preferences work
as expected.

Include files are now merged with library source files, it's just
easier that way, at least in this instance.

Diffstat:
AMakefile | 6++++++
Aapc/Makefile | 6++++++
Mapc/mkfile | 10++++------
Aaps/Makefile | 12++++++++++++
Daps/mkfile | 20--------------------
Aconfig.mk | 6++++++
Alib/ap/Makefile | 6++++++
Rinclude/ap/ap.h -> lib/ap/ap.h | 0
Rinclude/ap/buf.h -> lib/ap/buf.h | 0
Rinclude/ap/client.h -> lib/ap/client.h | 0
Rinclude/ap/con.h -> lib/ap/con.h | 0
Rinclude/ap/item.h -> lib/ap/item.h | 0
Dlib/ap/mkfile | 17-----------------
Rinclude/ap/quote.h -> lib/ap/quote.h | 0
Rinclude/ap/sock.h -> lib/ap/sock.h | 0
Amk/c.mk | 11+++++++++++
Dmk/clean.mk | 4----
Dmk/config.mk | 12------------
Dmk/dir.mk | 10----------
Amk/exe.mk | 12++++++++++++
Mmk/lib.mk | 26+++++++++++++++++---------
Mmk/obj.mk | 8+++++---
Mmk/prog.mk | 12++----------
23 files changed, 87 insertions(+), 91 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,6 @@ +subdirs = lib/ap aps apc + +all clean install uninstall: +.for subdir in ${subdirs} + make -C ${subdir} $@ +.endfor diff --git a/apc/Makefile b/apc/Makefile @@ -0,0 +1,6 @@ +name = apc +src = apc.c +ldlibs = ../lib/ap/libap.a +cflags = -I../inc + +.include "../mk/exe.mk" diff --git a/apc/mkfile b/apc/mkfile @@ -1,21 +1,19 @@ -# Copyright 2021 Jacob R. Edwards +# Copyright 2021, 2022 Jacob R. Edwards name = apc src = apc.c -obj = ${src:%.c=%.o} -lib = ap +lib = ../lib/ap/libap.a mk = ../mk cppflags = -I../include/ -ldflags = ${lib:%=-L../lib/%} -ldlibs = ${lib:%=-l%} +ldlibs = $lib all:V: $name apc.h:VQ: # -$obj: mkfile ${obj:%.o=%.h} +$obj: mkfile ${obj:%.o=%.h} $lib < $mk/config.mk < $mk/clean.mk diff --git a/aps/Makefile b/aps/Makefile @@ -0,0 +1,12 @@ +name = aps +src = aps.c arg.c asplit.c bug.c command.c find.c log.c main.c match.c \ + player.c queue.c response.c split.c +inc = ${src:.c=.h} util.h +ldlibs = ../lib/ap/libap.a +cflags = -I../inc + +.include "../mk/exe.mk" + +main.h: + +.PHONY: main.h diff --git a/aps/mkfile b/aps/mkfile @@ -1,20 +0,0 @@ -# Copyright 2021, 2022, 2022 Jacob R. Edwards - -name = aps -src = aps.c arg.c asplit.c bug.c command.c find.c log.c main.c\ - match.c player.c queue.c response.c split.c -lib = ../lib/ap/libap.a -mk = ../mk - -cppflags = -I../include -ldlibs = $lib - -all:V: $name - -< $mk/config.mk -< $mk/prog.mk - -main.h:VQ: - # - -$obj: mkfile config.h util.h ${obj:%.o=%.h} $lib diff --git a/config.mk b/config.mk @@ -0,0 +1,6 @@ +AR = ar +CC = cc +CFLAGS = -Wall -Wno-write-strings ${cflags} +LDFLAGS = -static ${ldflags} +LDLIBS = ${ldlibs} +PREFIX = /usr/local diff --git a/lib/ap/Makefile b/lib/ap/Makefile @@ -0,0 +1,6 @@ +name = ap +src = buf.c client.c con.c item.c quote.c sock.c +inc = ap.h ${src:.c=.h} +cflags = -I.. + +.include "../../mk/lib.mk" diff --git a/include/ap/ap.h b/lib/ap/ap.h diff --git a/include/ap/buf.h b/lib/ap/buf.h diff --git a/include/ap/client.h b/lib/ap/client.h diff --git a/include/ap/con.h b/lib/ap/con.h diff --git a/include/ap/item.h b/lib/ap/item.h diff --git a/lib/ap/mkfile b/lib/ap/mkfile @@ -1,17 +0,0 @@ -# Copyright 2021 Jacob R. Edwards - -name = libap.a -src = buf.c client.c con.c item.c quote.c sock.c -obj = ${src:%.c=%.o} -hdir = ../../include/ -mk = ../../mk - -cppflags = -I$hdir - -$name: $obj -all:V: $name - -< $mk/config.mk -< $mk/clean.mk -< $mk/obj.mk -< $mk/lib.mk diff --git a/include/ap/quote.h b/lib/ap/quote.h diff --git a/include/ap/sock.h b/lib/ap/sock.h diff --git a/mk/c.mk b/mk/c.mk @@ -0,0 +1,11 @@ +.include "../config.mk" +.include "obj.mk" + +all: ${name} + +${name}: Makefile ${obj} + +clean: + rm -f ${name} ${obj} + +.PHONY: all clean diff --git a/mk/clean.mk b/mk/clean.mk @@ -1,4 +0,0 @@ -# Copyright 2021 Jacob R. Edwards - -clean:V: - rm -f $name $obj diff --git a/mk/config.mk b/mk/config.mk @@ -1,12 +0,0 @@ -# Copyright 2021 Jacob R. Edwards - -ar = ar -cc = tcc - -cflags = $cflags -Wall -Wno-write-strings -static -cppflags = $cppflags -I/usr/include -ldflags = $ldflags -L/usr/lib -ldlibs = $ldlibs -lc - -prefix = /usr/local -manprefix = $prefix/man diff --git a/mk/dir.mk b/mk/dir.mk @@ -1,10 +0,0 @@ -# Copyright 2021 Jacob R. Edwards - -dir:Q: - PS4='' - set -x - for dir in $prereq - do ( - cd $dir - mk $MKFLAGS - ) done diff --git a/mk/exe.mk b/mk/exe.mk @@ -0,0 +1,12 @@ +.include "c.mk" + +${name}: ${lib} + ${CC} ${LDFLAGS} -o ${name} ${obj} ${LDLIBS} + +install: ${name} + cp -f ${name} ${PREFIX}/bin/${name} + +uninstall: + rm -f ${PREFIX}/bin/${name} + +.PHONY: install uninstall diff --git a/mk/lib.mk b/mk/lib.mk @@ -1,12 +1,20 @@ -# Copyright 2021 Jacob R. Edwards +.include "c.mk" -$name: $obj - $ar rcs $target $newprereq +lib = lib${name}.a -install:V: $name - cp -f $name $prefix/lib - cp -rf $hdir $prefix/include +${name}: ${lib} -uninstall:V: - rm -f $prefix/lib/$name - rm -rf $prefix/include/$(basename $hdir) +${lib}: ${obj} + ${AR} urcs $@ ${obj} + +install: + cp -f ${lib} ${PREFIX}/lib/${lib} + mkdir -p ${PREFIX}/include/${name} + cp -f ${inc} ${PREFIX}/include/${name} + +uninstall: + rm -f ${PREFIX}/lib/${lib} + rm -rf ${PREFIX}/include/${name} + +.PHONY: ${name} install uninstall +.SUFFIXES: .a .o diff --git a/mk/obj.mk b/mk/obj.mk @@ -1,4 +1,6 @@ -# Copyright 2021 Jacob R. Edwards +obj = ${src:.c=.o} -%.o: %.c - $cc $cppflags $cflags -c -o $stem.o $stem.c +.c.o: + ${CC} ${CFLAGS} -c -o $@ $< + +.SUFFIXES: .c .o diff --git a/mk/prog.mk b/mk/prog.mk @@ -1,10 +1,2 @@ -# Copyright 2021 Jacob R. Edwards - -$name: $obj - $cc $ldflags -o $target $obj $ldlibs - -install:V: $name - cp -f $name $prefix/bin - -uninstall:V: - rm -f $prefix/bin/$name +${name}: ${obj} + ${cc} ${ldflags} -o ${name} ${obj} ${lib}