| 1 |
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ |
| 2 |
# All rights reserved |
| 3 |
|
| 4 |
# @synopsis: |
| 5 |
# |
| 6 |
# The 'cc-shared' module provides support for shared libraries and shared objects. |
| 7 |
# It defines the following variables: |
| 8 |
# |
| 9 |
## SH_CFLAGS Flags to use compiling sources destined for a shared library |
| 10 |
## SH_LDFLAGS Flags to use linking (creating) a shared library |
| 11 |
## SH_SOPREFIX Prefix to use to set the soname when creating a shared library |
| 12 |
## SH_SOFULLPATH Set to 1 if the shared library soname should include the full install path |
| 13 |
## SH_SOEXT Extension for shared libs |
| 14 |
## SH_SOEXTVER Format for versioned shared libs - %s = version |
| 15 |
## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object |
| 16 |
## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed |
| 17 |
## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved |
| 18 |
## SH_LINKRPATH Format for setting the rpath when linking an executable, %s = path |
| 19 |
## SH_LINKFLAGS Flags to use linking an executable which will load shared objects |
| 20 |
## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries |
| 21 |
## STRIPLIBFLAGS Arguments to strip a dynamic library |
| 22 |
|
| 23 |
options {} |
| 24 |
|
| 25 |
# Defaults: gcc on unix |
| 26 |
define SHOBJ_CFLAGS -fPIC |
| 27 |
define SHOBJ_LDFLAGS -shared |
| 28 |
define SH_CFLAGS -fPIC |
| 29 |
define SH_LDFLAGS -shared |
| 30 |
define SH_LINKFLAGS -rdynamic |
| 31 |
define SH_LINKRPATH "-Wl,-rpath -Wl,%s" |
| 32 |
define SH_SOEXT .so |
| 33 |
define SH_SOEXTVER .so.%s |
| 34 |
define SH_SOPREFIX -Wl,-soname, |
| 35 |
define LD_LIBRARY_PATH LD_LIBRARY_PATH |
| 36 |
define STRIPLIBFLAGS --strip-unneeded |
| 37 |
|
| 38 |
# Note: This is a helpful reference for identifying the toolchain |
| 39 |
# http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers |
| 40 |
|
| 41 |
switch -glob -- [get-define host] { |
| 42 |
*-*-darwin* { |
| 43 |
define SHOBJ_CFLAGS "-dynamic -fno-common" |
| 44 |
define SHOBJ_LDFLAGS "-bundle -undefined dynamic_lookup" |
| 45 |
define SHOBJ_LDFLAGS_R -bundle |
| 46 |
define SH_CFLAGS -dynamic |
| 47 |
define SH_LDFLAGS -dynamiclib |
| 48 |
define SH_LINKFLAGS "" |
| 49 |
define SH_SOEXT .dylib |
| 50 |
define SH_SOEXTVER .%s.dylib |
| 51 |
define SH_SOPREFIX -Wl,-install_name, |
| 52 |
define SH_SOFULLPATH |
| 53 |
define LD_LIBRARY_PATH DYLD_LIBRARY_PATH |
| 54 |
define STRIPLIBFLAGS -x |
| 55 |
} |
| 56 |
*-*-ming* - *-*-cygwin - *-*-msys { |
| 57 |
define SHOBJ_CFLAGS "" |
| 58 |
define SHOBJ_LDFLAGS -shared |
| 59 |
define SH_CFLAGS "" |
| 60 |
define SH_LDFLAGS -shared |
| 61 |
define SH_LINKRPATH "" |
| 62 |
define SH_LINKFLAGS "" |
| 63 |
define SH_SOEXT .dll |
| 64 |
define SH_SOEXTVER .dll |
| 65 |
define SH_SOPREFIX "" |
| 66 |
define LD_LIBRARY_PATH PATH |
| 67 |
} |
| 68 |
sparc* { |
| 69 |
if {[msg-quiet cc-check-decls __SUNPRO_C]} { |
| 70 |
msg-result "Found sun stdio compiler" |
| 71 |
# sun stdio compiler |
| 72 |
# XXX: These haven't been fully tested. |
| 73 |
define SHOBJ_CFLAGS -KPIC |
| 74 |
define SHOBJ_LDFLAGS "-G" |
| 75 |
define SH_CFLAGS -KPIC |
| 76 |
define SH_LINKFLAGS -Wl,-export-dynamic |
| 77 |
define SH_SOPREFIX -Wl,-h, |
| 78 |
} |
| 79 |
} |
| 80 |
*-*-solaris* { |
| 81 |
if {[msg-quiet cc-check-decls __SUNPRO_C]} { |
| 82 |
msg-result "Found sun stdio compiler" |
| 83 |
# sun stdio compiler |
| 84 |
# XXX: These haven't been fully tested. |
| 85 |
define SHOBJ_CFLAGS -KPIC |
| 86 |
define SHOBJ_LDFLAGS "-G" |
| 87 |
define SH_CFLAGS -KPIC |
| 88 |
define SH_LINKFLAGS -Wl,-export-dynamic |
| 89 |
define SH_SOPREFIX -Wl,-h, |
| 90 |
} |
| 91 |
} |
| 92 |
*-*-hpux* { |
| 93 |
define SHOBJ_CFLAGS +z |
| 94 |
define SHOBJ_LDFLAGS -b |
| 95 |
define SH_CFLAGS +z |
| 96 |
define SH_LDFLAGS -b |
| 97 |
define SH_LINKFLAGS -Wl,+s |
| 98 |
define SH_LINKRPATH "-Wl,+b -Wl,%s" |
| 99 |
define SH_SOPREFIX -Wl,+h, |
| 100 |
define STRIPLIBFLAGS -Wl,-s |
| 101 |
} |
| 102 |
*-*-haiku { |
| 103 |
define SHOBJ_CFLAGS "" |
| 104 |
define SHOBJ_LDFLAGS -shared |
| 105 |
define SH_CFLAGS "" |
| 106 |
define SH_LDFLAGS -shared |
| 107 |
define SH_LINKFLAGS "" |
| 108 |
define SH_SOPREFIX "" |
| 109 |
define LD_LIBRARY_PATH LIBRARY_PATH |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
if {![is-defined SHOBJ_LDFLAGS_R]} { |
| 114 |
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS] |
| 115 |
} |