-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
217 lines (170 loc) · 6.62 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#####################################################################
# #
# #
# Makefile for the Xinu operating system #
# #
# includes: .deps and .defs #
# #
# #
#####################################################################
include Makedefs
NODE=0
GPORT=556${NODE}
ifndef PLATFORM
$(error PLATFORM is not set. Edit your Makedefs file and add 'PLATFORM=arm-qemu'or 'PLATFORM=arm-bbb')
endif
ifeq ($(PLATFORM),arm-qemu)
PLAT_CFLAGS = -DARM_QEMU -mcpu=arm1176jz-s -ggdb3
PLAT_LOADADDR = 0x00010000
else ifeq ($(PLATFORM),arm-bbb)
PLAT_CFLAGS = -DARM_BBB -mcpu=cortex-a8 -g
PLAT_LOADADDR = 0x81000000
else ifeq ($(PLATFORM),x86-galileo)
PLAT_CFLAGS =
endif
TOPDIR = ..
CC = ${COMPILER_ROOT}gcc
LD = ${COMPILER_ROOT}ld
OBJCOPY = ${COMPILER_ROOT}objcopy
XINU = $(TOPDIR)/compile/xinu
XINUBIN = $(TOPDIR)/compile/xinu.bin
XINUBOOT = $(TOPDIR)/compile/xinu.boot
BUILDMAKE = $(TOPDIR)/compile/bin/build-make
MKVERS = $(TOPDIR)/compile/bin/mkvers
MAKEDEP = $(CC) -M -MG
DEPSFILE = .deps
DEFSFILE = .defs
VERSIONFILE = version
LDSCRIPT = ld.script.${PLATFORM}
REBUILDFLAGS = -s $(TOPDIR)/system debug.c \
-s $(TOPDIR)/system/platform/$(PLATFORM)\
-s $(TOPDIR)/lib \
-s $(TOPDIR)/shell 'xsh_rdstest*' \
-s $(TOPDIR)/apps \
ifeq ($(PLATFORM),arm-qemu)
REBUILDFLAGS += -s $(TOPDIR)/device/tty \
-s $(TOPDIR)/device/nam \
-s $(TOPDIR)/device/ram \
-s $(TOPDIR)/device/lfs \
-s $(TOPDIR)/device/uart \
-s $(TOPDIR)/device/uart-pl011 \
-s $(TOPDIR)/device/loopback
else ifeq ($(PLATFORM),arm-bbb)
REBUILDFLAGS += -s $(TOPDIR)/device/tty \
-s $(TOPDIR)/device/nam \
-s $(TOPDIR)/device/eth \
-s $(TOPDIR)/device/rds \
-s $(TOPDIR)/device/ram \
-s $(TOPDIR)/device/lfs \
-s $(TOPDIR)/device/rfs \
-s $(TOPDIR)/net 'arp_dump*' \
'dhcp_dump*' pxe.c \
else ifeq ($(PLATFORM),x86-galileo)
endif
INCLUDE = -I$(TOPDIR)/include
DEFS = -DBSDURG -DVERSION=\""`cat $(VERSIONFILE)`"\"
# Compiler flags
CFLAGS = ${PLAT_CFLAGS} -mno-unaligned-access -marm -fno-builtin -fno-stack-protector -nostdlib -c -Wall -O ${DEFS} ${INCLUDE}
SFLAGS = ${INCLUDE}
# Loader flags
LDFLAGS = -dn -m armelf -Map xinu.map -T ld.script.${PLATFORM}
all: xinu
#--------------------------------------------------------------------------------
# Handle generation of a new version string when initialize is recompiled
#--------------------------------------------------------------------------------
newversion:
@echo creating new version
@$(MKVERS) $(PLATFORM) > version
#--------------------------------------------------------------------------------
# Include generic make targets and rules from the file generated by build-make
#--------------------------------------------------------------------------------
-include $(DEFSFILE)
#--------------------------------------------------------------------------------
# Add files that require special rules and place start.o at the front
#--------------------------------------------------------------------------------
LD_LIST = binaries/start.o $(filter-out binaries/start.o,$(OBJ_FILES))
#------------------------------------------------------------
# Rules for files that need special handling
#------------------------------------------------------------
# Define variables for the Configuration file and generated files
CONFFILE = $(TOPDIR)/config/Configuration.${PLATFORM}
CONFH = $(TOPDIR)/include/conf.h
CONFC = $(TOPDIR)/system/conf.c
# Define variables for the config program and its sources
CONFPGM = $(TOPDIR)/config/config
CONFL = $(TOPDIR)/config/config.l
CONFY = $(TOPDIR)/config/config.y
# Set up the required build directory structure
BLDDIRS = binaries
export
#--------------------------------------------------------------------------------
# Specific additional rules and exceptions
#--------------------------------------------------------------------------------
xinu: Makefile rebuild $(BLDDIRS) $(DEFSFILE) $(DEPSFILE) $(CONFH) $(CONFC) $(LD_LIST) uboot-tool/mkimage
@echo;echo 'Loading object files to produce xinu'
@$(LD) $(LDFLAGS) $(LD_LIST) -o $(XINU) -L$(LIBGCC_LOC) -lgcc
@$(OBJCOPY) -O binary $(XINU) $(XINUBIN)
@./uboot-tool/mkimage -A arm -O linux -T kernel -C none -a $(PLAT_LOADADDR) -e $(PLAT_LOADADDR) -d $(XINUBIN) $(XINUBOOT)
uboot-tool/mkimage: uboot-tool/mkimage.c
@echo making mkimage
@(cd uboot-tool; make)
$(BLDDIRS):
@mkdir -p $(BLDDIRS)
objects: $(LD_LIST)
$(CONFH): $(CONFFILE) $(CONFPGM)
@echo making $(CONFH)
@make configure
$(CONFC): $(CONFFILE) $(CONFPGM)
@echo making $(CONFC)
@make configure
$(CONFPGM): $(CONFL) $(CONFY)
@echo making the config program
@make -C $(TOPDIR)/config clean all install
configure:
@echo forcing a rebuild of conf.h and conf.c
@make newversion
@(cd $(TOPDIR)/config; make PLATFORM=$(PLATFORM) install)
clean:
@echo removing .o files
@rm -f binaries/*.o
@echo removing configuration files ...
@rm -f $(CONFH) $(CONFC)
@(cd $(TOPDIR)/config; make clean)
@echo removing xinu ...
@rm -f $(XINU)
@rm -f $(XINUBIN)
@rm -f $(XINUBOOT)
@rm -f .defs
install: xinu
cp xinu.boot /tftpboot
etags:
@(cd $(TOPDIR); find . -name '*.[chS]' -exec etags -a {} \;)
qemu: xinu
export QEMU_AUDIO_DRV=wav; export QEMU_WAV_PATH=$(TOPDIR)/compile/.wav.wav; qemu-system-arm -M versatilepb -m 512M -nographic -cpu arm1176 -kernel xinu.boot
qemu-gdb: xinu
export QEMU_AUDIO_DRV=wav; export QEMU_WAV_PATH=$(TOPDIR)/compile/.wav.wav;qemu-system-arm -M versatilepb -m 512M -nographic -cpu arm1176 -kernel xinu.boot -S -gdb tcp::${GPORT}
#--------------------------------------------------------------------------------
# Locations of source directories and exceptions (.c and .[sS] files to exclude)
#--------------------------------------------------------------------------------
$(DEFSFILE):
@rm -f $(DEFSFILE)
@echo "" > $(DEFSFILE)
@make rebuild
$(DEPSFILE):
@rm -f $(DEPSFILE)
@echo "" > $(DEPSFILE)
@make depend
rebuild: $(CONFC)
@echo Rebuilding the $(DEFSFILE) file
@$(BUILDMAKE) $(REBUILDFLAGS) > $(DEFSFILE)
defclean:
rm -f $(DEFSFILE)
echo "" > $(DEFSFILE)
depend: $(DEFSFILE)
@echo;echo Making all dependencies in $(DEPSFILE)
@$(MAKEDEP) ${INCLUDE} ${SRC_FULL} > $(DEPSFILE)
@echo;echo Finished making dependencies
depclean:
rm -f $(DEPSFILE)
echo "" > $(DEPSFILE)
-include $(DEPSFILE)