dotfiles/vim/.vim/UltiSnips/make.snippets

31 lines
463 B
Plaintext
Raw Permalink Normal View History

2024-01-03 11:04:20 +01:00
snippet base "tonitch's makefile base" b
.PHONY: all clean run
VERSION = 0.0.1
2024-01-10 14:46:47 +01:00
LIBS = $2
2024-01-03 11:04:20 +01:00
CMACRO = -DVERSION=\"$(VERSION)\"
CC = gcc
CFLAGS = -g -Wall -Wextra -pedantic $(shell pkg-config $(LIBS) --cflags) $(CMACRO)
LDFLAGS = $(shell pkg-config $(LIBS) --libs)
2024-01-10 14:46:47 +01:00
all: ${1:${VISUAL:main}}
2024-01-03 11:04:20 +01:00
2024-01-10 14:46:47 +01:00
$1: $1.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
2024-01-03 11:04:20 +01:00
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
2024-01-10 14:46:47 +01:00
$0
2024-01-03 11:04:20 +01:00
clean:
rm -f *.o
2024-01-10 14:46:47 +01:00
rm -f $1
2024-01-03 11:04:20 +01:00
bear: clean
bear -- make
2024-01-10 14:46:47 +01:00
run: $1
2024-01-03 11:04:20 +01:00
./$<
endsnippet