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

Last change on this file since 144 was 136, checked in by bird, 22 years ago

Modules isn't required to specify .TSRC targets.

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