summaryrefslogtreecommitdiffstats
path: root/package/modutils/modutils.mk
blob: b3e4492594c5aa813aafc5e8c7ef29673ca1e0b2 (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#############################################################
#
# modutils
#
#############################################################
MODUTILS_SOURCE=modutils-2.4.27.tar.bz2
MODUTILS_SITE=ftp://ftp.kernel.org/pub/linux/utils/kernel/modutils/v2.4/
MODUTILS_DIR1=$(BUILD_DIR)/modutils-2.4.27
MODUTILS_DIR2=$(TOOL_BUILD_DIR)/modutils-2.4.27
MODUTILS_BINARY=depmod/depmod
MODUTILS_TARGET_BINARY=$(TARGET_DIR)/sbin/$(MODUTILS_BINARY)

STRIPPROG=$(STRIP)

$(DL_DIR)/$(MODUTILS_SOURCE):
	$(WGET) -P $(DL_DIR) $(MODUTILS_SITE)/$(MODUTILS_SOURCE)

#############################################################
#
# build modutils for use on the target system
#
#############################################################
$(MODUTILS_DIR1)/.source: $(DL_DIR)/$(MODUTILS_SOURCE)
	bzcat $(DL_DIR)/$(MODUTILS_SOURCE) | tar -C $(BUILD_DIR) -xvf -
	toolchain/patch-kernel.sh $(MODUTILS_DIR1) \
		package/modutils \*.patch
	touch $(MODUTILS_DIR1)/.source

$(MODUTILS_DIR1)/.configured: $(MODUTILS_DIR1)/.source
	(cd $(MODUTILS_DIR1); \
		$(TARGET_CONFIGURE_OPTS) \
		INSTALL=$(MODUTILS_DIR1)/install-sh \
		./configure \
		--target=$(GNU_TARGET_NAME) \
		--host=$(GNU_TARGET_NAME) \
		--build=$(GNU_HOST_NAME) \
		--prefix=/ \
		--sysconfdir=/etc \
	);
	touch $(MODUTILS_DIR1)/.configured;

$(MODUTILS_DIR1)/$(MODUTILS_BINARY): $(MODUTILS_DIR1)/.configured
	$(MAKE1) CC=$(TARGET_CC) -C $(MODUTILS_DIR1)
	touch -c $(MODUTILS_DIR1)/$(MODUTILS_BINARY)

$(TARGET_DIR)/$(MODUTILS_TARGET_BINARY): $(MODUTILS_DIR1)/$(MODUTILS_BINARY)
	STRIPPROG='$(STRIPPROG)' \
	$(MAKE) prefix=$(TARGET_DIR) -C $(MODUTILS_DIR1) install-bin
	rm -Rf $(TARGET_DIR)/usr/man
	touch -c $(TARGET_DIR)/$(MODUTILS_TARGET_BINARY)

modutils: uclibc $(TARGET_DIR)/$(MODUTILS_TARGET_BINARY)

modutils-source: $(DL_DIR)/$(MODUTILS_SOURCE)

modutils-clean:
	$(MAKE) prefix=$(TARGET_DIR)/usr -C $(MODUTILS_DIR1) uninstall
	-$(MAKE) -C $(MODUTILS_DIR1) clean

modutils-dirclean:
	rm -rf $(MODUTILS_DIR1)


#############################################################
#
# build modutils for use on the host system
#
#############################################################
ifeq ($(strip $(BR2_mips)),y)
DEPMOD_EXTRA_STUFF=CFLAGS=-D__MIPSEB__
endif
ifeq ($(strip $(BR2_mipsel)),y)
DEPMOD_EXTRA_STUFF=CFLAGS=-D__MIPSEL__
endif

$(MODUTILS_DIR2)/.source: $(DL_DIR)/$(MODUTILS_SOURCE)
	bzcat $(DL_DIR)/$(MODUTILS_SOURCE) | tar -C $(TOOL_BUILD_DIR) -xvf -
	toolchain/patch-kernel.sh $(MODUTILS_DIR2) \
		package/modutils \*.patch
	touch $(MODUTILS_DIR2)/.source

$(MODUTILS_DIR2)/.configured: $(MODUTILS_DIR2)/.source
	(cd $(MODUTILS_DIR2); \
		./configure $(DEPMOD_EXTRA_STUFF) \
		--target=$(GNU_TARGET_NAME) \
		--host=$(GNU_HOST_NAME) \
		--build=$(GNU_HOST_NAME) \
		--prefix=/ \
		--sysconfdir=/etc \
	);
	touch $(MODUTILS_DIR2)/.configured;

$(MODUTILS_DIR2)/$(MODUTILS_BINARY): $(MODUTILS_DIR2)/.configured
	$(MAKE1) -C $(MODUTILS_DIR2)
	touch -c $(MODUTILS_DIR2)/$(MODUTILS_BINARY)

$(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-depmod: $(MODUTILS_DIR2)/$(MODUTILS_BINARY)
	cp $(MODUTILS_DIR2)/$(MODUTILS_BINARY) $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-depmod
	touch -c $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-depmod

cross-depmod: uclibc $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-depmod

cross-depmod-source: $(DL_DIR)/$(MODUTILS_SOURCE)

cross-depmod-clean:
	$(MAKE) prefix=$(TARGET_DIR)/usr -C $(MODUTILS_DIR2) uninstall
	-$(MAKE) -C $(MODUTILS_DIR2) clean

cross-depmod-dirclean:
	rm -rf $(MODUTILS_DIR2)



#############################################################
#
## Toplevel Makefile options
#
##############################################################
ifeq ($(strip $(BR2_PACKAGE_MODUTILS)),y)
TARGETS+=modutils
endif