stc/Makefile

38 lines
684 B
Makefile

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
PREFIX = /usr
default: obj bin $(BIN)
obj:
@mkdir obj
bin:
@mkdir bin
$(BIN): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
obj/%.o: src/%.c
$(CC) -c -o $@ $^ $(CFLAGS)
clean:
@[ -d obj ] && rm -rf obj
@[ -d bin ] && rm -rf bin
format:
@clang-format -i -style="{BasedOnStyle: mozilla, IndentWidth: 4}" src/*.c
install: default
install -Dm755 $(BIN) $(PREFIX)/bin/stc
uninstall:
rm -f $(PREFIX)/bin/stc
.PHONY: default clean format install uninstall