1XCOMM $XFree86: xc/config/cf/bsdiLib.rules,v 3.3 2003/10/09 22:43:18 herrb Exp $ 2 3/* 4 * BSDI shared library rules (converted from SVr4/Linux rules) 5 */ 6 7#ifndef HasSharedLibraries 8#define HasSharedLibraries YES 9#endif 10#ifndef ForceNormalLib 11#define ForceNormalLib YES 12#endif 13#ifndef SharedDataSeparation 14#define SharedDataSeparation NO 15#endif 16#ifndef SharedCodeDef 17#define SharedCodeDef /**/ 18#endif 19#ifndef SharedLibraryDef 20#define SharedLibraryDef /**/ 21#endif 22#ifndef ShLibIncludeFile 23#define ShLibIncludeFile <bsdiLib.tmpl> 24#endif 25#ifndef SharedLibraryLoadFlags 26#define SharedLibraryLoadFlags -shared 27#endif 28#ifndef PositionIndependentCFlags 29#define PositionIndependentCFlags -fPIC 30#endif 31#ifndef PositionIndependentCplusplusFlags 32#define PositionIndependentCplusplusFlags -fPIC 33#endif 34#ifndef BaseShLibReqs 35#define BaseShLibReqs -lc 36#endif 37#ifndef RanlibInstFlags 38#define RanlibInstFlags -t 39#endif 40#ifndef SharedCCLdCmd 41/* NOT $(CC), which is probably 'shlicc'. */ 42#define SharedCCLdCmd cc 43#endif 44 45/* 46 * InstallSharedLibrary - generate rules to install the shared library. 47 */ 48#ifndef InstallSharedLibrary 49#define InstallSharedLibrary(libname,rev,dest) @@\ 50install:: Concat(lib,libname.so.rev) @@\ 51 MakeDir($(DESTDIR)dest) @@\ 52 $(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.so.rev) $(DESTDIR)dest @@\ 53 $(RM) Concat($(DESTDIR)dest/lib,libname.so) @@\ 54 $(LN) Concat(lib,libname.so.rev) Concat($(DESTDIR)dest/lib,libname.so) 55#endif /* InstallSharedLibrary */ 56 57/* 58 * InstallSharedLibraryData - generate rules to install the shared library data 59 */ 60#ifndef InstallSharedLibraryData 61#define InstallSharedLibraryData(libname,rev,dest) 62#endif /* InstallSharedLibraryData */ 63 64 65/* 66 * SharedLibraryTarget - generate rules to create a shared library; 67 * build it into a different name so that we do not hose people by having 68 * the library gone for long periods. 69 */ 70#ifndef SharedLibraryTarget 71#define SharedLibraryTarget(libname,rev,solist,down,up) @@\ 72AllTarget(Concat(lib,libname.so.rev)) @@\ 73 @@\ 74Concat(lib,libname.so.rev): solist @@\ 75 $(RM) $@~ @@\ 76 @SONAME=`echo $@ | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; set -x; \ @@\ 77 (cd down; $(CCENVSETUP) SharedCCLdCmd -o up/$@~ $(SHLIBLDFLAGS) \ 78 -Wl,-soname,$$SONAME solist $(REQUIREDLIBS) BaseShLibReqs); \ 79 $(RM) $$SONAME; $(LN) $@ $$SONAME; \ 80 LinkBuildSonameLibrary($$SONAME) @@\ 81 $(RM) $@ @@\ 82 $(MV) $@~ $@ @@\ 83 $(RM) Concat(lib,libname.so) @@\ 84 $(LN) $@ Concat(lib,libname.so) @@\ 85 LinkBuildLibrary($@) @@\ 86 LinkBuildLibrary(Concat(lib,libname.so)) @@\ 87 @@\ 88clean:: @@\ 89 @SONAME=`echo Concat(lib,libname.so.rev) | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; \ @@\ 90 set -x; $(RM) $$SONAME @@\ 91 $(RM) Concat(lib,libname.so.rev) Concat(lib,libname.so) 92 93#endif /* SharedLibraryTarget */ 94 95/* 96 * SharedDepLibraryTarget - generate rules to create a shared library; 97 * build it into a different name so that we do not hose people by having 98 * the library gone for long periods. 99 */ 100#ifndef SharedDepLibraryTarget 101#define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up) @@\ 102AllTarget(Concat(lib,libname.so.rev)) @@\ 103 @@\ 104Concat(lib,libname.so.rev): deplist @@\ 105 $(RM) $@~ @@\ 106 @SONAME=`echo $@ | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; set -x; \ @@\ 107 (cd down; $(CCENVSETUP) SharedCCLdCmd -o up/$@~ $(SHLIBLDFLAGS) \ 108 -Wl,-soname,$$SONAME solist $(REQUIREDLIBS) BaseShLibReqs); \ 109 $(RM) $$SONAME; $(LN) $@ $$SONAME; \ 110 LinkBuildSonameLibrary($$SONAME) @@\ 111 $(RM) $@ @@\ 112 $(MV) $@~ $@ @@\ 113 $(RM) Concat(lib,libname.so) @@\ 114 $(LN) $@ Concat(lib,libname.so) @@\ 115 LinkBuildLibrary($@) @@\ 116 LinkBuildLibrary(Concat(lib,libname.so)) @@\ 117 @@\ 118clean:: @@\ 119 @SONAME=`echo Concat(lib,libname.so.rev) | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; \ @@\ 120 set -x; $(RM) $$SONAME @@\ 121 $(RM) Concat(lib,libname.so.rev) Concat(lib,libname.so) 122 123#endif /* SharedDepLibraryTarget */ 124 125#ifndef SharedDepModuleTarget 126#define SharedDepModuleTarget(name,deps,solist) @@\ 127AllTarget(name) @@\ 128 @@\ 129name: deps @@\ 130 $(RM) $@~ @@\ 131 $(CCENVSETUP) SharedCCLdCmd -o $@~ $(SHLIBLDFLAGS) \ 132 solist $(REQUIREDLIBS) BaseShLibReqs @@\ 133 $(RM) $@ @@\ 134 $(MV) $@~ $@ @@\ 135 @@\ 136clean:: @@\ 137 $(RM) name 138 139#endif /* SharedDepModuleTarget */ 140 141 142/* 143 * SharedLibraryDataTarget - generate rules to create shlib data file; 144 */ 145#ifndef SharedLibraryDataTarget 146#define SharedLibraryDataTarget(libname,rev,salist) 147#endif /* SharedLibraryTarget */ 148 149/* 150 * Hacks for BSD/OS static shared libraries. 151 * We replace the normal library build and install rules. 152 */ 153 154SHLIB_MAP=$${SHLIB_MAP-/etc/shlib.map} 155 156#define BsdiStaticLibraryName(libname)Concat(Concat(lib,libname),_s) 157#define BsdiStaticStubLibraryName(libname)BsdiStaticLibraryName(libname).a 158 159#define MakeBsdiStaticSharedLibrary(libname) \ 160 @SHARED=; \ 161 eval $$( (echo 'MAP() { [ "X$$1" = "X-l'libname'" ] || return 0;' \ 162 'echo "TADDR=$$2;";' \ 163 'echo "DADDR=$$3;";' \ 164 'echo "SHARED=$$5;";' \ 165 'shift 5; echo "ARGS='"'"'"$$@"'"'"';";' \ 166 'exit 0; }'; cat $(SHLIB_MAP)) | sh); \ 167 [ -n "$$SHARED" ] || exit 0; \ 168 echo building static shared libname library; \ 169 shlib -m $(SHLIB_MAP) -t $$TADDR -d $$DADDR \ 170 -n BsdiStaticLibraryName(libname) \ 171 -s BsdiStaticStubLibraryName(libname) \ 172 $$( [ -f 'loader.lib'libname'.c' ] && \ 173 echo -b 'loader.lib'libname'.c') \ 174 $$( [ -f 'lib'libname'.const' ] && \ 175 echo -c 'lib'libname'.const') \ 176 $$( [ -f 'lib'libname'.except' ] && \ 177 echo -e 'lib'libname'.except') \ 178 $$( [ -f $$SHARED ] && echo -i $$SHARED) \ 179 $$ARGS LibraryTargetName(libname) 180 181#define InstallBsdiStaticSharedLibrary(libname) \ 182 @SHARED=; \ 183 eval $$( (echo 'MAP() { [ "X$$1" = "X-l'libname'" ] || return 0;' \ 184 'echo "SHARED=$$5;";' \ 185 'echo "STUB=$$(dirname $$4)/$$(basename $$5).a;";' \ 186 'exit 0; }'; cat $(SHLIB_MAP)) | sh); \ 187 [ -n "$$SHARED" ] || exit 0; \ 188 echo installing static shared libname library; \ 189 $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) \ 190 BsdiStaticLibraryName(libname) $(DESTDIR)$$SHARED; \ 191 $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) \ 192 BsdiStaticStubLibraryName(libname) $(DESTDIR)$$STUB; \ 193 RanLibrary($(RANLIBINSTFLAGS) $(DESTDIR)$$STUB) @@\ 194 -@eval $$( (echo 'MAP() { [ "X$$1" = "X-l'libname'" ] || return 0;' \ 195 'echo "LDIR=$$(dirname $$4)"; exit 0; }'; \ 196 cat $(SHLIB_MAP)) | sh); \ 197 [ -f Concat(loader.lib,libname.c) ] && \ 198 $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) \ 199 Concat(loader.lib,libname.c) \ 200 $(DESTDIR)$$LDIR/Concat(loader.lib,libname.c); \ 201 [ -f Concat(lib,libname.const) ] && \ 202 $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) \ 203 Concat(lib,libname.const) \ 204 $(DESTDIR)$$LDIR/Concat(lib,libname.const); \ 205 [ -f Concat(lib,libname.except) ] && \ 206 $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) \ 207 Concat(lib,libname.except) \ 208 $(DESTDIR)$$LDIR/Concat(lib,libname.except); exit 0 209 210#ifndef UnsharedLibraryTarget 211#define UnsharedLibraryTarget(libname,objlist,down,up) @@\ 212AllTarget(LibraryTargetName(libname)) @@\ 213 @@\ 214LibraryTargetName(libname): objlist @@\ 215 RemoveFile($@) @@\ 216 (cd down; MakeLibrary(up/$@,objlist)) @@\ 217 RanLibrary($@) @@\ 218 _LinkBuildLibrary($@) @@\ 219 MakeBsdiStaticSharedLibrary(libname) @@\ 220 @@\ 221clean:: @@\ 222 $(RM) BsdiStaticLibraryName(libname) BsdiStaticStubLibraryName(libname) 223#endif /* UnsharedLibraryTarget */ 224 225#ifndef UnsharedLibraryTarget3 226#define UnsharedLibraryTarget3(libname,objlist1,objlist2,objlist3,down,up) @@\ 227 UnsharedLibraryTarget(libname,objlist1 objlist2 objlist3,down,up) 228#endif /* UnsharedLibraryTarget3 */ 229 230#ifndef InstallLibrary 231#define InstallLibrary(libname,dest) @@\ 232install:: LibraryTargetName(libname) @@\ 233 MakeDir($(DESTDIR)dest) @@\ 234 $(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) \ 235 LibraryTargetName(libname) $(DESTDIR)dest @@\ 236 RanLibrary($(RANLIBINSTFLAGS) \ 237 $(DESTDIR)dest/LibraryTargetName(libname)) @@\ 238 InstallBsdiStaticSharedLibrary(libname) 239#endif /* InstallLibrary */ 240