csope/Makefile

50 lines
883 B
Makefile
Raw Normal View History

# CC=gcc
2023-08-04 15:17:55 -04:00
CFLAGS:=-Wall -Wextra -Wpedantic
CPPFLAGS:=-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
LDLIBS=-I ${CHDRD} -lncurses -ltinfo -lreadline
2023-07-27 14:04:50 -04:00
LEX:=flex
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
2023-08-04 15:17:55 -04:00
ifeq (${DEBUG},1)
CFLAGS += -Og -ggdb
else
CFLAGS += -O3 -flto=auto -fomit-frame-pointer
endif
ifdef SAN
CFLAGS += -fsanitize=${SAN}
endif
2023-07-27 14:04:50 -04:00
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}