21 lines
534 B
Bash
21 lines
534 B
Bash
|
#!/bin/sh
|
||
|
|
||
|
CC=cc
|
||
|
LIBNAME=mean
|
||
|
LIBREV=1
|
||
|
LIBVER=1.0.0
|
||
|
TEST=main
|
||
|
rm *.out *.o *.a *.0 *.1 ${TEST}_* *.so &>/dev/null
|
||
|
# --- dynamic ---
|
||
|
$CC -c -fPIC $LIBNAME.c -o $LIBNAME.o
|
||
|
$CC -shared -Wl,-soname,lib${LIBNAME}.so.${LIBREV} -o lib${LIBNAME}.so.$LIBVER $LIBNAME.o
|
||
|
ldconfig -n .
|
||
|
ln -s lib${LIBNAME}.so.${LIBREV} lib${LIBNAME}.so
|
||
|
$CC $TEST.c -L. -l${LIBNAME} -o ${TEST}_dynamic
|
||
|
# --- static ---
|
||
|
ar rcs lib${LIBNAME}.a $LIBNAME.o
|
||
|
$CC $TEST.c -static -L. -l${LIBNAME} -o ${TEST}_static
|
||
|
|
||
|
# --- run dynamic ---
|
||
|
LD_LIBRARY_PATH=. ./main_dynamic
|