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
|
# Part of the A-A-P recipe executive: Setup using GCC
# Copyright (c) 2002-2003 stichting NLnet Labs
# Permission to copy and use this file is specified in the file COPYING.
# If this file is missing you can find it here: http://www.a-a-p.org/COPYING
#
# This module sets up variables and actions for using the GCC compiler tools.
# Last Change: 2004 Jun 11
#
from RecPython import *
import Global
from Action import action_add
from Dictlist import str2dictlist
from RecPos import RecPos
def exists():
"""
Return TRUE when the GCC toolchain can be found.
"""
# TODO: "cc" may also be gcc, use the gcc configure check for this.
return program_path("gcc")
def define_actions():
"""
Define the actions that GCC can accomplish.
"""
# Allow the user to define the gcc command to be used with $GCC.
rd = Global.globals
if not rd.get("GCC"):
rd["GCC"] = "gcc"
# When "g++" or "gxx" can be found use it for compiling C++. When it
# cannot be found use "gcc" (causes problems when linking?).
if not rd.get("GXX"):
if program_path("g++"):
rd["GXX"] = "g++"
elif program_path("gxx"):
rd["GXX"] = "gxx"
else:
rd["GXX"] = "gcc"
define_action("compile_gcc", 0, """
:buildcheck $OPTIMIZE $?DEBUG
:sys $GCC $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` $CFLAGS -o $target -c $source
""",
outtypes = ["object", "libobject"],
intypes = ["c"])
define_action("compile_gcc", 0, """
:buildcheck $OPTIMIZE $?DEBUG
:sys $GCC $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` $CFLAGS -fPIC -o $target -c $source
""",
outtypes = ["dllobject"],
intypes = ["c"])
define_action("compile_gxx", 0, """
:buildcheck $OPTIMIZE $?DEBUG
:sys $GXX $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` $CXXFLAGS -o $target -c $source
""",
outtypes = ["object", "libobject"],
intypes = ["cpp"])
define_action("compile_gxx", 0, """
:buildcheck $OPTIMIZE $?DEBUG
:sys $GXX $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` $CXXFLAGS -fPIC -o $target -c $source
""",
outtypes = ["dllobject"],
intypes = ["cpp"])
define_action("build_gcc", 0, """
:sys $GCC $LDFLAGS `cflags_normal()` -o $target $source $?LIBS
""",
outtypes = ["default"],
intypes = ["object", "libobject"])
define_action("build_gxx", 0, """
:sys $GXX $LDFLAGS `cflags_normal()` -o $target $source $?LIBS
""",
outtypes = ["default"],
intypes = ["object", "libobject"])
def use_actions(scope):
"""
Setup variables so that the default actions use the GCC actions.
"""
scope["C_COMPILE_ACTION"] = "compile_gcc"
scope["CXX_COMPILE_ACTION"] = "compile_gxx"
scope["C_BUILD_ACTION"] = "build_gcc"
scope["CXX_BUILD_ACTION"] = "build_gxx"
# Attempt using gcc for dependency checks.
scope["HASGCC"] = ""
scope["HASGCCXX"] = ""
# vim: set sw=4 et sts=4 tw=79 fo+=l:
|