source: trunk/include/pdwin32.wat.post@ 4642

Last change on this file since 4642 was 4642, checked in by bird, 25 years ago

More changes and correction. Tried to sync watcom files.
New tool.

File size: 9.3 KB
Line 
1# $Id: pdwin32.wat.post,v 1.6 2000-11-20 04:58:14 bird Exp $
2#
3# Odin32 API
4#
5# Common dll makefile rules (must be included at the last line of the makefile)
6#
7# If ORGTARGET is defined it is used to generate the importlibrary.
8#
9# Define NOTEXPDEF to remove the $(TARGET).lib and $(TARGET)exp.def rules.
10# Define EXETARGET to make an executable. (This also applies to pdwin32.mk.)
11# Define LIBTARGET to make an internal library.
12# Define LOCALCLEAN if only the local directory is to be clean.
13# Define CLEAN2 to invoke a second clean rule named 'clean2'.
14# Define NOCLEAN to exclude the clean rule. (Remember to make your own!)
15#
16# New style: (!defined OLD_STYLE)
17# Define NO_ALL_RULE to not make default all rule.
18# Define NO_LIB_RULE to not make default lib rule.
19# Define NO_MAIN_RULE to not make default main target rule.
20# Define NO_LNKFILE_RULE to not make default link-file rule.
21# Define NO_DEP_RULE to not make dependencies rule.
22# Define NO_CLEAN_RULE to not make clean rule (same as NOCLEAN - use this!).
23# Define NO_INTERNAL_LIBS to not include libs rule for subdirectories.
24# Define NO_MAIN_BIN_COPY to not copy the target and sym file to the main
25# binary directory. It is only copied to the compiler specific directory.
26# Main bin is /bin. Compiler specific bin is /bin/debug, /bin/debug.vac36, etc.
27# Define ADDITIONAL_DEP to add dependencies rules.
28#
29# Define MAKEFILE if the name of the makefile isn't "makefile".
30# Define DEFFILE to specify another file than $(TARGET).def or $(ORGTARGET).def.
31# Define this if your .exe file have a .def file.
32# Define OS2RES as the names of the OS/2 .res file to create and link
33# with the target .dll or .exe.
34# Define LIBS as a list of all the libraries to link
35# with the target .dll or .exe.
36# Define SUBDIRS when you have subdirectories which should be made.
37# dep and lib supports this fully. The rule libs are added, since we assume you
38# makes internal libraries in the subdirectories. The libs rule is one of the
39# dependencies of the main target.
40#
41
42!ifndef TARGET_EXTENSION
43! ifdef EXETARGET
44TARGET_EXTENSION=exe
45! else
46! ifdef LIBTARGET
47TARGET_EXTENSION=lib
48! else
49TARGET_EXTENSION=dll
50! endif
51! endif
52!endif
53
54
55!ifndef OLD_STYLE
56
57# Set default MAKEFILE if needed
58!ifndef MAKEFILE
59MAKEFILE = makefile
60!endif
61
62# Set default ORGTARGET if needed.
63!ifndef ORGTARGET
64ORGTARGET=$(TARGET)
65!endif
66
67# Set default DEFFILE if needed. (Currently for dlls only.)
68!ifndef DEFFILE
69! ifndef EXETARGET
70DEFFILE = $(ORGTARGET).def
71! endif
72!endif
73
74# Set INTLIBS (interal) if SUBDIRS is defined and NO_INTERNAL_LIBS is undefined.
75!ifdef SUBDIRS
76! ifndef NO_INTERNAL_LIBS
77! ifndef LIBTARGET
78INTLIBS = libs
79! else
80INTLIBS = libs_sub
81! endif
82! endif
83!endif
84
85
86!ifndef LIBTARGET
87!ifndef EXETARGET
88###############################################################################
89# DLL Target
90###############################################################################
91
92#
93# Dll: All rule - build objs, target dll, copies target to bin and makes libs.
94#
95!ifndef NO_ALL_RULE
96all: $(OBJDIR) \
97 $(INTLIBS) \
98 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
99 $(OBJDIR)\$(TARGET).sym \
100 $(PDWIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) \
101 $(PDWIN32_BIN)\$(TARGET).sym \
102 lib
103!endif
104
105#
106# Dll: Lib rule - build importlibrary (and evt. other libs)
107#
108!ifndef NO_LIB_RULE
109lib: $(ORGTARGET).lib $(PDWIN32_LIB)\$(ORGTARGET).lib
110!endif
111
112
113#
114# Dll: Main target rule - builds the target dll.
115#
116!ifndef NO_MAIN_RULE
117$(OBJDIR)\$(TARGET).$(TARGET_EXTENSION): $(OBJS) $(OS2RES) $(DEFFILE) $(OBJDIR)\$(TARGET).lrf
118 $(LD2) @$(OBJDIR)\$(TARGET).lrf
119!ifdef OS2RES
120 $(OS2RC) $(OS2RCLFLAGS) $(OS2RES) $@
121!endif
122!endif
123
124
125#
126# Dll: Linker file - creates the parameter file passed on to the linker.
127#
128!ifndef NO_LNKFILE_RULE
129$(OBJDIR)\$(TARGET).lnk: makefile $(DEFFILE) $(PDWIN32_INCLUDE)\pdwin32.wat.post
130 $(RM) $(OBJDIR)\$(TARGET).lnk2 $@
131 $(KDEF2WAT) $(DEFFILE) $@ <<$(OBJDIR)\$(TARGET).lnk2
132$(LD2FLAGS)
133name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
134option map=$(OBJDIR)\$(TARGET).map
135file {$(OBJS)}
136library {$(LIBS)}
137<<
138!endif
139
140
141!else # !ifndef EXETARGET
142###############################################################################
143# EXE Target
144###############################################################################
145
146#
147# Exe: All rule - build objs, target exe, copies target to bin.
148#
149!ifndef NO_ALL_RULE
150all: $(OBJDIR) \
151 $(INTLIBS) \
152 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
153 $(OBJDIR)\$(TARGET).sym \
154 $(PDWIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) \
155 $(PDWIN32_BIN)\$(TARGET).sym
156!endif
157
158#
159# Exe: Lib rule - dummy rule
160#
161!ifndef NO_LIB_RULE
162lib:
163!endif
164
165
166#
167# Exe: Main target rule - builds the target exe.
168#
169!ifndef NO_MAIN_RULE
170$(OBJDIR)\$(TARGET).$(TARGET_EXTENSION): $(OBJS) $(OS2RES) $(DEFFILE) $(OBJDIR)\$(TARGET).lrf
171 $(LD2) @$(OBJDIR)\$(TARGET).lrf
172!ifdef OS2RES
173 $(OS2RC) $(OS2RCLFLAGS) $(OS2RES) $@
174!endif
175!endif
176
177
178#
179# Exe: Linker file - creates the parameter file passed on to the linker.
180#
181!ifndef NO_LNKFILE_RULE
182$(OBJDIR)\$(TARGET).lnk: makefile $(PDWIN32_INCLUDE)\pdwin32.wat.post $(DEFFILE)
183 $(RM) $(OBJDIR)\$(TARGET).lnk2 $@
184 $(KDEF2WAT) $(DEFFILE) $@ <<$(OBJDIR)\$(TARGET).lnk2
185$(LD2FLAGS)
186name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
187option map=$(OBJDIR)\$(TARGET).map
188file {$(OBJS)}
189library {$(LIBS)}
190<<
191!endif
192
193!endif # !ifndef EXETARGET !else
194!else # !ifndef LIBTARGET
195###############################################################################
196# LIB target (internal object library)
197###############################################################################
198
199#
200# Localcleanup is default for internal object libraries.
201#
202LOCALCLEAN = 1
203
204
205#
206# Lib: All rule - build objs and target library.
207#
208!ifndef NO_ALL_RULE
209all: $(OBJDIR) \
210 $(INTLIBS) \
211 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
212!endif
213
214
215#
216# Lib: Lib rule - dummy rule
217#
218!ifndef NO_LIB_RULE
219lib:
220!endif
221
222
223#
224# Lib: Internal library rule. Same as the all rule.
225#
226!ifndef NO_INTERNAL_LIBS
227libs: all
228!endif
229
230
231#
232# Lib: Main target rule - builds the target internal library.
233# (fixme)
234!ifndef NO_MAIN_RULE
235$(OBJDIR)\$(TARGET).$(TARGET_EXTENSION): $(OBJS)
236 $(RM) $@
237 $(ILIB) $(ILIBFLAGS) $@ @<<
238$(OBJS: =&^
239)
240$(OBJDIR)\$(@B).lst
241<<
242!endif
243
244
245!endif # !ifndef LIBTARGET
246
247
248###############################################################################
249# Common rules for both exe and dll, new style
250###############################################################################
251
252#
253# Common (new): Dep rule - makes depenencies for C, C++ and Asm files.
254#
255!ifndef NO_DEP_RULE
256dep: dep_internal $(ADDITIONAL_DEP)
257dep_internal:
258 $(DEPEND) $(CINCLUDES) *.c *.cpp *.h *.asm *.inc \
259 *.rc *.dlg $(PDWIN32_INCLUDE)\*.h -robj *.orc
260!ifdef SUBDIRS
261 $(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) dep
262!endif
263!endif
264
265
266#
267# Common: Internal library rule. Make libraries in subdirectories.
268# For makefiles with subdirectories is common to have make libraries in subdirectories.
269#
270!ifndef NO_INTERNAL_LIBS
271!ifdef INTLIBS
272$(INTLIBS):
273 $(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) libs
274!endif
275!endif
276
277!endif # OLD_STYLE
278
279###############################################################################
280# Common rules for both exe and dll, old and new style.
281###############################################################################
282
283#
284# Common: Copy library rule.
285#
286$(PDWIN32_LIB)\$(ORGTARGET).lib: $(ORGTARGET).lib
287 @if not exist $(@D) $(CREATEPATH) $(@D)
288 $(CP) $** $@
289
290
291#
292# Common: Copy dll/exe rule.
293#
294$(PDWIN32_BIN)\$(TARGET).$(TARGET_EXTENSION): $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
295 @if not exist $(@D) $(CREATEPATH) $(@D)
296 $(CP) $** $@
297!ifndef NO_MAIN_BIN_COPY
298 -$(CP) $** $(@D)..\..\$(@F)
299!endif
300
301
302#
303# Common: Copy sym rule.
304#
305$(PDWIN32_BIN)\$(TARGET).sym: $(OBJDIR)\$(TARGET).sym
306 @if not exist $(@D) $(CREATEPATH) $(@D)
307 $(CP) $** $@
308!ifndef NO_MAIN_BIN_COPY
309 -$(CP) $** $(@D)..\..\$(@F)
310!endif
311
312
313#
314# Common: Make sym file rule.
315#
316$(OBJDIR)\$(TARGET).sym: $(OBJDIR)\$(TARGET).map
317 cd $(OBJDIR)
318 $(MAPSYM) $(TARGET).map
319 cd ..\..
320
321
322#
323# Common: Make library from the <>exp.def or the <>.def file.
324#
325!ifndef NOTEXPDEF
326$(ORGTARGET).lib: $(ORGTARGET)exp.def
327 $(IMPLIB) $(IMPLIBFLAGS) $@ $**
328!else
329$(TARGET).lib: $(DEFFILE)
330 $(IMPLIB) $(IMPLIBFLAGS) $@ $**
331!endif
332
333
334#
335# Common: Make the <>exp.def file.
336#
337!ifndef NOTEXPDEF
338$(ORGTARGET)exp.def: $(DEFFILE)
339 $(IMPDEF) $** $@
340!endif
341
342
343#
344# Common: Create the object directory.
345#
346$(OBJDIR): .SYMBOLIC
347 @if not exist $(OBJDIR) $(CREATEPATH) $(OBJDIR)
348
349
350#
351# Common: General clean rule. To clean more add it to CLEANEXTRAS!
352#
353!ifndef NOCLEAN
354!ifndef CLEAN2
355clean:
356!else
357clean: clean2
358!endif
359 $(RM) *.lib *.res *.map *.pch \
360!if "$(OBJDIR)" != ""
361 $(OBJDIR)\* \
362!endif
363!ifndef LOCALCLEAN
364 $(PDWIN32_LIB)\$(ORGTARGET).lib \
365 $(ORGTARGET)exp.def \
366 $(PDWIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) *.$(TARGET_EXTENSION) \
367 $(PDWIN32_BIN)\$(TARGET).sym *.sym \
368 $(CLEANEXTRAS)
369!else
370 $(CLEANEXTRAS)
371!endif
372!endif
373!ifdef SUBDIRS
374 $(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) clean
375!endif
376
377
378#
379# Common: Include the .depend file.
380# If the depend file don't exists we'll complain about it.
381#
382#!ifndef NODEP
383#! if [$(EXISTS) .depend] == 0
384#! include .depend
385#! else
386#! if [$(ECHO) .depend doesn't exist]
387#! endif
388#! endif
389#!endif
390
Note: See TracBrowser for help on using the repository browser.