forked from Nek5000/gslib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
133 lines (107 loc) · 3.35 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
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
MPI ?= 1
ADDUS ?= 1
USREXIT ?= 0
NBC ?= 0
LIBNAME ?= gs
BLAS ?= 0
DEBUG ?= 0
CFLAGS ?= -O2
FFLAGS ?= -O2
CPREFIX ?= gslib_
FPREFIX ?= fgslib_
SRCROOT=.
TESTDIR=$(SRCROOT)/tests
FTESTDIR=$(TESTDIR)/fortran
SRCDIR=$(SRCROOT)/src
INCDIR=$(SRCROOT)/src
LIBDIR=$(SRCROOT)/lib
ifneq (,$(strip $(DESTDIR)))
INSTALL_ROOT = $(DESTDIR)
else
INSTALL_ROOT = $(SRCROOT)/build
endif
$(shell >config.h)
ifneq (0,$(MPI))
SN=MPI
G:=$(G) -D$(SN)
ifeq ($(origin CC),default)
CC = mpicc
endif
ifeq ($(origin FC),default)
FC = mpif77
endif
$(shell printf "#ifndef ${SN}\n#define ${SN}\n#endif\n" >>config.h)
endif
ifneq (0,$(ADDUS))
SN=UNDERSCORE
G:=$(G) -D$(SN)
$(shell printf "#ifndef ${SN}\n#define ${SN}\n#endif\n" >>config.h)
endif
SN=GLOBAL_LONG_LONG
G:=$(G) -D$(SN)
$(shell printf "#ifndef ${SN}\n#define ${SN}\n#endif\n" >>config.h)
SN=PREFIX
G:=$(G) -D$(SN)=$(CPREFIX)
$(shell printf "#ifndef ${SN}\n#define ${SN} ${CPREFIX}\n#endif\n" >>config.h)
SN=FPREFIX
G:=$(G) -D$(SN)=$(FPREFIX)
$(shell printf "#ifndef ${SN}\n#define ${SN} ${FPREFIX}\n#endif\n" >>config.h)
ifneq (0,$(USREXIT))
G+=-DUSE_USR_EXIT
endif
ifneq (0,$(NBC))
G+=-DUSE_NBC
endif
ifeq (0,$(BLAS))
SN=USE_NAIVE_BLAS
G:=$(G) -D$(SN)
$(shell printf "#ifndef ${SN}\n#define ${SN}\n#endif\n" >>config.h)
endif
ifeq (1,$(BLAS))
G+=-DUSE_CBLAS
endif
ifneq (0,$(DEBUG))
G+=-DGSLIB_DEBUG
CFLAGS+=-g
endif
CCCMD=$(CC) $(CFLAGS) -I$(INCDIR) $(G)
FCCMD=$(FC) $(FFLAGS) -I$(INCDIR) $(G)
TESTS=$(TESTDIR)/sort_test $(TESTDIR)/sort_test2 $(TESTDIR)/sarray_sort_test \
$(TESTDIR)/comm_test $(TESTDIR)/crystal_test \
$(TESTDIR)/sarray_transfer_test $(TESTDIR)/gs_test \
$(TESTDIR)/gs_test_gop_blocking $(TESTDIR)/gs_test_gop_nonblocking \
$(TESTDIR)/gs_unique_test \
$(TESTDIR)/findpts_el_2_test \
$(TESTDIR)/findpts_el_2_test2 $(TESTDIR)/findpts_el_3_test \
$(TESTDIR)/findpts_el_3_test2 $(TESTDIR)/findpts_local_test \
$(TESTDIR)/findpts_test $(TESTDIR)/poly_test \
$(TESTDIR)/lob_bnd_test $(TESTDIR)/obbox_test
FTESTS=$(FTESTDIR)/f-igs
GS=$(SRCDIR)/gs.o $(SRCDIR)/sort.o $(SRCDIR)/sarray_transfer.o \
$(SRCDIR)/sarray_sort.o $(SRCDIR)/gs_local.o $(SRCDIR)/fail.o \
$(SRCDIR)/crystal.o $(SRCDIR)/comm.o $(SRCDIR)/tensor.o
FWRAPPER=$(SRCDIR)/fcrystal.o $(SRCDIR)/findpts.o
INTP=$(SRCDIR)/findpts_local.o $(SRCDIR)/obbox.o $(SRCDIR)/poly.o \
$(SRCDIR)/lob_bnd.o $(SRCDIR)/findpts_el_3.o $(SRCDIR)/findpts_el_2.o
.PHONY: all lib install tests clean objects
all : lib install
lib: $(GS) $(FWRAPPER) $(INTP)
@$(AR) cr $(SRCDIR)/lib$(LIBNAME).a $?
@ranlib $(SRCDIR)/lib$(LIBNAME).a
install: lib
@mkdir -p $(INSTALL_ROOT)/lib 2>/dev/null
@cp -v $(SRCDIR)/lib$(LIBNAME).a $(INSTALL_ROOT)/lib 2>/dev/null
@mkdir -p $(INSTALL_ROOT)/include 2>/dev/null
@cp $(SRCDIR)/*.h $(INSTALL_ROOT)/include 2>/dev/null
@cp $(SRCDIR)/*.h $(INSTALL_ROOT)/include 2>/dev/null
@mv config.h $(INSTALL_ROOT)/include 2>/dev/null
tests: $(TESTS)
clean: ; @$(RM) config.h $(SRCDIR)/*.o $(SRCDIR)/*.s $(SRCDIR)/*.a $(TESTDIR)/*.o $(FTESTDIR)/*.o $(TESTS)
$(TESTS): % : %.c | lib install
$(CC) $(CFLAGS) -I$(INSTALL_ROOT)/include $< -o $@ -L$(INSTALL_ROOT)/lib -l$(LIBNAME) -lm $(LDFLAGS)
$(FTESTS): % : %.o | lib install
$(FCCMD) $^ -o $@ -L$(SRCDIR) -l$(LIBNAME)
%.o: %.c ; $(CCCMD) -c $< -o $@
%.o: %.f ; $(FCCMD) -c $< -o $@
%.s: %.c ; $(CCCMD) -S $< -o $@
objects: $(OBJECTS) ;