Whamcloud - gitweb
Fixes from b_port_step needed to get HEAD to build.
[fs/lustre-release.git] / lustre / liblustre / genlib.sh
1 #!/bin/bash
2 #set -xv
3
4 #
5 # This script is to generate lib lustre library as a whole. It will leave
6 # two files on current directory: liblustre.a and liblustre.so.
7 #
8 # Most concern here is the libraries linking order
9 #
10 # FIXME: How to do this cleanly use makefile?
11 #
12
13 AR=/usr/bin/ar
14 LD=/usr/bin/ld
15 RANLIB=/usr/bin/ranlib
16
17 CWD=`pwd`
18
19 SYSIO=$1
20 CRAY_PORTALS_PATH=$2
21
22 if [ ! -f $SYSIO/lib/libsysio.a ]; then
23   echo "ERROR: $SYSIO/lib/libsysio.a dosen't exist"
24   exit 1
25 fi
26
27 # do cleanup at first
28 rm -f liblustre.so
29
30 ALL_OBJS=
31
32 build_obj_list() {
33   _objs=`$AR -t $1/$2`
34   for _lib in $_objs; do
35     ALL_OBJS=$ALL_OBJS"$1/$_lib ";
36   done;
37 }
38
39 prepend_obj_list() {
40   _objs=`$AR -t $1/$2`
41   for _lib in $_objs; do
42     ALL_OBJS="$1/$_lib "$ALL_OBJS;
43   done;
44 }
45
46 #
47 # special treatment for libsysio
48 #
49 sysio_tmp=$CWD/sysio_tmp_`date +%s`
50 rm -rf $sysio_tmp
51 build_sysio_obj_list() {
52   _objs=`$AR -t $1`
53   mkdir -p $sysio_tmp
54   cd $sysio_tmp
55   $AR -x $1
56   cd ..
57   for _lib in $_objs; do
58     ALL_OBJS=$ALL_OBJS"$sysio_tmp/$_lib ";
59   done
60 }
61
62 #
63 # special treatment for libportals.a
64 #
65 cray_tmp=$CWD/cray_tmp_`date +%s`
66 rm -rf $cray_tmp
67 build_cray_portals_obj_list() {
68   _objs=`$AR -t $1`
69   mkdir -p $cray_tmp
70   cd $cray_tmp
71   $AR -x $1
72   cd ..
73   for _lib in $_objs; do
74     ALL_OBJS=$ALL_OBJS"$cray_tmp/$_lib ";
75   done
76 }
77
78 # lustre components libs
79 build_obj_list . liblutils.a
80 build_obj_list ../lov liblov.a
81 build_obj_list ../obdecho libobdecho.a
82 build_obj_list ../osc libosc.a
83 build_obj_list ../mdc libmdc.a
84 build_obj_list ../ptlrpc libptlrpc.a
85 build_obj_list ../obdclass liblustreclass.a
86 build_obj_list ../lvfs liblvfs.a
87
88 # portals components libs
89 build_obj_list ../../portals/utils libuptlctl.a
90
91 if [ "x$CRAY_PORTALS_PATH" = "x" ]; then
92   build_obj_list ../../portals/unals libtcpnal.a
93   build_obj_list ../../portals/portals libportals.a
94 else
95   build_cray_portals_obj_list $CRAY_PORTALS_PATH/lib_TV/snos64/libportals.a
96 fi
97
98 # create static lib lsupport
99 rm -f $CWD/liblsupport.a
100 $AR -cru $CWD/liblsupport.a $ALL_OBJS
101 $RANLIB $CWD/liblsupport.a
102
103 # libllite should be at the beginning of obj list
104 prepend_obj_list . libllite.a
105
106 # libsysio
107 build_sysio_obj_list $SYSIO/lib/libsysio.a
108
109 # create static lib lustre
110 rm -f $CWD/liblustre.a
111 $AR -cru $CWD/liblustre.a $ALL_OBJS
112 $RANLIB $CWD/liblustre.a
113
114 # create shared lib lustre
115 rm -f $CWD/liblustre.so
116 $LD -shared -o $CWD/liblustre.so -init __liblustre_setup_ -fini __liblustre_cleanup_ \
117         $ALL_OBJS -lcap -lpthread
118
119 rm -rf $sysio_tmp
120 rm -rf $cray_tmp