Makefile 2.72 KB
Newer Older
Ryan Jackson's avatar
Ryan Jackson committed
1
2
SOURCE_PATH	=	$(PWD)/source
TARGET_PATH	=	$(PWD)/target
3
TARGET_BUILD_PATH	=	$(PWD)/build
Ryan Jackson's avatar
Ryan Jackson committed
4
5
6
7
SCRIPTS_PATH	=	$(PWD)/scripts
INITRAMFS_PATH	=	$(PWD)/initramfs.tmp
BUILDROOT_PATH	=	$(PWD)/buildroot
FAKEROOT_ENVIRONMENT	=	$(PWD)/fs_fakeroot.env
8
STAGING_DIR	=	$(PWD)/buildroot/build_x86_64/staging_dir
Ryan Jackson's avatar
Ryan Jackson committed
9
BOOT_PATH	=	$(PWD)/boot
10
INITRAMFS	=	$(BOOT_PATH)/initramfs.gz
11

12
13
14
#FAKEROOT_BIN	=	$(STAGING_DIR)/usr/bin/fakeroot
FAKEROOT_BIN	=	fakeroot

Ryan Jackson's avatar
Ryan Jackson committed
15
16
MODULES := busybox zlib linux dropbear testbed hdparm target_template sudo e2fsprogs openssl wget perl portmap file
#MODULES := busybox zlib linux dropbear testbed hdparm target_template sudo e2fsprogs openssl wget portmap file
Ryan Jackson's avatar
Ryan Jackson committed
17
INSTALL_MODULES := $(addsuffix -install,$(MODULES))
18
19
EXTRACT_MODULES := $(addsuffix -extract,$(MODULES))
PATCH_MODULES := $(addsuffix -patch,$(MODULES))
Ryan Jackson's avatar
Ryan Jackson committed
20
CLEAN_MODULES := $(addsuffix -clean,$(MODULES))
21

Ryan Jackson's avatar
Ryan Jackson committed
22
23
24
.PHONY: all clean install root-template-install devices \
	root-base root-install $(MODULES) $(INSTALL_MODULES) \
	$(CLEAN_MODULES) initramfs
25

Ryan Jackson's avatar
Ryan Jackson committed
26
all: $(MODULES)
27

Ryan Jackson's avatar
Ryan Jackson committed
28
install: uclibc-install $(INSTALL_MODULES)
29

Ryan Jackson's avatar
Ryan Jackson committed
30
31
32
33
34
35
36
clean:
	rm -rf $(TARGET_PATH)
	rm -f $(FAKEROOT_ENVIRONMENT)
	rm -rf $(INITRAMFS_PATH)
	rm -f $(INITRAMFS)
	rm -rf $(TARGET_BUILD_PATH)
	rm -rf $(BOOT_PATH)
37

Ryan Jackson's avatar
Ryan Jackson committed
38
39
$(MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$@ all
40

Ryan Jackson's avatar
Ryan Jackson committed
41
42
$(CLEAN_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -clean,,$@) clean
43

44
45
46
47
48
49
$(EXTRACT_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -extract,,$@) extract

$(PATCH_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -patch,,$@) patch

Ryan Jackson's avatar
Ryan Jackson committed
50
51
$(INSTALL_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -install,,$@) install
52

Ryan Jackson's avatar
Ryan Jackson committed
53
$(TARGET_PATH)/lib/libc.so.0:
54
	mkdir -p $(TARGET_PATH)/lib
55
	cp -dpR $(BUILDROOT_PATH)/project_build_x86_64/uclibc/root/lib/* $(TARGET_PATH)/lib
56

Ryan Jackson's avatar
Ryan Jackson committed
57
uclibc-install: $(TARGET_PATH)/lib/libc.so.0
58
59
60
61
62
63

$(FAKEROOT_ENVIRONMENT):
	touch $@

devices: $(FAKEROOT_ENVIRONMENT)
	rm -rf $(TARGET_PATH)/dev
64
	$(FAKEROOT_BIN) -s $(FAKEROOT_ENVIRONMENT) \
65
66
67
68
		-i $(FAKEROOT_ENVIRONMENT) \
		$(SCRIPTS_PATH)/makedevs.sh \
		$(SCRIPTS_PATH)/devices $(TARGET_PATH)

Ryan Jackson's avatar
Ryan Jackson committed
69
permissions: $(FAKEROOT_ENVIRONMENT) devices install
70
	$(FAKEROOT_BIN) -s $(FAKEROOT_ENVIRONMENT) \
71
72
73
		-i $(FAKEROOT_ENVIRONMENT) \
		$(SCRIPTS_PATH)/fixperms.sh $(TARGET_PATH)

Ryan Jackson's avatar
Ryan Jackson committed
74
75
76
77
78
initramfs: install
	rm -rf $(INITRAMFS_PATH)
	cp -dpR $(TARGET_PATH) $(INITRAMFS_PATH)
	cat /dev/null > $(FAKEROOT_ENVIRONMENT)
	rm -rf $(INITRAMFS_PATH)/dev
79
	$(FAKEROOT_BIN) -s $(FAKEROOT_ENVIRONMENT) \
Ryan Jackson's avatar
Ryan Jackson committed
80
81
82
		-i $(FAKEROOT_ENVIRONMENT) \
		$(SCRIPTS_PATH)/makedevs.sh \
		$(SCRIPTS_PATH)/devices $(INITRAMFS_PATH)
83
	$(FAKEROOT_BIN) -s $(FAKEROOT_ENVIRONMENT) \
Ryan Jackson's avatar
Ryan Jackson committed
84
85
		-i $(FAKEROOT_ENVIRONMENT) \
		$(SCRIPTS_PATH)/fixperms.sh $(INITRAMFS_PATH)
86
	$(FAKEROOT_BIN) -i $(FAKEROOT_ENVIRONMENT) \
Ryan Jackson's avatar
Ryan Jackson committed
87
88
89
		$(SCRIPTS_PATH)/gen_initramfs.sh $(INITRAMFS_PATH) $(INITRAMFS)
	rm -f $(FAKEROOT_ENVIRONMENT)
	rm -rf $(INITRAMFS_PATH)