-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
88 lines (67 loc) · 1.92 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
79
80
81
82
83
84
85
86
87
.DEFAULT_GOAL := lib/libnsat.so
# .DEFAULT_GOAL := ./bin/run_any_test
MODE=LB
TARGET = run_any_test
LTARGET = libnsat.so
INCDIR=include
SRCDIR=src
BINDIR=bin
DATADIR=data
OBJDIR=obj
#DEMODIR=tests/python
DEMODIR=tests/c
EXPDIR=examples
LIBDIR=lib
PYTHON=pyNSATlib
CC=gcc
LINKER=gcc -o
# LDFLAGS = -lm -std=c99 -pthread
LDFLAGS = -lm -pthread
#LDFLAGS = -pthread
# LDFLAGS = -lm -std=c99 -pg -pthread -no-pie # profiler
#LDFLAGS = -lm -pthread -pg
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
LDFLAGS = -pthread
endif
ifeq ($(MODE), DB)
CFLAGS=-g -Wall -Wextra -Wpedantic -fstack-protector-all -fPIC -I$(INCDIR)
# CFLAGS=-g -Wall -Wextra -Wpedantic -fstack-protector-all -I$(INCDIR)
# CFLAGS=-g -Wall -pedantic -fstack-protector-all -pg -I$(INCDIR)
else ifeq ($(MODE), LB)
CFLAGS= -Ofast -ftree-vectorize -fPIC -flto -msse2 -march=native -mtune=native -Wno-unused-result -I$(INCDIR)
else
CFLAGS=-Ofast -ftree-vectorize -msse2 -pipe -march=native -mtune=native -flto -Wno-unused-result -I$(INCDIR)
# CFLAGS=-O2 -funroll-loops -flto -I$(INCDIR)
endif
SOURCES := $(wildcard $(SRCDIR)/*.c)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
DEMOSRC := $(wildcard $(DEMODIR)/*.c)
#DEMOSRC := $(DEMODIR)/run_any_test.c
DEMOOBJ := $(DEMOSRC:$(DEMODIR)/%.c=$(OBJDIR)/%.o)
INCLUDES := $(wildcard $(INCDIR)/*.h)
$(OBJECTS): | $(OBJDIR) $(LIBDIR)
$(OBJDIR):
mkdir -p $@
$(LIBDIR):
mkdir -p $@
$(DATADIR):
mkdir -p $@
$(BINDIR)/$(TARGET): $(OBJECTS) $(DEMOOBJ)
$(LINKER) $@ $^ $(LDFLAGS)
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
$(DEMOOBJ): $(OBJDIR)/%.o : $(DEMODIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
$(LIBDIR)/$(LTARGET): $(OBJECTS)
$(CC) -shared -o $@ $^ $(LDFLAGS)
.PHONY: clean cleanall cleanpyc
cleanpyc:
@find . -name "*.pyc" -delete
clean: cleanpyc
rm -rf $(OBJDIR) \
rm -f *~ core $(INCDIR)/*~ \
rm -f $(LIBDIR)/*.so \
rm -f $(BINDIR)/*
cleanall: clean
rm -f $(DATADIR)/*