added initial support for -exports option, Linux/OpenBSD only for now
[mesa.git] / bin / mklib
1 #!/bin/sh
2
3 # Make a shared library.
4 # Basically do a switch/case depending on the OS and make a shared (or static)
5 # library conforming to that OS.
6
7
8 # Usage:
9 # mklib [options] objects ...
10 # Options:
11 # -o LIBRARY specifies the name of resulting library
12 # ("-o GL" for example, might result in "libGL.so" being made)
13 # -major N specifies major version number (default is 1)
14 # -minor N specifies minor version number (default is 0)
15 # -patch N specifies patch version number (default is 0)
16 # -lLIBRARY specifies a dependency on LIBRARY
17 # -LDIR search in DIR for library dependencies
18 # -cplusplus link with C++ runtime
19 # -static make a static library (default is dynamic/shared)
20 # -install DIR move resulting library file(s) to DIR
21 # -arch ARCH override using `uname` to determine architecture
22 # -archopt OPT specify an extra achitecture-specific option OPT
23 # -noprefix don't prefix library name with "lib" or any suffix
24 # -exports FILE only export the symbols listed in FILE
25 #
26 # The library name should just be "GL" or "GLU", etc. The 'lib' prefix
27 # will be added here if needed, as well as the ".so" or ".a" suffix,
28 # etc (unless the -noprefix option is used).
29 #
30 # objects should be: foo.o bar.o etc.o
31 #
32 # Environment variables recognized:
33 # CC C compiler command
34 # CXX C++ compiler command
35 #
36
37
38 #
39 # Option defaults
40 #
41 LIBNAME=""
42 MAJOR=1
43 MINOR=0
44 PATCH=""
45 DEPS=""
46 CPLUSPLUS=0
47 STATIC=0
48 INSTALLDIR="."
49 ARCH="auto"
50 ARCHOPT=""
51 NOPREFIX=0
52 EXPORTS=""
53
54
55 #
56 # Parse arguments
57 #
58 while true
59 do
60 case $1 in
61 '-o') shift 1; LIBNAME=$1;;
62 '-major') shift 1; MAJOR=$1;;
63 '-minor') shift 1; MINOR=$1;;
64 '-patch') shift 1; PATCH=$1;;
65 -l*) DEPS="$DEPS $1";;
66 -L*) DEPS="$DEPS $1";;
67 '-cplusplus') CPLUSPLUS=1;;
68 '-static') STATIC=1;;
69 '-install') shift 1; INSTALLDIR=$1;;
70 '-arch') shift 1; ARCH=$1;;
71 '-archopt') shift 1; ARCHOPT=$1;;
72 '-noprefix') NOPREFIX=1;;
73 '-exports') shift 1; EXPORTS=$1;;
74 -*) echo "mklib: Unknown option: " $1 ; exit 1;;
75 *) break
76 esac
77 shift 1
78 done
79 OBJECTS=$@
80
81 if [ ${ARCH} = "auto" ] ; then
82 ARCH=`uname`
83 fi
84
85
86 #
87 # Error checking
88 #
89 if [ "x${LIBNAME}" = "x" ] ; then
90 echo "mklib: Error: no library name specified"
91 exit 1
92 fi
93 if [ "x${OBJECTS}" = "x" ] ; then
94 echo "mklib: Error: no object files specified"
95 exit 1
96 fi
97
98
99 #
100 # Debugging info
101 #
102 if [ ] ; then
103 echo "-----------------"
104 echo ARCH is $ARCH
105 echo LIBNAME is $LIBNAME
106 echo MAJOR is $MAJOR
107 echo MINOR is $MINOR
108 echo PATCH is $PATCH
109 echo DEPS are $DEPS
110 echo "EXPORTS in" $EXPORTS
111 echo "-----------------"
112 fi
113
114
115 #
116 # OK, make the library now
117 #
118 case $ARCH in
119
120 'Linux' | 'OpenBSD')
121 # we assume gcc
122
123 # Set default compilers if env vars not set
124 if [ "x$CXX" = "x" ] ; then
125 CXX=g++
126 fi
127 if [ "x$CC" = "x" ] ; then
128 CC=gcc
129 fi
130
131 if [ $NOPREFIX = 1 ] ; then
132 # No "lib" or ".so" part
133 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
134 #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname???
135 OPTS="-shared"
136 if [ $CPLUSPLUS = 1 ] ; then
137 LINK=$CXX
138 else
139 LINK=$CC
140 fi
141 rm -f ${LIBNAME}
142
143 # make lib
144 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
145 # finish up
146 FINAL_LIBS="${LIBNAME}"
147 elif [ $STATIC = 1 ] ; then
148 LIBNAME="lib${LIBNAME}" # prefix with "lib"
149 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
150 LINK="ar"
151 OPTS="-ru"
152 # make lib
153 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
154 ranlib ${LIBNAME}.a
155 # finish up
156 FINAL_LIBS=${LIBNAME}.a
157 else
158 LIBNAME="lib${LIBNAME}" # prefix with "lib"
159 if [ $ARCH = 'Linux' ] ; then
160 OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
161 else
162 OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
163 fi
164 if [ $EXPORTS ] ; then
165 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
166 # Make the 'exptmp' file for --version-script option
167 echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
168 echo "global:" >> exptmp
169 sed 's/$/;/' ${EXPORTS} >> exptmp
170 echo "local:" >> exptmp
171 echo "*;" >> exptmp
172 echo "};" >> exptmp
173 OPTS="${OPTS} -Xlinker --version-script=exptmp"
174 # exptmp is removed below
175 fi
176 if [ x${PATCH} = "x" ] ; then
177 VERSION="${MAJOR}.${MINOR}"
178 else
179 VERSION="${MAJOR}.${MINOR}.${PATCH}"
180 fi
181
182 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
183
184 if [ $CPLUSPLUS = 1 ] ; then
185 LINK=$CXX
186 else
187 LINK=$CC
188 fi
189
190 # rm any old libs
191 rm -f ${LIBNAME}.so.${VERSION}
192 rm -f ${LIBNAME}.so.${MAJOR}
193 rm -f ${LIBNAME}.so
194
195 # make lib
196 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
197 # make usual symlinks
198 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
199 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
200 # finish up
201 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
202 rm -f exptmp
203 fi
204 ;;
205
206 'SunOS')
207 if [ $STATIC = 1 ] ; then
208 LIBNAME="lib${LIBNAME}.a"
209 echo "mklib: Making SunOS static library: " ${LIBNAME}
210 rm -f ${LIBNAME}
211 ar -ruv ${LIBNAME} ${OBJECTS}
212 FINAL_LIBS=${LIBNAME}
213 else
214 LIBNAME="lib${LIBNAME}.so"
215 echo "mklib: Making SunOS shared library: " ${LIBNAME}
216 # XXX OPTS for gcc should be -shared, but that doesn't work.
217 # Using -G does work though.
218 if [ $CPLUSPLUS = 1 ] ; then
219 # determine linker and options for C++ code
220 if [ "x${CXX}" = "xg++" ] ; then
221 # use g++
222 LINK="g++"
223 OPTS="-G"
224 elif [ "x${CXX}" = "xCC" ] ; then
225 # use Sun CC
226 LINK="CC"
227 OPTS="-G"
228 elif [ "x${CXX}" = "xc++" ] ; then
229 # use Sun c++
230 LINK="c++"
231 OPTS="-G"
232 elif [ `which c++` ] ; then
233 # use Sun c++
234 LINK="c++"
235 OPTS="-G"
236 elif [ `type g++` ] ; then
237 # use g++
238 LINK="g++"
239 OPTS="-G"
240 else
241 echo "mklib: warning: can't find C++ comiler, trying CC."
242 LINK="CC"
243 OPTS="-G"
244 fi
245 elif [ "x${CC}" = "xgcc" ] ; then
246 # use gcc for linking
247 LINK="gcc"
248 OPTS="-G"
249 else
250 # use native Sun linker
251 LINK="ld"
252 OPTS="-G"
253 fi
254 echo "mklib: linker is" ${LINK} ${OPTS}
255 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
256 ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
257 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
258 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
259 fi
260 ;;
261
262 'FreeBSD')
263 if [ $NOPREFIX = 1 ] ; then
264 # No "lib" or ".so" part
265 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
266 rm -f ${LIBNAME}
267 ld -Bshareable -o ${LIBNAME} ${OBJECTS}
268 FINAL_LIBS=${LIBNAME}
269 elif [ $STATIC = 1 ] ; then
270 STLIB="lib${LIBNAME}.a"
271 echo "mklib: Making FreeBSD static library: " ${STLIB}
272 rm -f ${STLIB}
273 ar cq ${STLIB} ${OBJECTS}
274 ranlib ${STLIB}
275 FINAL_LIBS=${STLIB}
276 else
277 SHLIB="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
278 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
279 rm -f ${SHLIB}
280 ld -Bshareable -o ${SHLIB} ${OBJECTS}
281 # XXX make lib${LIBNAME}.so.${MAJOR} symlink?
282 FINAL_LIBS=${SHLIB}
283 fi
284 ;;
285
286 'NetBSD')
287 if [ $STATIC = 1 ] ; then
288 LIBNAME="lib${LIBNAME}_pic.a"
289 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
290 rm -f ${LIBNAME}
291 ar cq ${LIBNAME} ${OBJECTS}
292 ranlib ${LIBNAME}
293 FINAL_LIBS=${LIBNAME}
294 else
295 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
296 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
297 rm -f ${LIBNAME}
298 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
299 FINAL_LIBS=${LIBNAME}
300 fi
301 ;;
302
303 'IRIX' | 'IRIX64')
304 if [ $STATIC = 1 ] ; then
305 LIBNAME="lib${LIBNAME}.a"
306 rm -f ${LIBNAME}
307 ar rc ${LIBNAME} ${OBJECTS}
308 FINAL_LIBS=${LIBNAME}
309 else
310 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
311 if [ $ARCHOPT = "64" ] ; then
312 # 64-bit ABI
313 OPTS="-64 -shared -all"
314 echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME}
315 elif [ $ARCHOPT = "o32" ] ; then
316 # old 32-bit ABI
317 OPTS="-32 -shared -all"
318 echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME}
319 else
320 # new 32-bit ABI
321 OPTS="-n32 -shared -all"
322 echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME}
323 fi
324 if [ $CPLUSPLUS = 1 ] ; then
325 LINK="CC"
326 else
327 LINK="ld"
328 fi
329 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
330 FINAL_LIBS=${LIBNAME}
331 fi
332 ;;
333
334 'linux-cygwin')
335 LIBNAME="lib${LIBNAME}.a"
336 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
337 rm -f ${LIBNAME}
338 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
339 FINAL_LIBS=${LIBNAME}
340 ;;
341
342 'HP-UX')
343 if [ $STATIC = 1 ] ; then
344 LIBNAME="lib${LIBNAME}.a"
345 echo "mklib: Making HP-UX static library: " ${LIBNAME}
346 rm -f ${LIBNAME}
347 ar -ruv ${LIBNAME} ${OBJECTS}
348 FINAL_LIBS=${LIBNAME}
349 else
350 RUNLIB="lib${LIBNAME}.${MAJOR}"
351 DEVLIB="lib${LIBNAME}.sl"
352 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
353 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
354 ln -s ${RUNLIB} ${DEVLIB}
355 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
356 fi
357 ;;
358
359 'AIX')
360 if [ $STATIC = 1 ] ; then
361 LIBNAME="lib${LIBNAME}.a"
362 echo "mklib: Making AIX static library: " ${LIBNAME}
363 ar -ruv ${LIBNAME} ${OBJECTS}
364 FINAL_LIBS=${LIBNAME}
365 else
366 EXPFILE="lib${LIBNAME}.exp"
367 OFILE=shr.o #Want to be consistent with the IBM libGL.a
368 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
369 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry"
370 rm -f ${EXPFILE} ${OFILE}
371 NM="/bin/nm -eC"
372 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
373 ${NM} ${OBJECTS} | awk '{
374 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
375 && ( substr($1,1,1) != ".")) {
376 if (substr ($1, 1, 7) != "__sinit" &&
377 substr ($1, 1, 7) != "__sterm") {
378 if (substr ($1, 1, 5) == "__tf1")
379 print (substr ($1, 7))
380 else if (substr ($1, 1, 5) == "__tf9")
381 print (substr ($1, 15))
382 else
383 print $1
384 }
385 }
386 }' | sort -u >> ${EXPFILE}
387 cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
388 ar -r ${LIBNAME} ${OFILE}
389 FINAL_LIBS="${LIBNAME}"
390 fi
391 ;;
392
393 'AIX64')
394 if [ $STATIC = 1 ] ; then
395 LIBNAME="lib${LIBNAME}.a"
396 echo "mklib: Making AIX static library: " ${LIBNAME}
397 ar -X64 -ruv ${LIBNAME} ${OBJECTS}
398 FINAL_LIBS=${LIBNAME}
399 else
400 EXPFILE="lib${LIBNAME}.exp"
401 OFILE=shr.o #Want to be consistent with the IBM libGL.a
402 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
403 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
404 rm -f ${EXPFILE} ${OFILE}
405 NM="/bin/nm -eC -X64"
406 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
407 ${NM} ${OBJECTS} | awk '{
408 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
409 && ( substr($1,1,1) != ".")) {
410 if (substr ($1, 1, 7) != "__sinit" &&
411 substr ($1, 1, 7) != "__sterm") {
412 if (substr ($1, 1, 5) == "__tf1")
413 print (substr ($1, 7))
414 else if (substr ($1, 1, 5) == "__tf9")
415 print (substr ($1, 15))
416 else
417 print $1
418 }
419 }
420 }' | sort -u >> ${EXPFILE}
421 cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
422 ar -X64 -r ${LIBNAME} ${OFILE}
423 FINAL_LIBS="${LIBNAME}"
424 fi
425 ;;
426
427 'OpenSTEP')
428 LIBNAME="lib${LIBNAME}.a"
429 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
430 libtool -static -o ${LIBNAME} - ${OBJECTS}
431 FINAL_LIBS=${LIBNAME}
432 ;;
433
434 'OSF1')
435 if [ $STATIC = 1 ] ; then
436 LIBNAME="lib${LIBNAME}.a"
437 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
438 rm -f ${LIBNAME}
439 ar -ruv ${LIBNAME} ${OBJECTS}
440 FINAL_LIBS=${LIBNAME}
441 else
442 VERSION="${MAJOR}.${MINOR}"
443 LIBNAME="lib${LIBNAME}.so"
444 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
445 rm -f ${LIBNAME}.${VERSION}
446 ld -o ${LIBNAME}.${VERSION} -shared -no_archive -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
447 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
448 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
449 fi
450 ;;
451
452 'Darwin')
453 if [ $STATIC = 1 ] ; then
454 LIBNAME="lib${LIBNAME}.a"
455 echo "mklib: Making Darwin static library: " ${LIBNAME}
456 LINK="ar"
457 OPTS="-ruv"
458 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
459 FINAL_LIBS=${LIBNAME}
460 else
461 LIBNAME="${LIBNAME}.dylib"
462 echo "mklib: Making Darwin shared library: " ${LIBNAME}
463 FLAGS="-dynamiclib -multiply_defined suppress"
464 if [ $CPLUSPLUS = 1 ] ; then
465 LINK="g++"
466 else
467 LINK="cc"
468 fi
469 ${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
470 FINAL_LIBS=${LIBNAME}
471 fi
472 ;;
473
474 'LynxOS')
475 LIBNAME="lib${LIBNAME}.a"
476 echo "mklib: Making LynxOS static library: " ${LIBNAME}
477 rm -f ${LIBNAME}
478 ar ru ${LIBNAME} ${OBJECTS}
479 FINAL_LIBS=${LIBNAME}
480 ;;
481
482 'BeOS')
483 if [ $STATIC = 1 ] ; then
484 LIBNAME="lib${LIBNAME}.a"
485 echo "mklib: Making BeOS static library: " ${LIBNAME}
486 ar -cru "${LIBNAME}" ${OBJECTS}
487 else
488 LIBNAME="lib${LIBNAME}.so"
489 echo "mklib: Making BeOS shared library: " ${LIBNAME}
490 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
491 mimeset -f "${LIBNAME}"
492 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
493 fi
494 FINAL_LIBS=${LIBNAME}
495 ;;
496
497 'QNX')
498 LIBNAME="lib${LIBNAME}.a"
499 echo "mklib: Making QNX library: " ${LIBNAME}
500 wlib ${LIBNAME} ${OBJECTS}
501 FINAL_LIBS=${LIBNAME}
502 ;;
503
504 'MorphOS')
505 LIBNAME="lib${LIBNAME}.a"
506 echo "mklib: Making MorphOS library: " ${LIBNAME}
507 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
508 FINAL_LIBS="${LIBNAME}"
509 ;;
510
511 'icc')
512 # Intel C compiler
513 LIBNAME="lib${LIBNAME}" # prefix with "lib"
514
515 if [ $STATIC = 1 ] ; then
516 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
517 LINK="ar"
518 OPTS="-ruv"
519 # make lib
520 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
521 # finish up
522 FINAL_LIBS="${LIBNAME}.a"
523 else
524 OPTS="-shared"
525 VERSION="${MAJOR}.${MINOR}.${PATCH}"
526 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
527
528 if [ $CPLUSPLUS = 1 ] ; then
529 LINK="icc"
530 else
531 LINK="icc"
532 fi
533 # rm any old libs
534 rm -f ${LIBNAME}.so.${VERSION}
535 rm -f ${LIBNAME}.so.${MAJOR}
536 rm -f ${LIBNAME}.so
537 # make lib
538 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
539 # make usual symlinks
540 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
541 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
542 # finish up
543 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
544 fi
545 ;;
546
547 'aix-gcc')
548 # AIX with gcc
549 if [ $STATIC = 1 ] ; then
550 LIBNAME="lib${LIBNAME}.a"
551 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
552 rm -f ${LIBNAME}
553 ar ru ${LIBNAME} ${OBJECTS}
554 FINAL_LIBS=${LIBNAME}
555 else
556 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
557 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
558 # remove old lib
559 rm -f ${LIBNAME}
560 # make the lib
561 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
562 # NOTE: the application linking with this library must specify
563 # the -Wl,-brtl flags to gcc
564 FINAL_LIBS=${LIBNAME}
565 fi
566 ;;
567
568 'ultrix')
569 # XXX untested
570 if [ $STATIC = 0 ] ; then
571 echo "mklib: Warning shared libs not supported on Ultrix"
572 fi
573 LIBNAME="lib${LIBNAME}.a"
574 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
575 rm -f ${LIBNAME}
576 ar ru ${LIBNAME} ${OBJECTS}
577 FINAL_LIBS="${LIBNAME}"
578 ;;
579
580 CYGWIN*)
581 # GCC-based environment
582 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
583 LIBNAME="lib${LIBNAME}" # prefix with "lib"
584
585 if [ $STATIC = 1 ] ; then
586 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
587 LINK="ar"
588 OPTS="-ru"
589 # make lib
590 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
591 ranlib ${LIBNAME}.a
592 # finish up
593 FINAL_LIBS=${LIBNAME}.a
594 else
595 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
596 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
597
598 if [ $CPLUSPLUS = 1 ] ; then
599 LINK="g++"
600 else
601 LINK="gcc"
602 fi
603
604 # rm any old libs
605 rm -f ${LIBNAME}-${MAJOR}.dll
606 rm -f ${LIBNAME}.dll.a
607 rm -f ${LIBNAME}.a
608
609 # make lib
610 ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
611 # make usual symlinks
612 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
613 # finish up
614 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
615 # special case for installing in bin
616 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
617 fi
618 ;;
619
620 'example')
621 # If you're adding support for a new architecture, you can
622 # start with this:
623 if [ $STATIC = 1 ] ; then
624 LIBNAME="lib${LIBNAME}.a"
625 echo "mklib: Making static library for example arch: " ${LIBNAME}
626 rm -f ${LIBNAME}
627 ar rv ${LIBNAME} ${OBJECTS}
628 FINAL_LIBS="${LIBNAME}"
629 else
630 LIBNAME="lib${LIBNAME}.so" # prefix with "lib"
631 echo "mklib: Making shared library for example arch: " ${LIBNAME}
632 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
633 FINAL_LIBS="${LIBNAME}"
634 fi
635 ;;
636
637 *)
638 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
639 echo "mklib: Please add necessary commands to mklib script."
640 ;;
641 esac
642
643
644 #
645 # Put library files into installation directory if specified.
646 #
647 if [ ${INSTALLDIR} != "." ] ; then
648 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
649 mv ${FINAL_LIBS} ${INSTALLDIR}/
650 fi