summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/iproute2/iproute2/configure-cross.patch
blob: 5536fb57656491e9eda89cc4bf969d04bdc51324 (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
From 85b0589b4843c03e8e6fd9416d71ea449a73c5c0 Mon Sep 17 00:00:00 2001
From: Koen Kooi <koen@dominion.thruhere.net>
Date: Thu, 3 Nov 2011 10:46:16 +0100
Subject: [PATCH] make configure cross compile safe

According to Kevin Tian:
Upstream-Status: Pending

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Shane Wang <shane.wang@intel.com>

Index: iproute2-4.11.0/configure
===================================================================
--- iproute2-4.11.0.orig/configure
+++ iproute2-4.11.0/configure
@@ -2,6 +2,7 @@
 # This is not an autoconf generated configure
 #
 INCLUDE=${1:-"$PWD/include"}
+SYSROOT=$1
 
 # Make a temp directory in build tree.
 TMPDIR=$(mktemp -d config.XXXXXX)
@@ -192,7 +193,7 @@ check_ipt_lib_dir()
 		return
 	fi
 
-	for dir in /lib /usr/lib /usr/local/lib
+	for dir in $SYSROOT/lib $SYSROOT/usr/lib $SYSROOT/usr/local/lib
 	do
 		for file in $dir/{xtables,iptables}/lib*t_*so ; do
 			if [ -f $file ]; then
highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/env python
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
#
# Copyright (c) 2013, Intel Corporation.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# DESCRIPTION 'wic' is the OpenEmbedded Image Creator that users can
# use to generate bootable images.  Invoking it without any arguments
# will display help screens for the 'wic' command and list the
# available 'wic' subcommands.  Invoking a subcommand without any
# arguments will likewise display help screens for the specified
# subcommand.  Please use that interface for detailed help.
#
# AUTHORS
# Tom Zanussi <tom.zanussi (at] linux.intel.com>
#

__version__ = "0.1.0"

# Python Standard Library modules
import os
import sys
import optparse
import logging
from distutils import spawn

# External modules
scripts_path = os.path.abspath(os.path.dirname(__file__))
lib_path = scripts_path + '/lib'
sys.path.append(lib_path)

bitbake_exe = spawn.find_executable('bitbake')
if bitbake_exe:
    bitbake_path = os.path.join(os.path.dirname(bitbake_exe), '../lib')
    sys.path.append(bitbake_path)
    from bb import cookerdata
    from bb.main import bitbake_main, BitBakeConfigParameters
else:
    bitbake_main = None

from image.help import *
from image.engine import *

def rootfs_dir_to_args(krootfs_dir):
    """
    Get a rootfs_dir dict and serialize to string
    """
    rootfs_dir = ''
    for k, v in krootfs_dir.items():
        rootfs_dir += ' '
        rootfs_dir += '='.join([k, v])
    return rootfs_dir.strip()

def callback_rootfs_dir(option, opt, value, parser):
    """
    Build a dict using --rootfs_dir connection=dir
    """
    if not type(parser.values.rootfs_dir) is dict:
        parser.values.rootfs_dir = dict()

    if '=' in value:
        (key, rootfs_dir) = value.split('=')
    else:
        key = 'ROOTFS_DIR'
        rootfs_dir = value

    parser.values.rootfs_dir[key] = rootfs_dir

def wic_create_subcommand(args, usage_str):
    """
    Command-line handling for image creation.  The real work is done
    by image.engine.wic_create()
    """
    parser = optparse.OptionParser(usage=usage_str)

    parser.add_option("-o", "--outdir", dest="outdir",
                      action="store", help="name of directory to create image in")
    parser.add_option("-i", "--infile", dest="properties_file",
                      action="store", help="name of file containing the values for image properties as a JSON file")
    parser.add_option("-e", "--image-name", dest="image_name",
                      action="store", help="name of the image to use the artifacts from e.g. core-image-sato")
    parser.add_option("-r", "--rootfs-dir", dest="rootfs_dir",
                      action="callback", callback=callback_rootfs_dir, type="string",
                      help="path to the /rootfs dir to use as the .wks rootfs source")
    parser.add_option("-b", "--bootimg-dir", dest="bootimg_dir",
                      action="store", help="path to the dir containing the boot artifacts (e.g. /EFI or /syslinux dirs) to use as the .wks bootimg source")
    parser.add_option("-k", "--kernel-dir", dest="kernel_dir",
                      action="store", help="path to the dir containing the kernel to use in the .wks bootimg")
    parser.add_option("-n", "--native-sysroot", dest="native_sysroot",
                      action="store", help="path to the native sysroot containing the tools to use to build the image")
    parser.add_option("-p", "--skip-build-check", dest="build_check",
                      action="store_false", default=True, help="skip the build check")
    parser.add_option("-f", "--build-rootfs", action="store_true", help="build rootfs")
    parser.add_option("-D", "--debug", dest="debug", action="store_true",
                      default=False, help="output debug information")

    (options, args) = parser.parse_args(args)

    if len(args) != 1:
        logging.error("Wrong number of arguments, exiting\n")
        parser.print_help()
        sys.exit(1)

    if options.build_rootfs and not bitbake_main:
        logging.error("Can't build roofs as bitbake is not in the $PATH")
        sys.exit(1)

    if not options.image_name and not (options.rootfs_dir and
                                       options.bootimg_dir and
                                       options.kernel_dir and
                                       options.native_sysroot):
        print "Build artifacts not completely specified, exiting."
        print "  (Use 'wic -e' or 'wic -r -b -k -n' to specify artifacts)"
        sys.exit(1)

    if not options.image_name:
        options.build_check = False

    if options.build_check and not options.properties_file:
        print "Checking basic build environment..."
        if not verify_build_env():
            print "Couldn't verify build environment, exiting\n"
            sys.exit(1)
        else:
            print "Done.\n"

    bitbake_env_lines = find_bitbake_env_lines(options.image_name)
    if not bitbake_env_lines:
        print "Couldn't get bitbake environment, exiting."
        sys.exit(1)
    set_bitbake_env_lines(bitbake_env_lines)

    bootimg_dir = ""

    if options.image_name:
        if options.build_rootfs:
            argv = ["bitbake", options.image_name]
            if options.debug:
                argv.append("--debug")

            print "Building rootfs...\n"
            if bitbake_main(BitBakeConfigParameters(argv),
                            cookerdata.CookerConfiguration()):
                sys.exit(1)

        (rootfs_dir, kernel_dir, bootimg_dir, native_sysroot) \
            = find_artifacts(options.image_name)

    else:
        if options.build_rootfs:
            print "Image name is not specified, exiting. (Use -e/--image-name to specify it)\n"
            sys.exit(1)

    wks_file = args[0]

    if not wks_file.endswith(".wks"):
        wks_file = find_canned_image(scripts_path, wks_file)
        if not wks_file:
            print "No image named %s found, exiting.  (Use 'wic list images' to list available images, or specify a fully-qualified OE kickstart (.wks) filename)\n" % wks_file
            sys.exit(1)

    image_output_dir = ""
    if options.outdir:
        image_output_dir = options.outdir

    if not options.image_name:
        rootfs_dir = ''
        if 'ROOTFS_DIR' in options.rootfs_dir:
            rootfs_dir = options.rootfs_dir['ROOTFS_DIR']
        bootimg_dir = options.bootimg_dir
        kernel_dir = options.kernel_dir
        native_sysroot = options.native_sysroot
        if rootfs_dir and not os.path.isdir(rootfs_dir):
            print "--roofs-dir (-r) not found, exiting\n"
            sys.exit(1)
        if not os.path.isdir(bootimg_dir):
            print "--bootimg-dir (-b) not found, exiting\n"
            sys.exit(1)
        if not os.path.isdir(kernel_dir):
            print "--kernel-dir (-k) not found, exiting\n"
            sys.exit(1)
        if not os.path.isdir(native_sysroot):
            print "--native-sysroot (-n) not found, exiting\n"
            sys.exit(1)
    else:
        not_found = not_found_dir = ""
        if not os.path.isdir(rootfs_dir):
            (not_found, not_found_dir) = ("rootfs-dir", rootfs_dir)
        elif not os.path.isdir(kernel_dir):
            (not_found, not_found_dir) = ("kernel-dir", kernel_dir)
        elif not os.path.isdir(native_sysroot):
            (not_found, not_found_dir) = ("native-sysroot", native_sysroot)
        if not_found:
            if not not_found_dir:
                not_found_dir = "Completely missing artifact - wrong image (.wks) used?"
            print "Build artifacts not found, exiting."
            print "  (Please check that the build artifacts for the machine"
            print "   selected in local.conf actually exist and that they"
            print "   are the correct artifacts for the image (.wks file)).\n"
            print "The artifact that couldn't be found was %s:\n  %s" % \
                (not_found, not_found_dir)
            sys.exit(1)

    krootfs_dir = options.rootfs_dir
    if krootfs_dir is None:
        krootfs_dir = {}
        krootfs_dir['ROOTFS_DIR'] = rootfs_dir

    rootfs_dir = rootfs_dir_to_args(krootfs_dir)

    print "Creating image(s)...\n"
    wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
               native_sysroot, scripts_path, image_output_dir,
               options.debug, options.properties_file)


