csope/Makefile

53 lines
921 B
Makefile
Raw Normal View History

2023-08-05 05:30:18 -04:00
DEBUG:=1
2023-08-08 14:34:15 -04:00
GCC:=0
2023-08-05 05:30:18 -04:00
CC=gcc
2023-08-04 15:17:55 -04:00
CFLAGS:=-Wall -Wextra -Wpedantic
2023-08-04 15:24:41 -04:00
CPPFLAGS:=${shell pkg-config --cflags ncurses readline}
LDLIBS=-I ${CHDRD} ${shell pkg-config --libs ncurses readline}
2023-07-27 14:04:50 -04:00
LEX:=flex
2023-08-08 14:34:15 -04:00
ifeq (${DEBUG},1)
CFLAGS += -O0 -ggdb
else
CFLAGS += -O3 -flto=auto -fomit-frame-pointer
endif
ifdef SAN
CFLAGS += -fsanitize=${SAN}
endif
2023-07-27 14:04:50 -04:00
LEXD:=src/
LEXF:=$(shell find ${LEXD} -iname '*.l')
GENLEX:=$(subst .l,.c,${LEXF})
2023-07-27 14:04:50 -04:00
SRCD:=src/
OBJD:=obj/
SRC:=$(shell find ${SRCD} -iname '*.c') ${GENLEX}
OBJ:=$(subst .c,.o,$(subst ${SRCD},${OBJD},${SRC}))
HDRD:=${SRCD}
CHDRD:=${OBJD}
HDR:=$(shell find ${HDRD} -iname '*.h')
CHDR:=$(addsuffix .gch,$(subst ${HDRD},${CHDRD},${HDR}))
OUTPUT:=csope
main: ${CHDR} ${OBJ}
${LINK.c} ${OBJ} -o ${OUTPUT} ${LDLIBS}
2023-07-27 14:04:50 -04:00
obj/%.o: src/%.c
${COMPILE.c} $< -o $@
src/%.c: src/%.l
${LEX} -o $@ $<
obj/%.h.gch: src/%.h
${CC} $< -o $@
clean:
-rm ${CHDR}
-rm ${GENLEX}
-rm ${OBJ}
-rm ${OUTPUT}