Makefile 5.1 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
include ../Makefile_var

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

.PHONY: doc
doc: 

55
LIBRARIES=libcseife.a libseife.a
56 57

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

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

$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR)

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

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

.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
84
	-find . -name \*.o77 | xargs --no-run-if-empty /bin/rm -v
85
	-/bin/rm -fv flist
86
	-/bin/rm -fv install-include *.a
87 88

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

AR=ar
AS=as
RANLIB=ranlib

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

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

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

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
#======================================================================
# 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)
126 127 128 129

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

134 135 136
.PHONY: reinstall
reinstall:
	$(MAKE) clean
137
	$(MAKE) clean-include
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
	$(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))
157
libseife.a: $(SUBS)
158

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

163 164 165 166 167 168 169 170 171 172 173 174 175
#======================================================================
# 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
176 177
# 
# ----- END OF Makefile -----