2023-08-28 14:56:34 -04:00
|
|
|
TARGET:=hl
|
|
|
|
|
2023-09-18 15:55:50 -04:00
|
|
|
CFLAGS := -std=c99
|
|
|
|
CPPFLAGS := -Iinclude -D_GNU_SOURCE
|
2023-08-28 14:56:34 -04:00
|
|
|
|
|
|
|
DEBUG=1
|
|
|
|
|
|
|
|
ifeq (${DEBUG},1)
|
2023-09-18 15:55:50 -04:00
|
|
|
CFLAGS += -Og -ggdb -pg -fno-inline -Wall -Wextra -Wpedantic -Wshadow -Wundef
|
2023-08-28 14:56:34 -04:00
|
|
|
else
|
2023-09-18 15:55:50 -04:00
|
|
|
CFLAGS += -O2 -flto=auto -D_FORTIFY_SOURCE=2
|
2023-08-28 14:56:34 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
PREFIX:=/usr/bin
|
|
|
|
|
|
|
|
USER=$(shell whoami)
|
|
|
|
|
2023-08-21 09:30:48 -04:00
|
|
|
include chad.mk
|
2023-08-21 09:05:27 -04:00
|
|
|
|
2023-09-18 15:55:50 -04:00
|
|
|
SRC.dir := source
|
|
|
|
OBJ.dir := object
|
2023-08-16 01:06:37 -04:00
|
|
|
|
|
|
|
SRC:=$(shell find ${SRC.dir} -iname '*.c')
|
2023-08-19 07:18:34 -04:00
|
|
|
HDR:=$(shell find ${SRC.dir} -iname '*.h')
|
2023-08-21 09:25:14 -04:00
|
|
|
OBJ:=$(subst $(SRC.dir),$(OBJ.dir),$(SRC:.c=.o))
|
2023-08-19 07:18:34 -04:00
|
|
|
|
2023-08-21 09:05:27 -04:00
|
|
|
VPATH=${SRC.dir} ${OBJ.dir}
|
2023-08-19 07:18:34 -04:00
|
|
|
|
2023-08-21 09:05:27 -04:00
|
|
|
${OBJ.dir}/%.o: ${SRC.dir}/%.c
|
2023-08-16 01:06:37 -04:00
|
|
|
${COMPILE.c} $< -o $@
|
|
|
|
|
2023-08-29 13:09:55 -04:00
|
|
|
${TARGET}: ${OBJ} | ${HDR}
|
|
|
|
${LINK.c} $+ -o $@
|
2023-08-21 09:05:27 -04:00
|
|
|
|
|
|
|
${SRC} ${HDR}:
|
|
|
|
|
|
|
|
install: ${PREFIX}
|
2023-08-27 03:31:36 -04:00
|
|
|
install -v -g ${USER} -o ${USER} -m 744 ${TARGET} ${PREFIX}/
|
2023-08-21 09:05:27 -04:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
-rm ${PREFIX}/bin/${TARGET}
|
2023-08-19 07:18:34 -04:00
|
|
|
|
|
|
|
clean:
|
2023-08-21 09:05:27 -04:00
|
|
|
-rm ${OBJ} ${TARGET}
|
2023-08-16 11:30:29 -04:00
|
|
|
|
2023-08-19 07:18:34 -04:00
|
|
|
test: chad_test
|
2023-08-21 09:05:27 -04:00
|
|
|
|
|
|
|
.PHONY: test clean install
|
|
|
|
|
|
|
|
.DEFAULT_GOAL:=${TARGET}
|