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

Last change on this file since 103 was 94, checked in by zap, 22 years ago

This is the start of work on making EMX C runtime EMX-independent ;-)
The first signs of a GNU Make-based build system.
Fixed a lot of .s files to comply with new GAS syntax.
Added a lot of submakefiles for every sub-library.
Replaced EM's getopt.h with the one from libiberty (which supports
getopt_long). The old getopt.h has moved to include/emx, so if
some tool needs it (and you don't want to fix it to use the new getopt),
replace #include <getopt.h> with #include <emx/getopt.h>. Did so in
most EMX tools.

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 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 mt,$(.TKIND)),)
22.tmp += mt
23else
24.tmp += st
25endif # neq ($(findstring mt,$(.TKIND)),)
26ifneq ($(findstring prof,$(.TKIND)),)
27.tmp += prof
28endif # neq ($(findstring prof,$(.TKIND)),)
29.TKIND := $(.tmp)
30.TKIND.DIR := $(subst $(SPACE),-,$(.TKIND))/
31.tmp :=
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 += cp.exe $.$(.TARG) $(INS)$(.INSDIR)$(.TARGET)$(NL)
38INSDIRS += $(INS)$(.INSDIR)
39endif # def .INSDIR
40
41# If module has any source files, find respective object file names
42# and directories where they will be built
43ifdef .TSRC
44
45.OBJS := $(addprefix $.,$(call OBJFILE,$(.TSRC)))
46.DIRS := $(sort $(dir $(.OBJS)))
47TARGDIRS += $(.DIRS)
48
49$(.MODULE): $(.DIRS) $.$(.TARG)
50
51# Remove the names of files for which we already generated build rules
52# so that we won't generate same rule twice. In general this is not very
53# correct since two targets may want a object file compiled with different
54# options (e.g. .TCF) but we assume that the developer knows what's doing.
55ifndef BUILD.RULES
56# We need BUILD.RULES to be a expand-value-on-assignment type variable,
57# rather than expand-value-on-reference.
58BUILD.RULES :=
59endif
60.TSRC := $(filter-out $(BUILD.RULES),$(join $(addsuffix :,$(.OBJS)),$(.TSRC)))
61BUILD.RULES += $(.TSRC)
62.TSRC := $(filter-out $(.OBJS),$(subst :, ,$(.TSRC)))
63
64#.TSRC := $(foreach x,$(.TSRC),$(if $(findstring $(call OBJFILE,$x):$x,$(BUILD.RULES)),,$x))
65#BUILD.RULES += $(foreach x,$(.TSRC),$(if $(findstring $(call OBJFILE,$x):$x,$(BUILD.RULES)),,$(call OBJFILE,$x):$x))
66
67# Generate compilation rules for C files
68RULES += $(foreach x,$(filter %.c,$(.TSRC)),\
69 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
70 $(call FECHO,_@, $$(call DO.COMPILE.c,$(.TCF) $(.TCF.$x)))$(NL)\
71)
72
73# Generate compilation rules for S files
74RULES += $(foreach x,$(filter %.s,$(.TSRC)),\
75 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
76 $(call FECHO,_@, $$(call DO.COMPILE.s,$(.TSF) $(.TSF.$x)))$(NL)\
77)
78
79# Generate compilation rules for asm files
80RULES += $(foreach x,$(filter %.asm,$(.TSRC)),\
81 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
82 $(call FECHO,_@, $$(call DO.COMPILE.asm,$(.TAF) $(.TAF.$x)))$(NL)\
83)
84
85endif # def .TSRC
86
87# Replace the special sequence in .TDEP @O@ with $.$(.TKIND.DIR)
88.DEPS := $(subst @O@,$.$(.TKIND.DIR),$(.TDEP))
Note: See TracBrowser for help on using the repository browser.