source: trunk/include/odin32.post.watn.mk@ 21561

Last change on this file since 21561 was 8617, checked in by bird, 23 years ago

Exclude dummy.c from the dependencies.

File size: 11.6 KB
Line 
1# $Id: odin32.post.watn.mk,v 1.4 2002-06-09 15:07:00 bird Exp $
2
3#
4# Odin32 API
5#
6# Common dll makefile rules (must be included at the last line of the makefile)
7#
8# If ORGTARGET is defined it is used to generate the importlibrary.
9#
10# Define NOTEXPDEF to remove the $(TARGET).lib and $(TARGET)exp.def rules.
11# Define EXETARGET to make an executable. (This also applies to odin32.mk.)
12# Define LIBTARGET to make an internal library.
13# Define LOCALCLEAN if only the local directory is to be clean.
14# Define CLEAN2 to invoke a second clean rule named 'clean2'.
15# Define NOCLEAN to exclude the clean rule. (Remember to make your own!)
16#
17# New style: (!defined OLD_STYLE)
18# Define NO_ALL_RULE to not make default all rule.
19# Define NO_LIB_RULE to not make default lib rule.
20# Define NO_MAIN_RULE to not make default main target rule.
21# Define NO_LNKFILE_RULE to not make default link-file rule.
22# Define NO_DEP_RULE to not make dependencies rule.
23# Define NO_CLEAN_RULE to not make clean rule (same as NOCLEAN - use this!).
24# Define NO_INTERNAL_LIBS to not include libs rule for subdirectories.
25# Define NO_MAIN_BIN_COPY to not copy the target and sym file to the main
26# binary directory. It is only copied to the compiler specific directory.
27# Main bin is /bin. Compiler specific bin is /bin/debug, /bin/debug.vac36, etc.
28# Define ADDITIONAL_DEP to add dependencies rules.
29# Define ADDITIONAL_ALL to add targets all should depend on.
30#
31# Define MAKEFILE if the name of the makefile isn't "makefile".
32# Define DEFFILE to specify another file than $(TARGET).def or $(ORGTARGET).def.
33# Define this if your .exe file have a .def file.
34# Define OS2RES as the names of the OS/2 .res file to create and link
35# with the target .dll or .exe.
36# Define LIBS as a list of all the libraries to link
37# with the target .dll or .exe.
38# Define SUBDIRS when you have subdirectories which should be made.
39# dep and lib supports this fully. The rule libs are added, since we assume you
40# makes internal libraries in the subdirectories. The libs rule is one of the
41# dependencies of the main target.
42#
43
44# Sanity check
45!ifndef ODIN32_LIB
46! error "ODIN32_LIB is not defined"
47!endif ODIN32_LIB
48!ifndef ODIN32_TOOLS
49! error "ODIN32_TOOLS is not defined"
50!endif ODIN32_TOOLS
51
52
53!ifndef TARGET_EXTENSION
54! ifdef LIBTARGET
55TARGET_EXTENSION=lib
56! else
57! ifdef EXETARGET
58TARGET_EXTENSION=exe
59! else
60TARGET_EXTENSION=dll
61! endif
62! endif
63!endif
64
65
66!ifndef OLD_STYLE
67
68# Set default MAKEFILE if needed
69!ifndef MAKEFILE
70MAKEFILE = makefile
71!endif
72
73# Set default ORGTARGET if needed.
74!ifndef ORGTARGET
75ORGTARGET=$(TARGET)
76!endif
77
78# Set default DEFFILE if needed. (Required for both DLLs and EXEs!)
79!ifndef DEFFILE
80DEFFILE = $(ORGTARGET).def
81!endif
82!ifndef ORGDEFFILE
83ORGDEFFILE = $(ORGTARGET).def
84!endif
85
86# Set INTLIBS (interal) if SUBDIRS is defined and NO_INTERNAL_LIBS is undefined.
87!ifdef SUBDIRS
88! ifndef NO_INTERNAL_LIBS
89! ifndef LIBTARGET
90INTLIBS = libs
91! else
92INTLIBS = libs_sub
93! endif
94! endif
95!endif
96
97
98!ifndef LIBTARGET
99!ifndef EXETARGET
100###############################################################################
101# DLL Target
102###############################################################################
103
104#
105# Dll: All rule - build objs, target dll, copies target to bin and makes libs.
106#
107!ifndef NO_ALL_RULE
108all: $(OBJDIR) \
109 $(INTLIBS) \
110 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
111 $(OBJDIR)\$(TARGET).sym \
112 $(ODIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) \
113 $(ODIN32_BIN)\$(TARGET).sym \
114 lib \
115 $(ADDITIONAL_ALL)
116!endif
117
118
119#
120# Dll: Lib rule - build importlibrary (and evt. other libs)
121#
122!ifndef NO_LIB_RULE
123lib: $(OBJDIR) \
124 $(OBJDIR)\$(ORGTARGET).lib \
125 $(ODIN32_LIB)\$(ORGTARGET).lib
126!endif
127
128
129#
130# Dll: Main target rule - builds the target dll.
131#
132!ifndef NO_MAIN_RULE
133$(OBJDIR)\$(TARGET).$(TARGET_EXTENSION): $(LIBS) $(OBJS) $(OS2RES) $(OBJDIR)\$(TARGET).lrf
134 $(CMDQD_WAIT)
135 $(LD2) @$(OBJDIR)\$(TARGET).lrf
136!ifdef OS2RES
137 $(OS2RC) $(OS2RCLFLAGS) $(OS2RES) $@
138!endif
139#!if !defined(DEBUG) && !defined(NO_LXLITE)
140# $(LXLITE) $@
141#!endif
142!endif
143
144
145#
146# Dll: Linker file - creates the parameter file passed on to the linker.
147#
148!ifndef NO_LNKFILE_RULE
149$(OBJDIR)\$(TARGET).lrf: $(MAKEFILE) $(OBJDIR)\bldlevel.$(ORGDEFFILE) $(DEFFILE) $(ODIN32_INCLUDE)\odin32.post.watn.mk
150 $(RM) $(OBJDIR)\$(TARGET).lrf2 $@
151 $(KDEF2WAT) $(OBJDIR)\bldlevel.$(ORGDEFFILE) $@ <<$(OBJDIR)\$(TARGET).lrf2
152$(LD2FLAGS)
153name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
154option map=$(OBJDIR)\$(TARGET).map
155file {$(OBJS)}
156library {$(LIBS)}
157<<
158!endif
159
160
161!else # !ifndef EXETARGET
162###############################################################################
163# EXE Target
164###############################################################################
165
166#
167# Exe: All rule - build objs, target exe, copies target to bin.
168#
169!ifndef NO_ALL_RULE
170all: $(OBJDIR) \
171 $(INTLIBS) \
172 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
173 $(OBJDIR)\$(TARGET).sym \
174 $(ODIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) \
175 $(ODIN32_BIN)\$(TARGET).sym \
176 $(ADDITIONAL_ALL)
177!endif
178
179
180#
181# Exe: Lib rule - dummy rule
182#
183!ifndef NO_LIB_RULE
184lib:
185!endif
186
187
188#
189# Exe: Main target rule - builds the target exe.
190#
191!ifndef NO_MAIN_RULE
192$(OBJDIR)\$(TARGET).$(TARGET_EXTENSION): $(LIBS) $(OBJS) $(OS2RES) $(OBJDIR)\$(TARGET).lrf
193 $(CMDQD_WAIT)
194 $(LD2) @$(OBJDIR)\$(TARGET).lrf
195!ifdef OS2RES
196 $(OS2RC) $(OS2RCLFLAGS) $(OS2RES) $@
197!endif
198!if !defined(DEBUG) && !defined(NO_LXLITE)
199 $(LXLITE) $@
200!endif
201!endif
202
203
204#
205# Exe: Linker file - creates the parameter file passed on to the linker.
206#
207!ifndef NO_LNKFILE_RULE
208$(OBJDIR)\$(TARGET).lrf: $(MAKEFILE) $(ODIN32_INCLUDE)\odin32.post.watn.mk $(OBJDIR)\bldlevel.$(ORGDEFFILE)
209 $(RM) $(OBJDIR)\$(TARGET).lrf2 $@
210!ifdef DEFFILE
211 $(KDEF2WAT) $(OBJDIR)\bldlevel.$(ORGDEFFILE) $@ <<$(OBJDIR)\$(TARGET).lrf2
212$(LD2FLAGS)
213name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
214option map=$(OBJDIR)\$(TARGET).map
215file {$(OBJS)}
216library {$(LIBS)}
217<<
218!else
219 $(ECHO) Creating <<$@
220$(LD2FLAGS)
221name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
222option map=$(OBJDIR)\$(TARGET).map
223file {$(OBJS)}
224library {$(LIBS)}
225<<
226!endif
227!endif
228
229
230!endif # !ifndef EXETARGET
231!else # !ifndef LIBTARGET
232###############################################################################
233# LIB target (internal or public object library)
234###############################################################################
235
236#
237# Localcleanup is default for internal object libraries.
238#
239!ifndef PUBLICLIB
240LOCALCLEAN = 1
241!endif
242
243
244#
245# Lib: All rule - build objs and target library.
246#
247!ifndef NO_ALL_RULE
248all: $(OBJDIR) \
249 $(INTLIBS) \
250!ifndef PUBLICLIB
251 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
252 $(ADDITIONAL_ALL)
253!else
254 $(OBJDIR)\$(TARGET)$(CUST).$(TARGET_EXTENSION) \
255 $(ODIN32_LIB)\$(TARGET)$(CUST).$(TARGET_EXTENSION) \
256 $(ADDITIONAL_ALL)
257!endif
258!endif
259
260
261#
262# Lib: Lib rule - dummy rule
263#
264!ifndef NO_LIB_RULE
265!ifndef PUBLICLIB
266lib:
267!else
268lib: all
269!endif
270!endif
271
272
273#
274# Lib: Internal library rule. Same as the all rule.
275#
276!ifndef NO_INTERNAL_LIBS
277libs: all
278!endif
279
280
281#
282# Lib: Main target rule - builds the target internal library.
283#
284!ifndef NO_MAIN_RULE
285$(OBJDIR)\$(TARGET)$(CUST).$(TARGET_EXTENSION): $(OBJS) $(ODIN32_INCLUDE)\odin32.post.watn.mk
286 $(CMDQD_WAIT)
287 $(RM) $@
288 $(ILIB) $(ILIBFLAGS) -l = $(OBJDIR)\$(@B).lst $@ @<<$@.parm
289+$(OBJS: =^
290+)
291<<keep
292!endif
293
294
295!endif # !ifndef LIBTARGET
296
297
298###############################################################################
299# Common rules for both exe and dll, new style
300###############################################################################
301
302#
303# Common (new): Dep rule - makes depenencies for C, C++ and Asm files.
304#
305!ifndef NO_DEP_RULE
306dep: dep_internal $(ADDITIONAL_DEP)
307dep_internal:
308 $(DEPEND) $(CINCLUDES) -xdummy.c *.c *.cpp *.h *.asm *.inc *.rc *.dlg -robj *.orc
309!ifdef SUBDIRS
310 @$(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) dep
311!endif
312!endif
313
314
315#
316# Common: Internal library rule. Make libraries in subdirectories.
317# For makefiles with subdirectories is common to have make libraries in subdirectories.
318#
319!ifndef NO_INTERNAL_LIBS
320!ifdef INTLIBS
321$(INTLIBS):
322 @$(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) libs
323!endif
324!endif
325
326!endif # OLD_STYLE
327
328###############################################################################
329# Common rules for both exe and dll, old and new style.
330###############################################################################
331
332#
333# Common: Copy library rule.
334#
335!ifndef PUBLICLIB
336$(ODIN32_LIB)\$(ORGTARGET).lib: $(OBJDIR)\$(ORGTARGET).lib
337!else
338$(ODIN32_LIB)\$(TARGET)$(CUST).$(TARGET_EXTENSION): $(OBJDIR)\$(TARGET)$(CUST).$(TARGET_EXTENSION)
339!endif
340 @if not exist $(@D) $(CREATEPATH) $(@D)
341 $(CP) $** $@
342
343
344#
345# Common: Copy dll/exe rule.
346#
347$(ODIN32_BIN)\$(TARGET).$(TARGET_EXTENSION): $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
348 @if not exist $(@D) $(CREATEPATH) $(@D)
349 $(CP) $** $@
350!ifndef NO_MAIN_BIN_COPY
351 -$(CP) $** $(@D)..\..\$(@F)
352!endif
353
354
355#
356# Common: Copy sym rule.
357#
358$(ODIN32_BIN)\$(TARGET).sym: $(OBJDIR)\$(TARGET).sym
359 @if not exist $(@D) $(CREATEPATH) $(@D)
360 $(CP) $** $@
361!ifndef NO_MAIN_BIN_COPY
362 -$(CP) $** $(@D)..\..\$(@F)
363!endif
364
365
366#
367# Common: Make sym file rule.
368#
369$(OBJDIR)\$(TARGET).sym: $(OBJDIR)\$(TARGET).map
370 cd $(OBJDIR)
371 $(MAPSYM) $(TARGET).map
372 cd ..\..
373
374
375#
376# Common: Make library from the <>exp.def or the <>.def file.
377#
378!ifndef LIBTARGET
379!ifndef NOTEXPDEF
380$(OBJDIR)\$(ORGTARGET).lib: $(OBJDIR)\$(ORGTARGET)exp.def
381 $(IMPLIB) $(IMPLIBFLAGS) $@ $**
382!else
383$(OBJDIR)\$(TARGET).lib: $(DEFFILE)
384 $(IMPLIB) $(IMPLIBFLAGS) $@ $**
385!endif
386!endif
387
388
389#
390# Common: Make the <>exp.def file.
391#
392!ifndef LIBTARGET
393!ifndef NOTEXPDEF
394$(OBJDIR)\$(ORGTARGET)exp.def: $(ORGDEFFILE)
395 $(IMPDEF) $(IMPDEF_FLAGS) $** $@
396!endif
397!endif
398
399
400#
401# Common: Make .def-file with buildlevel info.
402#
403$(OBJDIR)\bldlevel.$(ORGDEFFILE): $(DEFFILE)
404 $(BLDLEVELINF) $(DEFFILE) $@ -R"$(DEFFILE)" \
405 -V"#define=ODIN32_VERSION,$(ODIN32_INCLUDE)\odinbuild.h" \
406 -M"#define=ODIN32_BUILD_NR,$(ODIN32_INCLUDE)\odinbuild.h"
407
408
409#
410# Common: Create the object directory.
411#
412$(OBJDIR):
413 @if not exist $(OBJDIR) $(CREATEPATH) $(OBJDIR)
414
415
416#
417# Common: Generate Visual SlickEdit project.
418#
419!ifndef NO_VSLICKRULES
420!ifdef ORGTARGET
421vslick $(ORGTARGET).vpj:
422 $(RM) $(ORGTARGET).vtg
423 $(ODIN32_BASE)\tools\vslick\genproject.cmd $(CINCLUDES) $(ORGTARGET).vpj
424!endif
425!endif
426
427
428#
429# Common: General clean rule. To clean more add it to CLEANEXTRAS!
430#
431!ifndef NOCLEAN
432!ifndef CLEAN2
433clean:
434!else
435clean: clean2
436!endif
437 $(RM) *.lib *.res *.map *.pch dummy.c \
438!if "$(OBJDIR)" != ""
439 $(OBJDIR)\* \
440!endif
441!ifndef LOCALCLEAN
442 $(ODIN32_LIB)\$(ORGTARGET).lib \
443 $(ORGTARGET)exp.def \
444!ifndef PUBLICLIB
445 $(ODIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) *.$(TARGET_EXTENSION) \
446 $(ODIN32_BIN)\$(TARGET).sym *.sym \
447!endif
448 $(CLEANEXTRAS)
449!else
450 $(CLEANEXTRAS)
451!endif
452!ifdef SUBDIRS
453 @$(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) clean
454!endif
455!endif
456
457
458#
459# Common: Include the .depend file.
460# If the depend file don't exists we'll complain about it.
461#
462!ifndef NODEP
463! if [$(EXISTS) .depend] == 0
464! include .depend
465! else
466! if [$(ECHO) .depend doesn't exist]
467! endif
468! endif
469! if [$(EXISTS) $(ODIN32_INCLUDE)\.depend] == 0
470! include $(ODIN32_INCLUDE)\.depend
471! else
472! if [$(ECHO) /include/.depend doesn't exist]
473! endif
474! endif
475!endif
476
477
478#
479# Common: If MULTIJOBS is defined make sure cmdqd is running.
480#
481!ifndef NO_MULTIJOBS
482! ifdef MULTIJOBS
483! if [$(CMDQD) queryrunning] != 0
484! if [$(DODIRS) "$(ODIN32_BASE)\tools\cmdqd" $(MAKE_CMD) all] == 0
485! endif
486! if [$(CMDQD) init 7] == 0
487! endif
488! endif
489! endif
490!endif
491
492
Note: See TracBrowser for help on using the repository browser.