1XCOMM $OpenBSD: OpenBSDLib.rules,v 1.1 2000/10/09 20:43:58 matthieu Exp $ 2 3 4 5 6/* 7 * OpenBSD shared library rules 8 */ 9 10XCOMM $XFree86: xc/config/cf/OpenBSDLib.rules,v 1.10 2003/10/31 20:49:03 herrb Exp $ 11 12#ifndef UseElfFormat 13#define UseElfFormat NO 14#endif 15 16#ifndef HasSharedLibraries 17#define HasSharedLibraries YES 18#endif 19#ifndef ForceNormalLib 20#define ForceNormalLib YES 21#endif 22 23#ifndef UseRpath 24#define UseRpath YES 25#endif 26 27#ifndef BaseShLibReqs 28#define BaseShLibReqs /* -lc implied by $(CC) */ 29#endif 30 31#ifndef SharedDataSeparation 32#define SharedDataSeparation NO 33#endif 34#ifndef SharedCodeDef 35#define SharedCodeDef /**/ 36#endif 37#ifndef SharedLibraryDef 38#define SharedLibraryDef /**/ 39#endif 40#ifndef ShLibIncludeFile 41#define ShLibIncludeFile <OpenBSDLib.tmpl> 42#endif 43#ifndef RpathLoadFlags 44#if UseRpath 45#define RpathLoadFlags -Wl,-rpath,$(USRLIBDIRPATH) 46#else 47#define RpathLoadFlags /**/ 48#endif 49#endif 50#ifndef LibraryRpathLoadFlags 51#define LibraryRpathLoadFlags RpathLoadFlags 52#endif 53#ifndef SharedLibraryLoadFlags 54#define SharedLibraryLoadFlags -shared PositionIndependentCFlags LibraryRpathLoadFlags 55#endif 56#ifndef PositionIndependentCFlags 57#define PositionIndependentCFlags -fPIC 58#endif 59#ifndef PositionIndependentCplusplusFlags 60#define PositionIndependentCplusplusFlags -fPIC 61#endif 62#if UseElfFormat 63#ifndef ExtraLoadFlags 64#ifdef UseInstalled 65#define ExtraLoadFlags RpathLoadFlags 66#else 67#define ExtraLoadFlags RpathLoadFlags -Wl,-rpath-link,$(BUILDLIBDIR) 68#endif 69#endif 70#ifndef HardCodeLibdirFlag 71#define HardCodeLibdirFlag RpathLoadFlags 72#endif 73#endif /* UseElfFormat */ 74 75/* 76 * InstallSharedLibrary - generate rules to install the shared library. 77 * NOTE: file must be executable, hence "INSTBINFLAGS" 78 */ 79#ifndef InstallSharedLibrary 80#define InstallSharedLibrary(libname,rev,dest) @@\ 81install:: Concat(lib,libname.so.rev) @@\ 82 MakeDir($(DESTDIR)dest) @@\ 83 $(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.so.rev) $(DESTDIR)dest 84#endif /* InstallSharedLibrary */ 85 86/* 87 * InstallSharedLibraryData - generate rules to install the shared library data 88 */ 89#ifndef InstallSharedLibraryData 90#define InstallSharedLibraryData(libname,rev,dest) 91#endif /* InstallSharedLibraryData */ 92 93 94/* 95 * SharedLibraryTarget - generate rules to create a shared library; 96 * build it into a different name so that we do not hose people by having 97 * the library gone for long periods. 98 */ 99#ifndef SharedLibraryTarget 100 101#define SharedLibraryTarget(libname,rev,solist,down,up) @@\ 102AllTarget(Concat(lib,libname.so.rev)) @@\ 103 @@\ 104Concat(lib,libname.so.rev): solist @@\ 105 $(RM) $@~ @@\ 106 set -x; \ @@\ 107 (cd down; $(CC) -o up/$@~ $(SHLIBLDFLAGS) -Wl,-soname,$@\ @@\ 108 solist $(REQUIREDLIBS) BaseShLibReqs); @@\ 109 LinkBuildSonameLibrary($@) @@\ 110 $(RM) $@ @@\ 111 $(MV) $@~ $@ @@\ 112 @@\ 113clean:: @@\ 114 $(RM) Concat(lib,libname.so.rev) 115 116#endif /* SharedLibraryTarget */ 117 118 119/* 120 * SharedDepLibraryTarget - generate rules to create a shared library. 121 */ 122#ifndef SharedDepLibraryTarget 123#define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up) @@\ 124AllTarget(Concat(lib,libname.so.rev)) @@\ 125 @@\ 126Concat(lib,libname.so.rev): deplist $(EXTRALIBRARYDEPS) @@\ 127 $(RM) $@~ @@\ 128 (cd down; $(CC) -o up/$@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)) @@\ 129 $(RM) $@ @@\ 130 $(MV) $@~ $@ @@\ 131 LinkBuildLibrary($@) @@\ 132 @@\ 133clean:: @@\ 134 $(RM) Concat(lib,libname.so.rev) 135 136#endif /* SharedDepLibraryTarget */ 137 138#ifndef SharedDepModuleTarget 139#define SharedDepModuleTarget(name,deps,solist) @@\ 140AllTarget(name) @@\ 141 @@\ 142name: deps @@\ 143 $(RM) $@~ @@\ 144 $(CC) -o $@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS) @@\ 145 $(RM) $@ @@\ 146 $(MV) $@~ $@ @@\ 147 @@\ 148clean:: @@\ 149 $(RM) name 150 151#endif /* SharedDepModuleTarget */ 152 153#ifndef SharedDriModuleTarget 154#define SharedDriModuleTarget(name,deps,solist) @@\ 155AllTarget(name) @@\ 156 @@\ 157name: deps @@\ 158 $(RM) $@~ $@.map @@\ 159 $(CC) -o $@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS) BaseShLibReqs @@\ 160 $(RM) $@ $@.map @@\ 161 $(MV) $@~ $@ @@\ 162 @@\ 163clean:: @@\ 164 $(RM) name @@\ 165 $(RM) name.map 166 167#endif /* SharedDriModuleTarget */ 168 169/* 170 * SharedLibraryDataTarget - generate rules to create shlib data file; 171 */ 172#ifndef SharedLibraryDataTarget 173#define SharedLibraryDataTarget(libname,rev,salist) 174#endif /* SharedLibraryTarget */ 175 176/* 177 * DynamicModuleTarget - build a module to be dynamically loaded 178 */ 179#ifdef DynamicModuleTarget 180#undef DynamicModuleTarget 181#define DynamicModuleTarget(module,modlist) @@\ 182AllTarget(module) @@\ 183 @@\ 184module: modlist @@\ 185 RemoveFile($@) @@\ 186 $(CC) -o $@ $(SHLIBLDFLAGS) modlist @@\ 187 @@\ 188clean:: @@\ 189 RemoveFile(module) 190#endif /* DynamicModuleTarget */ 191 192