summaryrefslogtreecommitdiff
path: root/cygwin.rules
blob: b6a7e9de1c23999f3b65169007fbfc25a6903001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
/*
 * Cygwin shared library rules (DLL versions)
 */

#define HasSharedLibraries	YES
#define NeedLibInsideFlag	NO
#define ForceNormalLib		NO
#ifndef SharedLibX11
# define SharedLibX11		YES
#endif
#ifndef NormalLibX11
# define NormalLibX11		NO
#endif
#define SharedLibXaw		YES
#define SharedLibXmu		YES
#define SharedLibXt		YES
#define SharedLibFont		NO
#define SharedLibXaw7		YES
#define SharedLibXaw6		YES
#define SharedLibSM		YES
#define SharedLibICE		YES
#define SharedLibXext		YES
#define SharedLibXi		YES
#define SharedLibXtst		YES
#define SharedOldX		NO
#define SharedLibXp		NO
#define SharedLibGlx		YES
#define SharedLibDps		NO
#define SharedLibDpsTk		NO
#define SharedLibGlu		YES
#define SharedLibWindowsWM	NO
#ifndef SharedDataSeparation
#define SharedDataSeparation	NO
#endif

#ifndef SharedCodeDef
#define SharedCodeDef /**/
#endif
#ifndef SharedLibraryDef
#define SharedLibraryDef /**/
#endif
#ifndef ShLibIncludeFile
#define ShLibIncludeFile <cygwin.tmpl>
#endif
#ifndef SharedLibraryLoadFlags
#define SharedLibraryLoadFlags -dll /**/
#endif
#ifndef PositionIndependentCFlags
#define PositionIndependentCFlags -D_DLL
#endif
#ifndef PositionIndependentCplusplusFlags
#define PositionIndependentCplusplusFlags -D_DLL
#endif
#ifndef UseExportLists
#define UseExportLists YES
#endif

#define SharedLibraryName(libname, rev) \
Concat3(cyg,libname,-$(shell echo rev|sed s=\\..*==).dll)

#define ImportLibraryName(libname, rev) \
Concat3(lib,libname,.dll.a)

#define ShortImportLibraryName(libname, rev) \
Concat3(lib,libname,.dll.a)

/*
 * SharedDepLibraryTarget - generate rules to create a shared library.
 */

#ifndef SharedDepLibraryTarget
# ifdef UseInstalled
#  ifndef LinkBuildSonameLibrary
#   define LinkBuildSonameLibrary(lib)
#  endif
# else /* !UseInstalled */
#  ifndef LinkBuildSonameLibrary
#   define LinkBuildSonameLibrary(lib) (RemoveFile($(BUILDLIBDIR)/lib); @@\
	cd $(BUILDLIBDIR); $(LN) $(BUILDINCTOP)/$(CURRENT_DIR)/lib .)
#  endif
# endif /* UseInstalled */


/*
 * SharedDepLibraryTarget
 */

#define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
AllTarget(SharedLibraryName(libname,rev))                             @@\
									@@\
SharedLibraryName(libname,rev): deplist 				@@\
	RemoveFile(ImportLibraryName(libname,rev))			@@\
	RemoveFile(SharedLibraryName(libname,rev))			@@\
	MakeDLL(libname,solist,rev)					@@\
	LinkBuildLibrary(ImportLibraryName(libname,rev))		@@\
	LinkImportLibrary(ImportLibraryName(libname,rev),LibraryTargetName(libname))	@@\
	LinkBuildDLL(SharedLibraryName(libname,rev))			@@\
									@@\
clean::									@@\
	RemoveFile(ImportLibraryName(libname,rev))				@@\
	RemoveFile(SharedLibraryName(libname,rev))			@@\

#endif /* SharedDepLibraryTarget */

/*
 * SharedDepCplusplusLibraryTarget - generate rules to create a shared library.
 */

