quote-bot/makefile
2021-03-31 08:47:18 -04:00

54 lines
1.1 KiB
Makefile

INLINE_SQLITE ?= 0
WARN := -W -Wall -Wextra -pedantic -pedantic-errors
CC ?= gcc
SRC := $(wildcard *.c)
OBJ := $(SRC:.c=.o)
ifeq ($(INLINE_SQLITE),0)
TMP := $(OBJ)
OBJ := $(filter-out sqlite3.o,$(TMP))
LDFLAGS += -lsqlite3
endif
OPT := -ggdb -O0
ifeq ($(O),1)
OPT := -g -O1
else ifeq ($(O),2)
OPT := -g0 -O2
else ifeq ($(O),s)
OPT := -g0 -Os
endif
ifeq ($(LTO),1)
LDFLAGS += -funroll-loops -flto -fwhole-program
endif
ifeq ($(PROF),1)
DEBUG += --coverage -pg
LDFLAGS += -lgcov
endif
F := -Wl,-z,defs -Wl,-z,now -Wl,-z,relro -fpie -Wl,-pie -fpic -fstack-clash-protection -fstack-protector-all -fstack-protector-strong
FLAGS := -D_FORTIFY_SOURCE=2 -fasynchronous-unwind-tables -fexceptions -g -grecord-gcc-switches -fcf-protection -pipe -Wformat -Werror=format-security -Werror=implicit-function-declaration
CFLAGS += $(FLAGS)
LDFLAGS += $(FLAGS)
CFLAGS += $(OPT) -std=c99 $(WARN)
CFLAGS += -I.
LDFLAGS += -lircclient -lpthread
all: spammer
sqlite3.o: sqlite3.c
$(CC) -c $< -o $@ $(LDFLAGS)
spammer: $(OBJ)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
clean:
$(RM) -rf spammer db a.out *.o *.db *.sqlite3 *.exe *.dll