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

Last change on this file since 124 was 123, checked in by zap, 23 years ago

Started the work for re-designing the EMX C runtime library to not require
EMX.DLL. The new design is projected to be as follows:

  • all emx syscalls are replaced with the routines from the old sys.lib library which is now compilable in both a.out and OMF formats.
  • the sys.a library should be made replaceable and selectable by some gcc switch (e.g. -msyslib=emx would link with emx.a instead of sys.a which would give almost full backward compatibility with emx).
  • All C functions names were renamed to not contain the starting underscore (e.g. fopen and not _fopen). The underscored aliases will be added later with the c_alias library (which will be generated automatically from all public symbols of libc; any exported symbol that do not start with an underscore will be given an underscored alias unless such a symbol is already defined).

Also a lot of updates to the building system. It is now much faster (thanks
to Knut's suggestion of using ash's builtin echo).
Also re-wrote thunk1.asm and thunk2.asm to GAS format; this removes the need
for MASM and makes it possible to use 16-bit functions in a.out programs
without the need for EMX.DLL.
Also made a lot of small changes I don't remember now.

  • Property cvs2svn:cvs-rev set to 1.2
  • 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)
61
62ifdef .MDEP
63$(.MODULE): $(.MDEP)
64.MDEP :=
65endif
66
67ifdef .MODULE
68$(.MODULE): $(.DIRS) $.$(.TARG)
69endif
70
71# Remove the names of files for which we already generated build rules
72# so that we won't generate same rule twice. In general this is not very
73# correct since two targets may want a object file compiled with different
74# options (e.g. .TCF) but we assume that the developer knows what's doing.
75ifndef BUILD.RULES
76# We need BUILD.RULES to be a expand-value-on-assignment type variable,
77# rather than expand-value-on-reference.
78BUILD.RULES :=
79endif
80.TSRC := $(filter-out $(BUILD.RULES),$(join $(addsuffix :,$(.OBJS)),$(.TSRC)))
81BUILD.RULES += $(.TSRC)
82.TSRC := $(filter-out $(.OBJS),$(subst :, ,$(.TSRC)))
83
84# Generate compilation rules for C files
85RULES += $(foreach x,$(filter %.c,$(.TSRC)),\
86 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
87 $(call FECHO,_@, $$(call DO.COMPILE.c,$(.TCF) $(.TCF.$x)))$(NL)\
88)
89
90# Generate compilation rules for S files
91RULES += $(foreach x,$(filter %.s,$(.TSRC)),\
92 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
93 $(call FECHO,_@, $$(call DO.COMPILE.s,$(.TSF) $(.TSF.$x)))$(NL)\
94)
95
96# Generate compilation rules for asm files
97RULES += $(foreach x,$(filter %.asm,$(.TSRC)),\
98 $(call FECHO,_@,$$.$(call OBJFILE,$x): $x)$(NL)\
99 $(call FECHO,_@, $$(call DO.COMPILE.asm,$(.TAF) $(.TAF.$x)))$(NL)\
100)
101
102endif # def .TSRC
103
104# Replace the special sequence in .TDEP @O@ with $.$(.TKIND.DIR)
105.DEPS := $(subst @O@,$.$(.TKIND.DIR),$(.TDEP))
Note: See TracBrowser for help on using the repository browser.