#ifndef SharedDepCplusplusLibraryTarget
# ifdef UseInstalled
#  ifndef LinkBuildSonameLibrary
#   define LinkBuildSonameLibrary(lib)
#  endif
# else /* !UseInstalled */
#  ifndef LinkBuildSonameLibrary
#   define LinkBuildSonameLibrary(lib) (RemoveFile($(BUILDLIBDIR)/lib); @@\
	cd $(BUILDLIBDIR); $(LN) $(BUILDINCTOP)/$(CURRENT_DIR)/lib .)
#  endif
# endif /* UseInstalled */


/*
 * SharedDepCplusplusLibraryTarget
 */

#define SharedDepCplusplusLibraryTarget(libname,rev,deplist,solist,down,up) @@\
AllTarget(SharedLibraryName(libname,rev))                             @@\
                                                                            @@\
SharedLibraryName(libname,rev): deplist					@@\
	RemoveFile(ImportLibraryName(libname,rev))                      @@\
	RemoveFile(SharedLibraryName(libname,rev))                      @@\
	MakeCplusplusDLL(libname,solist,rev)                            @@\
	LinkBuildLibrary(ImportLibraryName(libname,rev))                @@\
	LinkImportLibrary(ImportLibraryName(libname,rev),LibraryTargetName(libname))	@@\
	LinkBuildDLL(SharedLibraryName(libname,rev))                    @@\
                                                                        @@\
clean::                                                                 @@\
	RemoveFile(ImportLibraryName(libname,rev))                      @@\
	RemoveFile(SharedLibraryName(libname,rev))                      @@\

#endif /* SharedDepCplusplusLibraryTarget */


/*
 * SharedDepModuleTarget
 */

#ifndef SharedDepModuleTarget
#define SharedDepModuleTarget(name,deps,solist)				@@\
AllTarget(name)								@@\
									@@\
name: deps								@@\
	$(CC) -o $@ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS) BaseShLibReqs @@\
									@@\
clean::									@@\
	RemoveFile(name)
#endif /* SharedDepModuleTarget */


/*
 * SharedLibraryDataTarget - generate rules to create shared data file
 */

#ifndef SharedLibraryDataTarget
#define SharedLibraryDataTarget(libname,rev,salist)
#endif


/*
 * InstallSharedLibraryData - generate rules to install the shared library data
 */

#ifndef InstallSharedLibraryData
#define InstallSharedLibraryData(libname,rev,dest)
#endif /* InstallSharedLibraryData */

/*
 * MakeDLLProg
 */

#define MakeDLLProg(libname,solist,prog,rev)			        @@\
	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)

/*
 * MakeDLL
 */

#define MakeDLL(libname,solist,rev)					@@\
    MakeDLLProg(libname,solist,$(CC),rev)

/*
 * MakeCplusplusDLL
 */

#define MakeCplusplusDLL(libname,solist,rev)				@@\
    MakeDLLProg(libname,solist,$(CXX),rev)



/*
 * SharedLibraryTarget
 */

#define SharedLibraryTarget(libname,rev,solist,down,up)                 @@\
AllTarget(SharedLibraryName(libname,rev))				@@\
                                                                        @@\
SharedLibraryName(libname,rev): solist					@@\
	RemoveFile(ImportLibraryName(libname,rev))			@@\
	RemoveFile(SharedLibraryName(libname,rev))			@@\
	MakeDLL(libname,solist,rev)					@@\
	LinkBuildLibrary(ImportLibraryName(libname,rev))		@@\
	LinkImportLibrary(ImportLibraryName(libname,rev),LibraryTargetName(libname))	@@\
	LinkBuildDLL(SharedLibraryName(libname,rev))			@@\
clean::									@@\
	RemoveFile(ImportLibraryName(libname,rev))			@@\
	RemoveFile(SharedLibraryName(libname,rev))			@@\


/*
 * InstallLink
 */

#ifndef InstallLink
#define InstallLink(step, file, link, dest)                             @@\
step::                                                                  @@\
	MakeDir($(DESTDIR)dest)                                         @@\
	$(LN) -sf file $(DESTDIR)dest/link
#endif

/*
 * InstallSharedLibrary
 */

#define InstallSharedLibrary(libname,rev,dest)                          @@\
InstallTarget(install,ImportLibraryName(libname,rev),$(INSTLIBFLAGS),$(USRLIBDIR)) @@\
InstallTarget(install,SharedLibraryName(libname,rev),$(INSTBINFLAGS),$(BINDIR))


