-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (83 loc) · 2.87 KB
/
Makefile
File metadata and controls
89 lines (83 loc) · 2.87 KB
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
#
# Copyright (C) 2000-2022 the YAMBO team
# http://www.yambo-code.org
#
# Authors (see AUTHORS file for details): AM
#
# This file is distributed under the terms of the GNU
# General Public License. You can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation;
# either version 2, or (at your option) any later version.
#
# This program is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330,Boston,
# MA 02111-1307, USA or visit http://www.gnu.org/copyleft/gpl.txt.
#
ifeq ($(wildcard config/defs.mk),config/defs.mk)
include config/defs.mk
else
$(error Run ./configure first)
endif
#
dopts=-D_CUDA -D_SCALAPACK -D_SLEPC -D_PAR_IO -D_HDF5_IO -D_HDF5_LIB -D_example_driver
linclude=-I./example/include/ -I./include
lib_target=./lib/libdriver.a
exe_target=bin/driver.x
#
objs_int_c :=$(patsubst %.c,%.o,$(wildcard src/interface/*.c))
objs_int_F :=$(patsubst %.F,%.o,$(wildcard src/interface/*.F))
objs_main_c:=$(patsubst %.c,%.o,$(wildcard src/main/*.c))
objs_opt_c :=$(patsubst %.c,%.o,$(wildcard src/options/*.c))
objs_eopt_c :=$(patsubst %.c,%.o,$(wildcard example/options/*.c))
objs_driver=example/main.o src/driver/driver.o
objs=$(objs_int_c) $(objs_int_F) $(objs_main_c) $(objs_opt_c) $(objs_eopt_c)
#
all: arcreate link
#
arcreate: $(objs) $(objs_driver)
@if test -f c_driver.mod; then mv c_driver.mod include; fi
@(eval $(ar) $(arflags) $(lib_target) $(objs)) > /dev/null
@chmod u+x $(lib_target)
link: $(objs_driver)
$(link)
release:
$(archive)
clean:
$(clean)
#
# Functions
#
define archive
cd ../; tar --exclude defs.mk --exclude config.status --exclude version.h --exclude \.swp -czvf Ydriver.tar.gz driver/ AUTHORS COPYING README.md
endef
define link
@(eval $(fc) $(fcflags) -o $(exe_target) $(objs_driver) $(lib_target) $(linclude) ) > /dev/null
endef
define clean
@find . \( -name '*.o' -o -name '*.f90' -o -name '*_source' -o -name '*.a' -o -name '*.mod' \
-o -name '*_cpp.f' -o -name 'ifc*' -o -name '__*' -o -name '*.s' -o -name 'penmp' -o -name '*.x' -o -name 'version.h' \) -type f -print | xargs rm -fr
@echo "[CLEAN] Objects ... done"
@rm -fr autom4te.cache config.log config.status config/defs.mk
@echo "[CLEAN] Config files ... done"
endef
#
# Suffixes
#
.SUFFIXES: .F .f90 .c .f .o .a
#
# Rules
#
.F.o:
@(eval $(fpp) $(dopts) $*.F > $*.tmp_source)
@mv $*.tmp_source $*$(f90suffix)
@($(fc) -c $(fcflags) $*$(f90suffix) $(linclude) -o $*.o) > /dev/null
.c.o:
@(eval $(cc) $(cflags) $(dopts) $(linclude) -c $*.c -o $*.o) > /dev/null