Makefile 5.89 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
thomas.forbriger's avatar
thomas.forbriger committed
3
# $Id$
thomas.forbriger's avatar
thomas.forbriger committed
4
5
6
7
# 
# Copyright (c) 2007 by Thomas Forbriger (BFO Schiltach) 
# 
# source code of libtf.a
8
#
thomas.forbriger's avatar
thomas.forbriger committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# ----
# 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
# ----
thomas.forbriger's avatar
thomas.forbriger committed
24
25
26
27
#
# some code in this library provides interfaces to other libraries like
# libpgplot or libgsl. All other code can be used without linking against
# additional libraries.
thomas.forbriger's avatar
thomas.forbriger committed
28
29
30
# 
# REVISIONS and CHANGES 
#    05/06/2007   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
31
#    27/11/2007   V1.1   g77 compilation is the default now
thomas.forbriger's avatar
thomas.forbriger committed
32
#    17/12/2007   V1.2   moved to gfortran
33
34
35
36
#    19/09/2010   V1.3   start migration to new SVN scheme
#                        discard f2c option (fallback)
#                        check variables
#                        creation of package not yet defined
37
#    13/11/2010   V1.4   added Fortran interface to GSL Bessel functions
38
#                 V1.5   avoid makefdoc.pl
39
#    17/01/2011   V1.6   distinguish library creation and installation
thomas.forbriger's avatar
thomas.forbriger committed
40
41
42
43
# 
# ============================================================================
#

44
45
.PHONY: all
all: install doc
thomas.forbriger's avatar
thomas.forbriger committed
46

47
48
49
50
51
52
.PHONY: doc
doc: libtf.doc

LIBRARIES=libtf.a

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

.PHONY: reinstall
reinstall:
	$(MAKE) clean
	$(MAKE) clean-include
	$(MAKE) install

#----------------------------------------------------------------------
thomas.forbriger's avatar
thomas.forbriger committed
65

thomas.forbriger's avatar
thomas.forbriger committed
66
67
.PHONY: clean edit
clean:
uqchw's avatar
uqchw committed
68
	-/bin/rm -fv *.o *.bak *.o77 flist *.xxx *.f2c.o *.a *.d
thomas.forbriger's avatar
thomas.forbriger committed
69
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
thomas.forbriger's avatar
thomas.forbriger committed
70
	-/bin/rm -vf flist testlibtf77 testlibf2ctf testlibtf
thomas.forbriger's avatar
thomas.forbriger committed
71

thomas.forbriger's avatar
thomas.forbriger committed
72
edit: flist ; vim flist
73
flist: *.c *.h *.f Makefile README COPYING README.PGPLOT.copyright.notice
74
	echo $^ | tr ' ' '\n' | sort > $@
75
76
77
78
79
80
	 
# ============================================================================
CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))

$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
81

82
83
84
85
86
87
88
89
INCLUDEFLAGS=$(addprefix -I,$(LOCINCLUDEDIR) $(subst :, ,$(SERVERINCLUDEDIR)))
LIBFLAGS=$(addprefix -L,$(LOCLIBDIR) $(subst :, ,$(SERVERLIBDIR)))
FLAGS += $(MYFLAGS)
FFLAGS += -ff2c -Wall -ffixed-line-length-0 -fno-backslash $(FLAGS)
CFLAGS += -O3 $(INCLUDEFLAGS) $(FLAGS)
CPPFLAGS += $(INCLUDEFLAGS) $(FLAGS)
LDFLAGS += $(LIBFLAGS) $(FLAGS)

thomas.forbriger's avatar
thomas.forbriger committed
90
91
AR=ar
RANLIB=ranlib
92
93
94
95
96
97
98

SUBS=tf_cmdline.o tf_costap.o tf_doubletoint.o tf_fork.o tf_inttodouble.o\
     tf_inttoreal.o tf_listselect.o tf_realtoint.o tf_rectint.o\
     tf_bess.o pgp.o gpt.o tf_magic.o tf_bytesex.o tf_swap.o tf_dfork.o\
     tf_nice.o tf_chain.o tf_gauss.o tf_cbytesex.o tf_cswap.o tf_random.o \
     tf_time.o tf_rcol.o tf_ttaper.o tfgmt_makexyz.o tffile_newtmp.o \
     tfstr_trimlen.o tfstr_trimbeg.o tf_nameext.o tf_hpbut.o tf_lpbut.o \
