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

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

Corrected some rules in the watcom makefiles.

File size: 9.3 KB
RevLine 
[4647]1# $Id: pdwin32.wat.post,v 1.7 2000-11-20 05:16:21 bird Exp $
[4075]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.)
[4642]11# Define LIBTARGET to make an internal library.
[4075]12# Define LOCALCLEAN if only the local directory is to be clean.
13# Define CLEAN2 to invoke a second clean rule named 'clean2'.
[4288]14# Define NOCLEAN to exclude the clean rule. (Remember to make your own!)
[4075]15#
[4642]16# New style: (!defined OLD_STYLE)
[4334]17# Define NO_ALL_RULE to not make default all rule.
18# Define NO_LIB_RULE to not make default lib rule.
[4642]19# Define NO_MAIN_RULE to not make default main target rule.
[4334]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!).
[4642]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.
[4334]28#
[4642]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#
[4075]41
[4547]42!ifndef TARGET_EXTENSION
[4642]43! ifdef EXETARGET
[4547]44TARGET_EXTENSION=exe
[4642]45! else
46! ifdef LIBTARGET
47TARGET_EXTENSION=lib
48! else
[4547]49TARGET_EXTENSION=dll
[4642]50! endif
51! endif
[4547]52!endif
[4642]53
54
55!ifndef OLD_STYLE
56
57# Set default MAKEFILE if needed
58!ifndef MAKEFILE
59MAKEFILE = makefile
[4547]60!endif
[4075]61
[4642]62# Set default ORGTARGET if needed.
63!ifndef ORGTARGET
64ORGTARGET=$(TARGET)
65!endif
[4547]66
[4642]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
[4334]87!ifndef EXETARGET
[4642]88###############################################################################
89# DLL Target
90###############################################################################
[4334]91
[4642]92#
93# Dll: All rule - build objs, target dll, copies target to bin and makes libs.
94#
[4334]95!ifndef NO_ALL_RULE
96all: $(OBJDIR) \
[4642]97 $(INTLIBS) \
[4547]98 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
[4642]99 $(OBJDIR)\$(TARGET).sym \
[4547]100 $(PDWIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) \
[4642]101 $(PDWIN32_BIN)\$(TARGET).sym \
[4334]102 lib
103!endif
104
[4642]105#
106# Dll: Lib rule - build importlibrary (and evt. other libs)
107#
[4334]108!ifndef NO_LIB_RULE
[4642]109lib: $(ORGTARGET).lib $(PDWIN32_LIB)\$(ORGTARGET).lib
[4334]110!endif
111
112
[4642]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) $@
[4334]121!endif
[4642]122!endif
[4334]123
124
[4642]125#
126# Dll: Linker file - creates the parameter file passed on to the linker.
127#
[4334]128!ifndef NO_LNKFILE_RULE
[4647]129$(OBJDIR)\$(TARGET).lrf: makefile $(DEFFILE) $(PDWIN32_INCLUDE)\pdwin32.wat.post
130 $(RM) $(OBJDIR)\$(TARGET).lrf2 $@
131 $(KDEF2WAT) $(DEFFILE) $@ <<$(OBJDIR)\$(TARGET).lrf2
[4334]132$(LD2FLAGS)
[4547]133name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
[4334]134option map=$(OBJDIR)\$(TARGET).map
135file {$(OBJS)}
136library {$(LIBS)}
[4401]137<<
[4334]138!endif
139
140
141!else # !ifndef EXETARGET
[4642]142###############################################################################
143# EXE Target
144###############################################################################
[4334]145
[4642]146#
147# Exe: All rule - build objs, target exe, copies target to bin.
148#
[4334]149!ifndef NO_ALL_RULE
150all: $(OBJDIR) \
[4642]151 $(INTLIBS) \
[4547]152 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION) \
[4642]153 $(OBJDIR)\$(TARGET).sym \
154 $(PDWIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) \
155 $(PDWIN32_BIN)\$(TARGET).sym
[4334]156!endif
157
[4642]158#
159# Exe: Lib rule - dummy rule
160#
[4334]161!ifndef NO_LIB_RULE
162lib:
163!endif
164
165
[4642]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) $@
[4334]174!endif
[4642]175!endif
[4334]176
177
[4642]178#
179# Exe: Linker file - creates the parameter file passed on to the linker.
180#
[4334]181!ifndef NO_LNKFILE_RULE
[4647]182$(OBJDIR)\$(TARGET).lrf: makefile $(PDWIN32_INCLUDE)\pdwin32.wat.post $(DEFFILE)
183 $(RM) $(OBJDIR)\$(TARGET).lrf2 $@
184!ifdef DEFFILE
185 $(KDEF2WAT) $(DEFFILE) $@ <<$(OBJDIR)\$(TARGET).lrf2
186!else
187 $(ECHO) Creating <<$@
188!endif
[4401]189$(LD2FLAGS)
[4547]190name $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
[4401]191option map=$(OBJDIR)\$(TARGET).map
192file {$(OBJS)}
193library {$(LIBS)}
194<<
[4334]195!endif
196
[4642]197!endif # !ifndef EXETARGET !else
198!else # !ifndef LIBTARGET
199###############################################################################
200# LIB target (internal object library)
201###############################################################################
[4334]202
[4642]203#
204# Localcleanup is default for internal object libraries.
205#
206LOCALCLEAN = 1
207
208
209#
210# Lib: All rule - build objs and target library.
211#
212!ifndef NO_ALL_RULE
213all: $(OBJDIR) \
214 $(INTLIBS) \
215 $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
[4334]216!endif
217
218
[4642]219#
220# Lib: Lib rule - dummy rule
221#
222!ifndef NO_LIB_RULE
223lib:
224!endif
[4334]225
226
[4642]227#
228# Lib: Internal library rule. Same as the all rule.
229#
230!ifndef NO_INTERNAL_LIBS
231libs: all
232!endif
[4334]233
234
[4642]235#
236# Lib: Main target rule - builds the target internal library.
237# (fixme)
238!ifndef NO_MAIN_RULE
239$(OBJDIR)\$(TARGET).$(TARGET_EXTENSION): $(OBJS)
240 $(RM) $@
241 $(ILIB) $(ILIBFLAGS) $@ @<<
242$(OBJS: =&^
243)
244$(OBJDIR)\$(@B).lst
245<<
246!endif
247
248
249!endif # !ifndef LIBTARGET
250
251
252###############################################################################
253# Common rules for both exe and dll, new style
254###############################################################################
255
256#
257# Common (new): Dep rule - makes depenencies for C, C++ and Asm files.
258#
259!ifndef NO_DEP_RULE
260dep: dep_internal $(ADDITIONAL_DEP)
261dep_internal:
262 $(DEPEND) $(CINCLUDES) *.c *.cpp *.h *.asm *.inc \
263 *.rc *.dlg $(PDWIN32_INCLUDE)\*.h -robj *.orc
264!ifdef SUBDIRS
265 $(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) dep
266!endif
267!endif
268
269
270#
271# Common: Internal library rule. Make libraries in subdirectories.
272# For makefiles with subdirectories is common to have make libraries in subdirectories.
273#
274!ifndef NO_INTERNAL_LIBS
275!ifdef INTLIBS
276$(INTLIBS):
277 $(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) libs
278!endif
279!endif
280
281!endif # OLD_STYLE
282
283###############################################################################
284# Common rules for both exe and dll, old and new style.
285###############################################################################
286
287#
288# Common: Copy library rule.
289#
[4075]290$(PDWIN32_LIB)\$(ORGTARGET).lib: $(ORGTARGET).lib
[4642]291 @if not exist $(@D) $(CREATEPATH) $(@D)
292 $(CP) $** $@
293
294
295#
296# Common: Copy dll/exe rule.
297#
298$(PDWIN32_BIN)\$(TARGET).$(TARGET_EXTENSION): $(OBJDIR)\$(TARGET).$(TARGET_EXTENSION)
299 @if not exist $(@D) $(CREATEPATH) $(@D)
300 $(CP) $** $@
301!ifndef NO_MAIN_BIN_COPY
302 -$(CP) $** $(@D)..\..\$(@F)
[4075]303!endif
[4642]304
305
306#
307# Common: Copy sym rule.
308#
309$(PDWIN32_BIN)\$(TARGET).sym: $(OBJDIR)\$(TARGET).sym
310 @if not exist $(@D) $(CREATEPATH) $(@D)
[4075]311 $(CP) $** $@
[4642]312!ifndef NO_MAIN_BIN_COPY
313 -$(CP) $** $(@D)..\..\$(@F)
314!endif
[4075]315
316
[4642]317#
318# Common: Make sym file rule.
319#
320$(OBJDIR)\$(TARGET).sym: $(OBJDIR)\$(TARGET).map
[4075]321 cd $(OBJDIR)
322 $(MAPSYM) $(TARGET).map
323 cd ..\..
324
325
[4642]326#
327# Common: Make library from the <>exp.def or the <>.def file.
328#
[4075]329!ifndef NOTEXPDEF
[4642]330$(ORGTARGET).lib: $(ORGTARGET)exp.def
331 $(IMPLIB) $(IMPLIBFLAGS) $@ $**
[4075]332!else
[4642]333$(TARGET).lib: $(DEFFILE)
334 $(IMPLIB) $(IMPLIBFLAGS) $@ $**
[4075]335!endif
336
337
[4642]338#
339# Common: Make the <>exp.def file.
340#
341!ifndef NOTEXPDEF
342$(ORGTARGET)exp.def: $(DEFFILE)
[4075]343 $(IMPDEF) $** $@
344!endif
345
346
[4642]347#
348# Common: Create the object directory.
349#
[4075]350$(OBJDIR): .SYMBOLIC
[4642]351 @if not exist $(OBJDIR) $(CREATEPATH) $(OBJDIR)
[4075]352
353
354#
[4642]355# Common: General clean rule. To clean more add it to CLEANEXTRAS!
[4075]356#
[4288]357!ifndef NOCLEAN
[4075]358!ifndef CLEAN2
[4642]359clean:
[4075]360!else
361clean: clean2
362!endif
[4642]363 $(RM) *.lib *.res *.map *.pch \
[4075]364!if "$(OBJDIR)" != ""
365 $(OBJDIR)\* \
366!endif
367!ifndef LOCALCLEAN
[4642]368 $(PDWIN32_LIB)\$(ORGTARGET).lib \
369 $(ORGTARGET)exp.def \
[4547]370 $(PDWIN32_BIN)\$(TARGET).$(TARGET_EXTENSION) *.$(TARGET_EXTENSION) \
371 $(PDWIN32_BIN)\$(TARGET).sym *.sym \
[4075]372 $(CLEANEXTRAS)
373!else
374 $(CLEANEXTRAS)
375!endif
[4288]376!endif
[4642]377!ifdef SUBDIRS
378 $(DODIRS) "$(SUBDIRS)" $(MAKE_CMD) clean
[4334]379!endif
[4075]380
381
[4642]382#
383# Common: Include the .depend file.
384# If the depend file don't exists we'll complain about it.
385#
386#!ifndef NODEP
387#! if [$(EXISTS) .depend] == 0
388#! include .depend
389#! else
390#! if [$(ECHO) .depend doesn't exist]
391#! endif
392#! endif
393#!endif
394
Note: See TracBrowser for help on using the repository browser.