tmus

TUI Music Player
git clone https://git.sinitax.com/sinitax/tmus
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

commit f07580d31d1148c4a1811c36b09ca0ad50d9576b
parent faee8e9c6db45c6adacfc5113d55927f92e8bf29
Author: Louis Burda <quent.burda@gmail.com>
Date:   Mon, 20 Dec 2021 16:25:43 +0100

Restructured repository and added automatic make dependency generation

Diffstat:
M.gitignore | 1+
MMakefile | 27+++++++++++++++++++++++----
Dlist.h | 34----------------------------------
Dref.h | 16----------------
Rhistory.c -> src/history.c | 0
Rhistory.h -> src/history.h | 0
Rlist.c -> src/list.c | 0
Asrc/list.h | 35+++++++++++++++++++++++++++++++++++
Rlistnav.c -> src/listnav.c | 0
Rlistnav.h -> src/listnav.h | 0
Rmain.c -> src/main.c | 0
Rplayer.c -> src/player.c | 0
Rplayer.h -> src/player.h | 0
Rref.c -> src/ref.c | 0
Asrc/ref.h | 16++++++++++++++++
Rtag.c -> src/tag.c | 0
Asrc/tag.h | 12++++++++++++
Rtrack.c -> src/track.c | 0
Rtrack.h -> src/track.h | 0
Rutil.c -> src/util.c | 0
Rutil.h -> src/util.h | 0
Dtag.h | 12------------
22 files changed, 87 insertions(+), 66 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -3,3 +3,4 @@ tmus env.sh *.o todo +build diff --git a/Makefile b/Makefile @@ -1,5 +1,11 @@ -CFLAGS = -I . -g +CC = clang +CFLAGS = -I src -g LDLIBS = -lcurses -lreadline -lmpdclient +WARNFLAGS = -Wno-pragma-once-outside-header + +SRCS = $(wildcard src/*.c) +OBJS = $(SRCS:src/%.c=build/%.o) +DEPS = $(OBJS:%.o=%.d) .PHONY: all tmus clean install uninstall @@ -8,10 +14,22 @@ all: tmus clean: rm tmus -%.o: %.c %.h - $(CC) -c -o $@ $< $(CFLAGS) $(LDLIBS) +build: + mkdir build + +build/%.o: src/%.c build/%.d + @echo DEPS: $^ + $(CC) -c -o $@ $< $(CFLAGS) + +build/main.d: src/main.c | build + $(CC) -c -MT build/main.o -MMD -MP -MF $@ $< -tmus: main.c util.o history.o list.o player.o tag.o track.o listnav.o ref.o +build/%.d: src/%.c src/%.h | build + $(CC) -c -MT build/$*.o -MMD -MP -MF $@ $^ $(WARNFLAGS) + +-include $(DEPS) + +tmus: $(OBJS) $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) install: @@ -19,3 +37,4 @@ install: uninstall: rm /usr/bin/tmus + diff --git a/list.h b/list.h @@ -1,34 +0,0 @@ -#pragma once - -#include <stdlib.h> - -#define OFFSET(type, attr) ((size_t) &((type *)0)->attr) -#define UPCAST(ptr, type) ({ \ - const typeof( ((type *)0)->link ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - OFFSET(type, link) ); }) - -#define LIST_HEAD ((struct link) { .prev = NULL, .next = NULL }) -#define LINK_EMPTY ((struct link) { 0 }) - -#define LINK(p) (&(p)->link) - -struct link { - struct link *prev; - struct link *next; -}; - -/* list_XXX functions operate on the list head */ - -int list_empty(struct link *head); -int list_len(struct link *head); -int list_ffind(struct link *head, struct link *link); - -struct link *link_back(struct link *list); -void link_prepend(struct link *list, struct link *link); -void link_append(struct link *list, struct link *link); -struct link *link_pop(struct link *link); - -struct link *link_iter(struct link *link, int n); - -void list_push_back(struct link *list, struct link *link); - diff --git a/ref.h b/ref.h @@ -1,16 +0,0 @@ -#pragma once - -#include "link.h" - -struct ref { - void *data; - - struct link link; -}; - -struct ref *ref_init(void *data); -void ref_free(struct ref *ref); - -void refs_free(struct link *head); -int refs_incl(struct link *head, void *data); -void refs_rm(struct link *head, void *data); diff --git a/history.c b/src/history.c diff --git a/history.h b/src/history.h diff --git a/list.c b/src/list.c diff --git a/src/list.h b/src/list.h @@ -0,0 +1,35 @@ +#pragma once + +#include <stdlib.h> + +#define OFFSET(type, attr) ((size_t) &((type *)0)->attr) +#define UPCAST(ptr, type) ({ \ + const typeof( ((type *)0)->link ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - OFFSET(type, link) ); }) + +#define LIST_HEAD ((struct link) { .prev = NULL, .next = NULL }) +#define LINK_EMPTY ((struct link) { 0 }) + +#define LINK(p) (&(p)->link) + +struct link { + struct link *prev; + struct link *next; +}; + +/* list_XXX functions operate on the list head */ + +int list_empty(struct link *head); +int list_len(struct link *head); +int list_ffind(struct link *head, struct link *link); + +struct link *link_back(struct link *list); +void link_prepend(struct link *list, struct link *link); +void link_append(struct link *list, struct link *link); +struct link *link_pop(struct link *link); + +struct link *link_iter(struct link *link, int n); + +void list_push_back(struct link *list, struct link *link); + +//rstrrrstrssiimmrsrsssts diff --git a/listnav.c b/src/listnav.c diff --git a/listnav.h b/src/listnav.h diff --git a/main.c b/src/main.c diff --git a/player.c b/src/player.c diff --git a/player.h b/src/player.h diff --git a/ref.c b/src/ref.c diff --git a/src/ref.h b/src/ref.h @@ -0,0 +1,16 @@ +#pragma once + +#include "list.h" + +struct ref { + void *data; + + struct link link; +}; + +struct ref *ref_init(void *data); +void ref_free(struct ref *ref); + +void refs_free(struct link *head); +int refs_incl(struct link *head, void *data); +void refs_rm(struct link *head, void *data); diff --git a/tag.c b/src/tag.c diff --git a/src/tag.h b/src/tag.h @@ -0,0 +1,12 @@ +#pragma once + +#include "list.h" +#include "util.h" + +struct tag { + char *name; + char *fname, *fpath; + + struct link link; +}; + diff --git a/track.c b/src/track.c diff --git a/track.h b/src/track.h diff --git a/util.c b/src/util.c diff --git a/util.h b/src/util.h diff --git a/tag.h b/tag.h @@ -1,12 +0,0 @@ -#pragma once - -#include "link.h" -#include "util.h" - -struct tag { - char *name; - char *fname, *fpath; - - struct link link; -}; -