/*
 * ProgramTargetName - This can be simply 'target' or 'target.exe' when
 * building on Cygwin proper, as Cygwin automatically appends .exe to compiled
 * executables and make, rm, ln, etc. will automatically search for a file
 * with .exe appended if the raw file name cannot be found.  However,
 * building with a cross compiler requires 'target.exe', as the cross
 * compiler doesn't know to append .exe, nor do the cross compiler tools
 * know to search for files with .exe appended if the raw file name cannot
 * be found.
 */

#define ProgramTargetName(target) Concat(target,.exe)


/*
 * HostProgramTargetName - Don't add .exe if cross-compiling.
 */

#ifndef HostProgramTargetName
# if CrossCompiling
#  define HostProgramTargetName(target) target
# else
#  define HostProgramTargetName(target) ProgramTargetName(target)
# endif
#endif


/*
 * LinkBuildDLL - Cygwin only rule, similar to LinkBuildModule.
 * Unfortunately, we have to create a copy of each DLL in xc/exports/bin;
 * linking doesn't work, the executables (e.g. xkbcomp) will report
 * that they cannot find DLLs (e.g. libX11.dll).
 */

#ifdef UseInstalled
#define LinkBuildDLL(lib) $(_NULLCMD_)
#else
#define LinkBuildDLL(lib) MakeDir($(BUILDBINDIR))			@@\
	RemoveFile($(BUILDBINDIR)/lib)					@@\
	cd $(BUILDBINDIR) && $(CP) $(BUILDBINTOP)/$(CURRENT_DIR)/lib .
#endif

#ifndef LinkImportLibrary
#ifdef UseInstalled
#define LinkImportLibrary(lib, importlib) $(_NULLCMD_)
#else
#define LinkImportLibrary(lib, importlib) MakeDir($(BUILDLIBDIR))     @@\
	RemoveFile($(BUILDLIBDIR)/importlib)                            @@\
	cd $(BUILDLIBDIR) && $(LN) lib importlib
#endif
#endif /* LinkImportLibrary */


/*
 * LinkBuildBinary - This rule normally creates a link in xc/exports/bin
 * to a binary, but we create an actual copy of the binary.
 * Creating a link causes the DLLs that the binary depend on, such as
 * libX11.dll, not to be found.  Copying the binary causes the runtime
 * directory to be xc/exports/bin, which is the location of the DLLs, thus,
 * the DLLs can now be found by the binary.  Phew...
 *
 * Note that sometimes the binary is not an executable.  One example
 * is the rgb binary file.
 *
 * Passing -p preserves the attributes as the date and prevents useless
 * rebuilds.
 *
 * ProgramTargetName is passed to LinkBuildBinary if the binary
 * is actually an executable; thus, we do not wrap the binary name
 * with ProgramTargetName here.
 */

#ifndef LinkBuildBinary
#define LinkBuildBinary(binary)						@@\
all:: binary								@@\
	MakeDir($(BUILDBINDIR))						@@\
	RemoveFile($(BUILDBINDIR)/binary)				@@\
	cd $(BUILDBINDIR) && $(CP) -p $(BUILDBINTOP)/$(CURRENT_DIR)/binary .
#endif /* LinkBuildBinary */

/*
 * ProfiledRelocatableTarget - generate rules to produce a  profiled
 * relocatable object file instead of a library.  Differs from Imake.rules
 * by passing '--oformat pe-i386' to ld.
 */

#ifndef ProfiledRelocatableTarget
#define	ProfiledRelocatableTarget(objname,objlist)			@@\
AllTarget(Concat(objname,_p.Osuf))					@@\
									@@\
Concat(objname,_p.Osuf): objlist $(EXTRALIBRARYDEPS)			@@\
	RemoveFile($@)							@@\
	$(LD) -X -r --oformat pe-i386 objlist -o $@

#endif /* ProfiledRelocatableTarget */


