File: remake

package info (click to toggle)
numerix 0.22-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,380 kB
  • ctags: 4,165
  • sloc: asm: 26,210; ansic: 12,168; ml: 4,912; sh: 3,899; pascal: 414; makefile: 179
file content (235 lines) | stat: -rwxr-xr-x 7,193 bytes parent folder | download | duplicates (2)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/sh
#  file kernel/c/remake: compile rules for the libnumerix-c library
#-----------------------------------------------------------------------+
#  Copyright 2005-2006, Michel Quercia (michel.quercia@prepas.org)      |
#                                                                       |
#  This file is part of Numerix. Numerix is free software; you can      |
#  redistribute it and/or modify it under the terms of the GNU Lesser   |
#  General Public License as published by the Free Software Foundation; |
#  either version 2.1 of the License, or (at your option) any later     |
#  version.                                                             |
#                                                                       |
#  The Numerix Library 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  |
#  Lesser General Public License for more details.                      |
#                                                                       |
#  You should have received a copy of the GNU Lesser General Public     |
#  License along with the GNU MP Library; see the file COPYING. If not, |
#  write to the Free Software Foundation, Inc., 59 Temple Place -       |
#  Suite 330, Boston, MA 02111-1307, USA.                               |
#-----------------------------------------------------------------------+
#                                                                       |
#                 Rgles de construction de libnumerix-c                |
#                                                                       |
#-----------------------------------------------------------------------+

# m_list = liste des modes (c/d/s)
m_list=
if test "$USE_CLONG" = "1"; then m_list="${m_list} c"; fi
if test "$USE_DLONG" = "1"; then m_list="${m_list} d"; fi
if test "$USE_SLONG" = "1"; then m_list="${m_list} s"; fi

# On y va
cat <<EOF
# File kernel/c/makefile: compile rules for the libnumerix-c library
EOF
sed -n -e '3,/^$/p' $0 
cat <<EOF
# This file was generated by the kernel/c/remake script
# switches:
#   USE_CLONG=$USE_CLONG
#   USE_DLONG=$USE_DLONG
#   USE_SLONG=$USE_SLONG
#   USE_GMP=$USE_GMP
#   MAKE_C_LIB=$MAKE_C_LIB
#   MAKE_PASCAL_LIB=$MAKE_PASCAL_LIB
#   SHARED=$SHARED
EOF

if test "$MAKE_C_LIB" = "0" && test "$MAKE_PASCAL_LIB" = "0"; then exit; fi

cat <<EOF
#-------------------- config files
lib_c_config = Makefile kernel/config.h kernel/c/makefile

#-------------------- source files
lib_c_c_src = \\
  kernel/c/c/numerix.c   \\
  kernel/x/c/add.c       \\
  kernel/x/c/cmp.c       \\
  kernel/x/c/convert.c   \\
  kernel/x/c/copy.c      \\
  kernel/x/c/div.c       \\
  kernel/x/c/dump.c      \\
  kernel/x/c/fact.c      \\
  kernel/x/c/gcd.c       \\
  kernel/x/c/mul.c       \\
  kernel/x/c/pow.c       \\
  kernel/x/c/powmod.c    \\
  kernel/x/c/prime.c     \\
  kernel/x/c/random.c    \\
  kernel/x/c/root.c      \\
  kernel/x/c/shift.c     \\
  kernel/x/c/sqrt.c      \\
  kernel/x/c/string.c

lib_c_h1_src = \\
  kernel/c/h/numerix.h   \\
  kernel/x/h/numerix.h   \\
  kernel/x/h/alloc.h

lib_c_h2_src = \\
  kernel/x/h/add.h       \\
  kernel/x/h/cmp.h       \\
  kernel/x/h/convert.h   \\
  kernel/x/h/copy.h      \\
  kernel/x/h/div.h       \\
  kernel/x/h/dump.h      \\
  kernel/x/h/fact.h      \\
  kernel/x/h/gcd.h       \\
  kernel/x/h/mul.h       \\
  kernel/x/h/pow.h       \\
  kernel/x/h/powmod.h    \\
  kernel/x/h/prime.h     \\
  kernel/x/h/random.h    \\
  kernel/x/h/root.h      \\
  kernel/x/h/shift.h     \\
  kernel/x/h/sqrt.h      \\
  kernel/x/h/string.h    \\
  kernel/x/h/chrono.h

lib_c_h_src = \$(lib_c_h1_src) \$(lib_c_h2_src)
EOF

cat <<EOF

#-------------------- object file list
lib_c_obj = \\
EOF

echo -n "  kernel/c/o/chrono.o "
for m in $m_list; do echo -n "\\
  kernel/c/o/numerix-$m.o "
done
echo

cat <<EOF

#-------------------- library compile rules
kernel/c/o/chrono.o: \$(lib_c_config) kernel/x/c/chrono.c kernel/x/h/chrono.h
	\$(GCC) \$(PIC) -Dc_api -c -o \$@ kernel/x/c/chrono.c