99
     tf_pglogwedg.o tf_readrc.o tf_gsl_rnd.o tf_gsl_bess.o
100

101
102
#======================================================================
# documentation
103
104
105
106
107
108
109
110
111
112
113
DOCSRC=tf_cmdline.f tf_listselect.f tf_chain.f tf_nameext.f\
       tf_rcol.f\
       tf_bytesex.f tf_magic.f tf_swap.f\
       tf_realtoint.f tf_inttoreal.f tf_doubletoint.f tf_inttodouble.f\
       tf_ttaper.f \
       tf_costap.f tf_rectint.f tf_nice.f\
       tf_hpbut.f tf_lpbut.f\
       tf_fork.f tf_dfork.f tf_gauss.f\
       pgp.f gpt.f tffile_newtmp.f tfstr_trimlen.f tfstr_trimbeg.f \
       tfgmt_makexyz.f tf_pglogwedg.f tf_readrc.f

114
docs: libtf.doc 
115
116

libtf.doc: $(DOCSRC)
117
118
119
120
121
122
	/usr/bin/awk 'BEGIN{ hot=0; } \
        /^cS/ { hot=1; \
          print "c\nc -----------------------------------------\nc"; \
          next; } \
        /^cE/ { hot=0; } \
        { if (hot==1) { print $$0; } }' $^ > $@
123

124
125
#======================================================================
# C header files
126
127
128
129

HEADERS=$(wildcard *.h)
INSTHEADER=$(addprefix $(LOCINCLUDEDIR)/,$(HEADERS))

130
.PHONY: install-include
131
132
install-include:  $(INSTHEADER)
$(LOCINCLUDEDIR)/%.h: %.h
thomas.forbriger's avatar
thomas.forbriger committed
133
134
	mkdir -pv $(dir $@)
	/bin/cp -fv $< $@
135
136
137
138

.PHONY: clean-include
clean-include: libtf.h
	-/bin/rm -vf $(addprefix $(LOCINCLUDEDIR),$^)
139

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

146
include $(patsubst %.c,%.d,$(wildcard *.c)) 
147
148
149
150

#======================================================================
# compile

thomas.forbriger's avatar
thomas.forbriger committed
151
%.o: %.c
152
	$(CC) -O2 -o $@ -c $< -Wall $(CFLAGS) $(CPPFLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
153
%.o: %.f
thomas.forbriger's avatar
thomas.forbriger committed
154
	$(FC) -O2 -o $@ -c $< $(FFLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
155
156
157
158
159

libtf.a: $(SUBS)
	$(AR) rcv libtf.a $(SUBS)
	$(RANLIB) libtf.a

160
testlibtf: testlibtf.o install
161
	$(FC) -o $@ $< -ltf -lm -lgsl -lgslcblas $(FFLAGS) $(LDFLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
162

thomas.forbriger's avatar
thomas.forbriger committed
163
#======================================================================
thomas.forbriger's avatar
thomas.forbriger committed
164
# testcode
thomas.forbriger's avatar
thomas.forbriger committed
165
166
167
168
169
170
%.sort.xxx: %.xxx; sort -n $< > $@
%.plot.xxx: %.xxx
	echo 'plot "$<" ' > $@
	echo 'pause -1 "press return to continue"' >> $@
%.plot: %.plot.xxx; gnuplot $<

171
rngtest: testlibtf
thomas.forbriger's avatar
thomas.forbriger committed
172
	./testlibtf -rng -f -n 9900
thomas.forbriger's avatar
thomas.forbriger committed
173
	$(MAKE) test_gaussian.sort.plot test_uniform.sort.plot
thomas.forbriger's avatar
thomas.forbriger committed
174

uqchw's avatar
uqchw committed
175
176
177
178
179
180
181
182
183
184
185
186
187
#======================================================================
# create package
# --------------

ifdef TF_MAKEPKG
.PHONY: package
package: $(TF_MAKEPKG)
	$(MAKE) -f $< \
        PACKAGE=libtf \
        PACKAGEEXPORT="trunk/src/libs/libtf:src" \
        PACKAGETARGETS="src:install: src:doc:" \
        PACKAGELIBS="-"
endif
thomas.forbriger's avatar
thomas.forbriger committed
188
# ----- END OF Makefile -----