Whamcloud - gitweb
LU-5456 hsm: hold inode mutex around ll_setattr_raw()
[fs/lustre-release.git] / lustre / liblustre / genlib.sh
1 #!/bin/bash
2 #set -xv
3 set -e
4
5 #
6 # This script is to generate lib lustre library as a whole. It will leave
7 # two files on current directory: liblustre.a and liblustre.so.
8 #
9 # Most concern here is the libraries linking order
10 #
11 # FIXME: How to do this cleanly use makefile?
12 #
13
14 # see http://osdir.com/ml/gmane.comp.gnu.binutils.bugs/2006-01/msg00016.php
15 ppc64_CPU=`uname -p`
16 if [ "x${ppc64_CPU}" = "xppc64" ]; then
17         LD="$CC -m64"
18 else
19         LD=$CC
20 fi
21
22 CWD=`pwd`
23
24 SYSIO=$1
25 LIBS=$2
26 LND_LIBS=$3
27 PTHREAD_LIBS=$4
28 CAP_LIBS=$5
29
30 if [ ! -f $SYSIO/lib/libsysio.a ]; then
31   echo "ERROR: $SYSIO/lib/libsysio.a dosen't exist"
32   exit 1
33 fi
34
35 # do cleanup at first
36 rm -f liblustre.so
37
38 ALL_OBJS=
39
40 build_obj_list() {
41         _objs=`$AR -t $1/$2 | grep -v SYMDEF | grep -v SORTED`
42   for _lib in $_objs; do
43     ALL_OBJS=$ALL_OBJS"$1/$_lib ";
44   done;
45 }
46
47 #
48 # special treatment for libsysio
49 #
50 sysio_tmp=$CWD/sysio_tmp_`date +%s`
51 rm -rf $sysio_tmp
52 build_sysio_obj_list() {
53   _objs=`$AR -t $1 | grep -v SYMDEF | grep -v SORTED`
54   mkdir -p $sysio_tmp
55   cd $sysio_tmp
56   $AR -x $1
57   cd ..
58   for _lib in $_objs; do
59     ALL_OBJS=$ALL_OBJS"$sysio_tmp/$_lib ";
60   done
61 }
62
63 # lustre components libs
64 build_obj_list . libllite.a
65 build_obj_list ../lov liblov.a
66 build_obj_list ../obdecho libobdecho.a
67 build_obj_list ../osc libosc.a
68 build_obj_list ../lmv liblmv.a
69 build_obj_list ../mdc libmdc.a
70 build_obj_list ../fid libfid.a
71 build_obj_list ../fld libfld.a
72 build_obj_list ../mgc libmgc.a
73 build_obj_list ../ptlrpc libptlrpc.a
74 build_obj_list ../obdclass liblustreclass.a
75
76 # lnet components libs
77 build_obj_list ../../lnet/utils libuptlctl.a
78 build_obj_list ../../libcfs/libcfs libcfs.a
79 build_obj_list ../../libcfs/libcfs libcfsutil.a
80 if $(echo "$LND_LIBS" | grep "socklnd" >/dev/null) ; then
81         build_obj_list ../../lnet/ulnds/socklnd libsocklnd.a
82 fi
83 build_obj_list ../../lnet/lnet liblnet.a
84
85 # create static lib lsupport
86 rm -f $CWD/liblsupport.a
87 $AR -cru $CWD/liblsupport.a $ALL_OBJS
88 $RANLIB $CWD/liblsupport.a
89
90 # if libsysio is already in our LIBS we don't need to link against it here
91 if $(echo "$LIBS" | grep -v -- "-lsysio" >/dev/null) ; then
92         build_sysio_obj_list $SYSIO/lib/libsysio.a
93 fi
94
95 # create static lib lustre
96 rm -f $CWD/liblustre.a
97 $AR -cru $CWD/liblustre.a $ALL_OBJS
98 $RANLIB $CWD/liblustre.a
99
100 # create shared lib lustre
101 rm -f $CWD/liblustre.so
102 OS=`uname`
103 if test x$OS = xAIX; then
104         $LD $LDFLAGS -shared -o $CWD/liblustre.so $ALL_OBJS -lpthread -Xlinker -bnoipath ../../libsyscall.so
105 else
106 # using -nostdlib on Ubuntu causes errors such as:
107 #./llite_lib.o: In function `liblustre_process_log':
108 #/home/brian/rpm/BUILD/lustre-1.8.2.50/lustre/liblustre/llite_lib.c:234: undefined reference to `__stack_chk_fail_local'
109 # due to the use of SSP
110 #$LD -shared -nostdlib -o $CWD/liblustre.so $ALL_OBJS $CAP_LIBS $PTHREAD_LIBS
111         $LD $LDFLAGS -shared -o $CWD/liblustre.so $ALL_OBJS $CAP_LIBS $PTHREAD_LIBS
112 fi
113
114 rm -rf $sysio_tmp