58701043c9cb26a7a891e22606ee3354daf302af
[open-ath9k-htc-firmware.git] / Makefile
1 include $(MAGPIE_ROOT)/build/make_opt/Makefile.h
2
3 DIRS =  \
4         $(PRJ_ROOT)/$(TARGET)/adf               \
5         $(PRJ_ROOT)/$(TARGET)/init              \
6         $(PRJ_ROOT)/$(TARGET)/wmi               \
7         $(PRJ_ROOT)/$(TARGET)/wlan              \
8         $(PRJ_ROOT)/$(TARGET)/carrier_apd       \
9         $(PRJ_ROOT)/$(TARGET)/cmnos             \
10         $(PRJ_ROOT)/$(TARGET)/htc               \
11         $(PRJ_ROOT)/$(TARGET)/hif               \
12         $(PRJ_ROOT)/$(TARGET)/buf_pool
13
14 COMPONENTS_sw.ram =                     \
15         $(LIB_PATH)/libcmnos.a          \
16         $(LIB_PATH)/libadf.a            \
17         $(LIB_PATH)/libwmi.a            \
18         $(LIB_PATH)/libwlan.a           \
19         $(LIB_PATH)/libcarrier_apd.a    \
20         $(LIB_PATH)/libbuf_pool.a       \
21         $(LIB_PATH)/libhif.a            \
22         $(LIB_PATH)/libhtc.a
23
24
25 ifeq ($(debug),1)
26 LINKFLAGS_sw.ram =                      \
27         -T./target.ram_debug.ld         \
28         --start-group                   \
29         $(COMPONENTS_sw.ram)            \
30         --end-group
31 else
32 LINKFLAGS_sw.ram =                      \
33         -T./target.ram.ld               \
34         --start-group                   \
35         $(COMPONENTS_sw.ram)            \
36         --end-group
37 endif
38
39 all: util toolchain_prep
40         @for i in $(DIRS) ; do $(MAKE) -C $$i all CC=$(XCC) LD=$(XLD) AR=$(XAR) || exit ; done
41
42 dep: util toolchain_prep
43         @for i in $(DIRS) ; do $(MAKE) -C $$i dep CC=$(XCC) LD=$(XLD) AR=$(XAR) || exit ; done
44
45 clean:
46         find $(PRJ_ROOT)/ram -name "*.o" -exec rm -f {} \;
47         rm -rf $(PRJ_ROOT)/lib/ram/*.a
48         @for i in $(DIRS) ; do echo $$i; $(MAKE) -C $$i clean; done
49         rm -f *.bin *.hex *.objdump *.out *.map *.c *.fw *.fw.back *.c.back
50         rm -f ../../../utility/athfw2lnx/athfw2lnx
51
52 init:   toolchain_prep
53         for i in $(DIRS) ; do $(MAKE) -C $$i init CC=$(XCC) LD=$(XLD) AR=$(XAR) ; done
54
55 build: binary image
56
57 binary:
58         $(XLD) $(PRJ_ROOT)/ram/init/obj/app_start.o $(PRJ_ROOT)/ram/init/obj/init.o $(PRJ_ROOT)/ram/init/obj/magpie.o $(LINKFLAGS_sw.ram) -Map $(PRJNAME).map -o $(PRJNAME).out
59
60 toolchain_prep:
61 ifeq ($(XTENSA_TOOL_INSTALLED),0)
62         @cd ../../../toolchain && \
63         (test -d tools) || tar xvzf toolchain.tgz
64 endif
65
66 image:
67         $(XOBJCOPY)                                             \
68                 --change-section-lma .text-0x400000             \
69                 --change-section-vma .text-0x400000             \
70                 -O binary $(PRJNAME).out $(PRJNAME).bin
71         rm -f ../../../utility/athfw2lnx/athfw2lnx
72         $(shell cp -f fwu.c fwu.c.back 2> /dev/null)
73         $(shell cp -f htc_9271.fw htc_9271.fw.back 2> /dev/null)
74         $(BIN2HEX) $(PRJNAME).bin fwu.c 0 $(MAGPIE_IF)
75         $(MAKE) -C ../../../utility/athfw2lnx ATH_FW=$(PRJ_ROOT)/image/k2_ram/fwu.c
76         $(shell ../../../utility/athfw2lnx/athfw2lnx > htc_9271.fw)
77
78 util:
79         $(MAKE) -C ../../../utility/ clean
80         $(MAKE) -C ../../../utility/ all