-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMake.rules
165 lines (132 loc) · 3.76 KB
/
Make.rules
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#-*- makefile -*-
#
# ParaGauss, a program package for high-performance computations of
# molecular systems
#
# Copyright (C) 2014 T. Belling, T. Grauschopf, S. Krüger,
# F. Nörtemann, M. Staufer, M. Mayer, V. A. Nasluzov, U. Birkenheuer,
# A. Hu, A. V. Matveev, A. V. Shor, M. S. K. Fuchs-Rohr, K. M. Neyman,
# D. I. Ganyushin, T. Kerdcharoen, A. Woiterski, A. B. Gordienko,
# S. Majumder, M. H. i Rotllant, R. Ramakrishnan, G. Dixit,
# A. Nikodem, T. Soini, M. Roderus, N. Rösch
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation [1].
#
# 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.
#
# [1] http://www.gnu.org/licenses/gpl-2.0.html
#
# Please see the accompanying LICENSE file for further information.
#
vpath %.h $(BASEDIR)/include
vpath %.inc $(BASEDIR)/include
mpif.h:
touch $(BASEDIR)/include/mpif.h
fxdr.inc:
touch $(BASEDIR)/include/fxdr.inc
mkdepf90 = $(BINDIR)/mkdepf90
ifeq ($(UPPERCASE.mod),1)
mkdepf90_options = -uc
endif
byproduct_build = $(BINDIR)/byproduct_build
remove ?= rm
ifeq ($(MAKECMDGOALS),clean)
nodeps = 1
endif
ifneq ($(nodeps),1)
include $(f90objs:.o=.m.dep)
include $(f90objs:.o=.o.dep)
include $(cobjs:.o=.d)
endif
#
# How to build dependencies for Fortran objects:
#
%.o.dep %.m.dep: %.$(src_ext)
$(mkdepf90) $(mkdepf90_options) -src $< -objdir $(@D) -mdeps $*.m.dep -odeps $*.o.dep
.SECONDARY: $(f90objs:.o=.$(src_ext))
#.SECONDARY:
#.INTERMEDIATE: $(f90objs:.o=.$(src_ext))
#
# How to build dependencies for C objects:
#
%.d: %.c
$(CC) -MT $(@:.d=.o) -MM $(<) > $(@)
# put @ at the beginning of a command
# to reduce verbosity
# how to preprocess sources:
%.$(src_ext) : %.f
cp -p $< $@
%.$(src_ext) : %.f90
$(f90_fpp)
# how to compile Fortran sources:
%.o : %.f
$(f_compile)
%.o : %.$(src_ext) #%.f90
$(f90_compile)
# how to compile C sources:
%.o : %.c
$(c_compile)
# for quick-hacks: recompile without
# rebuild of outdated prerequisites:
.PHONY: %.compile compile
%.compile :
rm -f $*.o
rm -f $*.$(src_ext)
$(MAKE) nodeps=1 $*.o
compile :
$(MAKE) nodeps=1
define f90_fpp
$(FPP) $(FPPOPTIONS) $< $*.$(src_ext)
endef
# compile these with F90ALTFLAGS:
$(f90objs_altflags) : altflags=1
# the rest with F90FLAGS
%.o : alflags=0
# debug targets
$(debug_targets) : DEBUG=1
# NOOPT targets
$(noopt_targets) : NOOPT=1
define f90_do_compile
( cd $(@D); $(FC) $(FFLAGS) $(INCLUDE) -c $(*F).$(src_ext) )
endef
# command to compare if MOD-files have changed:
# Intel seems to store "random" number at bytes 45:46 (decimal)
# use "cmp -s -i 46" in that special case
ifndef CMPMOD
CMPMOD = cmp -s
endif
define f90_compile
$(byproduct_build) -bld '$(f90_do_compile)' -provides '$@ $(byproduct)' -cmp '$(CMPMOD)' -quiet
endef
define f_compile
(cd $(@D); $(F77) $(FBASEFLAGS) $(F90FLAGS) $(INCLUDE) -c $(<F) )
endef
define c_compile
( cd $(@D); rm -f $(@F) ; \
$(CC) -c $(CCFLAGS) $(CINCLUDE) $(<F) -o $(@F); \
test -f $(@F) )
endef
# .f.doc:
# perl $(BINDIR)/make_interface.perl $<
# .fp.doc:
# perl $(BINDIR)/make_interface.perl $<
# .f90.doc:
# perl $(BINDIR)/make_interface.perl $<
##### CHECK DEPENDENCIES (old, and the only way) #####
objlist = objlist.makedependent
depfile = Dependencies.inc
makedependent = $(BINDIR)/makedependent -l -n -imd
#
# type 'make chkdepend' to CHECK dependencies
#
chkdepend $(depfile):
rm -f $(objlist)
@echo $(f90objs) > $(objlist)
rm -f $(depfile)
$(makedependent) > $(depfile)
# do not include $(depfile)