cygwin.rules revision 11d341ca
1/* 2 * Cygwin shared library rules (DLL versions) 3 */ 4 5#define HasSharedLibraries YES 6#define NeedLibInsideFlag NO 7#define ForceNormalLib NO 8#ifndef SharedLibX11 9# define SharedLibX11 YES 10#endif 11#ifndef NormalLibX11 12# define NormalLibX11 NO 13#endif 14#define SharedLibXaw YES 15#define SharedLibXmu YES 16#define SharedLibXt YES 17#define SharedLibFont NO 18#define SharedLibXaw7 YES 19#define SharedLibXaw6 YES 20#define SharedLibSM YES 21#define SharedLibICE YES 22#define SharedLibXext YES 23#define SharedLibXi YES 24#define SharedLibXtst YES 25#define SharedOldX YES 26#define SharedLibXp YES 27#define SharedLibGlx YES 28#define SharedLibDps YES 29#define SharedLibDpsTk YES 30#define SharedLibGlu YES 31#define SharedLibWindowsWM NO 32#ifndef SharedDataSeparation 33#define SharedDataSeparation NO 34#endif 35 36#ifndef SharedCodeDef 37#define SharedCodeDef /**/ 38#endif 39#ifndef SharedLibraryDef 40#define SharedLibraryDef /**/ 41#endif 42#ifndef ShLibIncludeFile 43#define ShLibIncludeFile <cygwin.tmpl> 44#endif 45#ifndef SharedLibraryLoadFlags 46#define SharedLibraryLoadFlags -dll /**/ 47#endif 48#ifndef PositionIndependentCFlags 49#define PositionIndependentCFlags -D_DLL 50#endif 51#ifndef PositionIndependentCplusplusFlags 52#define PositionIndependentCplusplusFlags -D_DLL 53#endif 54#ifndef UseExportLists 55#define UseExportLists YES 56#endif 57 58#define SharedLibraryName(libname, rev) \ 59Concat3(cyg,libname,-$(shell echo rev|sed s=\\..*==).dll) 60 61#define ImportLibraryName(libname, rev) \ 62Concat3(lib,libname,-$(shell echo rev|sed s=\\..*==).dll.a) 63 64#define ShortImportLibraryName(libname, rev) \ 65Concat3(lib,libname,.dll.a) 66 67/* 68 * SharedDepLibraryTarget - generate rules to create a shared library. 69 */ 70 71#ifndef SharedDepLibraryTarget 72# ifdef UseInstalled 73# ifndef LinkBuildSonameLibrary 74# define LinkBuildSonameLibrary(lib) 75# endif 76# else /* !UseInstalled */ 77# ifndef LinkBuildSonameLibrary 78# define LinkBuildSonameLibrary(lib) (RemoveFile($(BUILDLIBDIR)/lib); @@\ 79 cd $(BUILDLIBDIR); $(LN) $(BUILDINCTOP)/$(CURRENT_DIR)/lib .) 80# endif 81# endif /* UseInstalled */ 82 83 84/* 85 * SharedDepLibraryTarget 86 */ 87 88#define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up) @@\ 89AllTarget(SharedLibraryName(libname,rev)) @@\ 90 @@\ 91SharedLibraryName(libname,rev): deplist @@\ 92 RemoveFile(ImportLibraryName(libname,rev)) @@\ 93 RemoveFile(SharedLibraryName(libname,rev)) @@\ 94 MakeDLL(libname,solist,rev) @@\ 95 LinkBuildLibrary(ImportLibraryName(libname,rev)) @@\ 96 LinkImportLibrary(ImportLibraryName(libname,rev),LibraryTargetName(libname)) @@\ 97 LinkBuildDLL(SharedLibraryName(libname,rev)) @@\ 98 @@\ 99clean:: @@\ 100 RemoveFile(ImportLibraryName(libname,rev)) @@\ 101 RemoveFile(SharedLibraryName(libname,rev)) @@\ 102 103#endif /* SharedDepLibraryTarget */ 104 105/* 106 * SharedDepCplusplusLibraryTarget - generate rules to create a shared library. 107 */ 108 109#ifndef SharedDepCplusplusLibraryTarget 110# ifdef UseInstalled 111# ifndef LinkBuildSonameLibrary 112# define LinkBuildSonameLibrary(lib) 113# endif 114# else /* !UseInstalled */ 115# ifndef LinkBuildSonameLibrary 116# define LinkBuildSonameLibrary(lib) (RemoveFile($(BUILDLIBDIR)/lib); @@\ 117 cd $(BUILDLIBDIR); $(LN) $(BUILDINCTOP)/$(CURRENT_DIR)/lib .) 118# endif 119# endif /* UseInstalled */ 120 121 122/* 123 * SharedDepCplusplusLibraryTarget 124 */ 125 126#define SharedDepCplusplusLibraryTarget(libname,rev,deplist,solist,down,up) @@\ 127AllTarget(SharedLibraryName(libname,rev)) @@\ 128 @@\ 129SharedLibraryName(libname,rev): deplist @@\ 130 RemoveFile(ImportLibraryName(libname,rev)) @@\ 131 RemoveFile(SharedLibraryName(libname,rev)) @@\ 132 MakeCplusplusDLL(libname,solist,rev) @@\ 133 LinkBuildLibrary(ImportLibraryName(libname,rev)) @@\ 134 LinkImportLibrary(ImportLibraryName(libname,rev),LibraryTargetName(libname)) @@\ 135 LinkBuildDLL(SharedLibraryName(libname,rev)) @@\ 136 @@\ 137clean:: @@\ 138 RemoveFile(ImportLibraryName(libname,rev)) @@\ 139 RemoveFile(SharedLibraryName(libname,rev)) @@\ 140 141#endif /* SharedDepCplusplusLibraryTarget */ 142 143 144/* 145 * SharedDepModuleTarget 146 */ 147 148#ifndef SharedDepModuleTarget 149#define SharedDepModuleTarget(name,deps,solist) @@\ 150AllTarget(name) @@\ 151 @@\ 152name: deps @@\ 153 $(CC) -o $@ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS) BaseShLibReqs @@\ 154 @@\ 155clean:: @@\ 156 RemoveFile(name) 157#endif /* SharedDepModuleTarget */ 158 159 160/* 161 * SharedLibraryDataTarget - generate rules to create shared data file 162 */ 163 164#ifndef SharedLibraryDataTarget 165#define SharedLibraryDataTarget(libname,rev,salist) 166#endif 167 168 169/* 170 * InstallSharedLibraryData - generate rules to install the shared library data 171 */ 172 173#ifndef InstallSharedLibraryData 174#define InstallSharedLibraryData(libname,rev,dest) 175#endif /* InstallSharedLibraryData */ 176 177/* 178 * MakeDllProg 179 */ 180 181#define MakeDLLProg(libname,solist,prog,rev) @@\ 182 prog -shared -Wl,--out-implib=ImportLibraryName(libname,rev) -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc -Wl,--exclude-libs,ALL -o SharedLibraryName(libname,rev) solist $(REQUIREDLIBS) 183 184/* 185 * MakeDll 186 */ 187 188#define MakeDLL(libname,solist,rev) @@\ 189 MakeDLLProg(libname,solist,$(CC),rev) 190 191/* 192 * MakeCplusplusDll 193 */ 194 195#define MakeCplusplusDLL(libname,solist,rev) @@\ 196 MakeDLLProg(libname,solist,$(CXX),rev) 197 198 199 200/* 201 * SharedLibraryTarget 202 */ 203 204#define SharedLibraryTarget(libname,rev,solist,down,up) @@\ 205AllTarget(SharedLibraryName(libname,rev)) @@\ 206 @@\ 207SharedLibraryName(libname,rev): solist @@\ 208 RemoveFile(ImportLibraryName(libname,rev)) @@\ 209 RemoveFile(SharedLibraryName(libname,rev)) @@\ 210 MakeDLL(libname,solist,rev) @@\ 211 LinkBuildLibrary(ImportLibraryName(libname,rev)) @@\ 212 LinkImportLibrary(ImportLibraryName(libname,rev),LibraryTargetName(libname)) @@\ 213 LinkBuildDLL(SharedLibraryName(libname,rev)) @@\ 214clean:: @@\ 215 RemoveFile(ImportLibraryName(libname,rev)) @@\ 216 RemoveFile(SharedLibraryName(libname,rev)) @@\ 217 218 219/* 220 * InstallLink 221 */ 222 223#ifndef InstallLink 224#define InstallLink(step, file, link, dest) @@\ 225step:: @@\ 226 MakeDir($(DESTDIR)dest) @@\ 227 $(LN) -sf file $(DESTDIR)dest/link 228#endif 229 230/* 231 * InstallSharedLibrary 232 */ 233 234#define InstallSharedLibrary(libname,rev,dest) @@\ 235InstallTarget(install,ImportLibraryName(libname,rev),$(INSTLIBFLAGS),$(USRLIBDIR)) @@\ 236InstallTarget(install,SharedLibraryName(libname,rev),$(INSTBINFLAGS),$(BINDIR)) @@\ 237InstallLink(install,ImportLibraryName(libname,rev),ShortImportLibraryName(libname,rev),$(USRLIBDIR)) 238 239 240/* 241 * ProgramTargetName - This can be simply 'target' or 'target.exe' when 242 * building on Cygwin proper, as Cygwin automatically appends .exe to compiled 243 * executables and make, rm, ln, etc. will automatically search for a file 244 * with .exe appended if the raw file name cannot be found. However, 245 * building with a cross compiler requires 'target.exe', as the cross 246 * compiler doesn't know to append .exe, nor do the cross compiler tools 247 * know to search for files with .exe appended if the raw file name cannot 248 * be found. 249 */ 250 251#define ProgramTargetName(target) Concat(target,.exe) 252 253 254/* 255 * HostProgramTargetName - Don't add .exe if cross-compiling. 256 */ 257 258#ifndef HostProgramTargetName 259# if CrossCompiling 260# define HostProgramTargetName(target) target 261# else 262# define HostProgramTargetName(target) ProgramTargetName(target) 263# endif 264#endif 265 266 267/* 268 * LinkBuildDLL - Cygwin only rule, similar to LinkBuildModule. 269 * Unfortunately, we have to create a copy of each DLL in xc/exports/bin; 270 * linking doesn't work, the executables (e.g. xkbcomp) will report 271 * that they cannot find DLLs (e.g. libX11.dll). 272 */ 273 274#ifdef UseInstalled 275#define LinkBuildDLL(lib) $(_NULLCMD_) 276#else 277#define LinkBuildDLL(lib) MakeDir($(BUILDBINDIR)) @@\ 278 RemoveFile($(BUILDBINDIR)/lib) @@\ 279 cd $(BUILDBINDIR) && $(CP) $(BUILDBINTOP)/$(CURRENT_DIR)/lib . 280#endif 281 282#ifndef LinkImportLibrary 283#ifdef UseInstalled 284#define LinkImportLibrary(lib, importlib) $(_NULLCMD_) 285#else 286#define LinkImportLibrary(lib, importlib) MakeDir($(BUILDLIBDIR)) @@\ 287 RemoveFile($(BUILDLIBDIR)/importlib) @@\ 288 cd $(BUILDLIBDIR) && $(LN) lib importlib 289#endif 290#endif /* LinkImportLibrary */ 291 292 293/* 294 * LinkBuildBinary - This rule normally creates a link in xc/exports/bin 295 * to a binary, but we create an actual copy of the binary. 296 * Creating a link causes the DLLs that the binary depend on, such as 297 * libX11.dll, not to be found. Copying the binary causes the runtime 298 * directory to be xc/exports/bin, which is the location of the DLLs, thus, 299 * the DLLs can now be found by the binary. Phew... 300 * 301 * Note that sometimes the binary is not an executable. One example 302 * is the rgb binary file. 303 * 304 * Passing -p preserves the attributes as the date and prevents useless 305 * rebuilds. 306 * 307 * ProgramTargetName is passed to LinkBuildBinary if the binary 308 * is actually an executable; thus, we do not wrap the binary name 309 * with ProgramTargetName here. 310 */ 311 312#ifndef LinkBuildBinary 313#define LinkBuildBinary(binary) @@\ 314all:: binary @@\ 315 MakeDir($(BUILDBINDIR)) @@\ 316 RemoveFile($(BUILDBINDIR)/binary) @@\ 317 cd $(BUILDBINDIR) && $(CP) -p $(BUILDBINTOP)/$(CURRENT_DIR)/binary . 318#endif /* LinkBuildBinary */ 319 320/* 321 * ProfiledRelocatableTarget - generate rules to produce a profiled 322 * relocatable object file instead of a library. Differs from Imake.rules 323 * by passing '--oformat pe-i386' to ld. 324 */ 325 326#ifndef ProfiledRelocatableTarget 327#define ProfiledRelocatableTarget(objname,objlist) @@\ 328AllTarget(Concat(objname,_p.Osuf)) @@\ 329 @@\ 330Concat(objname,_p.Osuf): objlist $(EXTRALIBRARYDEPS) @@\ 331 RemoveFile($@) @@\ 332 $(LD) -X -r --oformat pe-i386 objlist -o $@ 333 334#endif /* ProfiledRelocatableTarget */ 335 336 337/* 338 * DebuggedRelocatableTarget - generate rules to produce a debuggable 339 * relocatable object file instead of a library. Differs from Imake.rules 340 * by passing '--oformat pe-i386' to ld. 341 */ 342 343#ifndef DebuggedRelocatableTarget 344#define DebuggedRelocatableTarget(objname,objlist) @@\ 345AllTarget(Concat(objname,_d.Osuf)) @@\ 346 @@\ 347Concat(objname,_d.Osuf): objlist $(EXTRALIBRARYDEPS) @@\ 348 RemoveFile($@) @@\ 349 $(LD) -X -r --oformat pe-i386 objlist -o $@ 350 351#endif /* DebuggedRelocatableTarget */ 352 353 354/* 355 * DependDependencyStatement - Imake.rules wraps $(DEPEND) in 356 * ProgramTargetName(), which causes cross compiling to think that 357 * $(DEPEND) hasn't been built, as $(DEPEND) is a host tool, and should 358 * not be wrapped with ProgramTargetName(). Perhaps there should be 359 * a HostProgramTargetName()... 360 */ 361 362#ifndef DependDependencyStatement 363#if HasMakefileSafeInclude 364#define DependDependencyStatement() @@\ 365DependFileName:: $(DEPEND) 366#else 367#define DependDependencyStatement() @@\ 368depend:: $(DEPEND) 369#endif 370#endif 371 372 373/* 374 * DependDependency - Imake.rules wraps $(DEPEND) in ProgramTargetName(). 375 * This doesn't work when cross compiling, see the locally defined 376 * DependDependencyStatement comment (above) for more information. 377 */ 378 379#ifndef DependDependency 380#ifdef UseInstalled 381#define DependDependency() /**/ 382#else 383#define DependDependency() @@\ 384DependDependencyStatement() @@\ 385 @@\ 386NoCmpScript($(DEPEND)) @@\ 387 @@\ 388$(DEPEND): @@\ 389 @echo "checking $@ over in $(DEPENDSRC) first..."; \ @@\ 390 cd $(DEPENDSRC) && $(MAKE) makedependonly; \ @@\ 391 echo "okay, continuing in $(CURRENT_DIR)" 392 393#endif /* UseInstalled */ 394#endif /* DependDependency */ 395 396 397/* 398 * ImakeDependency - Imake.rules wraps $(IMAKE) in ProgramTargetName(), 399 * which doesn't work when cross compiling, as imake is supposed to be a 400 * host program. See the locally defined DependDependencyStatement 401 * comment (above) for more information. 402 */ 403 404#ifndef ImakeDependency 405#ifdef UseInstalled 406#define ImakeDependency(target) /**/ 407#else 408#define ImakeDependency(target) @@\ 409target:: $(IMAKE) @@\ 410 @@\ 411NoCmpScript($(IMAKE) $(IMAKE).Osuf) @@\ 412 @@\ 413$(IMAKE) $(IMAKE).Osuf: @@\ 414 -@(cd $(IMAKESRC) && if [ -f Makefile ]; then \ @@\ 415 echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) imakeonly; else \ @@\ 416 echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \ @@\ 417 $(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; fi; \ @@\ 418 echo "okay, continuing in $(CURRENT_DIR)") 419#endif /* UseInstalled */ 420#endif /* ImakeDependency */ 421 422 423/* 424 * ResourceObjectRule - Build a Windows resouce file (.res) into 425 * an object file (.o) that can be linked in with the executable 426 * or library being built. 427 */ 428 429#ifndef ResourceObjectRule 430#define ResourceObjectRule(basename,depends,options) @@\ 431AllTarget(basename.RESsuf) @@\ 432basename.RESsuf: basename.RCsuf depends @@\ 433 RemoveFile($@) @@\ 434 ClearmakeOSName \ @@\ 435 WindresCmd basename.RCsuf options -O coff -o basename.RESsuf @@\ 436clean:: @@\ 437 RemoveFiles(basename.RESsuf) 438 439#endif /* ResourceObjectRule */ 440 441/* The arglist can get quite long. Make sure we can delete it though */ 442#ifndef MakeFonts 443# define MakeFonts() @@\ 444all:: $(OBJS) @@\ 445 @@\ 446MakeFontsDir($(OBJS)) @@\ 447 @@\ 448clean:: @@\ 449 find -name "*.pcf" -o -name "*.pcf.Z" -o -name "*.pcf.gz" | xargs -r rm 450#endif /* MakeFonts */ 451 452#ifndef IncludeMakefile 453#define IncludeMakefile(file) @@sinclude file 454#endif 455