Makefile 3.19 KB
Newer Older
Ryan Jackson's avatar
Ryan Jackson committed
1
MFS_ARCH	=	i386
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 ethtool ncurses
Ryan Jackson's avatar
Ryan Jackson committed
18
#MODULES := busybox zlib linux dropbear testbed hdparm target_template sudo e2fsprogs openssl wget portmap file
Ryan Jackson's avatar
Ryan Jackson committed
19
INSTALL_MODULES := $(addsuffix -install,$(MODULES))
Ryan Jackson's avatar
Ryan Jackson committed
20
21
EXTRACT_MODULES := $(addsuffix -extract,$(MODULES) toolchain)
PATCH_MODULES := $(addsuffix -patch,$(MODULES) toolchain)
Ryan Jackson's avatar
Ryan Jackson committed
22
CONFIG_MODULES := $(addsuffix -config,$(MODULES) toolchain)
Ryan Jackson's avatar
Ryan Jackson committed
23
CLEAN_MODULES := $(addsuffix -clean,$(MODULES) toolchain)
24

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

Ryan Jackson's avatar
Ryan Jackson committed
29
all: $(MODULES) initramfs
30

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

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

Ryan Jackson's avatar
Ryan Jackson committed
42
43
44
45
toolchain:
	$(MAKE) -C $(SOURCE_PATH)/$@ all
	$(MAKE) -C $(SOURCE_PATH)/zlib install-sysroot
	$(MAKE) -C $(SOURCE_PATH)/openssl install
Ryan Jackson's avatar
Ryan Jackson committed
46
	$(MAKE) -C $(SOURCE_PATH)/ncurses install
Ryan Jackson's avatar
Ryan Jackson committed
47
48

$(MODULES): toolchain
Ryan Jackson's avatar
Ryan Jackson committed
49
	$(MAKE) -C $(SOURCE_PATH)/$@ all
50

Ryan Jackson's avatar
Ryan Jackson committed
51
52
$(CLEAN_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -clean,,$@) clean
53

54
55
56
57
58
59
$(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
60
61
62
$(CONFIG_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -config,,$@) config

Ryan Jackson's avatar
Ryan Jackson committed
63
64
$(INSTALL_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -install,,$@) install
65

Ryan Jackson's avatar
Ryan Jackson committed
66
$(TARGET_PATH)/lib/libc.so.0:
67
	mkdir -p $(TARGET_PATH)/lib
68
	cp -dpR $(BUILDROOT_PATH)/project_build_$(MFS_ARCH)/uclibc/root/lib/* $(TARGET_PATH)/lib
69

Ryan Jackson's avatar
Ryan Jackson committed
70
uclibc-install: $(TARGET_PATH)/lib/libc.so.0
71
72
73
74
75
76

$(FAKEROOT_ENVIRONMENT):
	touch $@

devices: $(FAKEROOT_ENVIRONMENT)
	rm -rf $(TARGET_PATH)/dev
77
	$(FAKEROOT_BIN) -s $(FAKEROOT_ENVIRONMENT) \
78
79
80
81
		-i $(FAKEROOT_ENVIRONMENT) \
		$(SCRIPTS_PATH)/makedevs.sh \
		$(SCRIPTS_PATH)/devices $(TARGET_PATH)

Ryan Jackson's avatar
Ryan Jackson committed
82
permissions: $(FAKEROOT_ENVIRONMENT) devices install
83
	$(FAKEROOT_BIN) -s $(FAKEROOT_ENVIRONMENT) \
84
85
86
		-i $(FAKEROOT_ENVIRONMENT) \
		$(SCRIPTS_PATH)/fixperms.sh $(TARGET_PATH)

Ryan Jackson's avatar
Ryan Jackson committed
87
88
89
90
91
initramfs: install
	rm -rf $(INITRAMFS_PATH)
	cp -dpR $(TARGET_PATH) $(INITRAMFS_PATH)
	cat /dev/null > $(FAKEROOT_ENVIRONMENT)
	rm -rf $(INITRAMFS_PATH)/dev
92
	$(FAKEROOT_BIN) -s $(FAKEROOT_ENVIRONMENT) \
Ryan Jackson's avatar
Ryan Jackson committed
93
94
95
		-i $(FAKEROOT_ENVIRONMENT) \
		$(SCRIPTS_PATH)/makedevs.sh \
		$(SCRIPTS_PATH)/devices $(INITRAMFS_PATH)
96
	$(FAKEROOT_BIN) -s $(FAKEROOT_ENVIRONMENT) \
Ryan Jackson's avatar
Ryan Jackson committed
97
98
		-i $(FAKEROOT_ENVIRONMENT) \
		$(SCRIPTS_PATH)/fixperms.sh $(INITRAMFS_PATH)
99
	$(FAKEROOT_BIN) -i $(FAKEROOT_ENVIRONMENT) \
Ryan Jackson's avatar
Ryan Jackson committed
100
101
102
		$(SCRIPTS_PATH)/gen_initramfs.sh $(INITRAMFS_PATH) $(INITRAMFS)
	rm -f $(FAKEROOT_ENVIRONMENT)
	rm -rf $(INITRAMFS_PATH)