-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
executable file
·139 lines (123 loc) · 5.46 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
#/usr/bin/make -f
ifeq ($(strip $(MACHINE)),)
$(error MACHINE variable not set. Usage: make MACHINE=<overo|duovero|pepper|beagle|panda>)
endif
#================================= CONFIG ======================================
CROSS_COMPILE := arm-linux-gnueabihf-
ARCH := arm
UBOOT_SRC_DIR := $(PWD)/u-boot
UBOOT_BRANCH := v2015.04
UBOOT_CONFIG_overo := omap3_overo_defconfig
UBOOT_CONFIG_duovero := duovero_defconfig
UBOOT_CONFIG_pepper := pepper_defconfig
UBOOT_CONFIG_beagle := omap3_beagle_defconfig
UBOOT_CONFIG_panda := omap4_panda_defconfig
# don't pass down MACHINE
MAKEOVERRIDES =
# prevent built-in rules---we're not using them
.SUFFIXES:
.PHONY: all uboot clean-uboot oem clean-oem
all: $(MACHINE).snap
clean: clean-uboot clean-oem
#================================== OEM =======================================
oem: $(MACHINE).snap
$(MACHINE).snap: uboot
@(cd $(MACHINE) && snappy build)
@cp $(MACHINE)/$(MACHINE)*.snap $(MACHINE).snap
clean-oem:
@rm -f $(MACHINE)/$(MACHINE)*.snap $(MACHINE).snap
#================================= UBOOT ======================================
UBOOT_CONFIG := $(UBOOT_CONFIG_$(MACHINE))
ifeq ($(strip $(UBOOT_CONFIG)),)
$(error No known u-boot configuration for $(MACHINE))
endif
UBOOT_OUT_DIR := $(PWD)/${MACHINE}
uboot: $(UBOOT_OUT_DIR)/MLO $(UBOOT_OUT_DIR)/u-boot.img
$(UBOOT_OUT_DIR)/MLO $(UBOOT_OUT_DIR)/u-boot.img: u-boot-output.intermediate
# Check-out u-boot (naively assume that if the directory exists, u-boot is checked out)
$(UBOOT_SRC_DIR):
@git clone git://github.com/gumstix/u-boot.git --depth 1 -b $(UBOOT_BRANCH) $(UBOOT_SRC_DIR)
# configure u-boot
$(UBOOT_SRC_DIR)/.config: | $(UBOOT_SRC_DIR)
@$(MAKE) -C $(UBOOT_SRC_DIR) CROSS_COMPILE=$(CROSS_COMPILE) $(UBOOT_CONFIG)
# if any file in the u-boot directory changes, build
.INTERMEDIATE: u-boot-output.intermediate
u-boot-output.intermediate: $(UBOOT_SRC_DIR)/.config $(shell find $(UBOOT_SRC_DIR) -type f 2>/dev/null)
@$(MAKE) -C $(UBOOT_SRC_DIR) CROSS_COMPILE=$(CROSS_COMPILE)
@cp $(UBOOT_SRC_DIR)/MLO $(UBOOT_SRC_DIR)/u-boot.img $(UBOOT_OUT_DIR)
clean-uboot:
@-$(MAKE) -C $(UBOOT_SRC_DIR) CROSS_COMPILE=$(CROSS_COMPILE) distclean
@-rm -f $(UBOOT_OUT_DIR)/MLO $(UBOOT_OUT_DIR)/u-boot.img
# This is experimental work-in-progress---ignore it for now
##================================ initrd ======================================
## To support a custom kernel, we need to (re-)build the initrd. As it isn't
## clear how to build this from scratch, let's borrow the method from
## snappy-device-builder :).
#DEVICE_DIR := $(PWD)/device-$(MACHINE)
#magical_upstream_tarball := http://cdimage.ubuntu.com/ubuntu-core/daily-preinstalled/current/vivid-preinstalled-core-armhf.device.tar.gz
#
#$(DEVICE_DIR):
# @mkdir -p $(DEVICE_DIR)
#
## We don't re-fetch this by default...
#$(DEVICE_DIR)/upstream.tar.gz: | $(DEVICE_DIR)
# @wget $(magical_upstream_tarball) -O $@
#
## use 'hardware.yaml' as an indicator
#$(DEVICE_DIR)/hardware.yaml: $(DEVICE_DIR)/upstream.tar.gz
# @tar xzf $< -C $(DEVICE_DIR)
#
#$(DEVICE_DIR)/ramdisk: $(DEVICE_DIR)/hardware.yaml
# mkdir -p $(DEVICE_DIR)/ramdisk
# xz --format=lzma -cd $(DEVICE_DIR)/assets/initrd.img | (cd $(DEVICE_DIR)/ramdisk && cpio -i)
#
## our re-packed version
#$(DEVICE_DIR)/fresh-initrd: kernel
# find $(DEVICE_DIR)/ramdisk | sort | cpio --quiet -o -H newc | lzma > $(DEVICE_DIR)/assets/initrd.img
# touch $@
#
#device: $(MACHINE).tar.xz
#$(MACHINE).tar.xz: $(DEVICE_DIR)/fresh-initrd $(shell find $(DEVICE_DIR) -type f)
# @tar -C $(DEVICE_DIR) -cavf $(MACHINE).tar.xz --exclude fresh-initrd --exclude ramdisk --exclude upstream.tar.gz --xform s:'./':: .
#
#clean-device:
# @rm -rf $(MACHINE).tar.xz $(DEVICE_DIR)
#
##================================= LINUX ======================================
## Check-out Linux (naively assume that if the directory exists, linux is checked out)
#KERNEL_SRC_DIR := $(PWD)/linux
#KERNEL_BRANCH := yocto-v3.17.y
#$(KERNEL_SRC_DIR):
# @git clone git://github.com/gumstix/linux.git --depth 1 -b $(KERNEL_BRANCH) $(KERNEL_SRC_DIR)
#
## copy linux defconfig and run configuration
#$(KERNEL_SRC_DIR)/.config: $(PWD)/$(MACHINE)_snappy_defconfig | $(KERNEL_SRC_DIR)
# @cp $< $@
# $(MAKE) -C $(KERNEL_SRC_DIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) oldconfig
#
#INSTALLED_KERNEL := $(DEVICE_DIR)/assets/vmlinuz
#INSTALL_MOD_PATH := $(DEVICE_DIR)/ramdisk
#INSTALL_DTBS_PATH := $(DEVICE_DIR)/assets/dtbs
#
#define install-kernel-extras
#@$(MAKE) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) -C $(KERNEL_SRC_DIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) INSTALL_MOD_STRIP=1 modules_install
#@$(MAKE) INSTALL_DTBS_PATH=$(INSTALL_DTBS_PATH) -C $(KERNEL_SRC_DIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) dtbs_install
#endef
#
## Consider all files in the KERNEL_SRC_DIR to be prerequsites for building
## the kernel. If any source files change, update the build (remove zImage to
## ensure it is updated even if a rebuild doesn't particularly update it). Build
## and install the kernel image and dtbs to 'assets'. Modules live in 'system'
#KERNEL_OUTPUT_FILE := $(KERNEL_SRC_DIR)/arch/arm/boot/zImage
#
#$(INSTALLED_KERNEL): $(KERNEL_SRC_DIR)/.config $(shell find $(KERNEL_SRC_DIR) -type f)
# rm -f $(KERNEL_OUTPUT_FILE)
# $(MAKE) -C $(KERNEL_SRC_DIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)
# $(install-kernel-extras)
# cp $(KERNEL_OUTPUT_FILE) $(INSTALLED_KERNEL)
#
#kernel: $(INSTALLED_KERNEL)
#
#clean-kernel:
# @-rm -rf $(INSTALLED_KERNEL) $(INSTALL_MOD_PATH) $(INSTALL_DTBS_PATH)*
# @-$(MAKE) -C $(KERNEL_SRC_DIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) mrproper