]> git.saurik.com Git - apple/libresolv.git/blob - BUILD
libresolv-46.1.tar.gz
[apple/libresolv.git] / BUILD
1 #! /bin/sh
2 # This script will build resolver library
3 #
4
5 TARGET=resolver
6 echo
7 echo "=================================================="
8 echo $TARGET
9 echo "=================================================="
10
11 PROJECT_ROOT=../netinfo.build/root
12 TARGET_DYNAMIC_LIB=libresolv.9.dylib
13 TARGET_LIB_LINK=libresolv.dylib
14 TARGET_STATIC_LIB=libresolv.a
15 TARGET_VERSION=A
16 TARGET_DIR=usr/lib
17 COMPAT_VERS=1.0.0
18 CURR_VERS=2.0.0
19 TARGET_MAN_DIR=/usr/share/man/man5
20
21 BLD=$TARGET.build
22 DERIVED_SRC_DIR=$BLD/derived_src
23 OBJECT_DIR=$BLD/objects
24
25 DST_DIR=$PROJECT_ROOT/$TARGET_DIR
26 PUBLIC_HEADERS_DIR=$PROJECT_ROOT/usr/include
27 PRIVATE_HEADERS_DIR=$PROJECT_ROOT/usr/local/include
28 PROJECT_HEADERS_DIR=../netinfo.build/ProjectHeaders
29 MAN_DIR=${PROJECT_ROOT}${TARGET_MAN_DIR}
30
31 CFLAGS="-g -dynamic -fno-common -Wall -D_REENTRANT"
32 INCLUDE="-I. -I$PUBLIC_HEADERS_DIR"
33 LIBS=
34 nm /usr/lib/libSystem.B.dylib | grep -q pselect
35 if [ $? = 1 ]; then
36 CFLAGS="$CFLAGS -DNEED_PSELECT"
37 fi
38
39 CLEAN=0
40 BUILD=1
41
42 while [ $# != 0 ]; do
43 if [ ${1}x = cleanx ]; then
44 CLEAN=1
45 BUILD=0
46 fi
47
48 if [ ${1}x = freshx ]; then
49 CLEAN=1
50 BUILD=1
51 fi
52
53 shift
54 done
55
56 if [ $CLEAN = 1 ]; then
57 echo "Cleaning $TARGET"
58 rm -rf $BLD
59 rm -rf .gdb_history
60 fi
61
62 if [ $BUILD = 0 ]; then
63 echo "Done"
64 exit 0
65 fi
66
67 if [ ! -d $BLD ]; then
68 mkdir $BLD
69 fi
70 if [ ! -d $DERIVED_SRC_DIR ]; then
71 mkdir $DERIVED_SRC_DIR
72 ln -s ../.. $DERIVED_SRC_DIR/NetInfo
73 fi
74 if [ ! -d $OBJECT_DIR ]; then
75 mkdir $OBJECT_DIR
76 fi
77
78 if [ ! -d $DST_DIR ]; then
79 if [ -f /bin/mkdirs ]; then
80 mkdirs $DST_DIR
81 else
82 mkdir -p $DST_DIR
83 fi
84 fi
85
86 if [ ! -d $PUBLIC_HEADERS_DIR ]; then
87 if [ -f /bin/mkdirs ]; then
88 mkdirs $PUBLIC_HEADERS_DIR
89 mkdirs $PUBLIC_HEADERS_DIR/arpa
90 else
91 mkdir -p $PUBLIC_HEADERS_DIR
92 mkdir -p $PUBLIC_HEADERS_DIR/arpa
93 fi
94 fi
95
96 if [ ! -d $PRIVATE_HEADERS_DIR ]; then
97 if [ -f /bin/mkdirs ]; then
98 mkdirs $PRIVATE_HEADERS_DIR
99 else
100 mkdir -p $PRIVATE_HEADERS_DIR
101 fi
102 fi
103
104 if [ ! -d $PROJECT_HEADERS_DIR ]; then
105 if [ -f /bin/mkdirs ]; then
106 mkdirs $PROJECT_HEADERS_DIR
107 else
108 mkdir -p $PROJECT_HEADERS_DIR
109 fi
110 fi
111
112 if [ ! -f $PUBLIC_HEADERS_DIR/dns.h ]; then
113 echo "cp dns.h $PUBLIC_HEADERS_DIR"
114 cp dns.h $PUBLIC_HEADERS_DIR
115 fi
116
117 if [ ! -f $PUBLIC_HEADERS_DIR/dns_util.h ]; then
118 echo "cp dns_util.h $PUBLIC_HEADERS_DIR"
119 cp dns_util.h $PUBLIC_HEADERS_DIR
120 fi
121
122 if [ ! -f $PRIVATE_HEADERS_DIR/dns_private.h ]; then
123 echo "cp dns_private.h $PRIVATE_HEADERS_DIR"
124 cp dns_private.h $PRIVATE_HEADERS_DIR
125 fi
126
127 if [ ! -f $PROJECT_HEADERS_DIR/dns_private.h ]; then
128 echo "cp dns_private.h $PROJECT_HEADERS_DIR"
129 cp dns_private.h $PROJECT_HEADERS_DIR
130 fi
131
132 if [ ! -f $PUBLIC_HEADERS_DIR/resolv.h ]; then
133 echo "cp resolv.h $PUBLIC_HEADERS_DIR"
134 cp resolv.h $PUBLIC_HEADERS_DIR
135 fi
136
137 if [ ! -f $PUBLIC_HEADERS_DIR/nameser.h ]; then
138 echo "cp nameser.h $PUBLIC_HEADERS_DIR"
139 cp nameser.h $PUBLIC_HEADERS_DIR
140 echo "ln -s ../nameser.h $PUBLIC_HEADERS_DIR/arpa/nameser.h"
141 ln -s ../nameser.h $PUBLIC_HEADERS_DIR/arpa/nameser.h
142 fi
143
144 if [ ! -d $MAN_DIR ]; then
145 if [ -f /bin/mkdirs ]; then
146 mkdirs $MAN_DIR
147 else
148 mkdir -p $MAN_DIR
149 fi
150 fi
151
152 if [ ! -f $MAN_DIR/resolver.5 ]; then
153 echo "cp resolver.5 $MAN_DIR"
154 cp resolver.5 $MAN_DIR
155 fi
156
157 MAKE_TARGET=0
158 if [ ! -f $DST_DIR/$TARGET_DYNAMIC_LIB ]; then
159 MAKE_TARGET=1
160 fi
161
162 for c in *.[mc]
163 do
164 OBJ=`echo $c | sed 's/..$/.o/'`
165 SRC=$c
166 DST=$OBJECT_DIR/$OBJ
167
168 MAKEIT=1
169 if [ -f $DST ]; then
170 RECENT=`/bin/ls -1t $DST $SRC | head -1`
171 if [ $RECENT = $DST ]; then
172 MAKEIT=0
173 fi
174 fi
175
176 if [ $MAKEIT = 1 ]; then
177 MAKE_TARGET=1
178 echo cc -c $CFLAGS $INCLUDE -o $DST $SRC
179 cc -c $CFLAGS $INCLUDE -o $DST $SRC
180 fi
181 done
182
183 if [ $MAKE_TARGET = 1 ]; then
184 echo libtool -dynamic -install_name /${TARGET_DIR}/${TARGET_DYNAMIC_LIB} -compatibility_version $COMPAT_VERS -current_version $CURR_VERS -arch_only ppc -o $DST_DIR/${TARGET_DYNAMIC_LIB} $OBJECT_DIR/*.o -lcc_dynamic -framework System
185 libtool -dynamic -install_name /${TARGET_DIR}/${TARGET_DYNAMIC_LIB} -compatibility_version $COMPAT_VERS -current_version $CURR_VERS -arch_only ppc -o $DST_DIR/${TARGET_DYNAMIC_LIB} $OBJECT_DIR/*.o -lcc_dynamic -ldnsinfo -framework System
186 echo "ln -s $TARGET_DYNAMIC_LIB $DST_DIR/${TARGET_LIB_LINK}"
187 ln -s $TARGET_DYNAMIC_LIB $DST_DIR/${TARGET_LIB_LINK}
188 fi
189
190 echo "Finished building $TARGET"
191 exit 0