1 | # |
---|
2 | # Shared compiler for all GNU tools configurations |
---|
3 | # |
---|
4 | |
---|
5 | ## |
---|
6 | # CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V are the values we |
---|
7 | # would want the corresponding macros to be set to. |
---|
8 | # |
---|
9 | # CFLAGS_OPTIMIZE, CFLAGS_DEBUG are set in the leaf |
---|
10 | # Makefiles by the 'debug:' targets to their _V values. |
---|
11 | # |
---|
12 | |
---|
13 | # default flags |
---|
14 | # XCPPFLAGS, XCFLAGS, XCXXFLAGS, XASFLAGS |
---|
15 | # are used to add flags from the shell |
---|
16 | # cf. make.info ("Implicit rules/variables" for details) |
---|
17 | |
---|
18 | # NOTE: Should these go to CPPFLAGS ? |
---|
19 | CFLAGS_DEFAULT=-Wall |
---|
20 | |
---|
21 | # NOTE: CPU_CFLAGS should probably be renamed to CPU_CPPFLAGS |
---|
22 | # NOTE: CPU_DEFINES should probably be merged with CPU_CFLAGS |
---|
23 | CPPFLAGS += $(CPU_DEFINES) $(CPU_CFLAGS) $(DEFINES) $(XCPPFLAGS) |
---|
24 | CFLAGS = $(CFLAGS_DEFAULT) $(XCFLAGS) |
---|
25 | CXXFLAGS = $(CFLAGS_DEFAULT) $(XCXXFLAGS) |
---|
26 | ASFLAGS = $(CPU_ASFLAGS) $(XASFLAGS) |
---|
27 | |
---|
28 | # NOTE: GCCSPECS probably belongs to CPPFLAGS |
---|
29 | GCCSPECS_OPTIMIZE_V = |
---|
30 | GCCSPECS_DEBUG_V = |
---|
31 | |
---|
32 | GCCSPECS = -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems |
---|
33 | GCCSPECS += $(GCCSPECS_$(VARIANT_V)_V) |
---|
34 | |
---|
35 | CC += $(GCCSPECS) |
---|
36 | CXX += $(GCCSPECS) |
---|
37 | |
---|
38 | CPPFLAGS += |
---|
39 | |
---|
40 | # Define this to yes if C++ is included in the development environment. |
---|
41 | # This requires that at least the GNU C++ compiler and libg++ be installed. |
---|
42 | ifeq ($(HAS_CPLUSPLUS),yes) |
---|
43 | CPLUS_LD_LIBS += $(PROJECT_RELEASE)/lib/librtems++$(LIBSUFFIX_VA) |
---|
44 | endif |
---|
45 | |
---|
46 | # debug flag; |
---|
47 | CFLAGS_DEBUG_V ?= -O0 -g |
---|
48 | CXXFLAGS_DEBUG_V ?= $(CFLAGS_DEBUG_V) |
---|
49 | |
---|
50 | # when debugging, optimize flag: typically empty |
---|
51 | # some compilers do allow optimization with their "-g" |
---|
52 | CFLAGS_OPTIMIZE_V ?= -O2 -g |
---|
53 | CXXFLAGS_OPTIMIZE_V ?= $(CFLAGS_OPTIMIZE_V) |
---|
54 | |
---|
55 | ifndef AUTOMAKE |
---|
56 | CPPFLAGS_$(VARIANT)=$(CPPFLAGS_$(VARIANT)_V) |
---|
57 | CFLAGS_$(VARIANT) =$(CFLAGS_$(VARIANT)_V) |
---|
58 | CXXFLAGS_$(VARIANT)=$(CXXFLAGS_$(VARIANT)_V) |
---|
59 | endif |
---|
60 | |
---|
61 | ifndef AUTOMAKE |
---|
62 | CPPFLAGS += $(CPPFLAGS_OPTIMIZE) $(CPPFLAGS_DEBUG) |
---|
63 | CFLAGS += $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) |
---|
64 | CXXFLAGS += $(CXXFLAGS_OPTIMIZE) $(CXXFLAGS_DEBUG) |
---|
65 | endif |
---|
66 | |
---|
67 | # List of library paths without -L |
---|
68 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
69 | |
---|
70 | # ld flag for incomplete link |
---|
71 | LDFLAGS_INCOMPLETE = -r |
---|
72 | |
---|
73 | # LDFLAGS=$(LDFLAGS_DEBUG) $(LD_PATHS:%=-L%) |
---|
74 | LDFLAGS += $(LDFLAGS_DEBUG) |
---|
75 | |
---|
76 | # |
---|
77 | # Stuff to clean and clobber for the compiler and its tools |
---|
78 | # |
---|
79 | |
---|
80 | CLEAN_CC = a.out *.o *.BAK |
---|
81 | CLOBBER_CC = |
---|
82 | |
---|
83 | # |
---|
84 | # Client compiler and support tools |
---|
85 | # |
---|
86 | |
---|
87 | # CPP command to write file to standard output with warnings suppressed |
---|
88 | CPP=$(CC) -E -w |
---|
89 | |
---|
90 | # egrep regexp to ignore symbol table entries in ar archives. |
---|
91 | # Only used to make sure we skip them when coalescing libraries. |
---|
92 | # skip __.SYMDEF and empty names (maybe bug in ranlib??). |
---|
93 | AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT" |
---|
94 | ARFLAGS=ruv |
---|
95 | |
---|
96 | # |
---|
97 | # How to compile stuff into ${ARCH} subdirectory |
---|
98 | # |
---|
99 | |
---|
100 | ${ARCH}/%.o: %.c |
---|
101 | ${COMPILE.c} $(AM_CPPFLAGS) $(AM_CFLAGS) -o $@ $< |
---|
102 | |
---|
103 | ${ARCH}/%.o: %.cc |
---|
104 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
105 | |
---|
106 | ${ARCH}/%.o: %.cpp |
---|
107 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
108 | |
---|
109 | ${ARCH}/%.o: %.cxx |
---|
110 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
111 | |
---|
112 | ${ARCH}/%.o: %.C |
---|
113 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
114 | |
---|
115 | ${ARCH}/%.o: %.S |
---|
116 | ${COMPILE.S} $(AM_CPPFLAGS) -DASM -o $@ $< |
---|
117 | |
---|
118 | # Make foo.rel from foo.o |
---|
119 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
120 | ${make-rel} |
---|
121 | |
---|
122 | # create $(ARCH)/pgm from pgm.sh |
---|
123 | ${ARCH}/%: %.sh |
---|
124 | $(RM) $@ |
---|
125 | $(CP) $< $@ |
---|
126 | $(CHMOD) +x $@ |
---|
127 | |
---|
128 | # Dependency files for use by gmake |
---|
129 | # NOTE: we don't put them into $(ARCH) |
---|
130 | # so that 'make clean' doesn't blow it away |
---|
131 | |
---|
132 | DEPEND=Depends-${ARCH} |
---|
133 | |
---|
134 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
135 | CLOBBER_DEPEND=$(DEPEND) |
---|
136 | |
---|
137 | # We deliberately don't have anything depend on the |
---|
138 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
139 | # on 'make clean' |
---|
140 | # |
---|
141 | |
---|
142 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
143 | ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) |
---|
144 | # Use gcc -M to generate dependencies |
---|
145 | # Replace foo.o with $(ARCH)/foo.o |
---|
146 | # Replace $(ARCH) value with string $(ARCH) |
---|
147 | # so that it will for debug cases |
---|
148 | $(COMPILE.c) $(AM_CPPFLAGS) $(AM_CFLAGS) -M $^ | \ |
---|
149 | $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
150 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
151 | $(MV) $(DEPEND).tmp $(DEPEND) |
---|
152 | endif |
---|
153 | depend: depend-am |
---|
154 | |
---|
155 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
156 | # that $(LINK_FILES) can be a dependency |
---|
157 | |
---|
158 | # |
---|
159 | # NOTE: a rule to link an rtems' application should look similar to this |
---|
160 | # (cf. "make-exe" in make/custom/*.cfg): |
---|
161 | # |
---|
162 | # gcc28: |
---|
163 | # $(PGM): $(LINK_FILES) |
---|
164 | # $(CC) $(CFLAGS) -o $@ $(LINK_OBJS) $(LINK_LIBS) |
---|
165 | # |
---|
166 | |
---|
167 | LINK_OBJS =\ |
---|
168 | $(CONSTRUCTOR) \ |
---|
169 | $(OBJS) |
---|
170 | |
---|
171 | LINK_FILES =\ |
---|
172 | $(CONSTRUCTOR) \ |
---|
173 | $(OBJS) \ |
---|
174 | $(PROJECT_RELEASE)/lib/librtemsbsp$(LIBSUFFIX_VA) \ |
---|
175 | $(PROJECT_RELEASE)/lib/librtemscpu$(LIBSUFFIX_VA) |
---|
176 | |
---|
177 | LINK_LIBS += $(LD_LIBS) |
---|
178 | |
---|
179 | # |
---|
180 | # Allow user to override link commands (to build a prom image, perhaps) |
---|
181 | # |
---|
182 | ifndef LINKCMDS |
---|
183 | LINKCMDS=$(PROJECT_RELEASE)/lib/linkcmds |
---|
184 | endif |
---|
185 | |
---|
186 | define make-rel |
---|
187 | $(LINK.c) $(CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \ |
---|
188 | -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^ |
---|
189 | endef |
---|