-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (62 loc) · 1.34 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
VERSION := 1.0.0
LIBS := -lffi -lgmp -ljansson -lmpfr
CC := gcc
CFLAGS := -Wall -Wextra -Wno-unused-parameter
LDFLAGS := -lm $(LIBS)
BUILDDIR := build
SOURCEDIR := src
HEADERDIR := src
NAME := not
BINARY := not
RM := rm -rf
MKDIR := mkdir
ifeq ($(OS),Windows_NT)
ifeq ($(ARCH), ARM64)
CC = arm-none-eabi-gcc
else
CC = gcc
CFLAGS += -DWINDOWS
LDFLAGS += -lws2_32 -lShlwapi
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
AR=gcc-ar
CFLAGS += -DLINUX -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
LDFLAGS += -Wl,-rpath=./ -lpthread -pthread
endif
ifeq ($(UNAME_S),Darwin)
AR=ar
CFLAGS += -DDARWIN
endif
CFLAGS += -fPIC
LDFLAGS += -ldl
endif
DEBUG ?= 0
ifeq ($(DEBUG),0)
CFLAGS += -O2 -DNDEBUG
else
CFLAGS += -g -DDEBUG
endif
ifeq ($(USE_MALLOC)),1)
CFLAGS += -DUSE_MALLOC
endif
SOURCES := $(shell find $(SOURCEDIR) -name '*.c')
OBJECTS := $(addprefix $(BUILDDIR)/,$(SOURCES:$(SOURCEDIR)/%.c=%.o))
$(BINARY): $(OBJECTS)
@mkdir -p $(@D)
$(CC) $(OBJECTS) -o $@ $(LDFLAGS)
@echo CC LINK $@
$(BUILDDIR)/%.o: $(SOURCEDIR)/%.c
@mkdir -p $(@D)
@$(CC) $(CFLAGS) -I $(HEADERDIR) -I $(dir $<) -c $< -o $@
@echo CC $<
all: $(BINARY)
clean:
$(RM) $(BINARY) $(OBJECTS)
setup:
$(MKDIR) -p $(BUILDDIR)
# Builder uses this target to run your application.
test: $(BINARY)
./$(BINARY) -f ./test/test.not
.PHONY: all clean