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

Last change on this file since 1036 was 894, checked in by bird, 22 years ago

Converted to make 3.80+, no need to generate makefiles.

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