2023-09-02 17:12:22 -04:00
|
|
|
DEBUG:=0
|
2023-08-05 05:30:18 -04:00
|
|
|
|
2023-08-15 04:56:04 -04:00
|
|
|
LIBS:=ncurses readline history
|
|
|
|
|
2023-08-11 13:20:52 -04:00
|
|
|
CC:=gcc
|
2023-08-04 15:17:55 -04:00
|
|
|
CFLAGS:=-Wall -Wextra -Wpedantic
|
2023-09-25 17:15:12 -04:00
|
|
|
CFLAGS +=$(if $(DEBUG),-O0 -ggdb -Wall -Wpedantic,-O3 -flto=auto -fomit-frame-pointer)
|
2023-08-11 13:20:52 -04:00
|
|
|
CFLAGS +=$(if $(SAN),-fsanitize=${SAN})
|
2023-08-15 04:56:04 -04:00
|
|
|
CPPFLAGS:=-I config/ -I ${CHDRD} ${shell pkg-config --cflags ${LIBS}}
|
|
|
|
LDLIBS=${shell pkg-config --libs ${LIBS}}
|
2023-07-27 14:04:50 -04:00
|
|
|
LEX:=flex
|
|
|
|
|
2023-10-01 14:47:54 -04:00
|
|
|
LEXD:=source/
|
2023-07-27 14:04:50 -04:00
|
|
|
LEXF:=$(shell find ${LEXD} -iname '*.l')
|
2023-08-04 15:09:58 -04:00
|
|
|
GENLEX:=$(subst .l,.c,${LEXF})
|
2023-07-27 14:04:50 -04:00
|
|
|
|
2023-10-01 14:47:54 -04:00
|
|
|
SRCD:=source//
|
|
|
|
OBJD:=object/
|
|
|
|
source:=$(shell find ${SRCD} -iname '*.c') ${GENLEX}
|
|
|
|
object:=$(subst .c,.o,$(subst ${SRCD},${OBJD},${source}))
|
2023-07-27 14:04:50 -04:00
|
|
|
|
|
|
|
HDRD:=${SRCD}
|
2023-08-11 13:20:52 -04:00
|
|
|
CONFD:=config/
|
2023-07-27 14:04:50 -04:00
|
|
|
CHDRD:=${OBJD}
|
2023-08-11 13:20:52 -04:00
|
|
|
HDR:=$(shell find ${HDRD} ${CONFD} -iname '*.h')
|
|
|
|
CHDR:=$(addsuffix .gch,$(subst ${HDRD},${CHDRD},$(subst ${CONFD}, ${CHDRD}, ${HDR})))
|
2023-07-27 14:04:50 -04:00
|
|
|
|
|
|
|
OUTPUT:=csope
|
|
|
|
|
2023-10-01 14:47:54 -04:00
|
|
|
main: ${CHDR} ${object}
|
|
|
|
${LINK.c} ${object} -o ${OUTPUT} ${LDLIBS}
|
2023-07-27 14:04:50 -04:00
|
|
|
|
2023-10-01 14:47:54 -04:00
|
|
|
object/%.o: source/%.c
|
2023-07-27 14:04:50 -04:00
|
|
|
${COMPILE.c} $< -o $@
|
|
|
|
|
2023-10-01 14:47:54 -04:00
|
|
|
source/%.c: source/%.l
|
2023-07-27 14:04:50 -04:00
|
|
|
${LEX} -o $@ $<
|
|
|
|
|
2023-10-01 14:47:54 -04:00
|
|
|
object/%.h.gch: source/%.h
|
2023-07-27 14:04:50 -04:00
|
|
|
${CC} $< -o $@
|
|
|
|
|
2023-10-01 14:47:54 -04:00
|
|
|
object/%.h.gch: config/%.h
|
2023-08-11 13:20:52 -04:00
|
|
|
${CC} $< -o $@
|
|
|
|
|
2023-08-16 09:00:06 -04:00
|
|
|
install: ${OUTPUT}
|
|
|
|
cp ${OUTPUT} /usr/bin/
|
|
|
|
|
2023-07-27 14:04:50 -04:00
|
|
|
clean:
|
|
|
|
-rm ${CHDR}
|
|
|
|
-rm ${GENLEX}
|
2023-10-01 14:47:54 -04:00
|
|
|
-rm ${object}
|
2023-07-27 14:04:50 -04:00
|
|
|
-rm ${OUTPUT}
|