aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 05525e7529ffe11ebae46c7810a65384b5012b6b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
BIN        := halk
PREFIX     := /usr/local/bin
CC         := gcc
REG_CFLAGS := -std=c99 -O3 -s
DBG_CFLAGS := -Og -ggdb -pedantic -Wall -Wno-deprecated-declarations -fsanitize=leak,address,undefined -fno-omit-frame-pointer
CFLAGS     := ${REG_CFLAGS}
SRCS       := $(wildcard src/*.c)
# SRCS       := $(filter-out src/parser.c, $(SRCS))
OBJS       := $(SRCS:.c=.o)

all: halk

reg_options:
	@echo "HALK build options:"
	@echo "CC:         ${CC}"
	@echo "REG_CFLAGS: ${REG_CFLAGS}"
	@echo

dbg_options:
	@echo "HALK build options (dbg):"
	@echo "CC:         ${CC}"
	@echo "DBG_CFLAGS: ${DBG_CFLAGS}"
	@echo

%.o: %.c include/%.h
	${CC} -c $< -o $@

halk: reg_options ${OBJS}
	${CC} ${OBJS} ${REG_CFLAGS} -o ${BIN}.out

dbg: CFLAGS += ${DBG_CFLAGS}
dbg: dbg_options ${OBJS}
	${CC} ${OBJS} ${DBG_CFLAGS} -o ${BIN}.out

install: all
	mkdir -p ${PREFIX}
	cp -f ${BIN}.out ${PREFIX}/${BIN}
	chmod 755 ${PREFIX}/${BIN}

uninstall:
	rm -f ${PREFIX}/${BIN}

clean:
	rm -f ${BIN}.out src/*.o

me a:
	@exit

sandwich:
	@[ $(id -u) -eq 0 ] && echo "Okay." || echo "What? Make(1) it yourself."

.PHONY: all reg_options dbg_options dbg install uninstall clean