forked from RedPitaya/RedPitaya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
154 lines (128 loc) · 4.56 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
#
# $Id: Makefile 1253 2014-02-23 21:09:06Z ales.bardorfer $
#
# Red Pitaya OS/Ecosystem main Makefile
#
# Red Pitaya operating system (OS) consists of the following components:
# 1. boot.bin
# a) First stage bootloader (FSBL)
# b) U-boot
# c) Optional fpga.bit
# 2. Linux kernel
# 3. Linux devicetree
# 4. Ramdisk with root filesystem
#
# There are many inter-relations between these components. This Makefile is
# responsible to build those in a coordinated way and to package them within
# the target redpitaya-OS ZIP archive.
#
# TODO #1: Make up a new name for OS dir, as OS is building one level higher now.
BUILD=build
TARGET=target
NAME=ecosystem
LINUX_DIR=OS/linux
LINUX_SOURCE_DIR=$(LINUX_DIR)/linux-xlnx
UBOOT_DIR=OS/u-boot
SOC_DIR=FPGA
URAMDISK_DIR=OS/buildroot
NGINX_DIR=Bazaar/nginx
MONITOR_DIR=Test/monitor
GENERATE_DIR=Test/generate
ACQUIRE_DIR=Test/acquire
CALIB_DIR=Test/calib
DISCOVERY_DIR=OS/discovery
ECOSYSTEM_DIR=Applications/ecosystem
LINUX=$(BUILD)/uImage
DEVICETREE=$(BUILD)/devicetree.dtb
UBOOT=$(BUILD)/u-boot.elf
BOOT=$(BUILD)/boot.bin
FPGA=$(BUILD)/fpga.bit
FSBL=$(BUILD)/fsbl.elf
TESTBOOT=testboot.bin
MEMTEST=$(BUILD)/memtest.elf
URAMDISK=$(BUILD)/uramdisk.image.gz
NGINX=$(BUILD)/sbin/nginx
MONITOR=$(BUILD)/bin/monitor
GENERATE=$(BUILD)/bin/generate
ACQUIRE=$(BUILD)/bin/acquire
CALIB=$(BUILD)/bin/calib
DISCOVERY=$(BUILD)/sbin/discovery
ECOSYSTEM=$(BUILD)/www/apps/info/info.json
# Versioning system
BUILD_NUMBER ?= 0
REVISION ?= devbuild
VER:=$(shell cat $(ECOSYSTEM_DIR)/info/info.json | grep version | sed -e 's/.*:\ *\"//' | sed -e 's/-.*//')
VERSION=$(VER)-$(BUILD_NUMBER)
export BUILD_NUMBER
export REVISION
export VERSION
all: zip
$(TARGET): $(BOOT) $(TESTBOOT) $(LINUX) $(DEVICETREE) $(URAMDISK) $(NGINX) $(MONITOR) $(GENERATE) $(ACQUIRE) $(CALIB) $(DISCOVERY) $(ECOSYSTEM)
mkdir $(TARGET)
cp -r $(BUILD)/* $(TARGET)
rm -f $(TARGET)/fsbl.elf $(TARGET)/fpga.bit $(TARGET)/u-boot.elf $(TARGET)/devicetree.dts $(TARGET)/memtest.elf
cp -r OS/filesystem/* $(TARGET)
rm `find $(TARGET) -iname .svn` -rf
echo "" > $(TARGET)/version.txt
echo "Red Pitaya GNU/Linux/Ecosystem version $(VERSION)" >> $(TARGET)/version.txt
echo "" >> $(TARGET)/version.txt
$(BUILD):
mkdir $(BUILD)
# Linux build provides: uImage kernel, dtc compiler.
$(LINUX): $(BUILD)
make -C $(LINUX_DIR) CROSS_COMPILE=arm-xilinx-linux-gnueabi-
make -C $(LINUX_DIR) install INSTALL_DIR=$(abspath $(BUILD))
# FPGA build provides: fsbl.elf, fpga.bit, devicetree.dts.
$(FPGA): $(BUILD)
make -C $(SOC_DIR)
make -C $(SOC_DIR) install INSTALL_DIR=$(abspath $(BUILD))
# U-Boot build provides: u-boot.elf
$(UBOOT): $(BUILD)
make -C $(UBOOT_DIR) RP_VERSION=$(VERSION) RP_REVISION=$(REVISION)
make -C $(UBOOT_DIR) install INSTALL_DIR=$(abspath $(BUILD))
$(BOOT): $(BUILD) $(UBOOT) $(FPGA)
@echo img:{[bootloader] $(FSBL) $(FPGA) $(UBOOT) } > b.bif
bootgen -image b.bif -w -o i $@
$(TESTBOOT): $(BOOT)
@echo img:{[bootloader] $(MEMTEST) $(FPGA) $(UBOOT) } > b.bif
bootgen -image b.bif -w -o i $@
$(DEVICETREE): $(BUILD) $(LINUX) $(FPGA)
$(LINUX_SOURCE_DIR)/scripts/dtc/dtc -I dts -O dtb -o $(DEVICETREE) $(BUILD)/devicetree.dts
$(URAMDISK): $(BUILD)
$(MAKE) -C $(URAMDISK_DIR)
$(MAKE) -C $(URAMDISK_DIR) install INSTALL_DIR=$(abspath $(BUILD))
$(NGINX): $(URAMDISK)
$(MAKE) -C $(NGINX_DIR) CROSS_COMPILE=arm-xilinx-linux-gnueabi-
$(MAKE) -C $(NGINX_DIR) install DESTDIR=$(abspath $(BUILD))
$(MONITOR):
$(MAKE) -C $(MONITOR_DIR) CROSS_COMPILE=arm-xilinx-linux-gnueabi-
$(MAKE) -C $(MONITOR_DIR) install INSTALL_DIR=$(abspath $(BUILD))
$(GENERATE):
$(MAKE) -C $(GENERATE_DIR) CROSS_COMPILE=arm-xilinx-linux-gnueabi-
$(MAKE) -C $(GENERATE_DIR) install INSTALL_DIR=$(abspath $(BUILD))
$(ACQUIRE):
$(MAKE) -C $(ACQUIRE_DIR) CROSS_COMPILE=arm-xilinx-linux-gnueabi-
$(MAKE) -C $(ACQUIRE_DIR) install INSTALL_DIR=$(abspath $(BUILD))
$(CALIB):
$(MAKE) -C $(CALIB_DIR) CROSS_COMPILE=arm-xilinx-linux-gnueabi-
$(MAKE) -C $(CALIB_DIR) install INSTALL_DIR=$(abspath $(BUILD))
$(DISCOVERY):
$(MAKE) -C $(DISCOVERY_DIR) CROSS_COMPILE=arm-xilinx-linux-gnueabi-
$(MAKE) -C $(DISCOVERY_DIR) install INSTALL_DIR=$(abspath $(BUILD))
$(ECOSYSTEM):
$(MAKE) -C $(ECOSYSTEM_DIR) install INSTALL_DIR=$(abspath $(BUILD))
zip: $(TARGET)
cd $(TARGET); zip -r ../$(NAME)-$(VER)-$(BUILD_NUMBER)-$(REVISION).zip *
clean:
make -C $(LINUX_DIR) clean
make -C $(SOC_DIR) clean
make -C $(UBOOT_DIR) clean
make -C $(NGINX_DIR) clean
make -C $(MONITOR_DIR) clean
make -C $(GENERATE_DIR) clean
make -C $(ACQUIRE_DIR) clean
make -C $(CALIB_DIR) clean
make -C $(DISCOVERY_DIR) clean
rm $(BUILD) -rf
rm $(TARGET) -rf
$(RM) $(NAME)*.zip