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

Last change on this file since 1330 was 1157, checked in by bird, 22 years ago

Added logging facilities.

  • Property cvs2svn:cvs-rev set to 1.10
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 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)),)
28ifneq ($(findstring log,$(.TKIND)),)
29.tmp += log
30endif # neq ($(findstring log,$(.TKIND)),)
31.TKIND := $(.tmp)
32ifdef .TKVAR
33.TKIND.DIR := $(subst $(SPACE),-,$(.TKIND))/$(.TKVAR)/
34else
35.TKIND.DIR := $(subst $(SPACE),-,$(.TKIND))/
36endif
37.DIRS :=
38
39ifdef .TARGET
40
41# .TARG is same as .TARGET except that it has a st/ or mt/ prefix
42.TARG := $(.TKIND.DIR)$(.TARGET)
43.DIRS += $.$(.TKIND.DIR)
44
45ifdef .INSDIR
46ifndef .NOINST
47INS.FILES += $(INS)$(.INSDIR)$(.TARGET)
48$(INS)$(.INSDIR)$(.TARGET): $.$(.TARG)
49 $(call CP,$<,$@)
50endif
51endif # def .INSDIR
52
53# We know how to create dependency files for .c and .cpp files
54.tmp := $(strip $(filter %.c,$(.TSRC)) $(filter %.cpp,$(.TSRC)))
55ifdef .tmp
56# Read the dependency file
57-include $.$(.TKIND.DIR)dep-$(.TARGET).smak
58
59TARGDEPEND += $.$(.TKIND.DIR)dep-$(.TARGET).smak
60
61ifdef BUILD_DEPS
62# How to build the dependency file
63$.$(.TKIND.DIR)dep-$(.TARGET).smak: $(.tmp)
64 $(DO.DEPS)
65endif # BUILD_DEPS
66endif # def .tmp
67
68endif # def .TARGET
69
70# If module has any source files, find respective object file names
71# and directories where they will be built
72ifdef .TSRC
73
74.OBJS := $(addprefix $.,$(call OBJFILE,$(.TSRC)))
75.DIRS += $(sort $(dir $(.OBJS)))
76
77# Remove the names of files for which we already generated build rules
78# so that we won't generate same rule twice. In general this is not very
79# correct since two targets may want a object file compiled with different
80# options (e.g. .TCF) but we assume that the developer knows what's doing.
81ifndef BUILD.RULES
82# We need BUILD.RULES to be a expand-value-on-assignment type variable,
83# rather than expand-value-on-reference.
84BUILD.RULES :=
85endif
86.TSRC := $(filter-out $(BUILD.RULES),$(join $(addsuffix :,$(.OBJS)),$(.TSRC)))
87BUILD.RULES += $(.TSRC)
88.TSRC := $(filter-out $(.OBJS),$(subst :, ,$(.TSRC)))
89
90# Generate compilation rules for C files
91$(foreach x,$(filter %.c,$(.TSRC)), $(eval $(call def_compile_c,$(x))))
92
93# Generate compilation rules for S files
94$(foreach x,$(filter %.s,$(.TSRC)), $(eval $(call def_compile_S,$(x))))
95
96# Generate compilation rules for asm files
97$(foreach x,$(filter %.asm,$(.TSRC)), $(eval $(call def_compile_asm,$(x))))
98
99endif # def .TSRC
100
101# Add target directories to module dependencies and to overall list of dirs
102ifneq ($(.DIRS),)
103TARGDIRS += $(.DIRS)
104ifdef .MODULE
105$(.MODULE): $(.DIRS)
106endif # def .MODULE
107endif # neq ($(.DIRS),)
108
109# Add the target to the list of module dependencies
110ifdef .TARGET
111$(.MODULE): $.$(.TARG)
112endif # def .TARGET
113
114# Replace the special sequence in .TDEP @O@ with $.$(.TKIND.DIR)
115.DEPS := $(subst @O@,$.$(.TKIND.DIR),$(.TDEP))
Note: See TracBrowser for help on using the repository browser.