put LINUX_KARCH in .kernel.mk
[openwrt.git] / include / host-build.mk
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/.host.mk
9
10 $(TOPDIR)/.host.mk: $(INCLUDE_DIR)/host-build.mk
11 echo "HOST_OS:=`uname`" > $@
12 echo "HOST_ARCH:=` \
13 $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
14 -e 's/sparc.*/sparc/' \
15 -e 's/arm.*/arm/' \
16 -e 's/m68k.*/m68k/' \
17 -e 's/ppc/powerpc/' \
18 -e 's/v850.*/v850/' \
19 -e 's/sh[234]/sh/' \
20 -e 's/mips-.*/mips/' \
21 -e 's/mipsel-.*/mipsel/' \
22 -e 's/cris.*/cris/' \
23 -e 's/i[3-9]86/i386/'`" >> $@
24 echo "GNU_HOST_NAME:=`$(HOSTCC) -dumpmachine`" >> $@
25
26
27 ifneq ($(strip $(PKG_CAT)),)
28 ifeq ($(PKG_CAT),unzip)
29 UNPACK=unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
30 else
31 UNPACK=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
32 endif
33 define Build/Prepare/Default
34 $(UNPACK)
35 @if [ -d ./patches ]; then \
36 $(PATCH) $(PKG_BUILD_DIR) ./patches; \
37 fi
38 endef
39 endif
40
41 define Build/Prepare
42 $(call Build/Prepare/Default)
43 endef
44
45 define Build/Configure/Default
46 @(cd $(PKG_BUILD_DIR)/$(3); \
47 [ -x configure ] && \
48 $(2) \
49 CPPFLAGS="-I$(STAGING_DIR)/host/include" \
50 LDFLAGS="-L$(STAGING_DIR)/host/lib" \
51 ./configure \
52 --target=$(GNU_TARGET_NAME) \
53 --host=$(GNU_TARGET_NAME) \
54 --build=$(GNU_HOST_NAME) \
55 --program-prefix="" \
56 --program-suffix="" \
57 --prefix=/usr \
58 --exec-prefix=/usr \
59 --bindir=/usr/bin \
60 --sbindir=/usr/sbin \
61 --libexecdir=/usr/lib \
62 --sysconfdir=/etc \
63 --datadir=/usr/share \
64 --localstatedir=/var \
65 --mandir=/usr/man \
66 --infodir=/usr/info \
67 $(DISABLE_NLS) \
68 $(1); \
69 true; \
70 )
71 endef
72
73 define Build/Configure
74 $(call Build/Configure/Default)
75 endef
76
77 define Build/Compile/Default
78 $(MAKE) -C $(PKG_BUILD_DIR) $(1)
79 endef
80
81 define Build/Compile
82 $(call Build/Compile/Default)
83 endef
84
85
86 ifneq ($(strip $(PKG_SOURCE)),)
87 download: $(DL_DIR)/$(PKG_SOURCE)
88
89 $(DL_DIR)/$(PKG_SOURCE):
90 mkdir -p $(DL_DIR)
91 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
92
93 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
94 endif
95
96 define HostBuild
97 $(PKG_BUILD_DIR)/.prepared:
98 @-rm -rf $(PKG_BUILD_DIR)
99 @mkdir -p $(PKG_BUILD_DIR)
100 $(call Build/Prepare)
101 touch $$@
102
103 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
104 $(call Build/Configure)
105 touch $$@
106
107 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
108 $(call Build/Compile)
109 touch $$@
110
111 $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
112 $(call Build/Install)
113 touch $$@
114
115 ifdef Build/Install
116 install-targets: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
117 endif
118
119 package-clean: FORCE
120 $(call Build/Clean)
121 $(call Build/Uninstall)
122 rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
123
124 download:
125 prepare: $(PKG_BUILD_DIR)/.prepared
126 configure: $(PKG_BUILD_DIR)/.configured
127
128 compile-targets: $(PKG_BUILD_DIR)/.built
129 compile: compile-targets
130
131 install-targets:
132 install: install-targets
133
134 clean-targets:
135 clean: FORCE
136 @$(MAKE) clean-targets
137 $(call Build/Clean)
138 rm -rf $(PKG_BUILD_DIR)
139
140 endef
This page took 0.049063 seconds and 5 git commands to generate.