1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
5 INSTALL_DIR
= install -d
-m0755
6 INSTALL_DATA
= install -m0644
7 INSTALL_BIN
= install -m0755
8 INSTALL_SCRIPT
= install -m0755
9 MAKEFLAGS
= $(EXTRA_MAKEFLAGS
)
10 BUILD_USER
= $(shell id
-un
)
11 BUILD_GROUP
= $(shell id
-gn
)
13 TARGET_DEBUGGING
:= -g3
-fno-omit-frame-pointer
15 TARGET_DEBUGGING
:= -fomit-frame-pointer
18 TARGET_SSP
:= -fstack-protector-all
20 TARGET_CFLAGS
:= $(TARGET_OPTIMIZATION
) $(TARGET_CFLAGS_ARCH
) $(TARGET_DEBUGGING
) $(TARGET_SSP
)
23 DISTDIR?
= ${BASE_DIR}/dl
24 BUILD_DIR
:= ${BASE_DIR}/build_
${CPU_ARCH}
25 BUILD_DIR_PFX
:= $(BASE_DIR
)/build_
*
26 STAGING_PARENT
:= ${BASE_DIR}/cross_
${CPU_ARCH}
27 STAGING_PARENT_PFX
:= ${BASE_DIR}/cross_
*
28 STAGING_TOOLS
:= ${STAGING_PARENT}/host
29 STAGING_DIR
:= ${STAGING_PARENT}/target
30 TOOLCHAIN_BUILD_DIR
= $(BASE_DIR
)/toolchain_build_
${CPU_ARCH}
31 TOOLCHAIN_BUILD_DIR_PFX
=$(BASE_DIR
)/toolchain_build_
*
32 TOOLS_BUILD_DIR
= $(BASE_DIR
)/tools_build
33 SCRIPT_DIR
:= $(BASE_DIR
)/scripts
34 BIN_DIR
:= $(BASE_DIR
)/bin_
${ADK_TARGET}
35 BIN_DIR_PFX
:= $(BASE_DIR
)/bin_
*
36 PACKAGE_DIR
:= $(BIN_DIR
)/packages
37 TARGET_DIR
:= $(BASE_DIR
)/root_
${ADK_TARGET}
38 TARGET_DIR_PFX
:= $(BASE_DIR
)/root_
*
39 TARGET_PATH
= ${SCRIPT_DIR}:${STAGING_TOOLS}/bin
:${STAGING_DIR}/scripts
:${_PATH}
40 REAL_GNU_TARGET_NAME
= $(CPU_ARCH
)-linux-
$(ADK_TARGET_SUFFIX
)
41 GNU_TARGET_NAME
= $(CPU_ARCH
)-linux
42 TOOLCHAIN_SYSROOT
:= $(TOOLCHAIN_BUILD_DIR
)/libc_dev
43 ifeq ($(ADK_NATIVE
),y
)
44 TARGET_COMPILER_PREFIX?
=
47 TARGET_COMPILER_PREFIX?
=${TARGET_CROSS}
48 TARGET_CROSS
:= $(STAGING_TOOLS
)/bin
/$(CPU_ARCH
)-linux-
$(ADK_TARGET_SUFFIX
)-
50 TARGET_CC
:= ${TARGET_COMPILER_PREFIX}gcc
51 TARGET_CXX
:= ${TARGET_COMPILER_PREFIX}g
++
52 TARGET_CPPFLAGS
+= -I
${STAGING_DIR}/usr
/include
53 TARGET_LDFLAGS
+= -Wl
,-O2
54 PATCH
= ${BASH} $(SCRIPT_DIR
)/patch.sh
56 LINUX_DIR
:= $(BUILD_DIR
)/linux
57 LINUX_HEADER_DIR
:= $(STAGING_DIR
)/linux-header
59 TARGET_CONFIGURE_OPTS
= PATH
='${TARGET_PATH}' \
60 AR
=$(TARGET_CROSS
)ar \
61 AS
=$(TARGET_CROSS
)as \
62 LD
=$(TARGET_CROSS
)ld \
63 NM
=$(TARGET_CROSS
)nm \
67 RANLIB
=$(TARGET_CROSS
)ranlib
68 HOST_CONFIGURE_OPTS
= CC_FOR_BUILD
='${HOSTCC}' \
69 CFLAGS_FOR_BUILD
='${HOSTCFLAGS}' \
70 CPPFLAGS_FOR_BUILD
='${HOSTCPPFLAGS}' \
71 LDFLAGS_FOR_BUILD
='${HOSTLDFLAGS}'
73 PKG_SUFFIX
:= $(strip $(subst ",, $(ADK_PACKAGE_SUFFIX)))
75 ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
76 PKG_BUILD:= ${BASH} ${SCRIPT_DIR}/ipkg-build -c -o 0 -g 0
78 PKG_INSTALL:= IPKG_TMP=$(BUILD_DIR)/tmp \
79 IPKG_INSTROOT=$(TARGET_DIR) \
80 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
81 IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
82 ${BASH} ${SCRIPT_DIR}/ipkg \
83 -force-defaults -force-depends install
84 PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/ipkg
86 PKG_BUILD:= ${BASH} ${SCRIPT_DIR}/tarpkg build
87 PKG_INSTALL:= INSTROOT=$(TARGET_DIR) \
88 ${BASH} ${SCRIPT_DIR}/tarpkg install
89 PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/pkg
92 ifeq ($(ADK_NATIVE),y)
93 RSTRIP:= prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh
95 RSTRIP:= prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh
98 EXTRACT_CMD= mkdir -p ${WRKDIR}; \
100 for file in ${FULLDISTFILES}; do case $$file in \
102 cat $$file | cpio -i -d --quiet ;; \
105 *.cpio.Z | *.cpio.gz | *.cgz | *.mcz) \
106 gzip -dc $$file | cpio -i -d --quiet ;; \
107 *.tar.Z | *.tar.gz | *.taz | *.tgz) \
108 gzip -dc $$file | tar -xf - ;; \
109 *.cpio.bz2 | *.cbz) \
110 bzip2 -dc $$file | cpio -i -d --quiet ;; \
111 *.tar.bz2 | *.tbz | *.tbz2) \
112 bzip2 -dc $$file | tar -xf - ;; \
114 unzip -qd ${WRKDIR} $$file ;; \
116 echo "Cannot extract
'$$file'" >&2; \
125 FETCH_CMD?= wget -t1 --timeout=30 $(QUIET)
127 include $(TOPDIR)/mk/mirrors.mk