source: branches/libc-0.6/src/emx/common.smak@ 2515

Last change on this file since 2515 was 2011, checked in by bird, 20 years ago

Support .S files.

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