source: trunk/make/process.mak@ 8768

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

No need for dependenices in TESTCASEes and EMPTY makefiles.

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