source: trunk/src/emx/common.smak@ 150

Last change on this file since 150 was 148, checked in by zap, 22 years ago

Moved .MODULE dependency out of ifdef .TSRC

  • Property cvs2svn:cvs-rev set to 1.4
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1# The common submakefile used for building all kinds of targets.
2
3ifdef .MODULE
4# If this is the first target in this module, add it to global variables
5ifeq ($(findstring $(.MODULE),$(MODULES)),)
6.PHONY: $(.MODULE)
7MODULES += $(.MODULE)
8ifdef .MDESC
9DO.HELP.MODULES += $(call ECHO, $(.MODULE) - $(.MDESC))$(NL)
10.MDESC :=
11endif # def .MDESC
12ifdef .MDEP
13$(.MODULE): $(.MDEP)
14.MDEP :=
15endif # def .MDEP
16endif # eq ($(findstring $(.MODULE),$(MODULES)),)
17endif # def .MODULE
18
19# Canonicalize target kind to the form objectformat-threadness{-profiling}
20ifneq ($(findstring aout,$(.TKIND)),)
21.tmp := aout
22else
23.tmp := omf
24endif # neq ($(findstring aout,$(.TKIND)),)
25ifneq ($(findstring prof,$(.TKIND)),)
26.tmp += prof
27endif # neq ($(findstring prof,$(.TKIND)),)
28.TKIND := $(.tmp)
29.TKIND.DIR := $(subst $(SPACE),-,$(.TKIND))/
30
31ifdef .TARGET
32
33# .TARG is same as .TARGET except that it has a st/ or mt/ prefix
34.TARG := $(.TKIND.DIR)$(.TARGET)
35
36ifdef .INSDIR
37DO.INSTALL += $(call CP,$.$(.TARG),$(INS)$(.INSDIR)$(.TARGET))$(NL)
38INSDIRS += $(INS)$(.INSDIR)
39endif # def .INSDIR
40
41# We know how to create dependency files for .c and .cpp files
42.tmp := $(strip $(filter %.c,$(.TSRC)) $(filter %.cpp,$(.TSRC)))
43ifdef .tmp
44# Read the dependency file
45-include $.$(.TKIND.DIR)dep-$(.TARGET).smak
46
47TARGDEPEND += $.$(.TKIND.DIR)dep-$(.TARGET).smak
48
49ifdef BUILD_DEPS
50# How to build the dependency file
51$.$(.TKIND.DIR)dep-$(.TARGET).smak: $(.tmp)
52 $(DO.DEPS)
53endif # BUILD_DEPS
54endif # def .tmp
55
56endif # def .TARGET
57
58# If module has any source files, find respective object file names
59# and directories where they will be built
60ifdef .TSRC
61
62.OBJS := $(addprefix $.,$(call OBJFILE,$(.TSRC)))
63.DIRS := $(sort $(dir $(.OBJS)))
64TARGDIRS += $(.DIRS)
65
66# Remove the names of files for which we already generated build rules
67# so that we won't generate same rule twice. In general this is not very
68# correct since two targets may want a object file compiled with different
69# options (e.g. .TCF) but we assume that the developer knows what's doing.
70ifndef BUILD.RULES
71# We need BUILD.RULES to be a expand-value-on-assignment type variable,
72# rather than expand-value-on-reference.
73BUILD.RULES :=
74endif
75.TSRC := $(filter-out $(BUILD.RULES),$(join $(addsuffix :,$(.OBJS)),$(.TSRC)))
76BUILD.RULES += $(.TSRC)
77.TSRC := $(filter-out $(.OBJS),$(subst :, ,$(.TSRC)))
78
79# Generate compilation rules for C files
80RULES += $(foreach x,$(filter %.c,$(.TSRC)),\
81 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
82 $(call FECHO,_@, $$(call DO.COMPILE.c,$(.TCF) $(.TCF.$x)))$(NL)\
83)
84
85# Generate compilation rules for S files
86RULES += $(foreach x,$(filter %.s,$(.TSRC)),\
87 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
88 $(call FECHO,_@, $$(call DO.COMPILE.s,$(.TSF) $(.TSF.$x)))$(NL)\
89)
90
91# Generate compilation rules for asm files
92RULES += $(foreach x,$(filter %.asm,$(.TSRC)),\
93 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
94 $(call FECHO,_@, $$(call DO.COMPILE.asm,$(.TAF) $(.TAF.$x)))$(NL)\
95)
96
97endif # def .TSRC
98
99ifdef .TARGET
100ifdef .MODULE
101$(.MODULE): $(.DIRS) $.$(.TARG)
102endif
103endif
104
105# Replace the special sequence in .TDEP @O@ with $.$(.TKIND.DIR)
106.DEPS := $(subst @O@,$.$(.TKIND.DIR),$(.TDEP))
Note: See TracBrowser for help on using the repository browser.