EOF
for m in $m_list; do cat <<EOF
kernel/c/o/numerix-$m.o: \$(lib_c_config) \$(lib_c_c_src) \$(lib_c_h_src) \$(lib_n_obj)
	\$(GCC) \$(PIC) -Duse_${m}long -c -o \$@ kernel/c/c/numerix.c
EOF
done

if test x$SHARED = x1; then
cat <<EOF
lib_c_0 = libnumerix-c.so
lib_c_1 = \$(lib_c_0).\$(NUMERIX_MAJOR)
lib_c_2 = \$(lib_c_1).\$(NUMERIX_MINOR)
lib_c = kernel/c/o/\$(lib_c_2)
\$(lib_c): \$(lib_c_obj) \$(lib_n_obj)
	\$(GCC) -shared -Wl,-soname,\$(lib_c_1) -o \$@ \$(lib_c_obj) \$(lib_n_obj)
	ln -s \$(lib_c_2) kernel/c/o/\$(lib_c_1)
	ln -s \$(lib_c_1) kernel/c/o/\$(lib_c_0)
EOF
else
cat <<EOF
lib_c = kernel/c/o/libnumerix-c.a
\$(lib_c): \$(lib_c_obj) \$(lib_n_obj)
	rm -f \$@
	\$(AR) \$@ \$(lib_c_obj) \$(lib_n_obj)
	\$(RANLIB) \$@
lib_c_lib = \$(lib_c)
EOF
fi

cat <<EOF

#-------------------- make a decent numerix.h for the outside world
kernel/c/o/numerix.h: \$(lib_c_config) kernel/c/h/numerix.h \$(lib_c_h2_src)
	(sed -e '/#if 0/d' -e '/End of the public interface/,\$\$d' kernel/c/h/numerix.h; \\
	  for i in \$(lib_c_h2_src); do sed -e '2,/\*\//d' \$\$i; done |\\
	  \$(GCC) -Dc_api -E -P -C -) >\$@
lib_c_include = kernel/c/o/numerix.h

#-------------------- installation
.PHONY: install_c
install_c: \$(lib_c) \$(lib_c_include)
	mkdir -p \$(C_INSTALL_LIB) \$(C_INSTALL_INCLUDE)
	cp -p \$(lib_c) \$(C_INSTALL_LIB)
	cp -p \$(lib_c_include) \$(C_INSTALL_INCLUDE)
EOF
if test x$SHARED = x1; then cat <<EOF
	ln -s \$(lib_c_2) \$(C_INSTALL_LIB)/\$(lib_c_1)
	ln -s \$(lib_c_1) \$(C_INSTALL_LIB)/\$(lib_c_0)
EOF
else cat <<EOF
	\$(RANLIB) \$(C_INSTALL_LIB)/libnumerix-c.a
EOF
fi

exemples="pi shanks simple"
other="chrono prime-test"
cat <<EOF

#-------------------- examples
EOF
echo -n "ex_c_obj = "
for m in $m_list; do for e in $exemples $other; do echo -n "\\
  exemples/c/$e-$m "
done; done
if test "$USE_GMP" = "1"; then echo -n "\\
  exemples/c/pi-g \\
  exemples/c/chrono-g "
fi
echo
echo

for m in $m_list; do for e in $exemples $other; do cat <<EOF
exemples/c/$e-$m: exemples/c/$e.c \$(lib_c) kernel/c/o/numerix.h
	\$(GCC) -Duse_${m}long -Ikernel/c/o -o \$@ exemples/c/$e.c -Lkernel/c/o -lnumerix-c
EOF
done; done
if test "$USE_GMP" = "1"; then cat <<EOF
exemples/c/pi-g: exemples/c/pi-gmp.c kernel/c/o/chrono.o
	\$(GCC) -o \$@ exemples/c/pi-gmp.c kernel/c/o/chrono.o -lgmp
exemples/c/chrono-g: exemples/c/chrono-gmp.c kernel/c/o/chrono.o
	\$(GCC) -o \$@ exemples/c/chrono-gmp.c kernel/c/o/chrono.o -lgmp
EOF
fi

cat <<EOF

.PHONY: test_c
test_c: \$(ex_c_obj)
	@echo "-------------------- Testing the C interface"
EOF
if test "$USE_GMP" = "1"; then cat <<EOF
	exemples/c/\pi-g -test && \\
EOF
fi
cat <<EOF
	for i in $exemples; do for j in $m_list; do \\
	    LD_LIBRARY_PATH=kernel/c/o:\$\$LD_LIBRARY_PATH exemples/c/\$\$i-\$\$j -test; \\
	done; done

#-------------------- cleanup
.PHONY: clean_c
clean_c:
	rm -f kernel/c/o/* exemples/c/*{-c,-d,-g,-s,.exe}
EOF

cat <<EOF

#-------------------- done
lib:          \$(lib_c) kernel/c/o/numerix.h
install:      install_c
exemples:     \$(ex_c_obj)
test:         test_c
clean:        clean_c
EOF