blob: 5c7ccc192ebf0c3e8a869231e983f269498d07c4 (
plain)
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
|
# whether to link dynamically
# if static=0 then link dynamically
# if static=2 then link statically
# if static=1 then link libkondo statically but other libraries dynamically
STATIC=1
VERSION=0.3.1
# products of the compilation
PROJECT_BINS= root_newton integral_gauss-legendre
# debug and optimization flags
#DB= -ggdb
OPT= -O3
# warning flags
WARNINGS= -Wall -Wextra -Wno-strict-overflow -std=c99 -pedantic -Wno-unused-parameter
# compiler
CC=/usr/bin/gcc
LD=$(CC)
# directories
INCLUDE =
LIB =
#INCLUDE = -I../../include
#LIB = -L../../build
# flags
override LDFLAGS +=$(LIB)
override CFLAGS +=$(INCLUDE) $(DB) $(OPT) $(WARNINGS)
# build directories
BUILDDIR=./build
SRCDIR=./src
OBJDIR=./objs
# objects
OBJS = $(addprefix $(OBJDIR)/, root_newton.o integral_gauss-legendre.o)
# flags which depend on whether to link statically or dynamically
# lib flag
LIBINUM_FLAG=-linum
# additional library required for static linking
XTRA_LIBS=
ifeq ($(STATIC),1)
# libinum is linked against libm, libmpfr, libgmp and libpthread
XTRA_LIBS=-lm -lmpfr -lgmp -lpthread
# link binaries using the static library
LIBINUM_FLAG=-l:libinum.a
else ifeq ($(STATIC),2)
# libinum is linked against libm, libmpfr, libgmp and libpthread
XTRA_LIBS=-lm -lmpfr -lgmp -lpthread
# link binaries statically
override LDFLAGS += -static
else
# required flag for subsequent dynamic linking
override CFLAGS += -fPIC
endif
all: init $(PROJECT_BINS)
# create dirs
init:
@[ -d $(OBJDIR) ] || /bin/mkdir $(OBJDIR)
@[ -d $(BUILDDIR) ] || /bin/mkdir $(BUILDDIR)
root_newton:
$(CC) -c $(CFLAGS) src/$@.c -o objs/$@.o
$(LD) $(LDFLAGS) -o $(BUILDDIR)/$@ objs/$@.o $(LIBINUM_FLAG) $(XTRA_LIBS)
integral_gauss-legendre:
$(CC) -c $(CFLAGS) src/$@.c -o objs/$@.o
$(LD) $(LDFLAGS) -o $(BUILDDIR)/$@ objs/$@.o $(LIBINUM_FLAG) $(XTRA_LIBS)
clean:
@rm -rf $(OBJDIR)
@rm -rf $(BUILDDIR)
|