def wic_list_subcommand(args, usage_str):
    """
    Command-line handling for listing available image properties and
    values.  The real work is done by image.engine.wic_list()
    """
    parser = optparse.OptionParser(usage=usage_str)

    parser.add_option("-o", "--outfile", action="store",
                      dest="properties_file",
                      help="dump the possible values for image properties to a JSON file")

    (options, args) = parser.parse_args(args)

    bitbake_env_lines = find_bitbake_env_lines(None)
    if not bitbake_env_lines:
        print "Couldn't get bitbake environment, exiting."
        sys.exit(1)
    set_bitbake_env_lines(bitbake_env_lines)

    if not wic_list(args, scripts_path, options.properties_file):
        logging.error("Bad list arguments, exiting\n")
        parser.print_help()
        sys.exit(1)


def wic_help_topic_subcommand(args, usage_str):
    """
    Command-line handling for help-only 'subcommands'.  This is
    essentially a dummy command that doesn nothing but allow users to
    use the existing subcommand infrastructure to display help on a
    particular topic not attached to any particular subcommand.
    """
    pass


wic_help_topic_usage = """
"""

subcommands = {
    "create":    [wic_create_subcommand,
                  wic_create_usage,
                  wic_create_help],
    "list":      [wic_list_subcommand,
                  wic_list_usage,
                  wic_list_help],
    "plugins":   [wic_help_topic_subcommand,
                  wic_help_topic_usage,
                  wic_plugins_help],
    "overview":   [wic_help_topic_subcommand,
                  wic_help_topic_usage,
                  wic_overview_help],
    "kickstart":  [wic_help_topic_subcommand,
                  wic_help_topic_usage,
                  wic_kickstart_help],
}


def start_logging(loglevel):
    logging.basicConfig(filname='wic.log', filemode='w', level=loglevel)


def main(argv):
    parser = optparse.OptionParser(version="wic version %s" % __version__,
                                   usage=wic_usage)

    parser.disable_interspersed_args()

    (options, args) = parser.parse_args(argv)

    if len(args):
        if args[0] == "help":
            if len(args) == 1:
                parser.print_help()
                sys.exit(1)

    invoke_subcommand(args, parser, wic_help_usage, subcommands)


if __name__ == "__main__":
    try:
        ret = main(sys.argv[1:])
    except Exception:
        ret = 1
        import traceback
        traceback.print_exc(5)
    sys.exit(ret)