forked from flintlib/flint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
136 lines (103 loc) · 4.56 KB
/
Makefile.in
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
LIBS=-L$(CURDIR) -L$(FLINT_MPIR_LIB_DIR) -L$(FLINT_MPFR_LIB_DIR) -L$(FLINT_NTL_LIB_DIR) -lflint -lmpir -lmpfr -lm
LIBS2=-L$(FLINT_MPIR_LIB_DIR) -L$(FLINT_MPFR_LIB_DIR) -L$(FLINT_NTL_LIB_DIR) -lmpir -lmpfr -lm
INCS=-I$(CURDIR) -I$(FLINT_MPIR_INCLUDE_DIR) -I$(FLINT_MPFR_INCLUDE_DIR) -I$(FLINT_NTL_INCLUDE_DIR)
LINKLIBS=
LD_LIBRARY_PATH:=${CURDIR}:${FLINT_MPFR_LIB_DIR}:${FLINT_MPIR_LIB_DIR}:${FLINT_NTL_LIB_DIR}:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
export
SOURCES = $(wildcard *.c)
HEADERS = $(wildcard *.h)
OBJS = $(patsubst %.c, build/%.o, $(LIB_SOURCES))
LIB_OBJS = $(patsubst %.c, build/%.lo, $(LIB_SOURCES))
LIB_SOURCES = $(SOURCES) $(foreach dir, $(BUILD_DIRS), $(wildcard $(dir)/*.c))
EXMP_SOURCES = $(wildcard examples/*.c)
TEST_SOURCES = $(wildcard test/*.c)
PROF_SOURCES = $(wildcard profile/*.c)
TUNE_SOURCES = $(wildcard tune/*.c)
EXMPS = $(patsubst %.c, %, $(EXMP_SOURCES))
TESTS = $(patsubst %.c, %, $(TEST_SOURCES))
PROFS = $(patsubst %.c, %, $(PROF_SOURCES))
TUNE = $(patsubst %.c, %, $(TUNE_SOURCES))
all: all-dirs $(OBJS) recursive library
all-dirs:
$(foreach dir, $(BUILD_DIRS), mkdir -p build/$(dir);)
clean:
$(foreach dir, $(BUILD_DIRS), export BUILD_DIR=../build/$(dir); $(MAKE) -C $(dir) clean;)
rm -f $(OBJS) $(LOBJS) $(TESTS) $(PROFS) $(EXMPS) $(FLINT_LIB) libflint.a
rm -rf build
distclean: clean
rm -f Makefile
dist:
git archive --format tar --prefix flint-2.3/ trunk > ../flint-2.3.tar; gzip ../flint-2.3.tar
profile: all profiler.o
mkdir -p build/profile
$(foreach prog, $(PROFS), $(CC) -O2 -std=c99 $(INCS) $(prog).c profiler.o -o build/$(prog) $(LIBS);)
$(foreach dir, $(BUILD_DIRS), mkdir -p build/$(dir)/profile; export BUILD_DIR=../build/$(dir); $(MAKE) -C $(dir) profile;)
tune: all
mkdir -p build/tune
$(foreach prog, $(TUNE), $(CC) -O2 -std=c99 $(INCS) $(prog).c -o build/$(prog) $(LIBS);)
$(foreach dir, $(BUILD_DIRS), mkdir -p build/$(dir)/tune; export BUILD_DIR=../build/$(dir); $(MAKE) -C $(dir) tune;)
recursive:
$(foreach dir, $(BUILD_DIRS), export BUILD_DIR=../build/$(dir); $(MAKE) -C $(dir);)
examples: all $(LOBJS) library
mkdir -p build/examples
$(foreach prog, $(EXMPS), $(CC) $(CFLAGS) $(INCS) $(prog).c -o build/$(prog) $(LIBS);)
check: $(FLINT_LIB)
ifndef MOD
mkdir -p build/test
mkdir -p build/interfaces/test
$(foreach prog, $(TESTS), $(CC) $(CFLAGS) $(INCS) $(prog).c -o build/$(prog) $(LIBS);)
$(foreach prog, $(TESTS), build/$(prog);)
$(foreach dir, $(BUILD_DIRS), mkdir -p build/$(dir)/test; export BUILD_DIR=../build/$(dir); $(MAKE) -C $(dir) check;)
if [ "$(WANT_NTL)" -eq "1" ]; then \
$(CXX) $(CFLAGS) $(INCS) interfaces/test/t-NTL-interface.cpp build/interfaces/NTL-interface.o -o build/interfaces/test/t-NTL-interface $(LIBS) -lntl; \
build/interfaces/test/t-NTL-interface; \
fi
else
$(foreach dir, $(MOD), mkdir -p build/$(dir)/test; export BUILD_DIR=../build/$(dir); $(MAKE) -C $(dir) check;)
endif
library: library-recursive $(OBJS) $(LIB_OBJS)
mkdir -p build
mkdir -p build/interfaces
if [ "$(WANT_NTL)" -eq "1" ]; then \
if [ "$(FLINT_SHARED)" -eq "1" ]; then \
$(CXX) -fPIC $(CFLAGS) $(INCS) -c interfaces/NTL-interface.cpp -o build/interfaces/NTL-interface.lo; \
fi; \
if [ "$(FLINT_STATIC)" -eq "1" ]; then \
$(CXX) -fPIC $(CFLAGS) $(INCS) -c interfaces/NTL-interface.cpp -o build/interfaces/NTL-interface.o; \
fi; \
fi
if [ "$(FLINT_SHARED)" -eq "1" ]; then \
$(CC) -fPIC -shared $(LIB_OBJS) $(LIBS2) -o $(FLINT_LIB); \
fi
if [ "$(FLINT_STATIC)" -eq "1" ]; then \
$(AR) rcs libflint.a $(OBJS) $(LINKLIBS); \
fi
library-recursive:
if [ "$(FLINT_STATIC)" -eq "1" ]; then \
$(foreach dir, $(BUILD_DIRS), mkdir -p build/$(dir); export BUILD_DIR=../build/$(dir); $(MAKE) -C $(dir);) \
fi
if [ "$(FLINT_SHARED)" -eq "1" ]; then \
$(foreach dir, $(BUILD_DIRS), mkdir -p build/$(dir); export BUILD_DIR=../build/$(dir); $(MAKE) -C $(dir) library;) \
fi
$(FLINT_LIB): library
install: library
mkdir -p $(PREFIX)/lib
mkdir -p $(PREFIX)/include
if [ "$(FLINT_SHARED)" -eq "1" ]; then \
cp $(FLINT_LIB) $(PREFIX)/lib;
fi
if [ "$(FLINT_STATIC)" -eq "1" ]; then \
cp libflint.a $(PREFIX)/lib;
fi
cp *.h $(PREFIX)/include
.PHONY: profile library library-recursive recursive clean check check-recursive all
build/%.lo: %.c
$(CC) -fPIC $(CFLAGS) $(INCS) -c $< -o $@
build/%.o: %.c
$(CC) -fPIC $(CFLAGS) $(INCS) -c $< -o $@
BUILD_DIRS = ulong_extras long_extras perm fmpz fmpz_vec fmpz_poly fmpq_poly \
fmpz_mat mpfr_vec mpfr_mat nmod_vec nmod_poly \
arith mpn_extras nmod_mat fmpq fmpq_mat padic fmpz_poly_q \
fmpz_poly_mat nmod_poly_mat fmpz_mod_poly fmpz_factor fmpz_poly_factor \
fft