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
|
2020-09-02 20:19:04 +02:00
|
|
|
MAN = man1/stc.1.gz
|
2020-09-02 19:09:52 +02:00
|
|
|
|
|
|
|
PREFIX = /usr
|
|
|
|
|
2020-09-02 20:19:04 +02:00
|
|
|
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)
|
|
|
|
|
2020-09-02 20:19:04 +02:00
|
|
|
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
|
2020-09-02 20:19:04 +02:00
|
|
|
@[ -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
|
2020-09-02 20:19:04 +02:00
|
|
|
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
|
2020-09-02 20:19:04 +02:00
|
|
|
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
|