Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / athos / src / xtos / Makefile
1 # Makefile for XTOS in <xtensa_tools_root>/xtensa-elf/src/xtos
2
3 # Copyright (c) 2000-2007 by Tensilica Inc.  ALL RIGHTS RESERVED.
4 # These coded instructions, statements, and computer programs are the
5 # copyrighted works and confidential proprietary information of Tensilica Inc.
6 # They may not be modified, copied, reproduced, distributed, or disclosed to
7 # third parties in any manner, medium, or form, in whole or in part, without
8 # the prior written consent of Tensilica Inc.
9
10 #
11 #  This makefile assumes GNU make features
12 #
13 #  Invoke this Makefile like this:
14 #       cd <some build directory>
15 #       make -f <this file> \
16 #               MAKEFILE_SRC=<this file> \
17 #               XTENSA_TOOLS_ROOT=<path to Xtensa Tools> \
18 #               XTENSA_ROOT=<path to Xtensa core package> \
19 #               INSTLIBDIR=<path to installation directory>
20 #
21
22 ifndef XTENSA_TOOLS_ROOT
23 $(error Please set XTENSA_TOOLS_ROOT to the path to Xtensa Tools)
24 endif
25 #  NOTE:  For now, we assume $(XTENSA_TOOLS_ROOT)/bin is on the PATH.
26 ifndef XTENSA_ROOT
27 $(error Please set XTENSA_ROOT to the path to your specific Xtensa core package)
28 endif
29
30 #ifndef INSTLIBDIR
31 #$(error Please set INSTLIBDIR to the path where libraries and objects are installed)
32 #INSTLIBDIR = $(call fixpath,$(XTENSA_ROOT)/xtensa-elf/arch/lib)
33 #endif
34
35 #  Select the specified Xtensa configuration:
36 export XTENSA_SYSTEM = $(XTENSA_ROOT)/config
37 export XTENSA_CORE = default
38
39 include $(XTENSA_TOOLS_ROOT)/misc/defs.mk
40
41 ifndef SRCDIR
42 $(error Please set MAKEFILE_SRC to the path to the XTOS Makefile.src)
43 endif
44
45 #  Native commands like $(MKPATH) and $(CP) need native directory separators:
46 #fixpath = $(subst /,$S,$(1))
47
48 XTCC  = $(CC_FOR_TARGET)
49 XTAR  = xt-ar
50
51 .PHONY: all clean
52
53 # Compilation flags
54 ASFLAGS  = -O2 -g -mlongcalls
55 CFLAGS   = -O2 -g -mlongcalls
56
57 #  File splitting:
58 #  Compile "split" files in separate parts that can be linked independently.
59 #  This allows keeping multiple related functions/etc together in one file
60 #  without forcing linking of unused functions (the GNU linker takes entire
61 #  object files; it does not currently provide automated dead code removal).
62 #  Files are split with "#[el]if defined(__SPLIT__<tag>)" lines using normal
63 #  C preprocessor syntax, where each <tag> must be unique and consist of
64 #  lowercase alphanumeric and underscore characters only (no dash etc).
65 #  The makefile function $(split_objs ...) returns the set of objects that
66 #  result for a given list of splittable source files; each ends in a -.o
67 #  suffix recognized by special rules further below.
68 #
69 split_objs = $(shell cd $(SRCDIR) && $(PERL) -ne '/__SPLIT__(\w+)/ and $$h{$$ARGV."--".$$1}++;\
70  END {foreach (sort keys %h) {s/\.(.)--/-$$1--/; print "$$_-.o\n";}}' $(1))
71
72 #  Vectors, handlers, and other code to build:
73 PERLEVEL_INTVECTOR_OBJS  =   $(foreach N,2 3 4 5 6,int-vector-level$(N).o)
74 PERLEVEL_INTHANDLER_OBJS =   $(foreach N,2 3 4 5 6,int-handler-level$(N).o)
75 PERLEVEL_INTINITLEV_OBJS = $(foreach N,1 2 3 4 5 6,int-init-level$(N).o)
76 XTOS_COMMON_OBJS = \
77         reset-vector-unpack.o \
78         user-vector.o \
79         nmi-vector.o \
80         window-vectors.o \
81         reloc-vectors.o \
82         $(call split_objs, memerror-vector.S) \
83         $(PERLEVEL_INTVECTOR_OBJS) \
84         exc-alloca-handler.o \
85         exc-return.o \
86         exc-sethandler.o \
87         exc-syscall-handler.o \
88         exc-syscall-c-handler.o \
89         exc-table.o \
90         exit.o \
91         init.o \
92         int-lowpri-dispatcher.o \
93         int-sethandler.o \
94         intlevel-set.o \
95         intlevel-setmin.o \
96         intlevel-restore.o \
97         ints-on.o \
98         ints-off.o \
99         switch_context.o \
100         $(call split_objs, deprecated.S tiny-refs.S) \
101         $(PERLEVEL_INTHANDLER_OBJS) \
102         $(PERLEVEL_INTINITLEV_OBJS)
103 #  These objects have simulator and board variants:
104 XTOS_SIMBOARD_OBJS = \
105         debug-vector.o \
106         double-vector.o \
107         kernel-vector.o \
108         interrupt-table.o \
109         exc-unhandled.o \
110         exc-c-wrapper-handler.o \
111         memep-initrams.o \
112         memep-enable.o
113 XTOS_BOARD_OBJS = $(XTOS_SIMBOARD_OBJS)
114 XTOS_SIM_OBJS = $(XTOS_SIMBOARD_OBJS:.o=-sim.o)
115
116 #  Optimize a few things for size rather than speed:
117 #FLAGS_exc-syscall-handler = -Os --no-target-align
118
119 TARGETS = \
120         _vectors.o \
121         crt0-app.o \
122         crt1-boards.o \
123         crt1-tiny.o \
124         crt1-sim.o \
125         libhandlers-sim.a \
126         libhandlers-board.a \
127         libhandlers-min.a \
128         libhandlers-null.a \
129         libnomovsp.a \
130         libnosyscall.a \
131         libhandler-reset.a
132 ifdef TENSILICA_INTERNAL
133 TARGETS += libhandler-reset-mp.a
134 endif
135
136 all: $(TARGETS)
137
138
139 #  Here's an example of how one could put a selected set of
140 #  objects into a specific section:
141 #
142 #XTOSSECFLAGS = \
143 #       -mrename-section-.text=.xtos.text \
144 #       -mrename-section-.literal=.xtos.literal \
145 #       -mrename-section-.rodata=.xtos.rodata \
146 #       -mrename-section-.data=.xtos.data
147 #$(XTOS_SIM_OBJS) : XTFLAGS = $(XTOSSECFLAGS)
148
149 libhandlers-sim.a: $(XTOS_SIM_OBJS) $(XTOS_COMMON_OBJS)
150
151 libhandlers-board.a: $(XTOS_BOARD_OBJS) $(XTOS_COMMON_OBJS)
152
153 libhandlers-min.a: user-vector-min.o tiny-refs-min.o
154
155 libhandlers-null.a: $(call split_objs, null-vectors.S) _vectors.o
156
157 libnomovsp.a: null-alloca.o
158
159 libnosyscall.a: null-syscall.o
160
161 $(PERLEVEL_INTVECTOR_OBJS): int-vector-level%.o: int-vector.S
162         $(XTCC) -c $(ASFLAGS) $(FLAGS_int-vector-level$*) $(XTFLAGS) -D_INTERRUPT_LEVEL=$* -o $@ $<
163
164 $(PERLEVEL_INTHANDLER_OBJS): int-handler-level%.o: int-handler.S
165         $(XTCC) -c $(ASFLAGS) $(FLAGS_int-handler-level$*) $(XTFLAGS) -D_INTERRUPT_LEVEL=$* -o $@ $<
166
167 $(PERLEVEL_INTINITLEV_OBJS): int-init-level%.o: int-initlevel.S
168         $(XTCC) -c $(ASFLAGS) $(FLAGS_int-init-level$*) $(XTFLAGS) -D_INTERRUPT_LEVEL=$* -o $@ $<
169
170
171 #  For split-source rules, determine various things from $* (extended basename):
172 #
173 SPLIT_SRC = $(patsubst %/,%,$(dir $(subst -c--,.c/,$(subst -S--,.S/,$*))))
174 SPLIT_FLAGS = $(FLAGS_$(basename $(SPLIT_SRC))) \
175                 -D__SPLIT__$(notdir $(subst --,/,$*))
176
177 #  (Okay we cheat a bit, CFLAGS matches ASFLAGS so this works; it's also simpler:)
178 %-.o:
179         $(XTCC) -c $(CFLAGS) $(SPLIT_FLAGS) $(XTFLAGS) -o $@ $(SRCDIR)/$(SPLIT_SRC)
180 %--sim.o:
181         $(XTCC) -c $(CFLAGS) $(SPLIT_FLAGS) $(XTFLAGS) -DSIMULATOR -o $@ $(SRCDIR)/$(SPLIT_SRC)
182
183
184 %.o: %.S
185         $(XTCC) -c $(ASFLAGS) $(FLAGS_$*) $(XTFLAGS) $<
186
187 %.o: %.c
188         $(XTCC) -c $(CFLAGS)  $(FLAGS_$*) $(XTFLAGS) $<
189
190 %-sim.o: %.S
191         $(XTCC) -c $(ASFLAGS) $(FLAGS_$*) $(XTFLAGS) -DSIMULATOR -o $@ $<
192
193 %-sim.o: %.c
194         $(XTCC) -c $(CFLAGS)  $(FLAGS_$*) $(XTFLAGS) -DSIMULATOR -o $@ $<
195
196 #  Explicit rule for crt1-sim.o to avoid using %-sim.o rule above:
197 crt1-sim.o: crt1-sim.S
198         $(XTCC) -c $(ASFLAGS) $(FLAGS_$*) $(XTFLAGS) $<
199
200
201 # When building the reset vector, leave the literals in
202 # the text section, so that the reset vector can be placed
203 # at address 0 (there's no lower address for the literals).
204 #
205 #FLAGS_reset-vector = -mtext-section-literals
206 #
207 reset-vector.o: reset-vector.S
208         $(XTCC) -c $(ASFLAGS) $(XTFLAGS) -mtext-section-literals -o $@ $<
209 reset-vector-unpack.o: reset-vector.S
210         $(XTCC) -c $(ASFLAGS) $(XTFLAGS) -mtext-section-literals -DXTOS_UNPACK -o $@ $<
211 reset-vector-mp.o: reset-vector.S
212         $(XTCC) -c $(ASFLAGS) $(XTFLAGS) -mtext-section-literals -DXTOS_MP -o $@ $<
213 #
214 #  These libraries provide alternative reset vectors:
215 #  Without any unpacking:
216 libhandler-reset.a: reset-vector.o
217 #  With experimental MP unpacking:
218 libhandler-reset-mp.a: reset-vector-mp.o
219
220 %.a:
221         -$(RM) $@
222         $(XTAR) rs $@ $^
223
224 #install:
225 #       -$(MKPATH) $(INSTLIBDIR)
226 #       $(CP) $(TARGETS) $(INSTLIBDIR)
227
228 clean:
229         -$(RM) *.o *.a
230
231 # NOTE: Header file dependencies not specified!
232