source: trunk/make/process.mak@ 9028

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

New TARGET_MODE: DEPEND

File size: 30.4 KB
Line 
1# $Id: process.mak,v 1.16 2002-08-19 15:00:25 bird Exp $
2
3#
4# Unix-like tools for OS/2
5#
6# The common build process rules
7#
8# Note: this makefile is supposed to be included from the
9# current source path.
10#
11
12
13# -----------------------------------------------------------------------------
14# Assertions.
15# This makefile expects setup.mak and the specific setup to be included
16# already.
17# It also requires the TARGET_NAME to be specified in the makefile.
18# -----------------------------------------------------------------------------
19!if "$(MAKE_SETUP_INCLUDED)" != "YES"
20! ifndef MAKEVER
21! if [$(ECHO) $(CLRERR)Fatal error: You must include setup.mak before process.mak in the makefile.$(CLRRST)]
22! endif
23! error
24!else
25! error $(CLRERR)Fatal error: You must include setup.mak before process.mak in the makefile.$(CLRRST)
26!endif
27!endif
28!if "$(ENV_STATUS)" != "OK"
29! ifndef MAKEVER
30! if [$(ECHO) $(CLRERR)Fatal error: The environment is not valid. Bad setup.mak?$(CLRRST)]
31! endif
32! error
33! else
34! error $(CLRERR)Fatal error: The environment is not valid. Bad setup.mak?$(CLRRST)
35! endif
36!endif
37
38!if "$(TARGET_NAME)" == "" && "$(TARGET_MODE)" != "EMPTY"
39! ifndef MAKEVER
40! if [$(ECHO) $(CLRERR)Fatal error: TARGET_NAME is not defined! Should be set in the makefile.$(CLRRST)]
41! endif
42! error
43! else
44! error $(CLRERR)Fatal error: TARGET_NAME is not defined! Should be set in the makefile.$(CLRRST)
45! endif
46!endif
47
48!ifdef TARGET_MODE
49# Executable target mode.
50! if "$(TARGET_MODE)" != "EXE"
51# Dynamic Load Library target mode.
52! if "$(TARGET_MODE)" != "DLL"
53# Drive (/ system software) target mode.
54! if "$(TARGET_MODE)" != "SYS"
55# Installable File System Drive target mode. (Also called FSD, File System Driver.)
56! if "$(TARGET_MODE)" != "IFS"
57# Virtual Device Driver target mode.
58! if "$(TARGET_MODE)" != "VDD"
59# Object Library target mode.
60! if "$(TARGET_MODE)" != "LIB"
61# Object Library target mode - Special variant which is to be linked with a SYS target.
62! if "$(TARGET_MODE)" != "SYSLIB"
63# Object Library target mode - Special variant which is to be linked with an IFS target.
64! if "$(TARGET_MODE)" != "IFSLIB"
65# Dummy/Hub/TopLevel empty makefile. This has no target.
66! if "$(TARGET_MODE)" != "EMPTY"
67# Dependency only makefile. (typical for include directories)
68! if "$(TARGET_MODE)" != "DEPEND"
69# Testcase makefile.
70! if "$(TARGET_MODE)" != "TESTCASE"
71# Bad TARGET_MODE complain.
72! ifndef MAKEVER
73! if [$(ECHO) $(CLRERR)Fatal Error: Bad TARGET_MODE="$(TARGET_MODE)". Valid ones are: EXE, DLL, SYS, IFS, VDD, LIB, SYSLIB, IFSLIB, TESTCASE and EMPTY.$(CLRRST)]
74! endif
75! error
76! else
77! error $(CLRERR)Fatal Error: Bad TARGET_MODE="$(TARGET_MODE)". Valid ones are: EXE, DLL, SYS, IFS, VDD, LIB, SYSLIB, IFSLIB, TESTCASE and EMPTY.$(CLRRST)
78! endif
79! endif
80! endif
81! endif
82! endif
83! endif
84! endif
85! endif
86! endif
87! endif
88! endif
89! endif
90!endif
91
92
93# -----------------------------------------------------------------------------
94# Provide overridable defaults
95# -----------------------------------------------------------------------------
96
97# Default target mode is executable.
98!ifndef TARGET_MODE
99TARGET_MODE = EXE
100!endif
101
102# Default extension corresponds to the target mode.
103!ifndef TARGET_EXT
104! if "$(TARGET_MODE)" == "DLL"
105TARGET_EXT = $(EXT_DLL)
106! endif
107! if "$(TARGET_MODE)" == "SYS"
108TARGET_EXT = $(EXT_SYS)
109! endif
110! if "$(TARGET_MODE)" == "IFS"
111TARGET_EXT = $(EXT_IFS)
112! endif
113! if "$(TARGET_MODE)" == "VDD"
114TARGET_EXT = $(EXT_VDD)
115! endif
116! if "$(TARGET_MODE)" == "EXE"
117TARGET_EXT = $(EXT_EXE)
118! endif
119! if "$(TARGET_MODE)" == "LIB" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFSLIB"
120TARGET_EXT = $(EXT_LIB)
121! endif
122! if "$(TARGET_MODE)" == "EMPTY"
123TARGET_EXT = empty
124! endif
125! if "$(TARGET_MODE)" == "DEPEND"
126TARGET_EXT = depend
127! endif
128! if "$(TARGET_MODE)" == "TESTCASE"
129TARGET_EXT = testcase
130! endif
131! ifndef TARGET_EXT
132! ifndef MAKEVER
133! if [$(ECHO) $(CLRERR)Internal Error: TARGET_EXT not set. Probably invalid TARGET_MODE. (TARGET_MODE="$(TARGET_MODE)")$(CLRRST)]
134! endif
135! error
136! else
137! error $(CLRERR)Internal Error: TARGET_EXT not set. Probably invalid TARGET_MODE. (TARGET_MODE="$(TARGET_MODE)")$(CLRRST)
138! endif
139! endif
140!endif
141
142# Default target path. (where all the generated stuff for this target goes)
143!ifndef PATH_TARGET
144PATH_TARGET = $(PATH_OBJ)\$(TARGET_NAME).$(TARGET_EXT)
145!endif
146
147# Default target file. (output)
148!ifndef TARGET
149! if "$(TARGET_MODE)" != "EMPTY"
150! if "$(TARGET_MODE)" != "TESTCASE"
151TARGET = $(PATH_TARGET)\$(TARGET_NAME).$(TARGET_EXT)
152! else
153TARGET = testcase
154! endif
155! endif
156!endif
157
158# Default target .sym file. (output)
159!ifndef TARGET_SYM
160TARGET_SYM = $(PATH_TARGET)\$(TARGET_NAME).$(EXT_SYM)
161!endif
162
163# Default object file. (output)
164!ifndef TARGET_OBJS
165TARGET_OBJS = $(PATH_TARGET)\$(TARGET_NAME).$(EXT_OBJ)
166!endif
167
168# Default libraries. (input)
169!ifndef TARGET_LIBS
170TARGET_LIBS = $(LIB_C_DLL) $(LIB_OS) $(LIB_C_RTDLL)
171!endif
172
173# Default definition file. (input)
174!ifndef TARGET_DEF
175TARGET_DEF = $(MAKEDIR)\$(PATH_DEF)\$(TARGET_NAME).def
176!endif
177
178# Default modified definition filename. (output)
179!ifndef TARGET_DEF_LINK
180TARGET_DEF_LINK = $(PATH_TARGET)\$(TARGET_NAME)_link.def
181!endif
182
183# Default definition file for generating the import library. (input)
184!ifndef TARGET_IDEF
185TARGET_IDEF = $(TARGET_DEF)
186!endif
187
188# Default map file. (output)
189!ifndef TARGET_MAP
190TARGET_MAP = $(PATH_TARGET)\$(TARGET_NAME).$(EXT_MAP)
191!endif
192
193# Default link file. (output)
194!ifndef TARGET_LNK
195TARGET_LNK = $(PATH_TARGET)\$(TARGET_NAME).lnk
196!endif
197
198# Default import library file. (output)
199!ifndef TARGET_ILIB
200! if "$(TARGET_MODE)" == "DLL"
201TARGET_ILIB =$(PATH_LIB)\$(TARGET_NAME).$(EXT_ILIB)
202! endif
203!endif
204
205# Default public name. (output)
206!ifndef TARGET_PUBNAME
207TARGET_PUBNAME=
208! ifdef TARGET_PUBLIC
209! if "$(TARGET_MODE)" == "LIB" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFSLIB"
210TARGET_PUBNAME=$(PATH_LIB)\$(TARGET_NAME).$(TARGET_EXT)
211! endif
212! if "$(TARGET_MODE)" == "EXE"
213TARGET_PUBNAME=$(PATH_EXE)\$(TARGET_NAME).$(TARGET_EXT)
214! endif
215! if "$(TARGET_MODE)" == "DLL"
216TARGET_PUBNAME=$(PATH_DLL)\$(TARGET_NAME).$(TARGET_EXT)
217! endif
218! if "$(TARGET_MODE)" == "SYS" || "$(TARGET_MODE)" == "IFS"
219TARGET_PUBNAME=$(PATH_SYS)\$(TARGET_NAME).$(TARGET_EXT)
220! endif
221! if "$(TARGET_MODE)" == "VDD"
222TARGET_PUBNAME=$(PATH_VDD)\$(TARGET_NAME).$(TARGET_EXT)
223! endif
224! endif
225!endif
226
227# Default depend filename.
228!ifndef TARGET_DEPEND
229TARGET_DEPEND = $(PATH_TARGET)\.depend
230!endif
231
232# Default makefile names.
233!ifndef BUILD_MAKEFILE
234BUILD_MAKEFILE = Makefile
235!endif
236
237# Default makefile name.
238!ifndef MAKEFILE
239MAKEFILE = $(BUILD_MAKEFILE)
240!endif
241
242# Ignore linker warnings for some target modes.
243!ifndef TARGET_IGNORE_LINKER_WARNINGS
244! if "$(TARGET_MODE)" == "DLL"
245TARGET_IGNORE_LINKER_WARNINGS = 1
246! endif
247!endif
248
249
250# Default stacksize
251# If 16bit: 8KB
252# Else (32bit): 64KB
253!ifndef TARGET_STACKSIZE
254! ifdef ENV_16BIT
255TARGET_STACKSIZE=0x2000
256! else
257TARGET_STACKSIZE=0x10000
258! endif
259!endif
260
261
262
263# -----------------------------------------------------------------------------
264# Tell user what we're building.
265# -----------------------------------------------------------------------------
266!ifndef BUILD_QUIET
267! ifndef MAKEVER
268! if [$(ECHO) Target is $(CLRFIL)$(TARGET)$(CLRRST)]
269! endif
270! else
271$(ECHO) Target is $(CLRFIL)$(TARGET)$(CLRRST)
272! endif
273!endif
274
275
276# -----------------------------------------------------------------------------
277# Ensure the platform-specific target path exists
278# -----------------------------------------------------------------------------
279
280!if "$(TARGET_MODE)" != "EMPTY"
281! if "$(PATH_TARGET)" != ""
282! ifndef MAKEVER
283! if [$(TOOL_EXISTS) $(PATH_TARGET)] != 0
284! ifndef BUILD_QUIET
285! if [$(ECHO) Target path $(CLRFIL)$(PATH_TARGET)$(CLRTXT) does NOT exist. Creating. $(CLRRST)]
286! endif
287! endif
288! if [$(TOOL_CREATEPATH) $(PATH_TARGET)]
289! if [$(ECHO) $(CLRERR)Error: Could not create $(CLRFIL)$(PATH_TARGET)$(CLRRST)]
290! endif
291! error
292! endif
293! endif
294! else
295! if %exist($(PATH_TARGET)) == 0
296! ifndef BUILD_QUIET
297$(ECHO) Target path $(CLRFIL)$(PATH_TARGET)$(CLRTXT) does NOT exist. Creating. $(CLRRST)
298! endif
299! else
300! if [$(TOOL_CREATEPATH) $(PATH_TARGET)]
301! error $(CLRERR)Error: Could not create $(CLRFIL)$(PATH_TARGET)$(CLRRST)
302! endif
303! endif
304! endif
305! endif
306!endif
307# not 100% sure about the != EMPTY stuff, but this is way faster.
308
309
310
311# -----------------------------------------------------------------------------
312# Common inference rules
313# -----------------------------------------------------------------------------
314.SUFFIXES:
315.SUFFIXES: .c .cpp .asm .$(EXT_OBJ) .$(EXT_RES) .rc .ii .s
316
317#
318# A workaround for SlickEdits inability to find the buggy files..
319# This makes the source filenames in the error listing have full path.
320# See setup.mak for compile command line.
321#
322_SRC = $<
323!ifdef SLKRUNS
324_SRC = $(PATH_CURRENT)\$<
325!endif
326
327
328# Assembling assembly source.
329.asm{$(PATH_TARGET)}.$(EXT_OBJ):
330 @$(ECHO) Assembling $(CLRFIL)$(_SRC) $(CLRTXT)$(TOOL_JOB_SUB_MSG) $(CLRRST)
331 \
332! ifndef BUILD_VERBOSE
333 @ \
334! endif
335!if "$(TARGET_MODE)" == "SYS" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFS" || "$(TARGET_MODE)" == "IFSLIB"
336 $(TOOL_JOB_SUB) $(AS) $(AS_FLAGS_SYS) $(_SRC) $(AS_OBJ_OUT)$@
337!else
338 $(TOOL_JOB_SUB) $(AS) $(AS_FLAGS) $(_SRC) $(AS_OBJ_OUT)$@
339!endif
340
341.asm.$(EXT_OBJ):
342 @$(ECHO) Assembling $(CLRFIL)$(_SRC) $(CLRRST)
343 \
344!ifndef BUILD_VERBOSE
345 @ \
346!endif
347!if "$(TARGET_MODE)" == "SYS" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFS" || "$(TARGET_MODE)" == "IFSLIB"
348 $(AS) $(AS_FLAGS_SYS) $(_SRC) $(AS_OBJ_OUT)$(PATH_TARGET)\$(@F)
349!else
350 $(AS) $(AS_FLAGS) $(_SRC) $(AS_OBJ_OUT)$(PATH_TARGET)\$(@F)
351!endif
352
353# C++ Compiler base line
354_CXX_BASELINE = $(CXX) \
355!if "$(TARGET_MODE)" == "EXE" || "$(TARGET_MODE)" == "LIB"
356 $(CXX_FLAGS_EXE) \
357!endif
358!if "$(TARGET_MODE)" == "DLL"
359 $(CXX_FLAGS_DLL) \
360!endif
361!if "$(TARGET_MODE)" == "SYS" || "$(TARGET_MODE)" == "SYSLIB"
362 $(CXX_FLAGS_SYS) \
363!endif
364!if "$(TARGET_MODE)" == "IFS" || "$(TARGET_MODE)" == "IFSLIB"
365 $(CXX_FLAGS_IFS) \
366!endif
367
368# Compiling C++ source.
369.cpp{$(PATH_TARGET)}.$(EXT_OBJ):
370 @$(ECHO) C++ Compiler $(CLRFIL)$(_SRC) $(CLRTXT)$(TOOL_JOB_SUB_MSG) $(CLRRST)
371 \
372!ifndef BUILD_VERBOSE
373 @ \
374!endif
375 $(TOOL_JOB_SUB) $(_CXX_BASELINE) \
376!if "$(CXX_LST_OUT)" != ""
377 $(CXX_LST_OUT)$(PATH_TARGET)\$(@B).s \
378!endif
379 $(CXX_OBJ_OUT)$@ $(_SRC)
380
381.cpp.$(EXT_OBJ):
382 @$(ECHO) C++ Compiler $(CLRFIL)$(_SRC) $(CLRRST)
383 \
384!ifndef BUILD_VERBOSE
385 @ \
386!endif
387 $(_CXX_BASELINE) \
388!if "$(CXX_LST_OUT)" != ""
389 $(CXX_LST_OUT)$(PATH_TARGET)\$(@B).s \
390!endif
391 $(CXX_OBJ_OUT)$(PATH_TARGET)\$(@F) $(_SRC)
392
393
394# Pre-Compiling C++ source.
395.cpp.ii:
396 @$(ECHO) C++ Compiler $(CLRFIL)$(_SRC) $(CLRRST)
397 \
398!ifndef BUILD_VERBOSE
399 @ \
400!endif
401 $(_CXX_BASELINE) \
402 $(CXX_PC_2_STDOUT) $(_SRC) > $@
403
404
405# Compiler C++ source to assembly.
406!if "$(CXX_AS_2_FILE)" != ""
407.cpp.s:
408 @$(ECHO) C++ To Assembly $(CLRFIL)$(_SRC) $(CLRRST)
409 \
410!ifndef BUILD_VERBOSE
411 @ \
412!endif
413 $(_CXX_BASELINE) \
414 $(CXX_AS_2_FILE)$@ $(_SRC)
415!endif
416
417
418
419# C Compiler base line
420_CC_BASELINE = $(CC) \
421!if "$(TARGET_MODE)" == "EXE" || "$(TARGET_MODE)" == "LIB"
422 $(CC_FLAGS_EXE) \
423!endif
424!if "$(TARGET_MODE)" == "DLL"
425 $(CC_FLAGS_DLL) \
426!endif
427!if "$(TARGET_MODE)" == "SYS" || "$(TARGET_MODE)" == "SYSLIB"
428 $(CC_FLAGS_SYS) \
429!endif
430!if "$(TARGET_MODE)" == "IFS" || "$(TARGET_MODE)" == "IFSLIB"
431 $(CC_FLAGS_IFS) \
432!endif
433
434# Compiling C source.
435.c{$(PATH_TARGET)}.$(EXT_OBJ):
436 @$(ECHO) C Compiler $(CLRFIL)$(_SRC) $(CLRTXT)$(TOOL_JOB_SUB_MSG) $(CLRRST)
437 \
438!ifndef BUILD_VERBOSE
439 @ \
440!endif
441 $(TOOL_JOB_SUB) $(_CC_BASELINE) \
442!if "$(CC_LST_OUT)" != ""
443 $(CC_LST_OUT)$(PATH_TARGET)\$(@B).s \
444!endif
445 $(CC_OBJ_OUT)$@ $(_SRC)
446
447.c.$(EXT_OBJ):
448 @$(ECHO) C Compiler $(CLRFIL)$(_SRC) $(CLRRST)
449 \
450!ifndef BUILD_VERBOSE
451 @ \
452!endif
453 $(_CC_BASELINE) \
454!if "$(CC_LST_OUT)" != ""
455 $(CC_LST_OUT)$(PATH_TARGET)\$(@B).s \
456!endif
457 $(CC_OBJ_OUT)$(PATH_TARGET)\$(@F) $(_SRC)
458
459
460# Pre-Compiling C source.
461.c.ii:
462 @$(ECHO) C PreCompiler $(CLRFIL)$(_SRC) $(CLRRST)
463 \
464!ifndef BUILD_VERBOSE
465 @ \
466!endif
467 $(_CC_BASELINE) \
468 $(CC_PC_2_STDOUT) $(_SRC) > $@
469
470
471# Compiler C source to assembly.
472!if "$(CC_AS_2_FILE)" != ""
473.c.s:
474 @$(ECHO) C To Assembly $(CLRFIL)$(_SRC) $(CLRRST)
475 \
476!ifndef BUILD_VERBOSE
477 @ \
478!endif
479 $(_CC_BASELINE) \
480 $(CC_AS_2_FILE)$@ $(_SRC)
481!endif
482
483
484# Compiling resources.
485.rc{$(PATH_TARGET)}.res:
486 @$(ECHO) RC Compiler $(CLRFIL)$(_SRC) $(CLRTXT)$(TOOL_JOB_SUB_MSG)$(CLRRST)
487 \
488!ifndef BUILD_VERBOSE
489 @ \
490!endif
491 $(TOOL_JOB_SUB) $(RC) $(RC_FLAGS) $(_SRC) $@
492
493.rc.res:
494 @$(ECHO) RC Compiler $(CLRFIL)$(_SRC) $(CLRRST)
495 \
496!ifndef BUILD_VERBOSE
497 @ \
498!endif
499 $(RC) $(RC_FLAGS) $(_SRC) $(PATH_TARGET)\$(@F)
500
501
502
503
504
505# -----------------------------------------------------------------------------
506# The all rule - The default one, as it's the first rule in the file.
507# -----------------------------------------------------------------------------
508all: build
509
510
511
512# -----------------------------------------------------------------------------
513# The build rule - Build the target.
514# Must take into account any subdirectories and makefiles which is is to be
515# made before and after the target. That makes it kind of messy, sorry.
516# -----------------------------------------------------------------------------
517!ifdef SUBDIRS
518SUBDIRS_BUILD = subbuild
519$(SUBDIRS_BUILD):
520 @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) build
521!endif
522
523!ifdef PREMAKEFILES
524PREMAKEFILES_BUILD = premakefiles_build
525$(PREMAKEFILES_BUILD):
526 @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) build
527!endif
528
529build: $(SUBDIRS_BUILD) $(PREMAKEFILES_BUILD) $(TARGET) $(TARGET_ILIB) $(TARGET_PUBNAME)
530 @$(ECHO) Successfully Built $(CLRFIL)$(TARGET) $(TARGET_ILIB)$(CLRRST)
531!ifdef POSTMAKEFILES
532 @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) $@
533!endif
534
535
536
537# -----------------------------------------------------------------------------
538# The lib rule - Make Public libraries.
539# Must take into account any subdirectories and makefiles which is is to be
540# made before and after the target. That makes it kind of messy, sorry.
541# -----------------------------------------------------------------------------
542!ifdef SUBDIRS
543SUBDIRS_LIB = subdir_lib
544$(SUBDIRS_LIB):
545 @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) lib
546!endif
547
548!ifdef PREMAKEFILES
549PREMAKEFILES_LIB = premakefiles_lib
550$(PREMAKEFILES_LIB):
551 @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) lib
552!endif
553
554!if "$(TARGET_PUBLIC_PART)" != "" && ("$(TARGET_MODE)" == "LIB" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFSLIB")
555lib: $(SUBDIRS_LIB) $(TARGET_ILIB) $(TARGET) $(TARGET_PUBNAME)
556!else
557lib: $(SUBDIRS_LIB) $(TARGET_ILIB)
558!endif
559!ifdef POSTMAKEFILES
560 @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) $@
561!endif
562
563
564
565# -----------------------------------------------------------------------------
566# The install rule - Copies target to main binary directory.
567# Installation order is not concidered vital, so subdirectories and
568# pre-makefiles are processed after this directory. This might be changed.
569# -----------------------------------------------------------------------------
570install:
571!if "$(TARGET_PUBLIC)" == ""
572! if "$(TARGET_MODE)" == "EXE"
573 @$(ECHO) Installing $(CLRFIL)$(TARGET)$(CLRTXT) in directory $(CLRFIL)$(PATH_BIN)$(CLRRST)
574 @if not exist $(TARGET) $(ECHO) $(CLRERR)WARNING: $(CLRFIL)$(TARGET)$(CLRERR) doesn't exist. $(CLRRST)
575 @if not exist $(PATH_BIN) $(TOOL_CREATEPATH) $(PATH_BIN)
576 @if exist $(TARGET) $(TOOL_COPY) $(TARGET) $(PATH_BIN)
577 @if exist $(TARGET_SYM) $(TOOL_COPY) $(TARGET_SYM) $(PATH_BIN)
578! endif
579! if "$(TARGET_MODE)" == "DLL"
580 @$(ECHO) Installing $(CLRFIL)$(TARGET)$(CLRTXT) in directory $(CLRFIL)$(PATH_DLL)$(CLRRST)
581 @if not exist $(TARGET) $(ECHO) $(CLRERR)WARNING: $(CLRFIL)$(TARGET)$(CLRERR) doesn't exist. $(CLRRST)
582 @if not exist $(PATH_DLL) $(TOOL_CREATEPATH) $(PATH_DLL)
583 @if exist $(TARGET) $(TOOL_COPY) $(TARGET) $(PATH_DLL)
584 @if exist $(TARGET_SYM) $(TOOL_COPY) $(TARGET_SYM) $(PATH_DLL)
585! endif
586! if "$(TARGET_MODE)" == "SYS" || "$(TARGET_MODE)" == "IFS"
587 @$(ECHO) Installing $(CLRFIL)$(TARGET)$(CLRTXT) in directory $(CLRFIL)$(PATH_SYS)$(CLRRST)
588 @if not exist $(TARGET) $(ECHO) $(CLRERR)WARNING: $(CLRFIL)$(TARGET)$(CLRERR) doesn't exist. $(CLRRST)
589 @if not exist $(PATH_SYS) $(TOOL_CREATEPATH) $(PATH_SYS)
590 @if exist $(TARGET) $(TOOL_COPY) $(TARGET) $(PATH_SYS)
591 @if exist $(TARGET_SYM) $(TOOL_COPY) $(TARGET_SYM) $(PATH_SYS)
592! endif
593!if 0 # these targets are either TARGET_PUBLIC or all private.
594! if "$(TARGET_MODE)" == "LIB" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFSLIB"
595 @$(ECHO) Installing $(CLRFIL)$(TARGET)$(CLRTXT) in directory $(CLRFIL)$(PATH_LIB)$(CLRRST)
596 @if not exist $(TARGET) $(ECHO) $(CLRERR)WARNING: $(CLRFIL)$(TARGET)$(CLRERR) doesn't exist. $(CLRRST)
597 @if not exist $(PATH_LIB) $(TOOL_CREATEPATH) $(PATH_LIB)
598 @if exist $(TARGET) $(TOOL_COPY) $(TARGET) $(PATH_LIB)
599 @if exist $(TARGET_SYM) $(TOOL_COPY) $(TARGET_SYM) $(PATH_LIB)
600! endif
601! endif
602!endif
603!if "$(TARGET_DOCS)" != ""
604 $(TOOL_COPY) $(TARGET_DOCS) $(PATH_DOC)
605!endif
606!ifdef SUBDIRS
607 @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) $@
608!endif
609!ifdef PREMAKEFILES
610 @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) $@
611!endif
612!ifdef POSTMAKEFILES
613 @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) $@
614!endif
615
616
617
618!if "$(TARGET_MODE)" != "TESTCASE"
619!ifndef BUILD_OWN_TESTCASE_RULE
620!ifndef MAKEVER
621_TESTCASE_TST1 = [$(TOOL_EXISTS) testcase] == 0
622_TESTCASE_TST2 = [$(TOOL_EXISTS) testcase.mak] == 0
623!else
624_TESTCASE_TST1 = exists(testcase) != 0
625_TESTCASE_TST2 = exists(testcase.mak) != 0
626!endif
627# -----------------------------------------------------------------------------
628# The testcase rule - Execute testcases when present.
629# Testcases are either a testcase.mak file or a testcase subdirectory.
630# -----------------------------------------------------------------------------
631testcase:
632!if $(_TESTCASE_TST1)
633 @$(TOOL_DODIRS) "testcase" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) $@
634!endif
635!if $(_TESTCASE_TST2)
636 @$(TOOL_DOMAKES) "testcase.mak" $(TOOL_MAKE) $@
637!endif
638!ifdef SUBDIRS
639 @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) $@
640!endif
641!ifdef PREMAKEFILES
642 @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) $@
643!endif
644!ifdef POSTMAKEFILES
645 @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) $@
646!endif
647!endif
648!endif #!TESTCASE
649
650
651
652# -----------------------------------------------------------------------------
653# The shell rule - Setup the correcte shell environment and start a shell.
654# -----------------------------------------------------------------------------
655shell:
656 \
657!ifndef BUILD_VERBOSE
658 @ \
659!endif
660 -$(TOOL_BUILDENV) $(BUILD_ENVS_BASE_PRE) $(BUILD_ENVS_PRE) $(ENV_ENVS) \
661 $(BUILD_ENVS_BASE_POST) $(BUILD_ENVS_POST) * $(COMSPEC)
662
663
664
665# -----------------------------------------------------------------------------
666# The dep rule - Make dependencies.
667# -----------------------------------------------------------------------------
668dep:
669 @$(ECHO) Building dependencies $(CLRRST)
670 \
671!ifndef BUILD_VERBOSE
672 @ \
673!endif
674!if "$(TARGET_MODE)" != "EMPTY" && "$(TARGET_MODE)" != "TESTCASE"
675 $(TOOL_DEP) $(TOOL_DEP_FLAGS) -o$$(PATH_TARGET) -d$(TARGET_DEPEND)\
676! ifdef TARGET_NO_DEP
677 -x$(TARGET_NO_DEP: =;)\
678! endif
679 $(TOOL_DEP_FILES)
680!endif
681!ifdef SUBDIRS
682 @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) NODEP=1 $@
683!endif
684!ifdef PREMAKEFILES
685 @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
686!endif
687!ifdef POSTMAKEFILES
688 @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
689!endif
690
691
692
693# -----------------------------------------------------------------------------
694# The clean rule - Clean up output files.
695# The current setup doesn't clean the installed ones.
696# -----------------------------------------------------------------------------
697!if "$(TARGET_MODE)" != "TESTCASE"
698clean:
699!if "$(PATH_TARGET)" != "" # paranoia
700 $(TOOL_RM) \
701 $(PATH_TARGET)\*.$(EXT_OBJ) \
702 $(PATH_TARGET)\*.$(EXT_ILIB) \
703 $(PATH_TARGET)\*.$(EXT_EXE) \
704 $(PATH_TARGET)\*.$(EXT_DLL) \
705 $(PATH_TARGET)\*.$(EXT_RES)
706 $(TOOL_RM) \
707 $(PATH_TARGET)\*.$(EXT_SYS) \
708 $(PATH_TARGET)\*.$(EXT_LIB) \
709 $(PATH_TARGET)\*.$(EXT_IFS) \
710 $(PATH_TARGET)\*.$(EXT_MAP) \
711 $(PATH_TARGET)\*.$(EXT_SYM)
712 $(TOOL_RM) \
713 $(PATH_TARGET)\*.s \
714 $(PATH_TARGET)\*.lst \
715 $(PATH_TARGET)\*.lnk \
716 $(PATH_TARGET)\*.ii \
717 $(PATH_TARGET)\.depend
718 $(TOOL_RM) \
719 .\*.ii \
720 .\*.err \
721 .\.depend
722!endif
723!ifdef SUBDIRS
724 @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) NODEP=1 $@
725!endif
726!ifdef PREMAKEFILES
727 @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
728!endif
729!ifdef POSTMAKEFILES
730 @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) NODEP=1 $@
731!endif
732!endif #!TESTCASE
733
734
735
736# -----------------------------------------------------------------------------
737# The nothing rule - Rule for testing the makefile structure.
738# -----------------------------------------------------------------------------
739nothing:
740!ifdef SUBDIRS
741 @$(TOOL_DODIRS) "$(SUBDIRS)" $(TOOL_MAKE) -f $(BUILD_MAKEFILE) $@
742!endif
743!ifdef PREMAKEFILES
744 @$(TOOL_DOMAKES) "$(PREMAKEFILES)" $(TOOL_MAKE) $@
745!endif
746!ifdef POSTMAKEFILES
747 @$(TOOL_DOMAKES) "$(POSTMAKEFILES)" $(TOOL_MAKE) $@
748!endif
749 @$(ECHO) Completed nothing in $(MAKEFILE).
750
751
752
753# -----------------------------------------------------------------------------
754# The $(TARGET) rule - For EXE, DLL, SYS and IFS targets
755# -----------------------------------------------------------------------------
756!if "$(TARGET_MODE)" == "EXE" || "$(TARGET_MODE)" == "DLL" || "$(TARGET_MODE)" == "SYS" || "$(TARGET_MODE)" == "IFS" || "$(TARGET_MODE)" == "VDD"
757$(TARGET): $(TARGET_OBJS) $(TARGET_RES) $(TARGET_DEF_LINK) $(TARGET_LNK) $(TARGET_DEPS)
758!if "$(TOOL_JOB_WAIT)" != ""
759! ifndef BUILD_QUIET
760 @$(ECHO) Waiting for jobs to complete $(CLRRST)
761! endif
762 \
763! ifndef BUILD_VERBOSE
764 @ \
765! endif
766 $(TOOL_JOB_WAIT)
767!endif
768 @$(ECHO) Linking $(TARGET_MODE) $(CLRFIL)$@ $(CLRRST)
769 \
770!ifndef BUILD_VERBOSE
771 @ \
772!endif
773!ifdef TARGET_IGNORE_LINKER_WARNINGS
774 -4 \
775!endif
776!if "$(TARGET_MODE)" == "EXE"
777 $(LINK_CMD_EXE)
778!endif
779!if "$(TARGET_MODE)" == "DLL"
780 $(LINK_CMD_DLL)
781!endif
782!if "$(TARGET_MODE)" == "SYS"
783 $(LINK_CMD_SYS)
784!endif
785!if "$(TARGET_MODE)" == "IFS"
786 $(LINK_CMD_IFS)
787!endif
788!if "$(TARGET_MODE)" == "VDD"
789 $(LINK_CMD_VDD)
790!endif
791!if "$(TARGET_RES)" != "" && "$(RL)" != ""
792 @$(ECHO) Linking Resources $(CLRRST)
793 \
794! ifndef BUILD_VERBOSE
795 @ \
796! endif
797 $(RL) $(RL_FLAGS) $(TARGET_RES) $@
798!endif
799!if "$(TARGET_DLLRNAME)" != ""
800 @$(ECHO) Dll Rename $(TARGET_DLLRNAME)
801 \
802! ifndef BUILD_VERBOSE
803 @ \
804! endif
805 $(TOOL_DLLRNAME) $(TARGET) $(TARGET_DLLRNAME)
806!endif
807!if "$(TOOL_MAPSYM)" != "" && "$(TARGET_SYM)" != "" && "$(TARGET_MAP)" != ""
808 \
809! ifndef BUILD_VERBOSE
810 @ \
811! endif
812 $(TOOL_MAPSYM) $(TARGET_MAP) $(TARGET_SYM)
813!endif
814
815
816#
817# Linker parameter file.
818#
819$(TARGET_LNK): $(MAKE_INCLUDE_PROCESS) $(MAKE_INCLUDE_SETUP) $(PATH_MAKE)\setup.mak $(MAKEFILE)
820!ifndef TOOL_DEFCONV
821 @$(TOOL_ECHO) Creating Linker Input File $(CLRRST)<<$@
822$(LINK_LNK1)
823$(LINK_LNK2)
824$(LINK_LNK3)
825$(LINK_LNK4)
826$(LINK_LNK5)
827<<KEEP
828!else
829 @$(ECHO) Creating Linker Input File $(CLRRST) $@
830 @$(TOOL_RM) $@
831 \
832! ifdef BUILD_VERBOSE
833 @ \
834! endif
835 $(TOOL_DEFCONV) $(TARGET_DEF_LINK) $@ <<$(TARGET_LNK)2
836#
837# LINK_LNK[1-5]:
838#
839$(LINK_LNK1)
840$(LINK_LNK2)
841$(LINK_LNK3)
842$(LINK_LNK4)
843$(LINK_LNK5)
844<<keep
845!endif
846!ifdef BUILD_VERBOSE
847 @type $@
848!endif
849
850
851#
852# Builddef modified definition file.
853#
854!if "$(TARGET_DEF_LINK)" != "$(TARGET_DEF)"
855$(TARGET_DEF_LINK): $(TARGET_DEF)
856! ifndef BUILD_QUIET
857 @$(ECHO) Stamping deffile with build level info.$(CLRRST)
858! endif
859 \
860! ifndef BUILD_VERBOSE
861 @ \
862! endif
863 $(TOOL_BLDLEVEL) $(BUILD_BLDLEVEL_FLAGS) $(TARGET_BLDLEVEL_FLAGS) -R$** $** $@
864!endif
865
866!endif
867
868
869# -----------------------------------------------------------------------------
870# The $(TARGET) rule - For LIB, SYSLIB, and IFSLIB targets.
871# -----------------------------------------------------------------------------
872!if "$(TARGET_MODE)" == "LIB" || "$(TARGET_MODE)" == "SYSLIB" || "$(TARGET_MODE)" == "IFSLIB"
873$(TARGET): $(TARGET_OBJS) $(TARGET_LNK) $(TARGET_DEPS)
874!if "$(TOOL_JOB_WAIT)" != ""
875! ifndef BUILD_QUIET
876 @$(ECHO) Waiting for jobs to complete $(CLRRST)
877! endif
878 \
879! ifndef BUILD_VERBOSE
880 @ \
881! endif
882 $(TOOL_JOB_WAIT)
883!endif
884 @$(ECHO) Creating Library $(CLRFIL)$@ $(CLRRST)
885!ifndef BUILD_VERBOSE
886 @$(TOOL_RM) $@
887 @$(AR_CMD)
888!else
889 $(TOOL_RM) $@
890 $(AR_CMD)
891!endif
892
893
894#
895# Lib parameter file.
896#
897$(TARGET_LNK): $(MAKE_INCLUDE_PROCESS) $(MAKE_INCLUDE_SETUP) $(PATH_MAKE)\setup.mak $(MAKEFILE)
898 @$(TOOL_ECHO) Creating Lib Input File $(CLRRST)<<$@
899$(AR_LNK1)
900$(AR_LNK2)
901$(AR_LNK3)
902$(AR_LNK4)
903$(AR_LNK5)
904<<KEEP
905!ifdef BUILD_VERBOSE
906 @type $@
907!endif
908!endif
909
910
911#
912# Copy rule for public targets.
913#
914!if "$(TARGET_PUBNAME)" != ""
915$(TARGET_PUBNAME): $(TARGET)
916 @$(ECHO) Copying $(CLRFIL)$(TARGET)$(CLRTXT) to $(CLRFIL)$(@D)$(CLRRST)
917 \
918!ifndef BUILD_VERBOSE
919 @if not exist $(@D) $(ECHO) Target public path $(CLRFIL)$(@D)$(CLRTXT) does NOT exist. Creating. $(CLRRST)
920!endif
921 @if not exist $(@D) $(TOOL_CREATEPATH) $(@D)
922 \
923!ifndef BUILD_VERBOSE
924 @ \
925!endif
926 $(TOOL_COPY) $** $@
927 @if exist $(TARGET_SYM) $(TOOL_COPY) $(TARGET_SYM) $(@R).sym
928!endif
929
930
931
932# -----------------------------------------------------------------------------
933# The $(TARGET) rule - For EMPTY targets.
934# -----------------------------------------------------------------------------
935# this doesn't work as we don't have a target name. Hence not needed.
936#!if "$(TARGET_MODE)" == "EMPTY"
937#$(TARGET):
938# @$(ECHO) .
939#!endif
940!if "$(TARGET_MODE)" == "DEPEND"
941$(TARGET):
942 @$(ECHO) .
943!endif
944
945
946
947# -----------------------------------------------------------------------------
948# The $(TARGET_ILIB) rule - Make import library.
949# -----------------------------------------------------------------------------
950!ifdef TARGET_ILIB
951$(TARGET_ILIB): $(TARGET_IDEF)
952 @$(ECHO) Creating Import Library $(CLRFIL)$@ $(CLRRST)
953 \
954!ifndef BUILD_VERBOSE
955 @ \
956!endif
957 $(IMPLIB) $(IMPLIB_FLAGS) $@ $(TARGET_IDEF)
958!endif
959
960
961
962# -----------------------------------------------------------------------------
963# The .force rule - Force a remake of something everytime.
964# -----------------------------------------------------------------------------
965.force:
966!ifndef BUILD_VERBOSE
967 @$(ECHO) .
968!else
969 @$(ECHO) . (force) .
970!endif
971
972
973
974# -----------------------------------------------------------------------------
975# Read Dependencies.
976# -----------------------------------------------------------------------------
977!if "$(TARGET_MODE)" != "TESTCASE" && "$(TARGET_MODE)" != "DEPEND"
978!if "$(TARGET_MODE)" != "EMPTY" && "$(NODEP)" == ""
979
980#
981# Read dependency file for current directory
982#
983!ifndef MAKEVER
984! if [$(TOOL_EXISTS) $(TARGET_DEPEND)] == 0
985! ifdef BUILD_VERBOSE
986! if [$(ECHO) Including dependency $(CLRFIL)$(TARGET_DEPEND)$(CLRRST)]
987! endif
988! endif
989! include $(TARGET_DEPEND)
990! else
991! ifndef NODEP
992! if [$(ECHO) $(CLRERR)WARNING: Please make dependencies first. $(TARGET_DEPEND) is missing.$(CLRRST)]
993! endif
994! endif
995! endif
996!else
997! if %exists($(TARGET_DEPEND)) != 0
998! ifdef BUILD_VERBOSE
999$(ECHO) Including dependency $(CLRFIL)$(TARGET_DEPEND)$(CLRRST)
1000! endif
1001! include $(TARGET_DEPEND)
1002! else
1003! ifndef NODEP
1004$(ECHO) $(CLRERR)WARNING: Please make dependencies first. $(TARGET_DEPEND) is missing.$(CLRRST)
1005! endif
1006! endif
1007!endif
1008
1009
1010#
1011# Read global dependency files.
1012#
1013!ifdef BUILD_DEPEND1
1014! ifndef MAKEVER
1015! if [$(TOOL_EXISTS) $(BUILD_DEPEND1)] == 0
1016! ifdef BUILD_VERBOSE
1017! if [$(ECHO) Including dependency $(CLRFIL)$(BUILD_DEPEND1)$(CLRRST)]
1018! endif
1019! endif
1020! include $(BUILD_DEPEND1)
1021! else
1022! ifndef NODEP
1023! if [$(ECHO) $(CLRERR)WARNING: Please make dependencies first. $(BUILD_DEPEND1) is missing.$(CLRRST)]
1024! endif
1025! endif
1026! endif
1027! else
1028! if %exists($(BUILD_DEPEND1)) != 0
1029! ifdef BUILD_VERBOSE
1030$(ECHO) Including dependency $(CLRFIL)$(BUILD_DEPEND1)$(CLRRST)
1031! endif
1032! include $(BUILD_DEPEND1)
1033! else
1034! ifndef NODEP
1035$(ECHO) $(CLRERR)WARNING: Please make dependencies first. $(BUILD_DEPEND1) is missing.$(CLRRST)
1036! endif
1037! endif
1038! endif
1039!endif
1040
1041
1042!ifdef BUILD_DEPEND2
1043! ifndef MAKEVER
1044! if [$(TOOL_EXISTS) $(BUILD_DEPEND2)] == 0
1045! ifdef BUILD_VERBOSE
1046! if [$(ECHO) Including dependency $(CLRFIL)$(BUILD_DEPEND2)$(CLRRST)]
1047! endif
1048! endif
1049! include $(BUILD_DEPEND2)
1050! else
1051! ifndef NODEP
1052! if [$(ECHO) $(CLRERR)WARNING: Please make dependencies first. $(BUILD_DEPEND2) is missing.$(CLRRST)]
1053! endif
1054! endif
1055! endif
1056! else
1057! if %exists($(BUILD_DEPEND2)) != 0
1058! ifdef BUILD_VERBOSE
1059$(ECHO) Including dependency $(CLRFIL)$(BUILD_DEPEND2)$(CLRRST)
1060! endif
1061! include $(BUILD_DEPEND2)
1062! else
1063! ifndef NODEP
1064$(ECHO) $(CLRERR)WARNING: Please make dependencies first. $(BUILD_DEPEND2) is missing.$(CLRRST)
1065! endif
1066! endif
1067! endif
1068!endif
1069
1070
1071!ifdef BUILD_DEPEND3
1072! ifndef MAKEVER
1073! if [$(TOOL_EXISTS) $(BUILD_DEPEND3)] == 0
1074! ifdef BUILD_VERBOSE
1075! if [$(ECHO) Including dependency $(CLRFIL)$(BUILD_DEPEND3)$(CLRRST)]
1076! endif
1077! endif
1078! include $(BUILD_DEPEND3)
1079! else
1080! ifndef NODEP
1081! if [$(ECHO) $(CLRERR)WARNING: Please make dependencies first. $(BUILD_DEPEND3) is missing.$(CLRRST)]
1082! endif
1083! endif
1084! endif
1085! else
1086! if %exists($(BUILD_DEPEND3)) != 0
1087! ifdef BUILD_VERBOSE
1088$(ECHO) Including dependency $(CLRFIL)$(BUILD_DEPEND3)$(CLRRST)
1089! endif
1090! include $(BUILD_DEPEND3)
1091! else
1092! ifndef NODEP
1093$(ECHO) $(CLRERR)WARNING: Please make dependencies first. $(BUILD_DEPEND3) is missing.$(CLRRST)
1094! endif
1095! endif
1096! endif
1097!endif
1098
1099
1100!endif
1101
1102
1103#
1104# If BUILD_MULTIJOBS is nonempty make sure the job daemon is up running.
1105#
1106!if "$(BUILD_MULTIJOBS)" != ""
1107! if [$(TOOL_JOB_UP)] != 0
1108! if "$(BUILD_QUITE)" == ""
1109! ifndef MAKEVER
1110! if [$(ECHO) Starting Job Daemon With $(TOOL_JOB_WORKERS) Workers...$(CLRRST)]
1111! endif
1112! else
1113$(ECHO) Starting Job Daemon With $(TOOL_JOB_WORKERS) Workers...$(CLRRST)
1114! endif
1115! endif
1116! if [$(TOOL_JOB_INIT) $(TOOL_JOB_WORKERS)] != 0
1117! ifndef MAKEVER
1118! if [$(ECHO) $(CLRERR)Fatal error: Failed to start job daemon.$(CLRRST)]
1119! endif
1120! error
1121!else
1122! error $(CLRERR)Fatal error: Failed to start job daemon.$(CLRRST)
1123!endif
1124! endif
1125! endif
1126!endif
1127
1128!endif #!TESTCASE
Note: See TracBrowser for help on using the repository browser.