aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 7899710ec60d6811af60358e300161a70005c523 (plain) (blame)
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
VERSION			=scm

CFLAGS			?= -Os
CXXFLAGS		?= $(CFLAGS)

CFLAGS			+= -static
LDFLAGS			+= -static

JOBS			?= $(shell expr $$(grep -c processor /proc/cpuinfo) + 4)

LIGHTER			?= $(PWD)
ARCHIVES		?= $(LIGHTER)/archives
BUILD			?= $(LIGHTER)/build
CONFIGS			?= $(LIGHTER)/configs
DOWNLOADS		?= $(LIGHTER)/downloads
TOOLCHAIN		?= $(LIGHTER)/toolchain

PATH			+=:$(TOOLCHAIN)
export CFLAGS
export CXXFLAGS
export LDFLAGS
export JOBS
export LIGHTER
export ARCHIVES
export BUILD
export CONFIGS
export DOWNLOADS
export TOOLCHAIN
export PATH

make            =	\
	busybox=http=//busybox.net/downloads/busybox-1.24.1.tar.bz2					\
	dropbear=https=//matt.ucc.asn.au/dropbear/releases/dropbear-2015.71.tar.bz2

all:
	@printf "lighter $(VERSION)\n\n"
	@printf "%-20s%-20s\n"	\
		"CFLAGS"		"$(CFLAGS)"		\
		"CXXFLAGS"		"$(CXXFLAGS)"	\
		"JOBS"          "$(JOBS)"	\
		"BUILD"			"$(BUILD)"
	@printf "\n"
	@$(MAKE) --no-print-directory build

$(BUILD)/.prepare:
	@printf "making build directories...\n"
	@sh -e scripts/prepare
	@printf "\n"

$(BUILD)/.toolchain: $(BUILD)/.prepare
	@printf "making any needed toolchain links...\n"
	@sh -e scripts/toolchain
	@touch "$(BUILD)"/.toolchain
	@printf "\n"

$(BUILD)/.fetch-%: $(BUILD)/.prepare
	@sh -e scripts/fetch "$*"

$(BUILD)/.extract-%: $(BUILD)/.fetch-%
	@sh -e scripts/extract "$*"

$(BUILD)/.build-%: $(BUILD)/.toolchain $(BUILD)/.extract-%
	@sh -e scripts/build "$*"

$(BUILD)/initramfs.cpio.gz:
	cd "$(BUILD)/root" && find . -print0 | cpio --null -ov --format=newc | gzip -9 > "$(BUILD)"/initramfs.cpio.gz

buildall:	$(foreach m,$(make),$(BUILD)/.build-$(m))
build:
	@$(MAKE) --no-print-directory buildall
	@$(MAKE) --no-print-directory "$(BUILD)/initramfs.cpio.gz"

clean:
	rm -rf downloads archives $(BUILD) toolchain

.PHONY:		all buildall build clean