forked from 400plus/400plus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
158 lines (125 loc) · 4.49 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
PROJECT := AUTOEXEC
ADDRESS := 0x7E0000
ifndef CROSS_COMPILE
CROSS_COMPILE := arm-elf-
endif
ifdef RELEASE
VERSION := VER-$(RELEASE)
RELNAME := 400plus-$(RELEASE)
D_FLAGS := -DRELEASE
else
VERSION := REV-$(shell git rev-parse --short HEAD)
D_FLAGS :=
endif
USE_FONTS := -DUSE_FONT_SMALL
COMMON_FLAGS := \
$(USE_FONTS) \
-DVERSION='"$(VERSION)"' \
-Wall \
-mcpu=arm946e-s \
-march=armv5te \
-fno-builtin \
-nostdlib \
-fomit-frame-pointer \
-fno-strict-aliasing \
-mfloat-abi=soft \
-msoft-float \
-mfpu=fpa \
#-nostdinc \
#-fno-builtin-puts \
#-fno-builtin-sprintf \
#-fno-builtin-bzero \
#-fno-builtin-memset \
#-fno-builtin-printf \
#-mlong-calls or -fPIC will fix the rellocation problems with the linker on 64bit toolchain
#-mlong-calls \
#-fomit-frame-pointer \
#-fno-strict-aliasing \
# alex had issues with struct alignment (gcc-4.6.0, -Os) in ML
# this fixes them, keep it here in case we need it
#-mstructure-size-boundary=32 \
CC := $(CROSS_COMPILE)gcc
CFLAGS += $(COMMON_FLAGS) \
$(D_FLAGS) \
-Wp,-MMD,$(patsubst %.o,.%.d,$(@)) \
-Wp,-MT,$@ \
-Os \
-nostdinc \
-Ivxworks \
-Werror \
-Wstrict-prototypes \
-Wmissing-prototypes \
-Wno-char-subscripts \
-fdata-sections \
-ffunction-sections \
#-fomit-frame-pointer \
#-fno-strict-aliasing \
#-Wno-unused-parameter \
#-Wno-unused-function \
AS := $(CROSS_COMPILE)as
ASFLAGS := $(COMMON_FLAGS)
LD := $(CROSS_COMPILE)ld
LDFLAGS := -Wl,-Ttext,$(ADDRESS) -Wl,-T,link.script -Wl,-Map,autoexec.map -Wl,--gc-sections -e _start -lm -lgcc -lc
OBJCOPY := $(CROSS_COMPILE)objcopy
S_SRCS := $(wildcard *.S) $(wildcard vxworks/*.S) $(wildcard firmware/*.S)
C_SRCS := $(wildcard *.c) $(wildcard vxworks/*.c) $(wildcard firmware/*.c)
S_OBJS := $(S_SRCS:.S=.o)
C_OBJS := $(C_SRCS:.c=.o)
OBJS := $(S_OBJS) $(C_OBJS)
DEPS := $(patsubst %.o,.%.d,$(C_OBJS))
ECHO := "/bin/echo"
ifdef TERM
BOLD := "\033[1m"
NORM := "\033[0m"
endif
install: all
ifdef INSTALL_HOST
@$(ECHO) -e $(BOLD)[UPLOAD]:AUTOEXEC.BIN$(NORM)
@curl -s http://$(INSTALL_HOST)/upload.cgi?UPDIR=/ | fgrep -io SUCCESS
@curl -s -F [email protected] -F submit=submit http://$(INSTALL_HOST)/upload.cgi | fgrep -io SUCCESS
@$(ECHO) -e $(BOLD)[UPLOAD]:languages.ini$(NORM)
@curl -s http://$(INSTALL_HOST)/upload.cgi?UPDIR=/400PLUS | fgrep -io SUCCESS
@curl -s -F [email protected] -F submit=submit http://$(INSTALL_HOST)/upload.cgi | fgrep -io SUCCESS
endif
ifdef INSTALL_PATH
@install AUTOEXEC.BIN $(INSTALL_PATH)/
@install -D languages.ini $(INSTALL_PATH)/400PLUS
@umount $(INSTALL_PATH)
endif
all: $(PROJECT).BIN languages.ini languages/new_lang.ini
@$(ECHO) -e $(BOLD)[ALL]$(NORM)
@ls -l AUTOEXEC.BIN
release: clean
@$(ECHO) -e $(BOLD)[RELEASE]$(NORM)
@git checkout-index -a --prefix $(RELNAME)/src/
@zip -9 -r $(RELNAME).src.zip $(RELNAME)
@mkdir $(RELNAME)/bin
@cd $(RELNAME)/src && CFLAGS="" make
@cp $(RELNAME)/src/AUTOEXEC.BIN $(RELNAME)/src/languages.ini $(RELNAME)/bin/
@zip -9 -r $(RELNAME).bin.zip $(RELNAME)/bin/
@$(ECHO) -e $(BOLD)[ZIP]$(NORM)
@rm -rf $(RELNAME)
@ls -l $(RELNAME).src.zip $(RELNAME).bin.zip
$(PROJECT).BIN: $(PROJECT).arm.elf
@$(ECHO) -e $(BOLD)[OBJCOPY]:$(NORM) $@
$(OBJCOPY) -O binary $(PROJECT).arm.elf $(PROJECT).BIN
$(PROJECT).arm.elf: $(OBJS) link.script
@$(ECHO) -e $(BOLD)[LINK]:$(NORM) $@
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c
@$(ECHO) -e $(BOLD)[C]:$(NORM) $<
@$(CC) $(CFLAGS) -c $<
%.o: %.S
@$(ECHO) -e $(BOLD)[ASM]:$(NORM) $<
@$(CC) $(ASFLAGS) -c -o $@ $<
clean:
@$(ECHO) -e $(BOLD)[CLEAN]$(NORM)
rm -f $(OBJS) $(DEPS)
rm -f $(PROJECT).arm.elf $(PROJECT).BIN
languages.ini: languages.h languages/*.ini
@$(ECHO) -e $(BOLD)[I18N]:$(NORM) $@
@./languages/lang_tool.pl -q -f languages -l languages.h -o languages.ini
languages/new_lang.ini: languages.h
@$(ECHO) -e $(BOLD)[I18N]:$(NORM) $@
@./languages/lang_tool.pl -q -f languages -l languages.h -g
-include .*.d