Makefile 5.13 KB
Newer Older
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
3
#   ($Id$)
4
5
6
7
# 
# 25/10/2000 by Thomas Forbriger (IMGF Frankfurt)
# 
# libseife Makefile
8
9
# 
# seife: seismic waveform filters
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# ----
# 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
# ----
#
27
28
29
# Please have a look at the README file coming along with the source code in
# this directory for further notes regarding provided functionality,
# prerequisites and installation.
30
#
31
#=============================================================================
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 
# REVISIONS and CHANGES
#    25/10/2000   V1.0   Thomas Forbriger
#    14/12/2007   V1.1   g77 compilation is the default now
#    17/12/2007   V1.2   moved to gfortran
#    18/09/2010   V1.3   start migration to new SVN scheme
#                        discard f2c option (fallback)
#                        check variables
#    15/11/2010   V1.4   do not use fdep.sh
#    17/11/2010   V1.5   libseifemon.a is out of use
#    17/01/2011   V1.6   distinguish library creation and installation
# 
# ============================================================================
# 

47
48
CONTRIBDIR=..
include $(CONTRIBDIR)/Makefile_var
49

50
51
52
53
54
55
.PHONY: all
all: install doc

.PHONY: doc
doc: 

56
LIBRARIES=libcseife.a libseife.a
57
58

.PHONY: install
59
60
61
62
install: $(addprefix $(LOCLIBDIR)/,$(LIBRARIES))
$(LOCLIBDIR)/%: install-include %
	mkdir -pv $(LOCLIBDIR)
	/bin/mv -fv $(word 2,$^) $(LOCLIBDIR)
63
64
65
	 
# ============================================================================

66
67
68
69
70
71
72
CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))

$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR)

#----------------------------------------------------------------------

73
74
CLIBSRC=$(wildcard cseife*.c)
HEADERS=$(shell find . -name \*.h)
75
76
77
78
INCINSTALLPATH=$(LOCINCLUDEDIR)
LIBINSTALLPATH=$(LOCLIBDIR)
# name of installed (exported) header files
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(notdir $(HEADERS)))
79
80
81
82
83
84

.PHONY: clean edit
clean:
	-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
	-find . -name \*.o | xargs --no-run-if-empty /bin/rm -v
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
85
	-find . -name \*.o77 | xargs --no-run-if-empty /bin/rm -v
86
	-/bin/rm -fv flist
87
	-/bin/rm -fv install-include *.a
88
89

edit: flist ; vim flist
90
91
flist: $(wildcard subs/*.f *.f Makefile *.c *.h subs/*.inc) COPYING \
  $(TF_EDIT) README
92
93
94
95
96
97
98
99
	echo $^ | tr ' ' '\n' | sort > $@

AR=ar
AS=as
RANLIB=ranlib

FLAGS += $(MYFLAGS)
CFLAGS += -O3 -Wall $(FLAGS)
100
101
102
FFLAGS += -ff2c -Wall -ffixed-line-length-0 -fno-backslash -Isubs $(FLAGS)
LDFLAGS+=$(addprefix -L,$(LOCLIBDIR) $(subst :, ,$(SERVERLIBDIR)))
CPPFLAGS+=$(addprefix -I,$(LOCINCLUDEDIR) $(subst :, ,$(SERVERINCLUDEDIR))) \
103
104
  $(FLAGS)

105
106
107
108
SUBS=$(patsubst %.f,%.o,$(wildcard subs/*.f))

%.o: %.f
	$(FC) -O2 -o $@ -c $< $(FFLAGS)
109
110
111
.c.o:
	$(CC) $(CFLAGS) $< -c $(CPPFLAGS)

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#======================================================================
# Fortran include dependencies
%.d: %.f
	echo $<: $(addprefix subs/,$(shell cat $< | egrep '^ +include' | cut -f 2 -d \' | sort | uniq)) > $@
include $(patsubst %.f,%.d,$(wildcard subs/*.f))

#======================================================================

$(INCINSTALLPATH)/%.h: %.h
	mkdir -p $(INCINSTALLPATH)
	-rm -fv $@
	/bin/cp -vpd $< $@

.PHONY: install-include
install-include: $(INSTHEADER)
127
128
129
130

#======================================================================
# reinstall target
# is necessary in case of header file problems (e.g. remcmmnt not installed)
131
132
133
134
.PHONY: clean-include
clean-include: 
	/bin/rm -fv $(INSTHEADER)

135
136
137
.PHONY: reinstall
reinstall:
	$(MAKE) clean
138
	$(MAKE) clean-include
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
	$(MAKE) install

#======================================================================
# pattern rules
# -------------

%.d: %.c
	$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< \
      | sed '\''s,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g'\'' \
        > $@; \
      [ -s $@ ] || rm -f $@'

#======================================================================
# library part
# ------------

include $(patsubst %.c,%.d,$(CLIBSRC))

libcseife.a: $(patsubst %.c,%.o,$(CLIBSRC))
158
libseife.a: $(SUBS)
159

160
libcseife.a libseife.a: 
161
162
163
	$(AR) rcv $@ $^
	$(RANLIB) $@

164
165
166
167
168
169
170
171
172
173
174
175
176
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
ifdef TF_MAKEPKG
.PHONY: package
package: $(TF_MAKEPKG)
	$(MAKE) -f $< \
	  PACKAGE=libseife \
	  PACKAGEEXPORT="trunk/src/libs/libseife:src" \
	  PACKAGETARGETS="src:all:" \
	  PACKAGELIBS="-"
endif
177
178
# 
# ----- END OF Makefile -----