Makefile 3.05 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
MODULES := busybox zlib linux dropbear testbed hdparm target_template sudo \
Ryan Jackson's avatar
Ryan Jackson committed
17
       	e2fsprogs openssl wget perl portmap file ethtool ncurses jove tcsh
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

42
43
44
45
toolchain: $(BUILDROOT_PATH)/toolchain-built

$(BUILDROOT_PATH)/toolchain-built:
	$(MAKE) -C $(SOURCE_PATH)/toolchain all
Ryan Jackson's avatar
Ryan Jackson committed
46
47
	$(MAKE) -C $(SOURCE_PATH)/zlib install-sysroot
	$(MAKE) -C $(SOURCE_PATH)/openssl install
Ryan Jackson's avatar
Ryan Jackson committed
48
	$(MAKE) -C $(SOURCE_PATH)/ncurses install
49
	touch $(BUILDROOT_PATH)/toolchain-built
Ryan Jackson's avatar
Ryan Jackson committed
50
51

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

Ryan Jackson's avatar
Ryan Jackson committed
54
55
$(CLEAN_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -clean,,$@) clean
56

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

Ryan Jackson's avatar
Ryan Jackson committed
66
67
$(INSTALL_MODULES):
	$(MAKE) -C $(SOURCE_PATH)/$(subst -install,,$@) install
68

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

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

$(FAKEROOT_ENVIRONMENT):
	touch $@

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