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

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

Ryan Jackson's avatar
Ryan Jackson committed
16
17
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
18
INSTALL_MODULES := $(addsuffix -install,$(MODULES))
19
20
EXTRACT_MODULES := $(addsuffix -extract,$(MODULES))
PATCH_MODULES := $(addsuffix -patch,$(MODULES))
Ryan Jackson's avatar
Ryan Jackson committed
21
CLEAN_MODULES := $(addsuffix -clean,$(MODULES))
22

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

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

Ryan Jackson's avatar
Ryan Jackson committed
29
install: uclibc-install $(INSTALL_MODULES)
30
	cp $(SCRIPTS_PATH)/remove_unneeded_modules.pl $(BOOT_PATH)
31

Ryan Jackson's avatar
Ryan Jackson committed
32
33
34
35
36
37
38
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)
39

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

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

46
47
48
49
50
51
$(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
52
53
$(INSTALL_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -install,,$@) install
54

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

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

$(FAKEROOT_ENVIRONMENT):
	touch $@

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

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

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