Files
guru/sci-libs/saclib/files/makefile.patch
Alessandro Barbieri eb546c5216 sci-libs/saclib: add stuff from qepcad bundled saclib to saclib
Signed-off-by: Alessandro Barbieri <lssndrbarbieri@gmail.com>
2021-10-30 21:37:44 +02:00

149 lines
4.1 KiB
Diff

--- a/bin/mklib
+++ b/bin/mklib
@@ -2,31 +2,17 @@
# USAGE:
# mklib <std|deb|opt|all>
-#
-# FUNCTION
-# Creates ".a" files in "$saclib/lib/" depending on the argument:
-# - 'std' causes a standard library to be built. The library file will have
-# the name "saclib.a" and the corresponding object files are in
-# "saclib/lib/obj".
-# - 'deb' switches on the '-g' option of the compiler which includes
-# debugging information in the object files. The library file will have
-# the name "saclibd.a" and the corresponding object files are in
-# "saclib/lib/objd".
-# - 'opt' switches on the '-O' option which produces optimized code. The
-# library file will have the name "saclibo.a" and the corresponding object
-# files are in "saclib/lib/objo".
-# - 'all' builds all three types of libraries.
-if [ $# -lt 1 ]
+if [ $# -lt 1 ]
then
echo "USAGE:"
echo " mklib <deb|opt|all>"
exit
fi
-if [ $1 = "clean" ]
+if [ $1 = "clean" ]
then
- ### remove .o and .a and makefiles
+ ### remove .o and .so and makefiles
echo "Removing object files, libraries and makefiles ..."
pushd >/dev/null $saclib/lib/objo
'rm' -f *
@@ -35,7 +21,7 @@
'rm' -f *
popd >/dev/null
pushd >/dev/null $saclib/lib/
- 'rm' -f *.a
+ 'rm' -f *.so
popd >/dev/null
### do sysdep cleanup
echo "Removing system-dependent files ..."
@@ -57,12 +43,6 @@
exit
fi
-
-if [ ! -n "${CC+1}" ]
-then
- CC=cc
-fi
-
echo "Compiling with" $CC
if [ $1 = "std" ]
@@ -70,15 +50,15 @@
echo "This option no longer exists!"
elif [ $1 = "deb" ]; then
pushd >/dev/null $saclib/lib/objd
- make CC=$CC "SACFLAG=-g -DNO_SACLIB_MACROS" EXTENSION=d
+ make CC=$CC "SACFLAG=-fPIC ${CFLAGS} -DNO_SACLIB_MACROS" EXTENSION=d
popd >/dev/null
elif [ $1 = "opt" ]; then
pushd >/dev/null $saclib/lib/objo
- make CC=$CC "SACFLAG=" EXTENSION=o
+ make CC=$CC "SACFLAG=-fPIC ${CFLAGS}" EXTENSION=o
popd >/dev/null
elif [ $1 = "all" ]; then
pushd >/dev/null $saclib/lib/objd
- make CC=$CC "SACFLAG=-g -DNO_SACLIB_MACROS" EXTENSION=d
+ make CC=$CC "SACFLAG=-fPIC ${CFLAGS} -DNO_SACLIB_MACROS" EXTENSION=d
popd >/dev/null
pushd >/dev/null $saclib/lib/objo
make CC=$CC "SACFLAG=" EXTENSION=o
--- a/bin/mkmake
+++ b/bin/mkmake
@@ -25,20 +25,16 @@
# E.g. if <flag> is -g and <character> is d, the library will be
# compiled with the debug option set and the library name will be
# "saclibg.a".
-#
+#
# REMARK
# This file should not be modified. Modify 'mkmake' instead and then use it
-# to create the new makefile.
+# to create the new makefile.
# Macros
SRCDIR = ${saclib}/src
-TARGET = ${saclib}/lib/saclib${EXTENSION}.a
-CFLAGS = -I${saclib}/include -c ${SACFLAG}
-AFLAGS = -I${saclib}/include -P
-AS = as
-AR = ar
-RANLIB = ranlib
+TARGET = ${saclib}/lib/${FULLLIBNAME}
+CFLAGS = -I${saclib}/include ${SACFLAG} -fPIC
# Object files
@@ -81,21 +77,13 @@
#
cat >> $MAKEFILE <<\EOF
-
+
# Target dependencies
-new: ${OBJS1} ${OBJS2a} ${OBJS2b} ${OBJS3} ${OBJS4}
+$(TARGET): ${OBJS1} ${OBJS2a} ${OBJS2b} ${OBJS3} ${OBJS4}
rm -f ${TARGET}
- ${AR} cq ${TARGET} ${OBJS1}
- ${AR} cq ${TARGET} ${OBJS2a}
- ${AR} cq ${TARGET} ${OBJS2b}
- ${AR} cq ${TARGET} ${OBJS3}
- ${AR} cq ${TARGET} ${OBJS4}
-# Use "ar ts" if your system does not have "ranlib".
-# ${AR} ts ${TARGET}
-# Use "ranlib" if your system's "ar" does not have the option "s".
- ${RANLIB} ${TARGET}
+ $(CXX) ${OBJS1} ${OBJS2a} ${OBJS2b} ${OBJS3} ${OBJS4} ${saclib}/src/gcword.cc -I${saclib}/include -I${saclib}/src -fPIC -shared ${CXXFLAGS} -o $@ ${LDFLAGS} -Wl,-soname,${FULLLIBNAME}
@echo "Created '${TARGET}'."
EOF
@@ -113,7 +101,7 @@
'ls' *.[c] 2> /dev/null |\
-awk -F. '{printf "%s.o: ${SRCDIR}/%s\n\t${CC} ${CFLAGS} ${SRCDIR}/%s\n",$1,$0,$0}' >>$MAKEFILE
+awk -F. '{printf "%s.o: ${SRCDIR}/%s\n\t${CC} ${CFLAGS} -c ${SRCDIR}/%s\n",$1,$0,$0}' >>$MAKEFILE
'ls' *.[s] 2> /dev/null |\
awk -F. '{printf "%s.o: ${SRCDIR}/%s\n\t${AS} ${AFLAGS} ${SRCDIR}/%s -o %s.o\n",$1,$0,$0,$1}' >>$MAKEFILE
@@ -123,7 +111,7 @@
#
## Done
-#
+#
'cp' $MAKEFILE $saclib/lib/objd
popd >/dev/null