-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (25 loc) · 787 Bytes
/
Makefile
File metadata and controls
34 lines (25 loc) · 787 Bytes
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
CC=gcc
SYMBOLS?=_ARCHLINUX # Arch linux symbol; replace with empty definition to compile for other linux / macOS
CFLAGS=-std=c18 $(addprefix -D , ${SYMBOLS}) -Wall -Wextra -pedantic -Wfatal-errors
LDLIBS=-ledit -lm
VPATH=src/
OBJPATH=out/
SRCS=grammar.c builtin.c execute.c mpc.c lisper.c value.c environment.c mempool.c prgparams.c
OBJS=$(SRCS:%.c=${OBJPATH}%.o)
HDRS=$(wildcard ${VPATH}*.h)
TARGET?=lisper
ifeq (${DEBUG}, 1) # use DEBUG=1 to enable debug symbols to be compiled in
CFLAGS+=-g3 -gdwarf-2
SYMBOLS+=_DEBUG
endif
.PHONY: all clean debug
all: $(TARGET)
debug: clean
DEBUG=1 $(MAKE) all
$(TARGET): $(OBJS) $(HDRS)
$(CC) $(CFLAGS) $^ -o $@ $(LDLIBS)
$(OBJS): $(OBJPATH)%.o: %.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
clean:
$(RM) -r $(TARGET) $(OBJPATH)