1 mike 1.1 #!/bin/sh
2
3 ##==============================================================================
4 ##
5 ## Extract leading arguments into $arg1 ... $arg9
6 ## Extract options int $opts
7 ##
8 ##==============================================================================
9
10 n="1"
11 argc="0"
12
13 for i
14 do
15
16 # Break on the first argument that starts with '-'
17 case $i in
18 -h|--help)
19 help=1
20 break;
21 ;;
22 mike 1.1 -*)
23 break;
24 ;;
25 esac
26
27 # Set arguments arg1 ... arg9
28 case $n in
29 1)
30 arg1="$i"
31 shift
32 ;;
33 2)
34 arg2="$i"
35 shift
36 ;;
37 3)
38 arg3="$i"
39 shift
40 ;;
41 4)
42 arg4="$i"
43 mike 1.1 shift
44 ;;
45 5)
46 arg5="$i"
47 shift
48 ;;
49 6)
50 arg6="$i"
51 shift
52 ;;
53 7)
54 arg7="$i"
55 shift
56 ;;
57 8)
58 arg8="$i"
59 shift
60 ;;
61 9)
62 arg9="$i"
63 shift
64 mike 1.1 ;;
65 esac
66
67 argc=`expr $argc + 1`
68 n=`expr $n + 1`
69
70 done
71
72 opts=$*
73
74 #echo "help=$help"
75 #echo "argc=$argc"
76 #echo "arg1=$arg1"
77 #echo "arg2=$arg2"
78 #echo "arg3=$arg3"
79 #echo "arg4=$arg4"
80 #echo "arg5=$arg5"
81 #echo "arg6=$arg6"
82 #echo "arg7=$arg7"
83 #echo "arg8=$arg8"
84 #echo "arg9=$arg9"
85 mike 1.1 #echo "opts{$opts}"
86
87 ##==============================================================================
88 ##
89 ## Print the help message
90 ##
91 ##==============================================================================
92
93 if [ "$help" = "1" ]; then
94
95 cat<<EOF
96 Usage: $0 [COMMAND] [ARGUMENTS] [OPTIONS]
97
98 COMMANDS:
99 platform
100 Print the platform ID for this platform.
101 os
102 Print operating system ID for this platform.
103 hostname
104 Print short hostname.
105 longhostname
106 mike 1.1 Print long hostname.
107 username
108 Print the username of the current user.
109 arch
110 Print architecture ID for this platform.
111 compiler
112 Print compiler ID for this platform.
113 cc
114 Print command name of C compiler.
115 cxx
116 Print command name of C++ compiler.
117 cflags [--debug --pic --errwarn]
118 Print C compiler flags.
119 cxxflags [--debug --pic --errwarn]
120 Print C++ compiler flags.
121 cshlibflags [--libpath=PATH]
122 Print compiler flags used to create a C shared library.
123 cxxshlibflags [--libpath=PATH]
124 Print compiler flags used to create a C++ shared library.
125 cprogflags [--libpath=PATH]
126 Print compiler flags used to create a C program.
127 mike 1.1 cxxprogflags [--libpath=PATH]
128 Print compiler flags used to create a C++ program.
129 mkdep
130 Print out command to build dependencies.
131 syslibs
132 Print a list of system libraries.
133 libpath
134 Print dynamic library path option.
135 shlibname BASENAME
136 Print the shared library name of the given basename.
137 shlibext
138 Print the shared library extension (e.g., 'so').
139
140 EOF
141 exit 0
142 fi
143
144 ##==============================================================================
145 ##
146 ## Check arguments
147 ##
148 mike 1.1 ##==============================================================================
149
150 if [ "$argc" = "0" ]; then
151 echo "Usage: $0 [COMMAND] [ARGUMENTS] [OPTIONS]"
152 echo "Try --help for help"
153 exit 1
154 fi
155
156 ##==============================================================================
157 ##
158 ## Get the platform ID and reject unknown platforms:
159 ##
160 ##==============================================================================
161
162 if [ -z "$CONFIG_TARGET" ]; then
163
164 __m=`uname -m 2>/dev/null` || __m=unknown
165 __s=`uname -s 2>/dev/null` || __s=unknown
166 __r=`uname -r 2>/dev/null` || __r=unknown
167 __v=`uname -v 2>/dev/null` || __v=unknown
168
169 mike 1.1 case "$__m:$__s:$__r:$__v" in
170 i686:Linux:*:*)
171 os=LINUX
172 arch=IX86
173 compiler=GNU
174 ;;
175 x86_64:Linux:*:*)
176 os=LINUX
177 arch=X86_64
178 compiler=GNU
179 ;;
180 sun4*:SunOS:*:*)
181 os=SUNOS
182 arch=SPARC
183 compiler=SUNPRO
184 ;;
185 i86pc:SunOS:*:*)
186 os=SUNOS
187 arch=I86PC
188 compiler=SUNPRO
189 ;;
190 mike 1.1 *:AIX:*:*)
191 os=AIX
192 arch=PPC
193 compiler=IBM
194 ;;
195 ia64:HP-UX:*:*)
196 os=HPUX
197 arch=IA64
198 compiler=HP
199 ;;
200 9000/800:HP-UX:*:*)
201 os=HPUX
202 arch=PARISC
203 compiler=HP
204 ;;
205
206 i386:Darwin:*:Darwin* | x86_64:Darwin:*:Darwin*)
207 os=DARWIN
208 arch=IX86
209 compiler=GNU
210 ;;
211 mike 1.1 *)
212 echo "$0: error: unsupported platform: $__m:$__s:$__r:$__v"
213 exit 1
214 ;;
215 esac
216 platform=$os"_"$arch"_"$compiler
217 else
218 platform=$CONFIG_TARGET
219 fi
220
221 case "$platform" in
222 LINUX_IX86_GNU|LINUX_X86_64_GNU)
223 ;;
224 MONTAVISTA_IX86_GNU)
225 ;;
226 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
227 ;;
228 AIX_PPC_IBM)
229 ;;
230 HPUX_IA64_HP|HPUX_PARISC_HP)
231 ;;
232 mike 1.1 DARWIN_IX86_GNU)
233 ;;
234 *)
235 echo "$0: error: unsupported platform: $platform"
236 exit 1
237 ;;
238 esac
239
240 ##==============================================================================
241 ##
242 ## platform command:
243 ##
244 ##==============================================================================
245
246 if [ "$arg1" = "platform" ]; then
247
248 if [ "$argc" != "1" -o "$opts" != "" ]; then
249 echo "Usage: $0 $arg1"
250 echo
251 exit 1
252 fi
253 mike 1.1
254 echo $platform
255 exit
256 fi
257
258 ##==============================================================================
259 ##
260 ## os command:
261 ##
262 ##==============================================================================
263
264 if [ "$arg1" = "os" ]; then
265
266 if [ "$argc" != "1" -o "$opts" != "" ]; then
267 echo "Usage: $0 $arg1"
268 echo
269 exit 1
270 fi
271
272 echo $os
273 exit
274 mike 1.1 fi
275
276 ##==============================================================================
277 ##
278 ## hostname command:
279 ##
280 ##==============================================================================
281
282 if [ "$arg1" = "hostname" ]; then
283
284 if [ "$argc" != "1" -o "$opts" != "" ]; then
285 echo "Usage: $0 $arg1"
286 echo
287 exit 1
288 fi
289
290 if [ "$os" = "DARWIN" ] ; then
291 hostname -s
292 else
293 hostname
294 fi
295 mike 1.1 exit
296 fi
297
298 ##==============================================================================
299 ##
300 ## longhostname command:
301 ##
302 ##==============================================================================
303
304 if [ "$arg1" = "longhostname" ]; then
305
306 if [ "$argc" != "1" -o "$opts" != "" ]; then
307 echo "Usage: $0 $arg1"
308 echo
309 exit 1
310 fi
311
312 case "$platform" in
313
314 LINUX*)
315 hostname -f
316 mike 1.1 ;;
317 MONTAVISTA*)
318 hostname
319 ;;
320 DARWIN*)
321 hostname
322 ;;
323 *)
324 ##
325 ## Attempt to obtain domain name from /etc/resolve.conf
326 ##
327 if [ -f "/etc/resolv.conf" ]; then
328 domain=`cat /etc/resolv.conf | grep '^domain' | awk '{print $2}'`
329
330 if [ -n "$domain" ]; then
331 echo `hostname`.$domain
332 exit 0
333 fi
334 fi
335
336 ##
337 mike 1.1 ## Attempt to obtain long hostname with 'nslookup' command
338 ##
339 if [ -n "`which nslookup`" ]; then
340 host=`hostname`
341 lhs=`nslookup $host | grep '^Name:' | awk '{print $2}' | grep $host`
342 if [ -n "$lhs" ]; then
343 echo $lhs
344 exit 0
345 fi
346 fi
347
348 ##
349 ## Just print host hostname:
350 ##
351 hostname
352 ;;
353 esac
354
355 exit
356 fi
357
358 mike 1.1 ##==============================================================================
359 ##
360 ## username command:
361 ##
362 ##==============================================================================
363
364 if [ "$arg1" = "username" ]; then
365
366 if [ "$argc" != "1" -o "$opts" != "" ]; then
367 echo "Usage: $0 $arg1"
368 echo
369 exit 1
370 fi
371
372 case "$platform" in
373
374 *)
375 id | cut -f2 -d'(' | cut -f1 -d')'
376 ;;
377 esac
378
379 mike 1.1 exit
380 fi
381
382 ##==============================================================================
383 ##
384 ## arch command:
385 ##
386 ##==============================================================================
387
388 if [ "$arg1" = "arch" ]; then
389
390 if [ "$argc" != "1" -o "$opts" != "" ]; then
391 echo "Usage: $0 $arg1"
392 echo
393 exit 1
394 fi
395
396 echo $arch
397 exit
398 fi
399
400 mike 1.1 ##==============================================================================
401 ##
402 ## compiler command:
403 ##
404 ##==============================================================================
405
406 if [ "$arg1" = "compiler" ]; then
407
408 if [ "$argc" != "1" -o "$opts" != "" ]; then
409 echo "Usage: $0 $arg1"
410 echo
411 exit 1
412 fi
413
414 echo $compiler
415 exit
416 fi
417
418 ##==============================================================================
419 ##
420 ## cc command:
421 mike 1.1 ##
422 ##==============================================================================
423
424 if [ "$arg1" = "cc" ]; then
425
426 if [ "$argc" != "1" -o "$opts" != "" ]; then
427 echo "Usage: $0 $arg1"
428 echo
429 exit 1
430 fi
431
432 case "$platform" in
433
434 LINUX_IX86_GNU|LINUX_X86_64_GNU)
435 echo gcc
436 ;;
437 MONTAVISTA_IX86_GNU)
438 echo 586-gcc
439 ;;
440 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
441 echo cc
442 mike 1.1 ;;
443 AIX_PPC_IBM)
444 echo xlc_r
445 ;;
446 HPUX_IA64_HP|HPUX_PARISC_HP)
447 echo aCC -Ae
448 ;;
449 DARWIN_IX86_GNU)
450 echo gcc
451 ;;
452 esac
453
454 exit
455 fi
456
457 ##==============================================================================
458 ##
459 ## cxx command:
460 ##
461 ##==============================================================================
462
463 mike 1.1 if [ "$arg1" = "cxx" ]; then
464
465 if [ "$argc" != "1" -o "$opts" != "" ]; then
466 echo "Usage: $0 $arg1"
467 echo
468 exit 1
469 fi
470
471 case "$platform" in
472 LINUX_IX86_GNU|LINUX_X86_64_GNU)
473 echo g++
474 ;;
475 MONTAVISTA_IX86_GNU)
476 echo 586-g++
477 ;;
478 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
479 echo CC
480 ;;
481 AIX_PPC_IBM)
482 echo xlC_r
483 ;;
484 mike 1.1 HPUX_IA64_HP|HPUX_PARISC_HP)
485 echo aCC -AA
486 ;;
487 DARWIN_IX86_GNU)
488 echo g++
489 ;;
490 esac
491
492 exit
493 fi
494
495 ##==============================================================================
496 ##
497 ## 'cflags' command:
498 ## 'cxxflags' command:
499 ##
500 ##==============================================================================
501
502 if [ "$arg1" = "cflags" -o "$arg1" = "cxxflags" ]; then
503
504 if [ "$argc" != "1" ]; then
505 mike 1.1 echo "Usage: $0 $arg1"
506 echo
507 exit 1
508 fi
509
510 if [ "$arg1" = "cflags" ]; then
511 c_opt=1
512 else
513 cxx_opt=1
514 fi
515
516 for opt in $opts
517 do
518 case $opt in
519 --debug)
520 debug_opt=1
521 ;;
522 --pic)
523 pic_opt=1
524 ;;
525 --errwarn)
526 mike 1.1 errwarn_opt=1
527 ;;
528 *)
529 echo "$arg1: unknown option: $opt"
530 exit 1
531 ;;
532 esac
533 done
534
535 r=""
536
537 case "$platform" in
538 LINUX_IX86_GNU|LINUX_X86_64_GNU|MONTAVISTA_IX86_GNU)
539 test -n "$debug_opt" && r="$r -g"
540 test -z "$debug_opt" && r="$r -g -O2"
541 test -n "$pic_opt" && r="$r -fPIC"
542 test -n "$errwarn_opt" && r="$r -Werror"
543 r="$r -Wall"
544 r="$r -fvisibility=hidden"
545 #test -n "$cxx_opt" && r="$r -fno-exceptions"
546 #test -n "$cxx_opt" && r="$r -fno-enforce-eh-specs"
547 mike 1.1 #test -n "$cxx_opt" && r="$r -fno-rtti"
548 ;;
549 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
550
551 ## Debugger options.
552 test -n "$debug_opt" && r="$r -g"
553
554 ## Optimization options.
555 if test -z "$debug_opt"; then
556 test -n "$c_opt" && r="$r -g"
557 test -n "$cxx_opt" && r="$r -g -O"
558 fi
559
560 ## Generate position independent code (PIC).
561 test -n "$pic_opt" && r="$r -KPIC"
562
563 ## treat warnings as errors.
564 test -n "$errwarn_opt" && r="$r -errwarn"
565
566 ## multi-threaded support.
567 r="$r -mt"
568 mike 1.1
569 ## avoid optimizations that increase object code size.
570 r="$r -xspace"
571
572 ## specify target system.
573 r="$r -xtarget=generic"
574
575 ## specify target architecture.
576 r="$r -xarch=generic"
577
578 ## hide all library symbols by default.
579 r="$r -xldscope=hidden"
580
581 ## display brief message tag for each warning message.
582 r="$r -errtags=yes"
583
584 ## use standar pthread funciton declarations
585 r="$r -D_POSIX_PTHREAD_SEMANTICS"
586
587 ## suppress all warning messages.
588 #r="$r -erroff=%all"
589 mike 1.1
590 ## suppress this warning message.
591 test -n "$c_opt" && r="$r -erroff=E_WHITE_SPACE_IN_DIRECTIVE"
592
593 ;;
594 AIX_PPC_IBM)
595 test -n "$debug_opt" && r="$r -g"
596 test -n "$debug_opt" && r="$r -qcheck"
597 test -z "$debug_opt" && r="$r -O2"
598 test -z "$debug_opt" && r="$r -qcompact"
599 test -n "$pic_opt" && r="$r -qpic"
600 r="$r -q32"
601 r="$r -Daix"
602
603 ;;
604 HPUX_IA64_HP)
605 test -n "$debug_opt" && r="$r -g"
606 test -z "$debug_opt" && r="$r -s +O1"
607 r="$r +DD32"
608 r="$r -mt"
609 r="$r +Z"
610 mike 1.1 r="$r -Dhpux"
611 r="$r +W4232"
612 r="$r +W4275"
613 r="$r -D_XOPEN_SOURCE=600"
614 r="$r -D__STDC_EXT__"
615 ;;
616 HPUX_PARISC_HP)
617 test -n "$debug_opt" && r="$r -g +noobjdebug"
618 test -z "$debug_opt" && r="$r +O2 -s"
619 r="$r +Z"
620 r="$r +DAportable"
621 r="$r -mt"
622 r="$r -D_PSTAT64"
623 r="$r +W749"
624 r="$r +W740"
625 r="$r -Wl,+s"
626 r="$r -D__STDC_EXT__"
627 r="$r -D_XOPEN_SOURCE_EXTENDED"
628 ;;
629 DARWIN_IX86_GNU)
630 test -n "$debug_opt" && r="$r -g"
631 mike 1.1 test -z "$debug_opt" && r="$r -g -O2"
632 test -n "$pic_opt" && r="$r -fPIC"
633 test -n "$errwarn_opt" && r="$r -Werror"
634 r="$r -Wall"
635 r="$r -fvisibility=hidden"
636 r="$r -bind_at_load"
637 ;;
638 esac
639
640 echo $r
641 exit
642 fi
643
644 ##==============================================================================
645 ##
646 ## 'cshlibflags' command:
647 ## 'cxxshlibflags' command:
648 ##
649 ##==============================================================================
650
651 if [ "$arg1" = "cshlibflags" -o "$arg1" = "cxxshlibflags" ]; then
652 mike 1.1
653 if [ "$argc" != "1" ]; then
654 echo "Usage: $0 $arg1"
655 echo
656 exit 1
657 fi
658
659 if [ "$arg1" = "cshlibflags" ]; then
660 c_opt=1
661 else
662 cxx_opt=1
663 fi
664
665 for opt in $opts
666 do
667 arg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
668 case $opt in
669 --libpath=*)
670 libpath_opt=$arg
671 ;;
672 *)
673 mike 1.1 echo "$arg1: unknown option: $opt"
674 exit 1
675 ;;
676 esac
677 done
678
679 r=""
680
681 case "$platform" in
682 LINUX_IX86_GNU|LINUX_X86_64_GNU)
683 r="$r -shared"
684 test -n "$libpath_opt" && r="$r -Wl,-rpath=$libpath_opt"
685 ;;
686 MONTAVISTA_IX86_GNU)
687 r="$r -shared"
688 test -n "$libpath_opt" && r="$r -Wl,-rpath=$libpath_opt"
689 ;;
690 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
691
692 ## multi-threaded support.
693 r="$r -mt"
694 mike 1.1
695 ## ignore the LD_LIBRARY_PATH variable when linking.
696 r="$r -i"
697
698 ## Build a dynamic shared library (rather than executable file).
699 r="$r -G"
700
701 ## Generate position independent code (PIC).
702 r="$r -KPIC"
703
704 ## Link with the standard C++ library.
705 test -n "$cxx_opt" && r="$r -lCstd"
706
707 ## link time library contains 'nanosleep'
708 r="$r -lrt"
709
710 ## hide all library symbols by default.
711 r="$r -xldscope=hidden"
712
713 ## Add libpath_opt to the dynamic library path.
714 test -n "$libpath_opt" && r="$r -R:$libpath_opt"
715 mike 1.1
716 ;;
717 AIX_PPC_IBM)
718 r="$r -brtl"
719 r="$r -G"
720 r="$r -qmkshrobj"
721 r="$r -q32"
722 if [ -n "$libpath_opt" ]; then
723 r="$r -blibpath:$libpath_opt:/usr/lib:/lib"
724 else
725 r="$r -blibpath:/usr/lib:/lib"
726 fi
727 r="$r -bnolibpath"
728 r="$r -Wl,-bnoautoexp"
729 r="$r -Wl,-bnoexpall"
730 ;;
731 HPUX_IA64_HP)
732 r="$r +DD32"
733 r="$r -mt"
734 r="$r +Z -Dhpux"
735 r="$r +W4232"
736 mike 1.1 r="$r +W4275"
737 r="$r -D_XOPEN_SOURCE=600"
738 r="$r -D__STDC_EXT__"
739 r="$r -lc"
740 r="$r -b"
741 test -n "$libpath_opt" && r="$r +b $libpath_opt"
742 test -n "$cxx_opt" && r="$r -lunwind"
743 test -n "$cxx_opt" && r="$r -lCsup"
744 ;;
745 HPUX_PARISC_HP)
746 r="$r -b"
747 r="$r -Wl,-Bsymbolic"
748 r="$r -Wl,+s"
749 ;;
750 DARWIN_IX86_GNU)
751 r="$r -dynamiclib"
752 test -n "$libpath_opt" && r="$r -R$libpath_opt"
753 r="$r -bind_at_load"
754 ;;
755 esac
756
757 mike 1.1 echo $r
758 exit
759 fi
760
761 ##==============================================================================
762 ##
763 ## 'cprogflags' command:
764 ## 'cxxprogflags' command:
765 ##
766 ##==============================================================================
767
768 if [ "$arg1" = "cprogflags" -o "$arg1" = "cxxprogflags" ]; then
769
770 if [ "$argc" != "1" ]; then
771 echo "Usage: $0 $arg1"
772 echo
773 exit 1
774 fi
775
776 if [ "$arg1" = "cprogflags" ]; then
777 c_opt=1
778 mike 1.1 else
779 cxx_opt=1
780 fi
781
782 for opt in $opts
783 do
784 arg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
785 case $opt in
786 --libpath=*)
787 libpath_opt=$arg
788 ;;
789 *)
790 echo "$arg1: unknown option: $opt"
791 exit 1
792 ;;
793 esac
794 done
795
796 r=""
797
798 case "$platform" in
799 mike 1.1 LINUX_IX86_GNU|LINUX_X86_64_GNU)
800 test -n "$libpath_opt" && r="$r -Wl,-rpath=$libpath_opt"
801 ;;
802 MONTAVISTA_IX86_GNU)
803 test -n "$libpath_opt" && r="$r -Wl,-rpath=$libpath_opt"
804 ;;
805 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
806
807 ## multi-threaded support.
808 r="$r -mt"
809
810 ## ignore the LD_LIBRARY_PATH variable when linking.
811 r="$r -i"
812
813 ## link time library contains 'nanosleep'
814 r="$r -lrt"
815
816 ## hide all library symbols by default.
817 r="$r -xldscope=hidden"
818
819 ## Add libpath_opt to the dynamic library path.
820 mike 1.1 test -n "$libpath_opt" && r="$r -R:$libpath_opt"
821
822 ;;
823
824 AIX_PPC_IBM)
825 r="$r -brtl"
826 r="$r -q32"
827 r="$r -qrtti=dyna"
828 r="$r -qcpluscmt"
829 if [ -n "$libpath_opt" ]; then
830 r="$r -blibpath:$libpath_opt:/usr/lib:/lib"
831 else
832 r="$r -blibpath:/usr/lib:/lib"
833 fi
834 ;;
835 HPUX_IA64_HP)
836 r="$r +DD32"
837 r="$r -mt"
838 r="$r +Z -Dhpux"
839 r="$r +W4232"
840 r="$r +W4275"
841 mike 1.1 r="$r -D_XOPEN_SOURCE=600"
842 r="$r -D__STDC_EXT__"
843 test -n "$libpath_opt" && r="$r +b $libpath_opt"
844 ;;
845 HPUX_PARISC_HP)
846 r="$r +Z"
847 r="$r +DAportable"
848 r="$r -mt"
849 r="$r -D_PSTAT64"
850 ;;
851 DARWIN_IX86_GNU)
852 test -n "$libpath_opt" && r="$r -R$libpath_opt"
853 r="$r -bind_at_load"
854 ;;
855 esac
856
857 echo $r
858 exit
859 fi
860
861 ##==============================================================================
862 mike 1.1 ##
863 ## mkdep command:
864 ##
865 ##==============================================================================
866
867 if [ "$arg1" = "mkdep" ]; then
868
869 if [ "$argc" != "1" -o "$opts" != "" ]; then
870 echo "Usage: $0 $arg1"
871 echo
872 exit 1
873 fi
874
875 r=""
876
877 case "$platform" in
878 LINUX_IX86_GNU|LINUX_X86_64_GNU)
879 r="gcc -M"
880 ;;
881 MONTAVISTA_IX86_GNU)
882 r="586-gcc -M"
883 mike 1.1 ;;
884 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
885 r="CC -xM1"
886 ;;
887 AIX_PPC_IBM)
888 r="xlc++_r -E -qmakedep=gcc"
889 ;;
890 HPUX_IA64_HP|HPUX_PARISC_HP)
891 r="aCC +make -E"
892 ;;
893 DARWIN_IX86_GNU)
894 r="gcc -M"
895 ;;
896 esac
897
898 echo "$r"
899 exit
900 fi
901
902 ##==============================================================================
903 ##
904 mike 1.1 ## syslibs command:
905 ##
906 ##==============================================================================
907
908 if [ "$arg1" = "syslibs" ]; then
909
910 if [ "$argc" != "1" -o "$opts" != "" ]; then
911 echo "Usage: $0 $arg1"
912 echo
913 exit 1
914 fi
915
916 r=""
917
918 case "$platform" in
919 LINUX_IX86_GNU|LINUX_X86_64_GNU)
920 r="-lpthread -ldl -lpam"
921 ;;
922 MONTAVISTA_IX86_GNU)
923 r="-lpthread -ldl -lpam"
924 ;;
925 mike 1.1 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
926 r="-lpthread -lsocket -lnsl -ldl -lpam"
927 ;;
928 AIX_PPC_IBM)
929 r="-lpthread -ldl -lpam"
930 ;;
931 HPUX_IA64_HP)
932 r="-lpthread -ldl -lpam"
933 ;;
934 HPUX_PARISC_HP)
935 r="-lpthread -lpam"
936 ;;
937 DARWIN_IX86_GNU)
938 r="-lpthread -ldl -lpam"
939 ;;
940 esac
941
942 echo "$r"
943 exit
944 fi
945
946 mike 1.1 ##==============================================================================
947 ##
948 ## libpath command:
949 ##
950 ##==============================================================================
951
952 if [ "$arg1" = "libpath" ]; then
953
954 if [ "$argc" -lt "2" -o "$opts" != "" ]; then
955 echo "Usage: $0 $arg1 PATH"
956 echo
957 exit 1
958 fi
959
960 r=""
961 args="$arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8 $arg9"
962
963 case "$platform" in
964 LINUX_IX86_GNU|LINUX_X86_64_GNU)
965 for path in $args
966 do
967 mike 1.1 r="$r -Wl,-rpath=$path"
968 done
969 ;;
970 MONTAVISTA_IX86_GNU)
971 for path in $args
972 do
973 r="$r -Wl,-rpath=$path"
974 done
975 ;;
976 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
977 for path in $args
978 do
979 r="$r -R:$path"
980 done
981 ;;
982 AIX_PPC_IBM)
983 r="-blibpath:/usr/lib:/lib"
984 for path in $args
985 do
986 r="$r:$path"
987 done
988 mike 1.1 ;;
989 HPUX_IA64_HP)
990 r="-Wl,+b,"
991 first=1
992 for path in $args
993 do
994 if [ -n "$first" ]; then
995 r="$r$path"
996 first=""
997 else
998 r="$r:$path"
999 fi
1000 done
1001 ;;
1002 HPUX_PARISC_HP)
1003 #r="-Wl,+cdp,"
1004 r="-Wl,+b,"
1005 first=1
1006 for path in $args
1007 do
1008 if [ -n "$first" ]; then
1009 mike 1.1 r="$r$path"
1010 first=""
1011 else
1012 r="$r:$path"
1013 fi
1014 done
1015 ;;
1016 DARWIN_IX86_GNU)
1017 for path in $args
1018 do
1019 r="$r -R$path"
1020 done
1021 ;;
1022 esac
1023
1024 echo "$r"
1025 exit
1026 fi
1027
1028 ##==============================================================================
1029 ##
1030 mike 1.1 ## libname command:
1031 ##
1032 ##==============================================================================
1033
1034 if [ "$arg1" = "libname" ]; then
1035
1036 if [ "$argc" -lt "2" -o "$opts" != "" ]; then
1037 echo "Usage: $0 $arg1 PATH"
1038 echo
1039 exit 1
1040 fi
1041
1042 r=""
1043
1044 case "$platform" in
1045 LINUX_IX86_GNU|LINUX_X86_64_GNU)
1046 ;;
1047 MONTAVISTA_IX86_GNU)
1048 ;;
1049 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
1050 ;;
1051 mike 1.1 AIX_PPC_IBM)
1052 ;;
1053 HPUX_IA64_HP)
1054 ;;
1055 HPUX_PARISC_HP)
1056 ;;
1057 DARWIN_IX86_GNU)
1058 r="$r -Wl,-install_name -Wl,$arg2"
1059 ;;
1060 esac
1061
1062 echo "$r"
1063 exit
1064 fi
1065
1066 ##==============================================================================
1067 ##
1068 ## 'shlibname' command:
1069 ##
1070 ##==============================================================================
1071
1072 mike 1.1 if [ "$arg1" = "shlibname" ]; then
1073
1074 if [ "$argc" != "2" -o "$opts" != "" ]; then
1075 echo "Usage: $0 $arg1 LIBBASENAME"
1076 echo
1077 exit 1
1078 fi
1079
1080 case "$platform" in
1081 LINUX_IX86_GNU|LINUX_X86_64_GNU)
1082 echo "lib$arg2.so"
1083 ;;
1084 MONTAVISTA_IX86_GNU)
1085 echo "lib$arg2.so"
1086 ;;
1087 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
1088 echo "lib$arg2.so"
1089 ;;
1090 AIX_PPC_IBM)
1091 echo "lib$arg2.so"
1092 ;;
1093 mike 1.1 HPUX_IA64_HP)
1094 echo "lib$arg2.so"
1095 ;;
1096 HPUX_PARISC_HP)
1097 echo "lib$arg2.sl"
1098 ;;
1099 DARWIN_IX86_GNU)
1100 echo "lib$arg2.dylib"
1101 ;;
1102 esac
1103
1104 exit
1105 fi
1106
1107 ##==============================================================================
1108 ##
1109 ## 'shlibext' command:
1110 ##
1111 ##==============================================================================
1112
1113 if [ "$arg1" = "shlibext" ]; then
1114 mike 1.1
1115 if [ "$argc" != "1" -o "$opts" != "" ]; then
1116 echo "Usage: $0 $arg1"
1117 echo
1118 exit 1
1119 fi
1120
1121 case "$platform" in
1122 LINUX_IX86_GNU|LINUX_X86_64_GNU)
1123 echo "so"
1124 ;;
1125 MONTAVISTA_IX86_GNU)
1126 echo "so"
1127 ;;
1128 SUNOS_I86PC_SUNPRO|SUNOS_SPARC_SUNPRO)
1129 echo "so"
1130 ;;
1131 AIX_PPC_IBM)
1132 echo "so"
1133 ;;
1134 HPUX_IA64_HP)
1135 mike 1.1 echo "so"
1136 ;;
1137 HPUX_PARISC_HP)
1138 echo "sl"
1139 ;;
1140 DARWIN_IX86_GNU)
1141 echo "dylib"
1142 ;;
1143 *)
1144 echo "so"
1145 esac
1146
1147 exit
1148 fi
1149
1150 ##==============================================================================
1151 ##
1152 ## 'openssllibdir' command:
1153 ##
1154 ##==============================================================================
1155
1156 mike 1.1 if [ "$arg1" = "openssllibdir" ]; then
1157
1158 if [ "$argc" != "1" -o "$opts" != "" ]; then
1159 echo "Usage: $0 $arg1"
1160 echo
1161 exit 1
1162 fi
1163
1164 ##
1165 ## (1) Locate libdir with pkg-config.
1166 ##
1167
1168 pkgconfig=`which pkg-config 2> /dev/null`
1169
1170 if [ -x "$pkgconfig" ]; then
1171 libdir=`$pkgconfig --variable=libdir openssl`
1172 fi
1173
1174 ##
1175 ## (2) Locate libdir relative to openssl program.
1176 ##
1177 mike 1.1
1178 if [ -z "$libdir" ]; then
1179 openssl=`which openssl 2> /dev/null`
1180
1181 if [ -x "$openssl" ]; then
1182 case "$platform" in
1183 HPUX_PARISC_HP)
1184 shlibext="sl"
1185 ;;
1186 DARWIN_IX86_GNU)
1187 shlibext="dylib"
1188 ;;
1189 *)
1190 shlibext="so"
1191 ;;
1192 esac
1193 dirname=`dirname $openssl`/..
1194 if [ -d "$dirname" ]; then
1195 dirname=`cd "$dirname"; pwd`
1196 if [ -f "$dirname/lib/libssl.$shlibext" ]; then
1197 libdir=$dirname/lib
1198 mike 1.1 elif [ -f "$dirname/ssl/lib/libssl.$shlibext" ]; then
1199 libdir=$dirname/ssl/lib
1200 fi
1201 fi
1202 fi
1203 fi
1204
1205 ##
1206 ## (3) Locate libdir based on platform identifier.
1207 ##
1208
1209 if [ -z "$libdir" ]; then
1210 case "$platform" in
1211 LINUX_IX86_GNU|LINUX_X86_64_GNU)
1212 if [ -f "/usr/lib/libssl.so" ]; then
1213 libdir=/usr/lib
1214 fi
1215 ;;
1216 MONTAVISTA_IX86_GNU)
1217 if [ -f "/usr/lib/libssl.so" ]; then
1218 libdir=/usr/lib
1219 mike 1.1 fi
1220 ;;
1221 SUNOS_I86PC_SUNPRO)
1222 if [ -f "/usr/sfw/lib/libssl.so" ]; then
1223 libdir=/usr/sfw/lib
1224 fi
1225 ;;
1226 SUNOS_SPARC_SUNPRO)
1227 if [ -f "/usr/local/ssl/lib/libssl.so" ]; then
1228 libdir=/usr/local/ssl/lib
1229 fi
1230 ;;
1231 AIX_PPC_IBM)
1232 if [ -f "/usr/lib/libssl.sl" ]; then
1233 libdir=/usr/lib
1234 fi
1235 ;;
1236 HPUX_IA64_HP)
1237 if [ -f "/opt/openssl/lib/libssl.sl" ]; then
1238 libdir=/opt/openssl/lib
1239 fi
1240 mike 1.1 ;;
1241 HPUX_PARISC_HP)
1242 if [ -f "/usr/local/lib/libssl.sl" ]; then
1243 libdir=/usr/local/lib
1244 fi
1245 ;;
1246 DARWIN_IX86_GNU)
1247 if [ -f "/usr/lib/libssl.dylib" ]; then
1248 libdir=/usr/lib
1249 fi
1250 ;;
1251 *)
1252 echo "so"
1253 esac
1254 fi
1255
1256 echo "$libdir"
1257 exit
1258
1259 fi
1260
1261 mike 1.1 ##==============================================================================
1262 ##
1263 ## 'ldlibrarypath' command:
1264 ##
1265 ##==============================================================================
1266
1267 if [ "$arg1" = "ldlibrarypath" ]; then
1268
1269 if [ "$argc" != "1" -o "$opts" != "" ]; then
1270 echo "Usage: $0 $arg1"
1271 echo
1272 exit 1
1273 fi
1274
1275 case "$platform" in
1276 HPUX_IA64_HP|HPUX_PARISC_HP)
1277 echo "SHLIB_PATH"
1278 ;;
1279 DARWIN_IX86_GNU)
1280 echo "DYLD_LIBRARY_PATH"
1281 ;;
1282 mike 1.1 *)
1283 echo "LD_LIBRARY_PATH"
1284 esac
1285
1286 exit
1287 fi
1288
1289 ##==============================================================================
1290 ##
1291 ## Unknown command:
1292 ##
1293 ##==============================================================================
1294
1295 echo "$0: unknown command: $arg1"
1296 exit 1
|