source: trunk/include/odin32.post.wat.mk@ 10366

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

Exclude dummy.c from the dependencies.

File size: 11.3 KB
Line 
1# $Id: odin32.post.wat.mk,v 1.20 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 .SYMBOLIC
117!endif
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 .SYMBOLIC
127!endif
128
129
130#
131# Dll: Main target rule - builds the target dll.
132#
133!ifndef NO_MAIN_RULE
134$(OBJDIR)\$(TARGET).$(TARGET_EXTENSION): $(LIBS) $(OBJS) $(OS2RES) $(OBJDIR)\$(TARGET).lrf
135 $(LD2) @$(OBJDIR)\$(TARGET).lrf
136!ifdef OS2RES
137 $(OS2RC) $(OS2RCLFLAGS) $(OS2RES) $@
138!endif
139!ifndef DEBUG
140!ifndef NO_LXLITE
141 $(LXLITE) $@
142!endif
143!endif
144!endif
145
146
147#
148# Dll: Linker file - creates the parameter file passed on to the linker.
149#
150!ifndef NO_LNKFILE_RULE
151$(OBJDIR)\$(TARGET).lrf: $(__MAKEFILES__) $(OBJDIR)\bldlevel.$(ORGDEFFILE) $(DEFFILE) $(ODIN32_INCLUDE)\odin32.post.wat.mk
152 $(RM) $(OBJDIR)\$(TARGET).lrf2 $@
153 $(KDEF2WAT) $(OBJDIR)\bldlevel.$(ORGDEFFILE) $@ <<$(OBJDIR)\$(TARGET).lrf2
154$(LD2FLAGS)
155name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
156option map=$(OBJDIR)\$(TARGET).map
157file {$(OBJS)}
158library {$(LIBS)}
159<<
160!endif
161
162
163!else # !ifndef EXETARGET
164###############################################################################
165# EXE Target
166###############################################################################
167
168#
169# Exe: All rule - build objs, target exe, copies target to bin.
170#
171!ifndef NO_ALL_RULE
172all: $(OBJDIR) \
173 $(INTLIBS) \
174 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
175 $(OBJDIR)\$(TARGET).sym \
176 $(ODIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) \
177 $(ODIN32_BIN)\$(TARGET).sym \
178 $(ADDITIONAL_ALL) \
179 .SYMBOLIC
180!endif
181
182#
183# Exe: Lib rule - dummy rule
184#
185!ifndef NO_LIB_RULE
186lib: .SYMBOLIC
187!endif
188
189
190#
191# Exe: Main target rule - builds the target exe.
192#
193!ifndef NO_MAIN_RULE
194$(OBJDIR)\$(TARGET).$(TARGET_EXTENSION): $(LIBS) $(OBJS) $(OS2RES) $(OBJDIR)\$(TARGET).lrf
195 $(LD2) @$(OBJDIR)\$(TARGET).lrf
196!ifdef OS2RES
197 $(OS2RC) $(OS2RCLFLAGS) $(OS2RES) $@
198!endif
199!ifndef DEBUG
200!ifndef NO_LXLITE
201 $(LXLITE) $@
202!endif
203!endif
204!endif
205
206
207#
208# Exe: Linker file - creates the parameter file passed on to the linker.
209#
210!ifndef NO_LNKFILE_RULE
211$(OBJDIR)\$(TARGET).lrf: $(__MAKEFILES__) $(ODIN32_INCLUDE)\odin32.post.wat.mk $(OBJDIR)\bldlevel.$(ORGDEFFILE)
212 $(RM) $(OBJDIR)\$(TARGET).lrf2 $@
213!ifdef DEFFILE
214 $(KDEF2WAT) $(OBJDIR)\bldlevel.$(ORGDEFFILE) $@ <<$(OBJDIR)\$(TARGET).lrf2
215!else
216 $(ECHO) Creating <<$@
217!endif
218$(LD2FLAGS)
219name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
220option map=$(OBJDIR)\$(TARGET).map
221file {$(OBJS)}
222library {$(LIBS)}
223<<
224!endif
225
226
227!endif # !ifndef EXETARGET !else
228!else # !ifndef LIBTARGET
229###############################################################################
230# LIB target (internal or public object library)
231###############################################################################
232
233#
234# Localcleanup is default for internal object libraries.
235#
236!ifndef PUBLICLIB
237LOCALCLEAN = 1
238!endif
239
240
241#
242# Lib: All rule - build objs and target library.
243#
244!ifndef NO_ALL_RULE
245all: $(OBJDIR) \
246 $(INTLIBS) \
247!ifndef PUBLICLIB
248 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
249 $(ADDITIONAL_ALL) \
250 .SYMBOLIC
251!else
252 $(OBJDIR)\$(TARGET)$(CUST).$(TARGET_EXTENSION) \
253 $(ODIN32_LIB)\$(TARGET)$(CUST).$(TARGET_EXTENSION) \
254 $(ADDITIONAL_ALL) \
255 .SYMBOLIC
256!endif
257!endif
258
259
260#
261# Lib: Lib rule - dummy rule
262#
263!ifndef NO_LIB_RULE
264!ifndef PUBLICLIB
265lib: .SYMBOLIC
266!else
267lib: all .SYMBOLIC
268!endif
269!endif
270
271
272#
273# Lib: Internal library rule. Same as the all rule.
274#
275!ifndef NO_INTERNAL_LIBS
276libs: all .SYMBOLIC
277!endif
278
279
280#
281# Lib: Main target rule - builds the target internal library.
282# (fixme)
283!ifndef NO_MAIN_RULE
284$(OBJDIR)\$(TARGET)$(CUST).$(TARGET_EXTENSION): $(OBJS)
285 $(RM) $@
286 $(ILIB) $(ILIBFLAGS) $@ @<<
287$(OBJS: =&^
288)
289$(OBJDIR)\$^&.lst
290<<
291!endif
292
293
294!endif # !ifndef LIBTARGET
295
296
297###############################################################################
298# Common rules for both exe and dll, new style
299###############################################################################
300
301#
302# Common (new): Dep rule - makes depenencies for C, C++ and Asm files.
303#
304!ifndef NO_DEP_RULE
305dep: dep_internal $(ADDITIONAL_DEP) .SYMBOLIC
306dep_internal: .SYMBOLIC
307 $(DEPEND) $(CINCLUDES) -xdummy.c *.c *.cpp *.h *.asm *.inc *.rc *.dlg -robj *.orc
308!ifdef SUBDIRS
309 @$(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) dep
310!endif
311!endif
312
313
314#
315# Common: Internal library rule. Make libraries in subdirectories.
316# For makefiles with subdirectories is common to have make libraries in subdirectories.
317#
318!ifndef NO_INTERNAL_LIBS
319!ifdef INTLIBS
320$(INTLIBS): .SYMBOLIC
321 @$(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) libs
322!endif
323!endif
324
325!endif # OLD_STYLE
326
327###############################################################################
328# Common rules for both exe and dll, old and new style.
329###############################################################################
330
331#
332# Common: Copy library rule.
333#
334!ifndef PUBLICLIB
335$(ODIN32_LIB)\$(ORGTARGET).lib: $(OBJDIR)\$(ORGTARGET).lib
336!else
337$(ODIN32_LIB)\$(TARGET)$(CUST).$(TARGET_EXTENSION): $(OBJDIR)\$(TARGET)$(CUST).$(TARGET_EXTENSION)
338!endif
339 @if not exist $^: $(CREATEPATH) $^:
340 $(CP) $[@ $@
341
342
343#
344# Common: Copy dll/exe rule.
345#
346$(ODIN32_BIN)\$(TARGET).$(TARGET_EXTENSION): $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
347 @if not exist $^: $(CREATEPATH) $^:
348 $(CP) $[@ $^@
349!ifndef NO_MAIN_BIN_COPY
350 -$(CP) $[@ $^:..\..\$^.
351!endif
352
353
354#
355# Common: Copy sym rule.
356#
357$(ODIN32_BIN)\$(TARGET).sym: $(OBJDIR)\$(TARGET).sym
358 @if not exist $^: $(CREATEPATH) $^:
359 $(CP) $[@ $@
360!ifndef NO_MAIN_BIN_COPY
361 -$(CP) $[@ $^:..\..\$^.
362!endif
363
364
365#
366# Common: Make sym file rule.
367#
368$(OBJDIR)\$(TARGET).sym: $(OBJDIR)\$(TARGET).map
369 cd $(OBJDIR)
370 $(MAPSYM) $(TARGET).map
371 cd ..\..
372
373
374#
375# Common: Make library from the <>exp.def or the <>.def file.
376#
377!ifndef LIBTARGET
378!ifndef NOTEXPDEF
379$(OBJDIR)\$(ORGTARGET).lib: $(OBJDIR)\$(ORGTARGET)exp.def
380 $(IMPLIB) $(IMPLIBFLAGS) $@ $[@
381!else
382$(OBJDIR)\$(TARGET).lib: $(DEFFILE)
383 $(IMPLIB) $(IMPLIBFLAGS) $@ $[@
384!endif
385!endif
386
387
388#
389# Common: Make the <>exp.def file.
390#
391!ifndef LIBTARGET
392!ifndef NOTEXPDEF
393$(OBJDIR)\$(ORGTARGET)exp.def: $(ORGDEFFILE)
394 $(IMPDEF) $(IMPDEF_FLAGS) $[@ $@
395!endif
396!endif
397
398
399#
400# Common: Make .def-file with buildlevel info.
401#
402$(OBJDIR)\bldlevel.$(ORGDEFFILE): $(DEFFILE)
403 $(BLDLEVELINF) $(DEFFILE) $@ -R"$(DEFFILE)" \
404 -V"$#define=ODIN32_VERSION,$(ODIN32_INCLUDE)\odinbuild.h" \
405 -M"$#define=ODIN32_BUILD_NR,$(ODIN32_INCLUDE)\odinbuild.h"
406
407
408#
409# Common: Create the object directory.
410#
411$(OBJDIR): .SYMBOLIC
412 @if not exist $(OBJDIR) $(CREATEPATH) $(OBJDIR)
413
414
415#
416# Common: Generate Visual SlickEdit project.
417#
418!ifndef NO_VSLICKRULES
419!ifdef ORGTARGET
420vslick $(ORGTARGET).vpj: .SYMBOLIC
421 $(RM) $(ORGTARGET).vtg
422 $(ODIN32_BASE)\tools\vslick\genproject.cmd $(CINCLUDES) $(ORGTARGET).vpj
423!endif
424!endif
425
426
427#
428# Common: General clean rule. To clean more add it to CLEANEXTRAS!
429#
430!ifndef NOCLEAN
431!ifndef CLEAN2
432clean: .SYMBOLIC
433!else
434clean: clean2 .SYMBOLIC
435!endif
436 $(RM) *.lib *.res *.map *.pch dummy.c \
437!if "$(OBJDIR)" != ""
438 $(OBJDIR)\* \
439!endif
440!ifndef LOCALCLEAN
441 $(ODIN32_LIB)\$(ORGTARGET).lib \
442 $(ORGTARGET)exp.def \
443!ifndef PUBLICLIB
444 $(ODIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) *.$(TARGET_EXTENSION) \
445 $(ODIN32_BIN)\$(TARGET).sym *.sym \
446!endif
447 $(CLEANEXTRAS)
448!else
449 $(CLEANEXTRAS)
450!endif
451!endif
452!ifdef SUBDIRS
453 @$(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) clean
454!endif
455
456
457#
458# Common: Include the .depend file.
459# If the depend file don't exists we'll complain about it.
460#
461#!ifndef NODEP
462#! if [$(EXISTS) .depend] == 0
463#! include .depend
464#! else
465#! if [$(ECHO) .depend doesn't exist]
466#! endif
467#! endif
468#! if [$(EXISTS) $(ODIN32_INCLUDE)\.depend] == 0
469#! include $(ODIN32_INCLUDE)\.depend
470#! else
471#! if [$(ECHO) /include/.depend doesn't exist]
472#! endif
473#! endif
474#!endif
475
Note: See TracBrowser for help on using the repository browser.