/*
 * DebuggedRelocatableTarget - generate rules to produce a debuggable
 * relocatable object file instead of a library.  Differs from Imake.rules
 * by passing '--oformat pe-i386' to ld.
 */

#ifndef DebuggedRelocatableTarget
#define	DebuggedRelocatableTarget(objname,objlist)			@@\
AllTarget(Concat(objname,_d.Osuf))					@@\
									@@\
Concat(objname,_d.Osuf): objlist $(EXTRALIBRARYDEPS)			@@\
	RemoveFile($@)							@@\
	$(LD) -X -r --oformat pe-i386 objlist -o $@

#endif /* DebuggedRelocatableTarget */


/*
 * DependDependencyStatement - Imake.rules wraps $(DEPEND) in
 * ProgramTargetName(), which causes cross compiling to think that
 * $(DEPEND) hasn't been built, as $(DEPEND) is a host tool, and should
 * not be wrapped with ProgramTargetName().  Perhaps there should be
 * a HostProgramTargetName()...
 */

#ifndef DependDependencyStatement
#if HasMakefileSafeInclude
#define DependDependencyStatement()					@@\
DependFileName:: $(DEPEND)
#else
#define DependDependencyStatement()					@@\
depend:: $(DEPEND)
#endif
#endif


/*
 * DependDependency - Imake.rules wraps $(DEPEND) in ProgramTargetName().
 * This doesn't work when cross compiling, see the locally defined
 * DependDependencyStatement comment (above) for more information.
 */

#ifndef DependDependency
#ifdef UseInstalled
#define DependDependency() /**/
#else
#define DependDependency()						@@\
DependDependencyStatement()						@@\
									@@\
NoCmpScript($(DEPEND))							@@\
									@@\
$(DEPEND):								@@\
	@echo "checking $@ over in $(DEPENDSRC) first..."; \		@@\
	cd $(DEPENDSRC) && $(MAKE) makedependonly; \			@@\
	echo "okay, continuing in $(CURRENT_DIR)"

#endif /* UseInstalled */
#endif /* DependDependency */


/*
 * ImakeDependency - Imake.rules wraps $(IMAKE) in ProgramTargetName(),
 * which doesn't work when cross compiling, as imake is supposed to be a
 * host program.  See the locally defined DependDependencyStatement
 * comment (above) for more information.
 */

#ifndef ImakeDependency
#ifdef UseInstalled
#define ImakeDependency(target) /**/
#else
#define ImakeDependency(target)						@@\
target:: $(IMAKE)							@@\
									@@\
NoCmpScript($(IMAKE) $(IMAKE).Osuf)					@@\
									@@\
$(IMAKE) $(IMAKE).Osuf:							@@\
	-@(cd $(IMAKESRC) && if [ -f Makefile ]; then \			@@\
	echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) imakeonly; else \	@@\
	echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \	@@\
	$(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; fi; \	@@\
	echo "okay, continuing in $(CURRENT_DIR)")
#endif /* UseInstalled */
#endif /* ImakeDependency */


/*
 * ResourceObjectRule - Build a Windows resource file (.res) into
 * an object file (.o) that can be linked in with the executable
 * or library being built.
 */

#ifndef ResourceObjectRule
#define ResourceObjectRule(basename,depends,options)			@@\
AllTarget(basename.RESsuf)						@@\
basename.RESsuf: basename.RCsuf depends					@@\
	RemoveFile($@)							@@\
	ClearmakeOSName \						@@\
	WindresCmd basename.RCsuf options -O coff -o basename.RESsuf	@@\
clean::									@@\
	RemoveFiles(basename.RESsuf)

#endif /* ResourceObjectRule */

/* The arglist can get quite long. Make sure we can delete it though */
#ifndef MakeFonts
# define MakeFonts()							@@\
all::  $(OBJS)								@@\
									@@\
MakeFontsDir($(OBJS))							@@\
									@@\
clean::									@@\
	find -name "*.pcf" -o -name "*.pcf.Z" -o -name "*.pcf.gz" | xargs -r rm
#endif /* MakeFonts */

#ifndef IncludeMakefile
#define IncludeMakefile(file) @@sinclude file
#endif