1 | # This program is free software; you can redistribute it and/or |
2 | # modify it under the terms of the GNU General Public License as |
3 | # published by the Free Software Foundation; either version 2 of |
4 | # the License, or (at your option) any later version. |
5 | # |
6 | # This program is distributed in the hope that it will be useful, |
7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9 | # GNU General Public License for more details. |
10 | # |
11 | # You should have received a copy of the GNU General Public License |
12 | # along with this program; if not, write to the Free Software |
13 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
14 | # MA 02111-1307 USA |
15 | # |
16 | |
17 | include config.mk |
18 | |
19 | BUILD_DATE := $(shell date) |
20 | BUILD_HOST := $(shell hostname) |
21 | BUILD_BRANCH := $(shell git branch | grep ^\* | cut -d' ' -f2) |
22 | BUILD_HEAD := $(shell git show --pretty=oneline | head -n1 | cut -d' ' -f1 | cut -b1-16) |
23 | BUILD_VERSION := ${BUILD_BRANCH}_${BUILD_HEAD} |
24 | |
25 | LDS = src/cpu/$(CPU)/qi.lds |
26 | INCLUDE = include |
27 | IMAGE_DIR = image |
28 | TOOLS = tools |
29 | CFLAGS = -Wall -Werror -I $(INCLUDE) -g -c -Os -fno-strict-aliasing -mlong-calls \ |
30 | -fno-common -ffixed-r8 -msoft-float -fno-builtin -ffreestanding \ |
31 | -march=armv4t -mno-thumb-interwork -Wstrict-prototypes \ |
32 | -DBUILD_HOST="${BUILD_HOST}" -DBUILD_VERSION="${BUILD_VERSION}" \ |
33 | -DBUILD_DATE="${BUILD_DATE}" -DQI_CPU="${CPU}" |
34 | LDFLAGS = |
35 | |
36 | S_SRCS = $(wildcard src/cpu/$(CPU)/*.S) |
37 | S_OBJS = $(patsubst %.S,%.o, $(S_SRCS)) |
38 | C_SRCS = $(wildcard src/*.c) \ |
39 | $(wildcard src/drivers/*.c) $(wildcard src/fs/*.c) \ |
40 | $(wildcard src/cpu/$(CPU)/*.c) |
41 | C_OBJS = $(patsubst %.c,%.o, $(C_SRCS)) |
42 | |
43 | SRCS = ${S_SRCS} ${C_SRCS} |
44 | OBJS = ${S_OBJS} ${C_OBJS} |
45 | LIBS = -L${COMPILER_LIB_PATH} -lgcc |
46 | |
47 | ifeq ($(CPU),s3c2410) |
48 | # GTA01 U-Boot IDs |
49 | UDFU_VID = 0x1457 |
50 | UDFU_PID = 0x5119 |
51 | UDFU_REV = 0x0240 |
52 | else |
53 | # GTA02 A5 and A6 U-Boot will eat these for DFU action |
54 | UDFU_VID = 0x1d50 |
55 | UDFU_PID = 0x5119 |
56 | UDFU_REV = 0x350 |
57 | endif |
58 | |
59 | TARGET = $(IMAGE_DIR)/start_qi_all-$(CPU) |
60 | IMAGE = $(IMAGE_DIR)/qi-$(CPU)-$(BUILD_VERSION) |
61 | UDFU_IMAGE = $(IMAGE_DIR)/qi-$(CPU)-$(BUILD_VERSION).udfu |
62 | |
63 | MKUDFU = $(TOOLS)/mkudfu |
64 | |
65 | %.o: %.S |
66 | @$(CC) $(CFLAGS) -o $@ $< |
67 | |
68 | %.o: %.c |
69 | @$(CC) $(CFLAGS) -o $@ $< |
70 | |
71 | all:${UDFU_IMAGE} |
72 | |
73 | ${OBJS}:${SRCS} ${INCLUDE}/*.h |
74 | |
75 | ${MKUDFU}: |
76 | make -C $(TOOLS) |
77 | |
78 | ${UDFU_IMAGE}:${OBJS} ${MKUDFU} |
79 | mkdir -p image |
80 | @$(LD) ${LDFLAGS} -T$(LDS) -g $(OBJS) -o ${TARGET} ${LIBS} |
81 | @$(OBJCOPY) -O binary -S ${TARGET} ${IMAGE} |
82 | @$(MKUDFU) -v ${UDFU_VID} -p ${UDFU_PID} -r ${UDFU_REV} \ |
83 | -d ${IMAGE} ${UDFU_IMAGE} |
84 | @$(OBJDUMP) -d ${TARGET} >${IMAGE}.dis |
85 | |
86 | clean: |
87 | @rm -f *~ src/*.o src/*~ |
88 | @rm -f src/cpu/*/*.o src/cpu/*/*~ |
89 | @rm -f src/drivers/*.o src/drivers/*~ |
90 | @rm -f src/fs/*.o src/fs/*~ |
91 | @rm -f include/*~ ${IMAGE_DIR}/* |
92 | @make clean -C $(TOOLS) |
93 | |