157 warnings: remove -DXK_MISCELLANY from Makefiles
[oweals/cde.git] / cde / config / cf / Library.tmpl
1 /*
2  * Library imakefile info  - this contains any special redefinitions, etc.
3  * that Imakefiles in the various library subtrees will need.
4  *
5  * Before including this, you must set the following boolean variables:
6  * DoNormalLib, DoSharedLib, DoDebugLib, DoProfileLib
7  *
8  * To get automatic generation of standard rules, also set the variables:
9  * LibName, SoRev, HasSharedData, and optionally HugeLibrary and IncSubdir.
10  *
11  * To suppress installation of the library define LibInstall NO.
12  * To suppress creating (and installing) the library define LibCreate NO.
13  * To suppress installing headers define LibHeaders NO.
14  * Define LargePICTable YES if large (32-bit) PIC tables are needed.
15  */
16
17 XCOMM $TOG: Library.tmpl /main/44 1997/04/28 11:47:53 kaleb $
18
19 #ifndef LibraryCplusplusOptions
20 # if DoSharedLib && defined(SharedLibraryCplusplusOptions)
21 #  define LibraryCplusplusOptions SharedLibraryCplusplusOptions
22 # else
23 #  define LibraryCplusplusOptions DefaultCplusplusOptions
24 # endif
25 #endif
26 #ifndef LibraryDefines
27 # define LibraryDefines StandardDefines
28 #endif
29 #ifndef LibraryCDebugFlags
30 # define LibraryCDebugFlags DefaultCDebugFlags
31 #endif
32 #ifndef LibraryCplusplusDebugFlags
33 # define LibraryCplusplusDebugFlags DefaultCplusplusDebugFlags
34 #endif
35 #ifndef SeparateSharedCompile
36 # define SeparateSharedCompile YES
37 #endif
38
39 #ifndef CplusplusSource
40 # ifndef LibraryCcCmd
41 #  if DoSharedLib && defined(SharedLibraryCcCmd)
42 #   define LibraryCcCmd SharedLibraryCcCmd
43 #  else
44 #   define LibraryCcCmd CcCmd
45 #  endif
46 # endif
47 # ifndef LibraryCCOptions
48 #  if DoSharedLib && defined(SharedLibraryCCOptions)
49 #   define LibraryCCOptions SharedLibraryCCOptions
50 #  else
51 #   define LibraryCCOptions DefaultCCOptions
52 #  endif
53 # endif
54
55          CC = LibraryCcCmd
56   CCOPTIONS = LibraryCCOptions
57 STD_DEFINES = LibraryDefines $(PROJECT_DEFINES)
58 CDEBUGFLAGS = LibraryCDebugFlags
59 # if defined(LargePICTable) && LargePICTable && defined(LargePositionIndependentCFlags)
60    PICFLAGS = LargePositionIndependentCFlags
61 # endif
62 #else
63 # ifndef LibraryCplusplusCmd
64 #  if DoSharedLib && defined(SharedLibraryCplusplusCmd)
65 #   define LibraryCplusplusCmd SharedLibraryCplusplusCmd
66 #  else
67 #   define LibraryCplusplusCmd CplusplusCmd
68 #  endif
69 # endif
70 # ifndef LibraryCplusplusOptions
71 #  if DoSharedLib && defined(SharedLibraryCplusplusOptions)
72 #   define LibraryCplusplusOptions SharedLibraryCplusplusOptions
73 #  else
74 #   define LibraryCplusplusOptions DefaultCplusplusOptions
75 #  endif
76 # endif
77
78           CXX = LibraryCplusplusCmd
79    CXXOPTIONS = LibraryCplusplusOptions
80   STD_DEFINES = LibraryDefines $(PROJECT_DEFINES)
81 CXXDEBUGFLAGS = LibraryCplusplusDebugFlags
82 # if defined(LargePICTable) && LargePICTable
83 #  ifdef LargePositionIndependentCplusplusFlags
84   CXXPICFLAGS = LargePositionIndependentCplusplusFlags
85 #  elif defined(LargePositionIndependentCFlags)
86   CXXPICFLAGS = LargePositionIndependentCFlags
87 #  endif
88 # endif
89 #endif
90
91 LIB_MT_DEFINES = LibraryMTDefines
92
93 #if defined(IHaveSubdirs) && HasSymLinks
94 #define _LibMkdir LibMkdirLinkSubdirs
95 #else
96 #define _LibMkdir LibMkdir
97 #endif
98
99 #if DoDebugLib
100 # define _DebuggedLibMkdir() _LibMkdir(debugger)
101 # define _DebuggedObjCompile(options) DebuggedLibObjCompile(options)
102 # define _DebuggedObjCplusplusCompile(options) DebuggedLibObjCplusplusCompile(options)
103 # define _DebuggedCleanDir() LibCleanDir(debugger)
104 #else
105 # define _DebuggedLibMkdir() $(_NULLCMD_)
106 # define _DebuggedObjCompile(options) $(_NULLCMD_)
107 # define _DebuggedObjCplusplusCompile(options) $(_NULLCMD_)
108 # define _DebuggedCleanDir() $(_NULLCMD_)
109 #endif
110
111 #if DoProfileLib
112 # define _ProfiledLibMkdir() _LibMkdir(profiled)
113 # define _ProfiledObjCompile(options) ProfiledLibObjCompile(options)
114 # define _ProfiledObjCplusplusCompile(options) ProfiledLibObjCplusplusCompile(options)
115 # define _ProfiledCleanDir() LibCleanDir(profiled)
116 #else
117 # define _ProfiledLibMkdir() $(_NULLCMD_)
118 # define _ProfiledObjCompile(options) $(_NULLCMD_)
119 # define _ProfiledObjCplusplusCompile(options) $(_NULLCMD_)
120 # define _ProfiledCleanDir() $(_NULLCMD_)
121 #endif
122
123 #if !DoNormalLib
124 # define _NormalLibMkdir() $(_NULLCMD_)
125 # define _NormalObjCompile(options) $(_NULLCMD_)
126 # define _NormalObjCplusplusCompile(options) $(_NULLCMD_)
127 # define _NormalCleanDir() $(_NULLCMD_)
128 #else
129 # if DoSharedLib && SeparateSharedCompile
130 #  define _NormalLibMkdir() _LibMkdir(unshared)
131 #  define _NormalObjCompile(options) UnsharedLibObjCompile(options)
132 #  define _NormalObjCplusplusCompile(options) UnsharedLibObjCplusplusCompile(options)
133 #  define _NormalCleanDir() LibCleanDir(unshared)
134 # else
135 #  define _NormalLibMkdir() $(_NULLCMD_)
136 #  define _NormalObjCompile(options) NormalLibObjCompile(options)
137 #  define _NormalObjCplusplusCompile(options) NormalLibObjCplusplusCompile(options)
138 #  define _NormalCleanDir() $(_NULLCMD_)
139 # endif
140 #endif
141
142 #if !DoSharedLib || (DoNormalLib && !SeparateSharedCompile)
143 # define _SharedObjCompile(options) $(_NULLCMD_)
144 # define _SharedObjCplusplusCompile(options) $(_NULLCMD_)
145 #else
146 # if SeparateSharedCompile
147 #  define _SharedObjCompile(options) NormalSharedLibObjCompile(options)
148 #  define _SharedObjCplusplusCompile(options) NormalSharedLibObjCplusplusCompile(options)
149 #else
150 # define _SharedObjCompile(options) NormalLibObjCompile(options)
151 # define _SharedObjCplusplusCompile(options) NormalLibObjCplusplusCompile(options)
152 #endif
153 #endif
154
155 #ifndef CplusplusSource
156 # define SRCsuf c
157 #else
158 # define SRCsuf CCsuf
159 # ifdef SunArchitecture
160 .SUFFIXES: .CCsuf
161 # endif
162 #endif
163
164 #define _CompileObj(target, options)                                    @@\
165 target                                                                  @@\
166         _DebuggedObjCompile(options)                                    @@\
167         _ProfiledObjCompile(options)                                    @@\
168         _NormalObjCompile(options)                                      @@\
169         _SharedObjCompile(options)
170
171 #ifdef CplusplusSource
172 # define _CompileObjCplusplus(target, options)                          @@\
173 target                                                                  @@\
174         _DebuggedObjCplusplusCompile(options)                           @@\
175         _ProfiledObjCplusplusCompile(options)                           @@\
176         _NormalObjCplusplusCompile(options)                             @@\
177         _SharedObjCplusplusCompile(options)
178 #else
179 # define _CompileObjCplusplus(target, options)
180 #endif
181
182 #ifndef LibraryObjectRule
183 # define LibraryObjectRule()                                            @@\
184 all::                                                                   @@\
185         _DebuggedLibMkdir()                                             @@\
186         _ProfiledLibMkdir()                                             @@\
187         _NormalLibMkdir()                                               @@\
188                                                                         @@\
189 includes::                                                              @@\
190         _DebuggedLibMkdir()                                             @@\
191         _ProfiledLibMkdir()                                             @@\
192         _NormalLibMkdir()                                               @@\
193                                                                         @@\
194 _CompileObj(.c.Osuf:,$(_NOOP_))                                         @@\
195 _CompileObjCplusplus(.SRCsuf.Osuf:,$(_NOOP_))                           @@\
196                                                                         @@\
197 clean::                                                                 @@\
198         _DebuggedCleanDir()                                             @@\
199         _ProfiledCleanDir()                                             @@\
200         _NormalCleanDir()                                               @@\
201
202 #endif /* LibraryObjectRule */
203
204 #ifndef SpecialLibObjectRule
205 # define SpecialLibObjectRule(objs,depends,options)                     @@\
206 _CompileObj(objs: depends,options)
207 #endif /* SpecialLibObjectRule */
208
209 #ifndef SpecialCLibObjectRule
210 # define SpecialCLibObjectRule(basename,depends,options)                @@\
211 _CompileObj(basename.Osuf: basename.SRCsuf depends,options)             @@\
212                                                                         @@\
213 basename.i: basename.SRCsuf depends                                     @@\
214         CPPOnlyCompile(basename.SRCsuf,options)                         @@\
215                                                                         @@\
216 CenterLoadTarget(debug_src,basename.SRCsuf,NullParameter,$(ALLDEFINES) options)
217 #endif /* SpecialCLibObjectRule */
218
219 #ifndef SpecialCplusplusLibObjectRule
220 # define SpecialCplusplusLibObjectRule(basename,depends,options)        @@\
221 _CompileObjCplusplus(basename.Osuf: basename.SRCsuf depends,options)    @@\
222                                                                         @@\
223 CenterLoadTarget(debug_src,basename.SRCsuf,NullParameter,$(ALLDEFINES) options)
224 #endif /* SpecialCplusplusLibObjectRule */
225
226 /*
227  * ToolkitMakeStrings generates a string-table, i.e., a C source
228  * file and the matching header(s), e.g., Xt's StringDefs.c, StringDefs.h,
229  * and Shell.h files; or Motif's XmStrDefs.c and XmStrDefs.h files.
230  *
231  * The 'files' argument is the list of files that will be produced by
232  * this rule, e.g., for Xt they would be "Shell.h StringDefs.c StringDefs.h"
233  * and for Motif they would be "XmStrDefs.c XmStrDefs.h".
234  *
235  * The 'source' argument is the string-list file to be parsed, e.g., in
236  * Xt that would be "util/string.list".  For Motif 2.0 it would be
237  * "../../tools/makestr/xmstring.list", and for Motif-CDE1 it would be
238  * "util/xmstring.list".
239  *
240  * The 'options' argument is passed by the library's Imakefile, see the
241  * Xt Imakefile for an example.  Typically this would be nothing, -intelabi,
242  * or -sparcabi; there are other choices, but these are typical.
243  *
244  * The 'depends' argument names additional files the target files
245  * depend on.  It should name the #ctmpl and #htmpl files from the
246  * 'source' file.
247  *
248  * The 'dest' argument is the C source output file.  For Xt this should
249  * be "StringDefs.c", and for all versions of Motif it would be "XmStrDefs.c"
250  *
251  * Headers are generated and named according to data in the 'source'
252  * file.
253  */
254 /*
255  * The NoCmpScript
256  * prevents clearmake from trying to remake makestrs if it exists.
257  * Including both $(MAKESTRS) and $(MAKESTRS).o as primary targets
258  * prevents clearmake from trying to recompile makestrs from here.
259  * We have includes, not files, depend on makestrs to try to get
260  * clearmake to wink in the files.  Bug in clearmake 2.0.2?
261  */
262
263 #ifndef MakeStringsDependency
264 # define MakeStringsDependency                                          @@\
265 MAKESTRS = $(CONFIGSRC)/util/makestrs                                   @@\
266 NoCmpScript(ProgramTargetName($(MAKESTRS)) $(MAKESTRS).Osuf)            @@\
267                                                                         @@\
268 ProgramTargetName($(MAKESTRS)) $(MAKESTRS).Osuf:                        @@\
269         cd $(CONFIGSRC)/util && $(MAKE) ProgramTargetName(makestrs)     @@\
270                                                                         @@\
271 includes:: ProgramTargetName($(MAKESTRS))
272 #endif
273 #ifndef ToolkitMakeStrings
274 # if defined(LibTookitMakeStringsDependency) && LibTookitMakeStringsDependency
275 #  define ToolkitMakeStrings(files,source,options,depends,dest)         @@\
276 files: source depends                                                   @@\
277         RemoveFiles(files)                                              @@\
278         RunProgram(MAKESTRS,options < source > dest)                    @@\
279                                                                         @@\
280 AllTarget(files)                                                        @@\
281                                                                         @@\
282 includes:: files                                                        @@\
283                                                                         @@\
284 depend:: files                                                          @@\
285                                                                         @@\
286 clean::                                                                 @@\
287         RemoveFiles(files)
288 # else
289 #  define ToolkitMakeStrings(files,source,options,depends,dest)         @@\
290 MakeStringsDependency                                                   @@\
291                                                                         @@\
292 files: source depends                                                   @@\
293         RemoveFiles(files)                                              @@\
294         RunProgram(MAKESTRS,options < source > dest)                    @@\
295                                                                         @@\
296 AllTarget(files)                                                        @@\
297                                                                         @@\
298 includes:: files                                                        @@\
299                                                                         @@\
300 depend:: files                                                          @@\
301                                                                         @@\
302 clean::                                                                 @@\
303         RemoveFiles(files)
304 # endif
305 #endif /* ToolkitMakeStrings */
306
307 #ifdef LibName
308
309 LIBNAME = LibName
310
311 # if defined(LibTookitMakeStringsDependency) && LibTookitMakeStringsDependency
312 /*
313  * Do ToolkitMakeStrings() before BuildIncludes so makestrs is still
314  * built first, even if the generated header will be installed.
315  */
316 MakeStringsDependency
317 # endif
318
319 LibraryObjectRule()
320
321 # undef _LinkBuildLibrary
322 # if !defined(LibInstall) || LibInstall
323 #  define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
324 # else
325 #  define _LinkBuildLibrary(lib) $(_NULLCMD_)
326 # endif
327
328 # if !defined(LibCreate) || LibCreate
329 #  if DoSharedLib
330 #   if HugeLibrary && defined(SharedLibraryTarget3)
331 SharedLibraryTarget3($(LIBNAME),$(SoRev),$(OBJS1),$(OBJS2),$(OBJS3),.,.)
332 #   else
333 SharedLibraryTarget($(LIBNAME),$(SoRev),$(OBJS),.,.)
334 #   endif
335 #   if !defined(LibInstall) || LibInstall
336 InstallSharedLibrary($(LIBNAME),$(SoRev),$(SHLIBDIR))
337 #   endif
338 #   if HasSharedData
339 SharedLibraryDataTarget($(LIBNAME),$(SoRev),$(UNSHAREDOBJS))
340 #    if !defined(LibInstall) || LibInstall
341 InstallSharedLibraryData($(LIBNAME),$(SoRev),$(SHLIBDIR))
342 #    endif
343 #   endif
344 #  endif
345 #  if DoNormalLib
346 #   if HugeLibrary
347 #    if DoSharedLib && SeparateSharedCompile
348 UnsharedLibraryTarget3($(LIBNAME),$(OBJS1),$(OBJS2),$(OBJS3),unshared,..)
349 #    else
350 NormalLibraryTarget3($(LIBNAME),$(OBJS1),$(OBJS2),$(OBJS3))
351 #    endif
352 #   else
353 #    if DoSharedLib && SeparateSharedCompile
354 UnsharedLibraryTarget($(LIBNAME),$(OBJS),unshared,..)
355 #    else
356 NormalLibraryTarget($(LIBNAME),$(OBJS))
357 #    endif
358 #   endif
359 #   if !defined(LibInstall) || LibInstall
360 InstallLibrary($(LIBNAME),$(USRLIBDIR))
361 #   endif
362 #  endif
363 #  if DoProfileLib
364 ProfiledLibraryTarget($(LIBNAME),$(OBJS))
365 #   if !defined(LibInstall) || LibInstall
366 InstallLibrary($(LIBNAME)_p,$(USRLIBDIR))
367 #   endif
368 #  endif
369 #  if DoDebugLib
370 DebuggedLibraryTarget($(LIBNAME),$(OBJS))
371 #   if !defined(LibInstall) || LibInstall
372 InstallLibrary($(LIBNAME)_d,$(USRLIBDIR))
373 #   endif
374 #  endif
375
376 LintLibraryTarget($(LIBNAME),$(SRCS))
377 #  if !defined(LibInstall) || LibInstall
378 InstallLintLibrary($(LIBNAME),$(LINTLIBDIR))
379 #  endif
380 # else /* not LibCreate */
381 #  if HugeLibrary
382 AllTarget($(OBJS1))
383 AllTarget($(OBJS2))
384 AllTarget($(OBJS3))
385 #  else
386 AllTarget($(OBJS))
387 #  endif
388 # endif /* LibCreate */
389 # ifdef IncSubdir
390 #  ifdef IncSubSubdir
391 BuildIncludes($(HEADERS),IncSubdir/IncSubSubdir,../..)
392 InstallMultipleFlags($(HEADERS),$(INCDIR)/IncSubdir/IncSubSubdir,$(INSTINCFLAGS))
393 #  else
394 BuildIncludes($(HEADERS),IncSubdir,..)
395 InstallMultipleFlags($(HEADERS),$(INCDIR)/IncSubdir,$(INSTINCFLAGS))
396 #  endif
397 # else
398 #  ifndef CplusplusSource
399 #   if !defined(LibHeaders) || LibHeaders
400 BuildIncludesTop($(HEADERS))
401 InstallMultipleFlags($(HEADERS),$(INCDIR),$(INSTINCFLAGS))
402 #   endif
403 #  endif
404 # endif
405
406 NormalLintTarget($(SRCS))
407 #endif /* defined(LibName) */