Makefile 5.13 KB
Newer Older
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
thomas.forbriger's avatar
thomas.forbriger committed
3
# $Id$
4
5
6
7
# 
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
# 
# main Makefile for Fortran77 gremlin versions
8
#
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# ----
# This program is free software; 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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ----
#
25
26
# REVISIONS and CHANGES 
#    01/03/2002   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
27
#    30/12/2002   V1.1   added C++ directory
28
#    09/02/2010   V1.2   transition to gfortran
29
#    17/11/2010   V1.3   migrated to SVN scheme; avoid incdep
30
31
#    10/01/2010   V1.4   libgin.a must be compiled before gremlin is going to
#                        be linked
32
#    14/01/2011   V1.5   call cxx/Makefile in top-level targets
33
34
35
# 
# ============================================================================
#
36
PROGRAMS=gremlin wgremlin gredim
37

38
.PHONY: all
39
all: install
40

41
42
.PHONY: install
install: 
43
	(cd cxx; $(MAKE) install)
44
	$(MAKE) libraries
45
	$(MAKE) programs
46

47
.PHONY: libraries
48
49
libraries: 
	(cd cxx; $(MAKE) install)
50
	(cd libs; $(MAKE) libs)
51

52
53
54
55
56
57
58
59
.PHONY: programs
programs: $(addprefix $(LOCBINDIR)/,$(PROGRAMS))
$(LOCBINDIR)/%: %
	mkdir -pv $(LOCBINDIR)
	/bin/mv -fv $< $(LOCBINDIR)

.PHONY: doc
doc: gremlin.pdf 
60
61
62
63
64
65
66
67
68
	
# check mandatory environment variable settings
# ---------------------------------------------

CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))

$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR LOCBINDIR)

69
70
71
72
LINLIB=-llapack -lblas

FLAGS += $(MYFLAGS)
FFLAGS += -ff2c -Wall -ffixed-line-length-0 -fno-backslash $(FLAGS)
73
CFLAGS += $(FLAGS)
uqchw's avatar
uqchw committed
74
CPPFLAGS=$(addprefix -I,$(LOCINCLUDEDIR) $(subst :, ,$(SERVERINCLUDEDIR)))
uqchw's avatar
uqchw committed
75
LDFLAGS=$(addprefix -L,$(LOCLIBDIR) $(subst :, ,$(SERVERLIBDIR)))
76
77
78
79

AR=ar
RANLIB=ranlib

80
#----------------------------------------------------------------------
81

82
83
.PHONY: clean edit

84
clean:
uqchw's avatar
uqchw committed
85
86
87
	-/bin/rm -vf *.o *.bak flist make.incdep *.d
	-/bin/rm -vf *.aux *.toc *.log *.dvi
	-cd docu; /bin/rm -vf *.aux *.toc *.log *.dvi *.bak *.blg *.bbl
88
	-cd libs; make clean
89

90
91
92
edit: flist
	vim flist

93
flist: *.f */*.f *.inc */*.inc Makefile */Makefile */*.h */*.cc COPYING README \
thomas.forbriger's avatar
thomas.forbriger committed
94
	$(wildcard docu/*.tex docu/*.bib docu/pepi.???)
95
96
	echo $^ | tr ' ' '\n' | sort > $@

97
98
99
100
101
102
#----------------------------------------------------------------------
# Fortran dependencies
# --------------------
%.d: %.f
	echo $<: $(shell cat $< | egrep '^ +include' | cut -f 2 -d \' | sort | uniq) > $@
-include $(patsubst %.f,%.d,$(wildcard *.f))
103

104
libs/glq_dim.inc: libs/glq_dimstd.inc; /bin/cp -v $< $@
105

106
#----------------------------------------------------------------------
107

108
109
%.o: %.f
	$(FC) -o $@ -c $< $(FFLAGS)
110

111
112
gremlin: gremlin.o gremlin_help.o
	$(FC) -o gremlin $^ \
thomas.forbriger's avatar
thomas.forbriger committed
113
	  -L$(LOCLIBDIR) \
114
115
        -lgin \
        -lgrrefsub -lrefread \
thomas.forbriger's avatar
thomas.forbriger committed
116
        $(LINLIB) -ltf  \
thomas.forbriger's avatar
thomas.forbriger committed
117
        $(BUGGY) -L$(LOCLIBDIR) $(TF_LINK_PGPLOT) $(LDFLAGS)
118
119
120
121
122
123

# version using wang code
wgremlin: gremlin.o gremlin_help.o
	$(FC) -o $@ $^ \
        -lgin \
        -lwrefsub -lrefread \
124
        $(LINLIB) -ltf $(TF_LINK_PGPLOT) \
thomas.forbriger's avatar
thomas.forbriger committed
125
        $(BUGGY) -L$(LOCLIBDIR) $(LDFLAGS)
126

127
128
129
130
131
gredim_comments.xxx: libs/glq_dimstd.inc
	awk "BEGIN { printf \"      print *,'%s'\n\", \"comments from $<:\"; } \
	  /^c glq[md]_/ { printf \"      call repline('%s')\n\", \$$0; }" $< > $@

gredim: gredim.o gredim_comments.xxx
thomas.forbriger's avatar
thomas.forbriger committed
132
	$(FC) -o gredim gredim.o $(GFLAG) $(F2CLIB) $(LDFLAGS)
133

uqchw's avatar
uqchw committed
134
135
136
137
138
.PHONY: list-libraries
list-libraries:
	grep ' -l' Makefile | tr ' ' '\n' | egrep '^-l' |sort | uniq
	grep ' -l' Makefile | tr ' ' '\n' | egrep 'PGP' |sort | uniq

139

140
141
142
143
144
145
146
#======================================================================
# documentation
docu/gremlin.dvi: docu/gremlin.tex
	cd docu; latex gremlin; bibtex gremlin; latex gremlin; latex gremlin
gremlin.pdf: docu/gremlin.dvi
	cd docu; pdflatex gremlin
	/bin/cp -vpd docu/gremlin.pdf $@
uqchw's avatar
uqchw committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
ifdef TF_MAKEPKG
.PHONY: package
package: $(TF_MAKEPKG)
	$(MAKE) -f $< \
          PACKAGE=gremlin \
          PACKAGEEXPORT="trunk/src/green/gremlin1:src" \
          PACKAGETARGETS="src:all" \
          PACKAGELIBS="-"
.PHONY: fullpackage
fullpackage: $(TF_MAKEPKG)
	$(MAKE) -f $< \
          PACKAGE=gremlinwithlibs \
          PACKAGEEXPORT="trunk/src/green/gremlin1:src trunk/src/synt/ref/refmet:contrib/refmet" \
          PACKAGETARGETS="contrib/refmet:all src:all" \
          PACKAGELIBS="libemod libsff libsffu libtf libts libfapidxx libtfxx libdatrwxx libsffxx libtime libgsexx libtsxx libseife libaff libgrrefsub libwrefsub"
endif
167

168
# ----- END OF Makefile -----