-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (49 loc) · 1.14 KB
/
Makefile
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
53
54
55
56
57
58
59
60
61
62
63
64
# ce Makefile
BIN=ce
CC?=cc
PREFIX?=/usr/local
OBJDIR?=obj
INSTALL_DIR=$(PREFIX)/bin
MAN_DIR?=$(PREFIX)/share/man
SRC= ce.c \
buffer.c \
dirlist.c \
editor.c \
game.c \
hist.c \
proc.c \
syntax.c \
term.c \
utf8.c
CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
CFLAGS+=-Wsign-compare -std=c99 -pedantic -ggdb
CFLAGS+=-DPREFIX='"$(PREFIX)"' -fstack-protector-all
OBJS= $(SRC:%.c=$(OBJDIR)/%.o)
LDFLAGS+=-lm
ifneq ("$(SANITIZE)", "")
CFLAGS+=-fsanitize=$(SANITIZE)
LDFLAGS+=-fsanitize=$(SANITIZE)
endif
OSNAME=$(shell uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
ifeq ("$(OSNAME)", "darwin")
OBJS+=$(OBJDIR)/macos.o
LDFLAGS+=-framework Foundation -framework Appkit
else ifeq ("$(OSNAME)", "linux")
CFLAGS+=-D_GNU_SOURCE
endif
all: $(BIN)
$(BIN): $(OBJDIR) $(OBJS)
$(CC) $(OBJS) $(LDFLAGS) -o $(BIN)
$(OBJDIR):
@mkdir -p $(OBJDIR)
install:
mkdir -p $(INSTALL_DIR)
install -m 555 $(BIN) $(INSTALL_DIR)/$(BIN)
$(OBJDIR)/%.o: %.m
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(BIN) $(OBJDIR)
.PHONY: all clean