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
|
#!/bin/sh
# file kernel/pascal/remake: compile rules for the Pascal interface
#-----------------------------------------------------------------------+
# 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 l'interface Pascal |
# |
#-----------------------------------------------------------------------+
# 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/pascal/makefile: compile rules for the Pascal interface
EOF
sed -n -e '3,/^$/p' $0
cat <<EOF
# This file was generated by the kernel/pascal/remake script
# switches:
# USE_CLONG=$USE_CLONG
# USE_DLONG=$USE_DLONG
# USE_SLONG=$USE_SLONG
# MAKE_PASCAL_LIB=$MAKE_PASCAL_LIB
# PASCAL=$PASCAL
EOF
if test "$MAKE_PASCAL_LIB" = "0"; then exit; fi
cat <<EOF
#-------------------- config files
lib_pascal_config = Makefile kernel/config.h kernel/pascal/makefile
#-------------------- unit compile rules
EOF
# Spcialisation en fonction du compilateur et de l'environnement
case $PASCAL in
fpc) uext=ppu
uswitch=
cdecl="cdecl; "
case $(uname) in
CYGWIN*|MINGW*)
links='{\$$link libnumerix-c.a}{\$$link libgcc.a}{\$$link libmsvcrt.a}'
cat <<EOF
kernel/pascal/o/libgcc.a: \$(lib_pascal_config)
cp \$\$(\$(GCC) -print-file-name=libgcc.a) kernel/pascal/o
kernel/pascal/o/libmsvcrt.a: \$(lib_pascal_config)
cp \$\$(\$(GCC) -print-file-name=libmsvcrt.a) kernel/pascal/o
EOF
runtime="kernel/pascal/o/libgcc.a kernel/pascal/o/libmsvcrt.a"
;;
*)
links='{\$$linklib numerix-c}{\$$linklib gcc_s}{\$$linklib c}'
runtime=
;;
esac
eswitch="-Fukernel/pascal/o -Fokernel/pascal/o -Flkernel/c/o -Fokernel/c/o"
;;
gpc) uext=gpi
uswitch=-c
cdecl=
links=
runtime=
eswitch="-o \$@ --unit-path=kernel/pascal/o -Lkernel/pascal/o -Lkernel/c/o -lnumerix-c"
;;
esac
for m in $m_list; do cat <<EOF
kernel/pascal/o/${m}long.p: \$(lib_pascal_config) kernel/pascal/p/xlong.p
sed -e "s/xx(\([^)]*\))/${m}x_\1/g" \\
-e "s/_name_/${m}long/g" \\
-e "s/_links_/${links}/g" \\
-e "s/_cdecl_/${cdecl}/g" \\
kernel/pascal/p/xlong.p >\$@
kernel/pascal/o/${m}long.$uext: kernel/pascal/o/${m}long.p $runtime
\$(PC) $uswitch kernel/pascal/o/${m}long.p
EOF
if test $PASCAL = gpc; then cat <<EOF
@mv ${m}long.* kernel/pascal/o
EOF
fi
done
echo
echo -n "lib_pascal = "
for m in $m_list; do echo -n "\\
kernel/pascal/o/${m}long.$uext "
done
echo
echo -n "lib_pascal_o = "
for m in $m_list; do echo -n "\\
kernel/pascal/o/${m}long.o "
done
echo
echo -n "lib_pascal_p = "
for m in $m_list; do echo -n "\\
kernel/pascal/o/${m}long.p "
done
echo
cat <<EOF
#-------------------- installation
.PHONY: install_pascal
install_pascal: \$(lib_pascal) \$(lib_pascal_p)
mkdir -p \$(PASCAL_INSTALL_LIB) \$(PASCAL_INSTALL_INCLUDE)
cp -p \$(lib_pascal) \$(lib_pascal_o) \$(PASCAL_INSTALL_LIB)
cp -p \$(lib_pascal_p) \$(PASCAL_INSTALL_INCLUDE)
EOF
exemples="pi simple shanks"
cat <<EOF
#-------------------- examples
EOF
echo -n "ex_pascal_obj = "
for m in $m_list; do for e in $exemples; do echo -n "\\
exemples/pascal/$e-$m "
done; done
echo
echo
for m in $m_list; do for e in $exemples; do cat <<EOF
exemples/pascal/$e-$m: exemples/pascal/$e.p \$(lib_c) \$(lib_pascal)
sed -e "s/_name_/${m}long/g" exemples/pascal/$e.p >exemples/pascal/$e-$m.p
\$(PC) exemples/pascal/$e-$m.p $eswitch
@rm -f exemples/pascal/$e-$m.p exemples/pascal/$e-$m.o
EOF
done; done
cat <<EOF
.PHONY: test_pascal clean_pascal
test_pascal: \$(ex_pascal_obj)
@echo "-------------------- Testing the Pascal interface"
for i in $exemples; do for j in $m_list; do \\
LD_LIBRARY_PATH=kernel/c/o:\$\$LD_LIBRARY_PATH exemples/pascal/\$\$i-\$\$j -test; \\
done; done
clean_pascal:
rm -f kernel/pascal/o/* exemples/pascal/*{-c,-d,-s,.exe}
#-------------------- done
lib: \$(lib_pascal)
install: install_pascal
exemples: \$(ex_pascal_obj)
test: test_pascal
clean: clean_pascal
EOF
|