stc/Makefile

47 lines
1009 B
Makefile
Raw Normal View History

2020-09-02 19:09:52 +02:00
CPPFLAGS = -D_FORTIFY_SOURCE=2 -D_DEFAULT_SOURCE
CFLAGS = $(CPPFLAGS) -std=c99 -pedantic -Wall -Wextra -Werror -Os -march=native -mtune=native -fPIE
LDFLAGS = -Wl,-z,now,-z,relro,-s,-pie
OBJS = obj/main.o
BIN = bin/stc
MAN = man1/stc.1.gz
2020-09-02 19:09:52 +02:00
PREFIX = /usr
default: obj bin $(BIN) $(MAN)
2020-09-02 19:09:52 +02:00
obj:
@mkdir obj
bin:
@mkdir bin
$(BIN): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
obj/%.o: src/%.c
$(CC) -c -o $@ $^ $(CFLAGS)
man1/%.1.gz: man1/%.1
gzip --keep --best -c $^ > $@
2020-09-02 19:09:52 +02:00
clean:
@[ -d obj ] && rm -rf obj
@[ -d bin ] && rm -rf bin
@[ -f $(MAN) ] && rm -f $(MAN)
2020-09-02 19:09:52 +02:00
format:
@clang-format -i -style="{BasedOnStyle: mozilla, IndentWidth: 4}" src/*.c
install: default
install -Dm755 $(BIN) $(PREFIX)/bin/stc
install -Dm644 LICENSE $(PREFIX)/share/licenses/stc/LICENSE
install -Dm644 man1/stc.1.gz $(PREFIX)/share//man/man1/stc.1.gz
2020-09-02 19:09:52 +02:00
uninstall:
rm -f $(PREFIX)/bin/stc
rm -f $(PREFIX)/share/licenses/stc/LICENSE
rm -f $(PREFIX)/share/man/man1/stc.1.gz
2020-09-02 19:09:52 +02:00
.PHONY: default clean format install uninstall