Merge change 1161 into donut

* changes:
  Initial import of new NDK into donut tree
This commit is contained in:
Android (Google) Code Review
2009-05-07 12:01:10 -07:00
1437 changed files with 79943 additions and 0 deletions

18
ndk/GNUmakefile Normal file
View File

@@ -0,0 +1,18 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# DO NOT MODIFY THIS FILE
include build/core/main.mk
# END OF FILE

27
ndk/README.TXT Normal file
View File

@@ -0,0 +1,27 @@
Android Native Development Kit (NDK)
Welcome, this NDK is designed to allow Android application developers
to include native code in their Android application packages, compiled
as JNI shared libraries.
A high-level overview of the NDK's features and limitations can be found
in docs/OVERVIEW.TXT. Please read this document as it contains crucial
information for correct usage.
Before using the NDK, you will need to follow the steps described by
docs/INSTALL.TXT which lists the NDK pre-requisites and the steps needed
to set it up properly on your machine.
We recommend developers to make themselves familiar with JNI concepts. Also
note that the NDK is *not* a good way to write non-JNI native code for the
Android platform.
The document docs/ROADMAP.TXT gives a tentative roadmap for upcoming
NDK features and improvements.
Finally, discussions related to the Android NDK happen on the public
"android-ndk" forum located at the following address:
http://groups.google.com/group/android-ndk

View File

@@ -0,0 +1,2 @@
APP_PROJECT_PATH := $(call my-dir)/project
APP_MODULES := hello-jni

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.HelloJni"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name">
<activity android:name=".HelloJni"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,15 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# The name of your application package as defined in the manifest.
# Used by the 'uninstall' rule.
#application-package=com.example.myproject
# The name of the source folder.
#source-folder=src
# The name of the output folder.
#out-folder=bin

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="HelloJni" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contain the path to the SDK. It should *NOT* be checked in in Version
Control Systems. -->
<property file="local.properties"/>
<!-- The build.properties file can be created by you and is never touched
by the 'android' tool. This is the place to change some of the default property values
used by the Ant rules.
Here are some properties you may want to change/update:
application-package
the name of your application package as defined in the manifest. Used by the
'uninstall' rule.
source-folder
the name of the source folder. Default is 'src'.
out-folder
the name of the output folder. Default is 'bin'.
Properties related to the SDK location or the project target should be updated
using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems.
-->
<property file="build.properties"/>
<!-- The default.properties file is created and updated by the 'android' tool, as well
as ADT.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems. -->
<property file="default.properties"/>
<!-- Custom Android task to deal with the project target, and import the proper rules.
This requires ant 1.6.0 or above. -->
<path id="android.antlibs">
<pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
<pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
<pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
<pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
<pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
</path>
<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs"/>
<!-- Execute the Android Setup task that will setup some properties specific to the target,
and import the rules files.
To customize the rules, copy/paste them below the task, and disable import by setting
the import attribute to false:
<setup import="false" />
This will ensure that the properties are setup correctly but that your customized
targets are used.
-->
<setup />
</project>

View File

@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-3

View File

@@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk-location=/opt/digit/android/main/cupcake/android/out/host/linux-x86/sdk/android-sdk_eng.digit_linux-x86

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, HelloJni"
/>
</LinearLayout>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">HelloJni</string>
</resources>

View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.HelloJni;
import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
public class HelloJni extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
/* Create a TextView and set its content.
* the text is retrieved by calling a native
* function.
*/
TextView tv = new TextView(this);
tv.setText( stringFromJNI() );
setContentView(tv);
}
/* A native method that is implemented by the
* 'hello-jni' native library, which is packaged
* with this application.
*/
public native String stringFromJNI();
/* This is another native method declaration that is *not*
* implemented by 'hello-jni'. This is simply to show that
* you can declare as many native methods in your Java code
* as you want, their implementation is searched in the
* currently loaded native libraries only the first time
* you call them.
*
* Trying to call this function will result in a
* java.lang.UnsatisfiedLinkError exception !
*/
public native String unimplementedStringFromJNI();
/* this is used to load the 'hello-jni' library on application
* startup. The library has already been unpacked into
* /data/data/com.example.HelloJni/lib/libhello-jni.so at
* installation time by the package manager.
*/
static {
System.loadLibrary("hello-jni");
}
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.HelloJni.tests"
android:versionCode="1"
android:versionName="1.0">
<!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
<application>
<uses-library android:name="android.test.runner" />
</application>
<!--
This declares that this application uses the instrumentation test runner targeting
the package of com.example.HelloJni. To run the tests use the command:
"adb shell am instrument -w com.example.HelloJni.tests/android.test.InstrumentationTestRunner"
-->
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.HelloJni"
android:label="Tests for HelloJni"/>
</manifest>

View File

@@ -0,0 +1,15 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# The name of your application package as defined in the manifest.
# Used by the 'uninstall' rule.
#application-package=com.example.myproject
# The name of the source folder.
#source-folder=src
# The name of the output folder.
#out-folder=bin

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="HelloJni" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contain the path to the SDK. It should *NOT* be checked in in Version
Control Systems. -->
<property file="local.properties"/>
<!-- The build.properties file can be created by you and is never touched
by the 'android' tool. This is the place to change some of the default property values
used by the Ant rules.
Here are some properties you may want to change/update:
application-package
the name of your application package as defined in the manifest. Used by the
'uninstall' rule.
source-folder
the name of the source folder. Default is 'src'.
out-folder
the name of the output folder. Default is 'bin'.
Properties related to the SDK location or the project target should be updated
using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems.
-->
<property file="build.properties"/>
<!-- The default.properties file is created and updated by the 'android' tool, as well
as ADT.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems. -->
<property file="default.properties"/>
<!-- Custom Android task to deal with the project target, and import the proper rules.
This requires ant 1.6.0 or above. -->
<path id="android.antlibs">
<pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
<pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
<pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
<pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
<pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
</path>
<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs"/>
<!-- Execute the Android Setup task that will setup some properties specific to the target,
and import the rules files.
To customize the rules, copy/paste them below the task, and disable import by setting
the import attribute to false:
<setup import="false" />
This will ensure that the properties are setup correctly but that your customized
targets are used.
-->
<setup />
</project>

View File

@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-3

View File

@@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk-location=/opt/digit/android/main/cupcake/android/out/host/linux-x86/sdk/android-sdk_eng.digit_linux-x86

View File

@@ -0,0 +1,21 @@
package com.example.HelloJni;
import android.test.ActivityInstrumentationTestCase;
/**
* This is a simple framework for a test of an Application. See
* {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
* how to write and extend Application tests.
* <p/>
* To run this test, you can type:
* adb shell am instrument -w \
* -e class com.example.HelloJni.HelloJniTest \
* com.example.HelloJni.tests/android.test.InstrumentationTestRunner
*/
public class HelloJniTest extends ActivityInstrumentationTestCase<HelloJni> {
public HelloJniTest() {
super("com.example.HelloJni", HelloJni.class);
}
}

View File

@@ -0,0 +1,2 @@
APP_PROJECT_PATH := $(call my-dir)/project
APP_MODULES := twolib-first twolib-second

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.TwoLib"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name">
<activity android:name=".TwoLib"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,15 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# The name of your application package as defined in the manifest.
# Used by the 'uninstall' rule.
#application-package=com.example.myproject
# The name of the source folder.
#source-folder=src
# The name of the output folder.
#out-folder=bin

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="TwoLib" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contain the path to the SDK. It should *NOT* be checked in in Version
Control Systems. -->
<property file="local.properties"/>
<!-- The build.properties file can be created by you and is never touched
by the 'android' tool. This is the place to change some of the default property values
used by the Ant rules.
Here are some properties you may want to change/update:
application-package
the name of your application package as defined in the manifest. Used by the
'uninstall' rule.
source-folder
the name of the source folder. Default is 'src'.
out-folder
the name of the output folder. Default is 'bin'.
Properties related to the SDK location or the project target should be updated
using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems.
-->
<property file="build.properties"/>
<!-- The default.properties file is created and updated by the 'android' tool, as well
as ADT.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems. -->
<property file="default.properties"/>
<!-- Custom Android task to deal with the project target, and import the proper rules.
This requires ant 1.6.0 or above. -->
<path id="android.antlibs">
<pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
<pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
<pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
<pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
<pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
</path>
<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs"/>
<!-- Execute the Android Setup task that will setup some properties specific to the target,
and import the rules files.
To customize the rules, copy/paste them below the task, and disable import by setting
the import attribute to false:
<setup import="false" />
This will ensure that the properties are setup correctly but that your customized
targets are used.
-->
<setup />
</project>

View File

@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-3

View File

@@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk-location=/opt/digit/android/main/cupcake/android/out/host/linux-x86/sdk/android-sdk_eng.digit_linux-x86

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, TwoLib"
/>
</LinearLayout>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TwoLib</string>
</resources>

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.TwoLib;
import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
public class TwoLib extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
int x = 1000;
int y = 42;
// here, we dynamically load the library at runtime
// before calling the native method.
//
System.loadLibrary("twolib-second");
int z = add(x, y);
tv.setText( "The sum of " + x + " and " + y + " is " + z );
setContentView(tv);
}
public native int add(int x, int y);
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.TwoLib.tests"
android:versionCode="1"
android:versionName="1.0">
<!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
<application>
<uses-library android:name="android.test.runner" />
</application>
<!--
This declares that this application uses the instrumentation test runner targeting
the package of com.example.TwoLib. To run the tests use the command:
"adb shell am instrument -w com.example.TwoLib.tests/android.test.InstrumentationTestRunner"
-->
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.TwoLib"
android:label="Tests for TwoLib"/>
</manifest>

View File

@@ -0,0 +1,15 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# The name of your application package as defined in the manifest.
# Used by the 'uninstall' rule.
#application-package=com.example.myproject
# The name of the source folder.
#source-folder=src
# The name of the output folder.
#out-folder=bin

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="TwoLib" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contain the path to the SDK. It should *NOT* be checked in in Version
Control Systems. -->
<property file="local.properties"/>
<!-- The build.properties file can be created by you and is never touched
by the 'android' tool. This is the place to change some of the default property values
used by the Ant rules.
Here are some properties you may want to change/update:
application-package
the name of your application package as defined in the manifest. Used by the
'uninstall' rule.
source-folder
the name of the source folder. Default is 'src'.
out-folder
the name of the output folder. Default is 'bin'.
Properties related to the SDK location or the project target should be updated
using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems.
-->
<property file="build.properties"/>
<!-- The default.properties file is created and updated by the 'android' tool, as well
as ADT.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems. -->
<property file="default.properties"/>
<!-- Custom Android task to deal with the project target, and import the proper rules.
This requires ant 1.6.0 or above. -->
<path id="android.antlibs">
<pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
<pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
<pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
<pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
<pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
</path>
<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs"/>
<!-- Execute the Android Setup task that will setup some properties specific to the target,
and import the rules files.
To customize the rules, copy/paste them below the task, and disable import by setting
the import attribute to false:
<setup import="false" />
This will ensure that the properties are setup correctly but that your customized
targets are used.
-->
<setup />
</project>

View File

@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-3

View File

@@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk-location=/opt/digit/android/main/cupcake/android/out/host/linux-x86/sdk/android-sdk_eng.digit_linux-x86

View File

@@ -0,0 +1,21 @@
package com.example.TwoLib;
import android.test.ActivityInstrumentationTestCase;
/**
* This is a simple framework for a test of an Application. See
* {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
* how to write and extend Application tests.
* <p/>
* To run this test, you can type:
* adb shell am instrument -w \
* -e class com.example.TwoLib.TwoLibTest \
* com.example.TwoLib.tests/android.test.InstrumentationTestRunner
*/
public class TwoLibTest extends ActivityInstrumentationTestCase<TwoLib> {
public TwoLibTest() {
super("com.example.TwoLib", TwoLib.class);
}
}

View File

@@ -0,0 +1,62 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this script is used to record an application definition in the
# NDK build system, before performing any build whatsoever.
#
# It is included repeatedly from build/core/main.mk and expects a
# variable named '_application_mk' which points to a given Application.mk
# file that will be included here. The latter must define a few variables
# to describe the application to the build system, and the rest of the
# code here will perform book-keeping and basic checks
#
$(call assert-defined, _application_mk)
$(call clear-vars, $(NDK_APP_VARS))
include $(_application_mk)
$(call check-required-vars,$(NDK_APP_VARS_REQUIRED),$(_application_mk))
# strip the 'lib' prefix in front of APP_MODULES modules
APP_MODULES := $(call strip-lib-prefix,$(APP_MODULES))
# check that APP_OPTIM, if defined, is either 'release' or 'debug'
$(if $(filter-out release debug,$(APP_OPTIM)),\
$(call __ndk_info, The APP_OPTIM defined in $(_application_mk) must only be 'release' or 'debug')\
$(call __ndk_error,Aborting)\
)
_dir := $(patsubst %/,%,$(dir $(_application_mk)))
_name := $(notdir $(_dir))
_app := NDK_APP.$(_name)
$(if $(strip $(APP.$(_app).defined)),\
$(call __ndk_info,Weird, the application $(_name) is already defined by $(APP.$(_app).defined))\
$(call __ndk_error,Aborting)\
)
APP.$(_app).defined := $(_application_mk)
# Record all app-specific variable definitions
$(foreach __name,$(NDK_APP_VARS),\
$(eval $(_app).$(__name) := $($(__name)))\
)
# Record the Application.mk for debugging
$(_app).Application.mk := $(_application_mk)
NDK_ALL_APPS += $(_name)

View File

@@ -0,0 +1,65 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this script is included repeatedly by main.mk to add a new toolchain
# definition to the NDK build system.
#
# 'toolchain_config' must be defined as the path of a toolchain
# configuration file (config.mk) that will be included here.
#
$(call assert-defined, _config_mk)
# The list of variables that must or may be defined
# by the toolchain configuration file
#
NDK_TOOLCHAIN_VARS_REQUIRED := TOOLCHAIN_ABIS
NDK_TOOLCHAIN_VARS_OPTIONAL :=
# Clear variables that are supposed to be defined by the config file
$(call clear-vars,$(NDK_TOOLCHAIN_VARS_REQUIRED))
$(call clear-vars,$(NDK_TOOLCHAIN_VARS_OPTIONAL))
# Include the config file
include $(_config_mk)
# Check that the proper variables were defined
$(call check-required-vars,$(NDK_TOOLCHAIN_VARS_REQUIRED),$(_config_mk))
# Check that the file didn't do something stupid
$(call assert-defined, _config_mk)
# Now record the toolchain-specific informatio
_dir := $(patsubst %/,%,$(dir $(_config_mk)))
_name := $(notdir $(_dir))
_abis := $(TOOLCHAIN_ABIS)
_toolchain := NDK_TOOLCHAIN.$(_name)
# check that the toolchain name is unique
$(if $(strip $($(_toolchain).defined)),\
$(call __ndk_error,Toolchain $(_name) defined in $(_parent) is\
already defined in $(NDK_TOOLCHAIN.$(_name).defined)))
$(_toolchain).defined := $(_toolchain_config)
$(_toolchain).abis := $(_abis)
$(_toolchain).setup := $(wildcard $(_dir)/setup.mk)
$(if $(strip $($(_toolchain).setup)),,\
$(call __ndk_error, Toolchain $(_name) lacks a setup.mk in $(_dir)))
NDK_ALL_TOOLCHAINS += $(_name)
NDK_ALL_ABIS += $(_abis)
# done

View File

@@ -0,0 +1,124 @@
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# we expect the 'my' variable to be defined, either to
# 'HOST_' or 'TARGET_', and this allows us to call the
# appropriate compiler with $($(my)CC)
#
$(call assert-defined,my)
# LOCAL_MAKEFILE must also exist and name the Android.mk that
# included the module build script.
#
$(call assert-defined,LOCAL_MAKEFILE)
include $(BUILD_SYSTEM)/build-module.mk
# list of generated object files
LOCAL_OBJECTS :=
#
# Add the default system shared libraries to the build
#
ifndef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
LOCAL_SHARED_LIBRARIES += $(TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
else
LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
endif
endif
#
# Check LOCAL_CPP_EXTENSION, use '.cpp' by default
#
LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
ifeq ($(LOCAL_CPP_EXTENSION),)
LOCAL_CPP_EXTENSION := .cpp
else
ifneq ($(words $(LOCAL_CPP_EXTENSION)),1)
$(call __ndk_log, LOCAL_CPP_EXTENSION in $(LOCAL_MAKEFILE) must be one word only, not '$(LOCAL_CPP_EXTENSION)')
$(call __ndk_error, Aborting)
endif
endif
#
# The original Android build system allows you to use the .arm prefix
# to a source file name to indicate that it should be defined in either
# 'thumb' or 'arm' mode, depending on the value of LOCAL_ARM_MODE
#
# First, check LOCAL_ARM_MODE, it should be empty, 'thumb' or 'arm'
# We make the default 'thumb'
#
LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
ifeq ($(LOCAL_ARM_MODE),)
LOCAL_ARM_MODE := thumb
else
ifneq ($(words $(LOCAL_ARM_MODE)),1)
$(call __ndk_log, LOCAL_ARM_MODE in $(LOCAL_MAKEFILE) must be one word, not '$(LOCAL_ARM_MODE)')
$(call __ndk_error, Aborting)
endif
# check that LOCAL_ARM_MODE is defined to either 'arm' or 'thumb'
$(if $(filter-out thumb arm, $(LOCAL_ARM_MODE)),\
$(call __ndk_log, LOCAL_ARM_MODE must be defined to either 'arm' or 'thumb' in $(LOCAL_MAKEFILE), not '$(LOCAL_ARM_MODE)')\
$(call __ndk_error, Aborting)\
)
endif
LOCAL_ARM_TEXT_arm = arm$(space)$(space)
LOCAL_ARM_TEXT_thumb = thumb
LOCAL_ARM_CFLAGS := $(TARGET_$(LOCAL_ARM_MODE)_$(LOCAL_BUILD_MODE)_CFLAGS)
LOCAL_ARM_TEXT := $(LOCAL_ARM_TEXT_$(LOCAL_ARM_MODE))
# As a special case, the original Android build system
# allows one to specify that certain source files can be
# forced to build in ARM mode by using a '.arm' suffix
# after the extension, e.g.
#
# LOCAL_SRC_FILES := foo.c.arm
#
# to build source file $(LOCAL_PATH)/foo.c as ARM
#
#
# Build C source files into .o
#
# XXX: TODO: support LOCAL_ARM_MODE
arm_sources := $(LOCAL_SRC_FILES:%.arm)
c_sources := $(filter %.c, \
$(LOCAL_SRC_FILES) \
$(arm_sources:%.arm=%))
s_sources := $(filter %.S, \
$(LOCAL_SRC_FILES) \
$(arm_sources:%.arm=%))
cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION), \
$(LOCAL_SRC_FILES) \
$(arm_sources:%.arm=%))
#
# The following will update LOCAL_OBJECTS and LOCAL_DEPENDENCY_DIRS
#
$(foreach src,$(c_sources), $(call compile-c-source,$(src)))
$(foreach src,$(s_sources), $(call compile-s-source,$(src)))
$(foreach src,$(cpp_sources), $(call compile-cpp-source,$(src)))
LOCAL_DEPENDENCY_DIRS := $(sort $(LOCAL_DEPENDENCY_DIRS))
CLEAN_OBJS_DIRS += $(LOCAL_OBJS_DIR)

View File

@@ -0,0 +1,72 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this file is included from Android.mk files to build a target-specific
# executable program
#
LOCAL_BUILD_SCRIPT := BUILD_EXECUTABLE
LOCAL_MODULE_CLASS := EXECUTABLE
LOCAL_MAKEFILE := $(local-makefile)
$(call check-defined-LOCAL_MODULE,$(LOCAL_BUILD_SCRIPT))
$(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE))
# only adjust the build if this module is needed by the current app
ifneq ($(filter $(LOCAL_MODULE),$(NDK_APP_MODULES)),)
# we are building target objects
my := TARGET_
LOCAL_BUILT_MODULE := $(call executable-path,$(LOCAL_MODULE))
LOCAL_OBJS_DIR := $(TARGET_OBJS)/$(LOCAL_MODULE)
include $(BUILD_SYSTEM)/build-binary.mk
LOCAL_STATIC_LIBRARIES := $(call strip-lib-prefix,$(LOCAL_STATIC_LIBRARIES))
LOCAL_SHARED_LIBRARIES := $(call strip-lib-prefix,$(LOCAL_SHARED_LIBRARIES))
static_libraries := $(call map,static-library-path,$(LOCAL_STATIC_LIBRARIES))
shared_libraries := $(call map,shared-library-path,$(LOCAL_SHARED_LIBRARIES)) \
$(TARGET_PREBUILT_SHARED_LIBRARIES)
$(LOCAL_BUILT_MODULE): $(static_libraries) $(shared_libraries)
LOCAL_LDLIBS := $(_module_libs) $(LOCAL_LDLIBS)
$(LOCAL_BUILT_MODULE): PRIVATE_STATIC_LIBRARIES := $(static_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBRARIES := $(shared_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_OBJECTS := $(LOCAL_OBJECTS)
$(LOCAL_BUILT_MODULE): PRIVATE_LDFLAGS := $(TARGET_LDFLAGS) $(LOCAL_LDFLAGS)
$(LOCAL_BUILT_MODULE): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) $(TARGET_LDLIBS)
$(LOCAL_BUILT_MODULE): PRIVATE_NAME := $(notdir $(LOCAL_BUILT_MODULE))
$(LOCAL_BUILT_MODULE): PRIVATE_DEST := $(NDK_APP_DEST)
$(LOCAL_BUILT_MODULE): PRIVATE_SRC := $(LOCAL_BUILT_MODULE)
$(LOCAL_BUILT_MODULE): PRIVATE_DST := $(PRIVATE_DEST)/$(PRIVATE_NAME)
$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
@ mkdir -p $(dir $@)
@ echo "Executable : $(PRIVATE_NAME)"
$(hide) $(cmd-build-executable)
@ echo "Install : $(PRIVATE_NAME) => $(PRIVATE_DEST)"
$(hide) mkdir -p $(PRIVATE_DEST)
$(hide) install -p $(PRIVATE_SRC) $(PRIVATE_DST)
$(hide) $(call cmd-strip, $(PRIVATE_DST))
ALL_EXECUTABLES += $(LOCAL_BUILT_MODULE)
endif # filter LOCAL_MODULE in NDK_APP_MODULES

View File

@@ -0,0 +1,78 @@
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Base rules shared to control the build of all modules.
# This should be included from build-binary.mk
#
$(call assert-defined,LOCAL_MODULE_CLASS LOCAL_BUILD_SCRIPT LOCAL_BUILT_MODULE)
# Check LOCAL_IS_HOST_MODULE and define 'my' as either HOST_ or TARGET_
#
LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
ifdef LOCAL_IS_HOST_MODULE
ifneq ($(LOCAL_IS_HOST_MODULE),true)
$(call __ndk_log,$(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)")
endif
my := HOST_
else
my := TARGET_
endif
# Compute 'intermediates' which is the location where we're going to store
# intermediate generated files like object (.o) files.
#
intermediates := $($(my)OBJS)
# LOCAL_INTERMEDIATES lists the targets that are generated by this module
#
LOCAL_INTERMEDIATES := $(LOCAL_BUILT_MODULE)
# LOCAL_BUILD_MODE will be either arm or thumb
#
ifneq ($(NDK_APP_OPTIM),)
LOCAL_BUILD_MODE := $(NDK_APP_OPTIM)
else
LOCAL_BUILD_MODE := thumb
endif
#
# Ensure that 'make <module>' and 'make clean-<module>' work
#
.PHONY: $(LOCAL_MODULE)
$(LOCAL_MODULE): $(LOCAL_BUILT_MODULE)
cleantarget := clean-$(LOCAL_MODULE)
.PHONY: $(cleantarget)
clean: $(cleantarget)
$(cleantarget): PRIVATE_MODULE := $(LOCAL_MODULE)
$(cleantarget): PRIVATE_CLEAN_FILES := $(PRIVATE_CLEAN_FILES) \
$(LOCAL_BUILT_MODULE) \
$(LOCAL_INSTALLED_MODULE) \
$(intermediates)
$(cleantarget)::
@echo "Clean: $(PRIVATE_MODULE)"
$(hide) rm -rf $(PRIVATE_CLEAN_FILES)
#
# Register module
#
ALL_MODULES += $(LOCAL_MODULE)

View File

@@ -0,0 +1,72 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this file is included from Android.mk files to build a target-specific
# executable program
#
LOCAL_BUILD_SCRIPT := BUILD_SHARED_LIBRARY
LOCAL_MODULE_CLASS := SHARED_LIBRARY
LOCAL_MAKEFILE := $(local-makefile)
$(call check-defined-LOCAL_MODULE,$(LOCAL_BUILD_SCRIPT))
$(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE))
# only adjust the build if this module is needed by the current app
ifneq ($(filter $(LOCAL_MODULE),$(NDK_APP_MODULES)),)
# we are building target objects
my := TARGET_
LOCAL_BUILT_MODULE := $(call shared-library-path,$(LOCAL_MODULE))
LOCAL_OBJS_DIR := $(TARGET_OBJS)/$(LOCAL_MODULE)
include $(BUILD_SYSTEM)/build-binary.mk
LOCAL_STATIC_LIBRARIES := $(call strip-lib-prefix,$(LOCAL_STATIC_LIBRARIES))
LOCAL_SHARED_LIBRARIES := $(call strip-lib-prefix,$(LOCAL_SHARED_LIBRARIES))
static_libraries := $(call map,static-library-path,$(LOCAL_STATIC_LIBRARIES))
shared_libraries := $(call map,shared-library-path,$(LOCAL_SHARED_LIBRARIES)) \
$(TARGET_PREBUILT_SHARED_LIBRARIES)
$(LOCAL_BUILT_MODULE): $(static_libraries) $(shared_libraries)
LOCAL_LDLIBS := $(_module_libs) $(LOCAL_LDLIBS)
$(LOCAL_BUILT_MODULE): PRIVATE_STATIC_LIBRARIES := $(static_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBRARIES := $(shared_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_OBJECTS := $(LOCAL_OBJECTS)
$(LOCAL_BUILT_MODULE): PRIVATE_LDFLAGS := $(TARGET_LDFLAGS) $(LOCAL_LDFLAGS)
$(LOCAL_BUILT_MODULE): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) $(TARGET_LDLIBS)
$(LOCAL_BUILT_MODULE): PRIVATE_NAME := $(notdir $(LOCAL_BUILT_MODULE))
$(LOCAL_BUILT_MODULE): PRIVATE_DEST := $(NDK_APP_DEST)
$(LOCAL_BUILT_MODULE): PRIVATE_SRC := $(LOCAL_BUILT_MODULE)
$(LOCAL_BUILT_MODULE): PRIVATE_DST := $(PRIVATE_DEST)/$(PRIVATE_NAME)
$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
@ mkdir -p $(dir $@)
@ echo "SharedLibrary : $(PRIVATE_NAME)"
$(hide) $(cmd-build-shared-library)
@ echo "Install : $(PRIVATE_NAME) => $(PRIVATE_DEST)"
$(hide) mkdir -p $(PRIVATE_DEST)
$(hide) install -p $(PRIVATE_SRC) $(PRIVATE_DST)
$(hide) $(call cmd-strip, $(PRIVATE_DST))
ALL_EXECUTABLES += $(LOCAL_BUILT_MODULE)
endif # filter LOCAL_MODULE in NDK_APP_MODULES

View File

@@ -0,0 +1,64 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this file is included from Android.mk files to build a target-specific
# executable program
#
LOCAL_BUILD_SCRIPT := BUILD_STATIC_LIBRARY
LOCAL_MODULE_CLASS := STATIC_LIBRARY
LOCAL_MAKEFILE := $(local-makefile)
$(call check-defined-LOCAL_MODULE,$(LOCAL_BUILD_SCRIPT))
$(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE))
# only adjust the build if this module is needed by the current app
ifneq ($(filter $(LOCAL_MODULE),$(NDK_APP_MODULES)),)
# we are building target objects
my := TARGET_
LOCAL_BUILT_MODULE := $(call static-library-path,$(LOCAL_MODULE))
LOCAL_OBJS_DIR := $(TARGET_OBJS)/$(LOCAL_MODULE)
include $(BUILD_SYSTEM)/build-binary.mk
static_libraries := $(call map,static-library-path,$(LOCAL_STATIC_LIBRARIES))
shared_libraries := $(call map,shared-library-path,$(LOCAL_SHARED_LIBRARIES)) \
$(TARGET_PREBUILT_SHARED_LIBRARIES)
$(LOCAL_BUILT_MODULE): $(static_libraries) $(shared_libraries)
LOCAL_LDLIBS := $(_module_libs) $(LOCAL_LDLIBS)
$(LOCAL_BUILT_MODULE): PRIVATE_STATIC_LIBRARIES := $(static_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBRARIES := $(shared_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_OBJECTS := $(LOCAL_OBJECTS)
$(LOCAL_BUILT_MODULE): PRIVATE_LDFLAGS := $(TARGET_LDFLAGS) $(LOCAL_LDFLAGS)
$(LOCAL_BUILT_MODULE): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) $(TARGET_LDLIBS)
$(LOCAL_BUILT_MODULE): PRIVATE_NAME := $(notdir $(LOCAL_BUILT_MODULE))
$(LOCAL_BUILT_MODULE): PRIVATE_SRC := $(LOCAL_BUILT_MODULE)
$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
@ mkdir -p $(dir $@)
@ echo "StaticLibrary : $(PRIVATE_NAME)"
$(hide) rm -rf $@
$(hide) $(cmd-build-static-library)
ALL_EXECUTABLES += $(LOCAL_BUILT_MODULE)
endif # filter LOCAL_MODULE in NDK_APP_MODULES

View File

@@ -0,0 +1,32 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this file is included repeatedly from Android.mk files in order to clean
# the module-specific variables from the environment,
NDK_LOCAL_VARS := \
LOCAL_MODULE \
LOCAL_SRC_FILES \
LOCAL_CFLAGS \
LOCAL_LDFLAGS \
LOCAL_ARFLAGS \
LOCAL_CPP_EXTENSION \
LOCAL_STATIC_LIBRARIES \
LOCAL_STATIC_WHOLE_LIBRARIES \
LOCAL_SHARED_LIBRARIES \
LOCAL_MAKEFILE \
$(call clear-vars, $(NDK_LOCAL_VARS))

View File

@@ -0,0 +1,485 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Common definitions for the Android NDK build system
#
# We use the GNU Make Standard Library
include build/gmsl/gmsl
# This is the Android NDK version number as a list of three items:
# major, minor, revision
#
ndk_version := 1 0 0
# Used to output warnings and error from the library, it's possible to
# disable any warnings or errors by overriding these definitions
# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS
__ndk_name := Android NDK
__ndk_info = $(info $(__ndk_name): $1 $2 $3 $4 $5)
__ndk_warning = $(warning $(__ndk_name): $1 $2 $3 $4 $5)
__ndk_error = $(error $(__ndk_name): $1 $2 $3 $4 $5)
ifdef NDK_NO_WARNINGS
__ndk_warning :=
endif
ifdef NDK_NO_ERRORS
__ndk_error :=
endif
# If NDK_TRACE is enabled then calls to the library functions are
# traced to stdout using warning messages with their arguments
ifdef NDK_TRACE
__ndk_tr1 = $(warning $0('$1'))
__ndk_tr2 = $(warning $0('$1','$2'))
__ndk_tr3 = $(warning $0('$1','$2','$3'))
else
__ndk_tr1 :=
__ndk_tr2 :=
__ndk_tr3 :=
endif
# -----------------------------------------------------------------------------
# Function : ndk_log
# Arguments: 1: text to print when NDK_LOG is defined
# Returns : None
# Usage : $(call ndk_log,<some text>)
# -----------------------------------------------------------------------------
ifdef NDK_LOG
ndk_log = $(info $(__ndk_name): $1)
else
ndk_log :=
endif
# -----------------------------------------------------------------------------
# Macro : empty
# Returns : an empty macro
# Usage : $(empty)
# -----------------------------------------------------------------------------
empty :=
# -----------------------------------------------------------------------------
# Macro : space
# Returns : a single space
# Usage : $(space)
# -----------------------------------------------------------------------------
space := $(empty) $(empty)
# -----------------------------------------------------------------------------
# Function : last2
# Arguments: a list
# Returns : the penultimate (next-to-last) element of a list
# Usage : $(call last2, <LIST>)
# -----------------------------------------------------------------------------
last2 = $(word $(words $1), x $1)
# -----------------------------------------------------------------------------
# Function : last3
# Arguments: a list
# Returns : the antepenultimate (second-next-to-last) element of a list
# Usage : $(call last3, <LIST>)
# -----------------------------------------------------------------------------
last3 = $(word $(words $1), x x $1)
# -----------------------------------------------------------------------------
# Macro : this-makefile
# Returns : the name of the current Makefile in the inclusion stack
# Usage : $(this-makefile)
# -----------------------------------------------------------------------------
this-makefile = $(lastword $(MAKEFILE_LIST))
# -----------------------------------------------------------------------------
# Macro : local-makefile
# Returns : the name of the last parsed Android.mk file
# Usage : $(local-makefile)
# -----------------------------------------------------------------------------
local-makefile = $(lastword $(filter %Android.mk,$(MAKEFILE_LIST)))
# -----------------------------------------------------------------------------
# Function : assert-defined
# Arguments: 1: list of variable names
# Returns : None
# Usage : $(call assert-defined, VAR1 VAR2 VAR3...)
# Rationale: Checks that all variables listed in $1 are defined, or abort the
# build
# -----------------------------------------------------------------------------
assert-defined = $(foreach __varname,$(strip $1),\
$(if $(strip $($(__varname))),,\
$(call __ndk_error, Assertion failure: $(__varname) is not defined)\
)\
)
# -----------------------------------------------------------------------------
# Function : clear-vars
# Arguments: 1: list of variable names
# 2: file where the variable should be defined
# Returns : None
# Usage : $(call clear-vars, VAR1 VAR2 VAR3...)
# Rationale: Clears/undefines all variables in argument list
# -----------------------------------------------------------------------------
clear-vars = $(foreach __varname,$1,$(eval $(__varname) := $(empty)))
# -----------------------------------------------------------------------------
# Function : check-required-vars
# Arguments: 1: list of variable names
# 2: file where the variable(s) should be defined
# Returns : None
# Usage : $(call check-required-vars, VAR1 VAR2 VAR3..., <file>)
# Rationale: Checks that all required vars listed in $1 were defined by $2
# or abort the build with an error
# -----------------------------------------------------------------------------
check-required-vars = $(foreach __varname,$1,\
$(if $(strip $($(__varname))),,\
$(call __ndk_info, Required variable $(__varname) is not defined by $2)\
$(call __ndk_error,Aborting)\
)\
)
# -----------------------------------------------------------------------------
# Function : modules-clear
# Arguments: None
# Returns : None
# Usage : $(call modules-clear)
# Rationale: clears the list of defined modules known by the build system
# -----------------------------------------------------------------------------
modules-clear = $(eval __ndk_modules := $(empty_set))
# -----------------------------------------------------------------------------
# Function : modules-add
# Arguments: 1: module name
# 2: path to Android.mk where the module is defined
# Returns : None
# Usage : $(call modules-add,<modulename>,<Android.mk path>)
# Rationale: add a new module. If it is already defined, print an error message
# and abort.
# -----------------------------------------------------------------------------
modules-add = \
$(if $(call set_is_member,$(__ndk_modules),$1),\
$(call __ndk_info,Trying to define local module '$1' in $2.)\
$(call __ndk_info,But this module was already defined by $(__ndk_modules.$1).)\
$(call __ndk_error,Aborting.)\
)\
$(eval __ndk_modules := $(call set_insert,$(__ndk_modules),$1))\
$(eval __ndk_modules.$1 := $2)\
# -----------------------------------------------------------------------------
# Function : check-user-define
# Arguments: 1: name of variable that must be defined by the user
# 2: name of Makefile where the variable should be defined
# 3: name/description of the Makefile where the check is done, which
# must be included by $2
# Returns : None
# -----------------------------------------------------------------------------
check-user-define = $(if $(strip $($1)),,\
$(call __ndk_error,Missing $1 before including $3 in $2))
# -----------------------------------------------------------------------------
# This is used to check that LOCAL_MODULE is properly defined by an Android.mk
# file before including one of the $(BUILD_SHARED_LIBRARY), etc... files.
#
# Function : check-user-LOCAL_MODULE
# Arguments: 1: name/description of the included build Makefile where the
# check is done
# Returns : None
# Usage : $(call check-user-LOCAL_MODULE, BUILD_SHARED_LIBRARY)
# -----------------------------------------------------------------------------
check-defined-LOCAL_MODULE = \
$(call check-user-define,LOCAL_MODULE,$(local-makefile),$(1)) \
$(if $(call seq,$(words $(LOCAL_MODULE)),1),,\
$(call __ndk_info,LOCAL_MODULE definition in $(local-makefile) must not contain space)\
$(call __ndk_error,Please correct error. Aborting)\
)
# -----------------------------------------------------------------------------
# Strip any 'lib' prefix in front of a given string.
#
# Function : strip-lib-prefix
# Arguments: 1: module name
# Returns : module name, without any 'lib' prefix if any
# Usage : $(call strip-lib-prefix,$(LOCAL_MODULE))
# -----------------------------------------------------------------------------
strip-lib-prefix = $(1:lib%=%)
# -----------------------------------------------------------------------------
# This is used to strip any lib prefix from LOCAL_MODULE, then check that
# the corresponding module name is not already defined.
#
# Function : check-user-LOCAL_MODULE
# Arguments: 1: path of Android.mk where this LOCAL_MODULE is defined
# Returns : None
# Usage : $(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE))
# -----------------------------------------------------------------------------
check-LOCAL_MODULE = \
$(eval LOCAL_MODULE := $$(call strip-lib-prefix,$$(LOCAL_MODULE)))\
$(call modules-add,$(LOCAL_MODULE),$1)
# -----------------------------------------------------------------------------
# Macro : my-dir
# Returns : the directory of the current Makefile
# Usage : $(my-dir)
# -----------------------------------------------------------------------------
my-dir = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
# -----------------------------------------------------------------------------
# Function : all-makefiles-under
# Arguments: 1: directory path
# Returns : a list of all makefiles immediately below some directory
# Usage : $(call all-makefiles-under, <some path>)
# -----------------------------------------------------------------------------
all-makefiles-under = $(wildcard $1/*/Android.mk)
# -----------------------------------------------------------------------------
# Macro : all-subdir-makefiles
# Returns : list of all makefiles in subdirectories of the current Makefile's
# location
# Usage : $(all-subdir-makefiles)
# -----------------------------------------------------------------------------
all-subdir-makefiles = $(call all-makefiles-under,$(call my-dir))
# =============================================================================
#
# Application.mk support
#
# =============================================================================
# the list of variables that *must* be defined in Application.mk files
NDK_APP_VARS_REQUIRED := APP_MODULES APP_PROJECT_PATH
# the list of variables that *may* be defined in Application.mk files
NDK_APP_VARS_OPTIONAL := APP_OPTIM APP_CPPFLAGS APP_CFLAGS APP_CXXFLAGS
# the list of all variables that may appear in an Application.mk file
NDK_APP_VARS := $(NDK_APP_VARS_REQUIRED) $(NDK_APPS_VARS_OPTIONAL)
# =============================================================================
#
# Android.mk support
#
# =============================================================================
# =============================================================================
#
# Generated files support
#
# =============================================================================
# -----------------------------------------------------------------------------
# Function : host-static-library-path
# Arguments : 1: library module name (e.g. 'foo')
# Returns : location of generated host library name (e.g. '..../libfoo.a)
# Usage : $(call host-static-library-path,<modulename>)
# -----------------------------------------------------------------------------
host-static-library-path = $(HOST_OUT)/lib$1.a
# -----------------------------------------------------------------------------
# Function : host-executable-path
# Arguments : 1: executable module name (e.g. 'foo')
# Returns : location of generated host executable name (e.g. '..../foo)
# Usage : $(call host-executable-path,<modulename>)
# -----------------------------------------------------------------------------
host-executable-path = $(HOST_OUT)/$1$(HOST_EXE)
# -----------------------------------------------------------------------------
# Function : static-library-path
# Arguments : 1: library module name (e.g. 'foo')
# Returns : location of generated static library name (e.g. '..../libfoo.a)
# Usage : $(call static-library-path,<modulename>)
# -----------------------------------------------------------------------------
static-library-path = $(TARGET_OUT)/lib$1.a
# -----------------------------------------------------------------------------
# Function : shared-library-path
# Arguments : 1: library module name (e.g. 'foo')
# Returns : location of generated shared library name (e.g. '..../libfoo.so)
# Usage : $(call shared-library-path,<modulename>)
# -----------------------------------------------------------------------------
shared-library-path = $(TARGET_OUT)/lib$1.so
# -----------------------------------------------------------------------------
# Function : executable-path
# Arguments : 1: executable module name (e.g. 'foo')
# Returns : location of generated exectuable name (e.g. '..../foo)
# Usage : $(call executable-path,<modulename>)
# -----------------------------------------------------------------------------
executable-path = $(TARGET_OUT)/$1
# =============================================================================
#
# Build commands support
#
# =============================================================================
# -----------------------------------------------------------------------------
# Macro : hide
# Returns : nothing
# Usage : $(hide)<make commands>
# Rationale: To be used as a prefix for Make build commands to hide them
# by default during the build. To show them, set V=1 in your
# environment or command-line.
#
# For example:
#
# foo.o: foo.c
# -->|$(hide) <build-commands>
#
# Where '-->|' stands for a single tab character.
#
# -----------------------------------------------------------------------------
ifeq ($(V),1)
hide = $(empty)
else
hide = @
endif
# -----------------------------------------------------------------------------
# Template : ev-compile-c-source
# Arguments : 1: single C source file name (relative to LOCAL_PATH)
# 2: target object file (without path)
# Returns : None
# Usage : $(eval $(call ev-compile-c-source,<srcfile>,<objfile>)
# Rationale : Internal template evaluated by compile-c-source and
# compile-s-source
# -----------------------------------------------------------------------------
define ev-compile-c-source
_SRC:=$$(LOCAL_PATH)/$(1)
_OBJ:=$$(LOCAL_OBJS_DIR)/$(2)
$$(_OBJ): PRIVATE_SRC := $$(_SRC)
$$(_OBJ): PRIVATE_OBJ := $$(_OBJ)
$$(_OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE)
$$(_OBJ): PRIVATE_ARM_MODE := $$(LOCAL_ARM_MODE)
$$(_OBJ): PRIVATE_ARM_TEXT := $$(LOCAL_ARM_TEXT)
$$(_OBJ): PRIVATE_CC := $$($$(my)CC)
$$(_OBJ): PRIVATE_CFLAGS := $$($$(my)CFLAGS) \
$$($$(my)_$(LOCAL_ARM_MODE)_$(LOCAL_BUILD_MODE)_CFLAGS) \
-I$$(LOCAL_PATH) \
-I$$(OBJS_DIR) \
$$(LOCAL_CFLAGS) \
$$(NDK_APP_CPPFLAGS) \
$$(NDK_APP_CFLAGS) \
$$(LOCAL_ARM_CFLAGS)
$$(_OBJ): $$(_SRC) $$(LOCAL_MAKEFILE) $$(NDK_APP_APPLICATION_MK)
@mkdir -p $$(dir $$(PRIVATE_OBJ))
@echo "Compile $$(PRIVATE_ARM_TEXT) : $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC)"
$(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c \
-MMD -MP -MF $$(PRIVATE_OBJ).d.tmp \
$$(PRIVATE_SRC) \
-o $$(PRIVATE_OBJ)
$$(call cmd-process-deps,$$(PRIVATE_OBJ))
LOCAL_OBJECTS += $$(_OBJ)
LOCAL_DEPENDENCY_DIRS += $$(dir $$(_OBJ))
endef
# -----------------------------------------------------------------------------
# Function : compile-c-source
# Arguments : 1: single C source file name (relative to LOCAL_PATH)
# Returns : None
# Usage : $(call compile-c-source,<srcfile>)
# Rationale : Setup everything required to build a single C source file
# -----------------------------------------------------------------------------
compile-c-source = $(eval $(call ev-compile-c-source,$1,$(1:%.c=%.o)))
# -----------------------------------------------------------------------------
# Function : compile-s-source
# Arguments : 1: single Assembly source file name (relative to LOCAL_PATH)
# Returns : None
# Usage : $(call compile-s-source,<srcfile>)
# Rationale : Setup everything required to build a single Assembly source file
# -----------------------------------------------------------------------------
compile-s-source = $(eval $(call ev-compile-s-source,$1,$(1:%.S=%.o)))
# -----------------------------------------------------------------------------
# Template : ev-compile-cpp-source
# Arguments : 1: single C++ source file name (relative to LOCAL_PATH)
# 2: target object file (without path)
# Returns : None
# Usage : $(eval $(call ev-compile-cpp-source,<srcfile>,<objfile>)
# Rationale : Internal template evaluated by compile-cpp-source
# -----------------------------------------------------------------------------
define ev-compile-cpp-source
_SRC:=$$(LOCAL_PATH)/$(1)
_OBJ:=$$(LOCAL_OBJS_DIR)/$(2)
$$(_OBJ): PRIVATE_SRC := $$(_SRC)
$$(_OBJ): PRIVATE_OBJ := $$(_OBJ)
$$(_OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE)
$$(_OBJ): PRIVATE_ARM_MODE := $$(LOCAL_ARM_MODE)
$$(_OBJ): PRIVATE_ARM_TEXT := $$(LOCAL_ARM_TEXT)
$$(_OBJ): PRIVATE_CXX := $$($$(my)CXX)
$$(_OBJ): PRIVATE_CXXFLAGS := $$($$(my)CXXFLAGS) \
$$($$(my)_$(LOCAL_ARM_MODE)_$(LOCAL_BUILD_MODE)_CFLAGS) \
-I$$(LOCAL_PATH) \
-I$$(OBJS_DIR) \
$$(LOCAL_CFLAGS) \
$$(NDK_APP_CPPFLAGS) \
$$(NDK_APP_CXXFLAGS) \
$$(LOCAL_ARM_CFLAGS)
$$(_OBJ): $$(_SRC) $$(LOCAL_MAKEFILE) $$(NDK_APP_APPLICATION_MK)
@mkdir -p $$(dir $$(PRIVATE_OBJ))
@echo "Compile++ $$(PRIVATE_ARM_TEXT): $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC)"
$(hide) $$(PRIVATE_CXX) $$(PRIVATE_CXXFLAGS) -c \
-MMD -MP -MF $$(PRIVATE_OBJ).d.tmp \
$$(PRIVATE_SRC) \
-o $$(PRIVATE_OBJ)
$$(call cmd-process-deps,$$(PRIVATE_OBJ))
LOCAL_OBJECTS += $$(_OBJ)
LOCAL_DEPENDENCY_DIRS += $$(dir $$(_OBJ))
endef
# -----------------------------------------------------------------------------
# Function : compile-cpp-source
# Arguments : 1: single C++ source file name (relative to LOCAL_PATH)
# Returns : None
# Usage : $(call compile-c-source,<srcfile>)
# Rationale : Setup everything required to build a single C++ source file
# -----------------------------------------------------------------------------
compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.o)))
# -----------------------------------------------------------------------------
# Command : cmd-process-deps
# Arguments : 1: object file path
# Returns : None
# Usage : $(call cmd-process-deps,<objectfile>)
# Rationale : To be used as a Make build command to process the dependencies
# generated by the compiler (in <obj>.d.tmp) into ones suited
# for our build system. See the comments in build/core/mkdeps.sh
# for more details.
# -----------------------------------------------------------------------------
cmd-process-deps = $(hide) $(BUILD_SYSTEM)/mkdeps.sh $(1) $(1).d.tmp $(1).d
# -----------------------------------------------------------------------------
# Command : cmd-install-file
# Arguments : 1: source file
# 2: destination file
# Returns : None
# Usage : $(call cmd-install-file,<srcfile>,<dstfile>)
# Rationale : To be used as a Make build command to copy/install a file to
# a given location.
# -----------------------------------------------------------------------------
define cmd-install-file
@mkdir -p $(dir $2)
$(hide) cp -fp $1 $2
endef

287
ndk/build/core/main.mk Normal file
View File

@@ -0,0 +1,287 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ====================================================================
#
# Define the main configuration variables, and read the host-specific
# configuration file that is normally generated by build/host-setup.sh
#
# ====================================================================
# Include common definitions
include build/core/definitions.mk
# The location of the build system files
BUILD_SYSTEM := build/core
# Where all generated files will be stored during a build
NDK_OUT := out
# Read the host-specific configuration file in $(NDK_OUT)
#
HOST_CONFIG_MAKE := $(NDK_OUT)/host/config.mk
ifeq ($(strip $(wildcard $(HOST_CONFIG_MAKE))),)
$(call __ndk_info,\
The configuration file '$(HOST_CONFIG_MAKE)' doesnt' exist.)
$(call __ndk_info,\
Please run 'build/host-setup.sh' to generate it.)
$(call __ndk_error, Aborting)
endif
include $(HOST_CONFIG_MAKE)
HOST_PREBUILT_TAG := $(HOST_TAG)
# Location where all prebuilt binaries for a given host architectures
# will be stored.
HOST_PREBUILT := build/prebuilt/$(HOST_TAG)
# Where all app-specific generated files will be stored
NDK_APP_OUT := $(NDK_OUT)/apps
# Where all host-specific generated files will be stored
NDK_HOST_OUT := $(NDK_OUT)/host/$(HOST_TAG)
# ====================================================================
#
# Read all toolchain-specific configuration files.
#
# Each toolchain must have a corresponding config.mk file located
# in build/toolchains/<name>/ that will be included here.
#
# Each one of these files should define the following variables:
# TOOLCHAIN_NAME toolchain name (e.g. arm-eabi-4.2.1)
# TOOLCHAIN_ABIS list of target ABIs supported by the toolchain.
#
# Then, it should include $(ADD_TOOLCHAIN) which will perform
# book-keeping for the build system.
#
# ====================================================================
# the build script to include in each toolchain config.mk
ADD_TOOLCHAIN := $(BUILD_SYSTEM)/add-toolchain.mk
# the list of all toolchains in this NDK
NDK_ALL_TOOLCHAINS :=
NDK_ALL_ABIS :=
TOOLCHAIN_CONFIGS := $(wildcard build/toolchains/*/config.mk)
$(foreach _config_mk,$(TOOLCHAIN_CONFIGS),\
$(eval include $(BUILD_SYSTEM)/add-toolchain.mk)\
)
#$(info ALL_TOOLCHAINS=$(ALL_TOOLCHAINS))
NDK_TARGET_TOOLCHAIN := $(firstword $(NDK_ALL_TOOLCHAINS))
$(call ndk_log, Default toolchain is $(NDK_TARGET_TOOLCHAIN))
NDK_ALL_TOOLCHAINS := $(call uniq,$(NDK_ALL_TOOLCHAINS))
NDK_ALL_ABIS := $(call uniq,$(NDK_ALL_ABIS))
$(call ndk_log, This NDK supports the following toolchains and target ABIs:)
$(foreach tc,$(NDK_ALL_TOOLCHAINS),\
$(call ndk_log, $(space)$(space)$(tc): $(NDK_TOOLCHAIN.$(tc).abis))\
)
# ====================================================================
#
# Read all application configuration files
#
# Each 'application' must have a corresponding Application.mk file
# located in apps/<name> where <name> is a liberal name that doesn't
# contain any space in it, used to uniquely identify the
#
# Each one of these files should define the following required
# variables:
#
# APP_MODULES the list of modules needed by this application
#
# APP_PROJECT_PATH
# path to the Java project root directory where the
# generated binaries will be copied to. The NDK will
# place them in appropriate locations so they are
# properly picked by aapt, the Android Packager tool,
# when generating your applications.
#
# As well as the following *optional* variables:
#
# APP_OPTIM either 'release' or 'debug'
#
# APP_CPPFLAGS extra flags passed when building C and C++ sources
# of application modules
#
# APP_CFLAGS extra flags passed when building C sources of
# application's modules (not C++ ones)
#
# APP_CXXFLAGS extra flags passed when building C++ sources of
# application's modules (not C ones)
#
# ====================================================================
NDK_ALL_APPS :=
NDK_APPLICATIONS := $(wildcard apps/*/Application.mk)
$(foreach _application_mk, $(NDK_APPLICATIONS),\
$(eval include $(BUILD_SYSTEM)/add-application.mk)\
)
# clean up environment, just to be safe
$(call clear-vars, $(NDK_APP_VARS))
ifeq ($(strip $(NDK_ALL_APPS)),)
$(call __ndk_info,\
The NDK could not find a proper application description under apps/*/Application.mk)
$(call __ndk_info,\
Please follow the instructions in docs/NDK-APPS.TXT to write one.)
$(call __ndk_error, Aborting)
endif
ifeq ($(strip $(APP)),)
$(call __ndk_info,\
The APP variable is undefined or empty.)
$(call __ndk_info,\
Please define it to one of: $(NDK_ALL_APPS))
$(call __ndk_info,\
You can also add new applications by writing an Application.mk file.)
$(call __ndk_info,\
See docs/APPLICATION-MK.TXT for details.)
$(call __ndk_error, Aborting)
endif
# now check that APP doesn't contain an unknown app name
# if it does, we ignore them if there is at least one known
# app name in the list. Otherwise, abort with an error message
#
_unknown_apps := $(filter-out $(NDK_ALL_APPS),$(APP))
_known_apps := $(filter $(NDK_ALL_APPS),$(APP))
NDK_APPS := $(APP)
$(if $(_unknown_apps),\
$(if $(_known_apps),\
$(call __ndk_info,WARNING:\
Removing unknown names from APP variable: $(_unknown_apps))\
$(eval NDK_APPS := $(_known_apps))\
,\
$(call __ndk_info,\
The APP variable contains unknown app names: $(_unknown_apps))\
$(call __ndk_info,\
Please use one of: $(NDK_ALL_APPS))\
$(call __ndk_error, Aborting)\
)\
)
$(call __ndk_info,Building for application '$(NDK_APPS)')
# ====================================================================
#
# Prepare the build for parsing Android.mk files
#
# ====================================================================
# These phony targets are used to control various stages of the build
.PHONY: all \
host_libraries host_executables \
executables libraries static_libraries shared_libraries \
clean clean-config clean-objs-dir \
clean-executables clean-libraries
# These macros are used in Android.mk to include the corresponding
# build script that will parse the LOCAL_XXX variable definitions.
#
CLEAR_VARS := $(BUILD_SYSTEM)/clear-vars.mk
BUILD_HOST_EXECUTABLE := $(BUILD_SYSTEM)/build-host-executable.mk
BUILD_HOST_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-host-static-library.mk
BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-static-library.mk
BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/build-shared-library.mk
BUILD_EXECUTABLE := $(BUILD_SYSTEM)/build-executable.mk
ANDROID_MK_INCLUDED := \
$(CLEAR_VARS) \
$(BUILD_HOST_EXECUTABLE) \
$(BUILD_HOST_STATIC_LIBRARY) \
$(BUILD_STATIC_LIBRARY) \
$(BUILD_SHARED_LIBRARY) \
$(BUILD_EXECUTABLE) \
# this is the list of directories containing dependency information
# generated during the build. It will be updated by build scripts
# when module definitions are parsed.
#
DEPENDENCY_DIRS :=
# this is the list of all generated files that we would need to clean
ALL_HOST_EXECUTABLES :=
ALL_HOST_STATIC_LIBRARIES :=
ALL_STATIC_LIBRARIES :=
ALL_SHARED_LIBRARIES :=
ALL_EXECUTABLES :=
# the first rule
all: libraries executables
# ====================================================================
#
# For each platform/abi combo supported by the application, we should
# setup the toolchain and parse all module definitions files again
# to build the right dependency tree.
#
# All this work is performed by build/core/setup-toolchain.mk
#
# ====================================================================
# XXX: For now, only support one platform and one target ABI with
# only one toolchain.
#
TARGET_PLATFORM := android-1.5
TARGET_ARCH_ABI := arm
TARGET_ARCH := arm
TARGET_TOOLCHAIN := $(NDK_TARGET_TOOLCHAIN)
include build/core/setup-toolchain.mk
# ====================================================================
#
# Now finish the build preparation with a few rules that depend on
# what has been effectively parsed and recorded previously
#
# ====================================================================
clean: clean-intermediates
distclean: clean clean-config
host_libraries: $(HOST_STATIC_LIBRARIES)
host_executables: $(HOST_EXECUTABLES)
static_libraries: $(STATIC_LIBRARIES)
shared_libraries: $(SHARED_LIBRARIES)
executables: $(EXECUTABLES)
libraries: static_libraries shared_libraries
clean-host-intermediates:
$(hide) rm -rf $(NDK_HOST_OUT)/objs $(HOST_EXECUTABLES) $(HOST_STATIC_LIBRARIES)
clean-intermediates: clean-host-intermediates
$(hide) rm -rf $(NDK_HOST_OUT)/objs $(EXECUTABLES) $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
clean-config:
$(hide) rm -f $(CONFIG_MAKE) $(CONFIG_H)
# include dependency information
DEPENDENCY_DIRS := $(sort $(DEPENDENCY_DIRS))
-include $(wildcard $(DEPENDENCY_DIRS:%=%/*.d))

51
ndk/build/core/mkdeps.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
#
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script is used to transform the dependency files generated by GCC
# For example, a typical .d file will have a line like:
#
# source.o: /full/path/to/source.c other.h headers.h
# ...
#
# the script is used to replace 'source.o' to a full path, as in
#
# objs/intermediates/emulator/source.o: /full/path/to/source.c other.h headers.h
#
# parameters
#
# $1: object file (full path)
# $2: source dependency file to modify (erased on success)
# $3: target source dependency file
#
# quote the object path. we change a single '.' into
# a '\.' since this will be parsed by sed.
#
OBJECT=`echo $1 | sed -e s/\\\\./\\\\\\\\./g`
#echo OBJECT=$OBJECT
OBJ_NAME=`basename $OBJECT`
#echo OBJ_NAME=$OBJ_NAME
# we replace $OBJ_NAME with $OBJECT only if $OBJ_NAME starts the line
# that's because some versions of GCC (e.g. 4.2.3) already produce
# a correct dependency line with the full path to the object file.
# In this case, we don't want to touch anything
#
cat $2 | sed -e s%^$OBJ_NAME%$OBJECT%g > $3 && rm -f $2

View File

@@ -0,0 +1,396 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# A collection of shell function definitions used by various build scripts
# in the Android NDK (Native Development Kit)
#
# Get current script name into PROGNAME
PROGNAME=`basename $0`
# Put location of Android NDK into ANDROID_NDK_ROOT and
# perform a tiny amount of sanity check
#
if [ -z "$ANDROID_NDK_ROOT" ] ; then
if [ ! -f build/core/ndk-common.sh ] ; then
echo "Please define ANDROID_NDK_ROOT to point to the root of your"
echo "Android NDK installation."
exit 1
fi
ANDROID_NDK_ROOT=.
fi
if [ ! -d $ANDROID_NDK_ROOT ] ; then
echo "ERROR: Your ANDROID_NDK_ROOT variable does not point to a directory."
exit 1
fi
if [ ! -f $ANDROID_NDK_ROOT/build/core/ndk-common.sh ] ; then
echo "ERROR: Your ANDROID_NDK_ROOT variable does not point to a valid directory."
exit 1
fi
## Logging support
##
VERBOSE=${VERBOSE-yes}
VERBOSE2=${VERBOSE2-no}
log ()
{
if [ "$VERBOSE" = "yes" ] ; then
echo "$1"
fi
}
log2 ()
{
if [ "$VERBOSE2" = "yes" ] ; then
echo "$1"
fi
}
## Utilities
##
# return the value of a given named variable
# $1: variable name
#
# example:
# FOO=BAR
# BAR=ZOO
# echo `var_value $FOO`
# will print 'ZOO'
#
var_value ()
{
# find a better way to do that ?
eval echo "$`echo $1`"
}
# convert to uppercase
# assumes tr is installed on the platform ?
#
to_uppercase ()
{
echo $1 | tr "[:lower:]" "[:upper:]"
}
## Normalize OS and CPU
##
HOST_ARCH=`uname -m`
case "$HOST_ARCH" in
i?86) HOST_ARCH=x86
;;
amd64) HOST_ARCH=x86_64
;;
powerpc) HOST_ARCH=ppc
;;
esac
log2 "HOST_ARCH=$HOST_ARCH"
# at this point, the supported values for CPU are:
# x86
# x86_64
# ppc
#
# other values may be possible but haven't been tested
#
HOST_EXE=""
HOST_OS=`uname -s`
case "$HOST_OS" in
Darwin)
HOST_OS=darwin
;;
Linux)
# note that building 32-bit binaries on x86_64 is handled later
HOST_OS=linux
;;
FreeBsd) # note: this is not tested
HOST_OS=freebsd
;;
CYGWIN*|*_NT-*)
HOST_OS=windows
HOST_EXE=.exe
if [ "x$OSTYPE" = xcygwin ] ; then
HOST_OS=cygwin
HOST_CFLAGS="$CFLAGS -mno-cygwin"
HOST_LDFLAGS="$LDFLAGS -mno-cygwin"
fi
;;
esac
log2 "HOST_OS=$HOST_OS"
log2 "HOST_EXE=$HOST_EXE"
# at this point, the value of HOST_OS should be one of the following:
# linux
# darwin
# windows (MSys)
# cygwin
#
# Note that cygwin is treated as a special case because it behaves very differently
# for a few things. Other values may be possible but have not been tested
#
# define HOST_TAG as a unique tag used to identify both the host OS and CPU
# supported values are:
#
# linux-x86
# linux-x86_64
# darwin-x86
# darwin-ppc
# windows
#
# other values are possible but were not tested.
#
compute_host_tag ()
{
case "$HOST_OS" in
windows|cygwin)
HOST_TAG="windows"
;;
*) HOST_TAG="${HOST_OS}-${HOST_ARCH}"
esac
log2 "HOST_TAG=$HOST_TAG"
}
compute_host_tag
# Compute the number of host CPU cores an HOST_NUM_CPUS
#
case "$HOST_OS" in
linux)
HOST_NUM_CPUS=`cat /proc/cpuinfo | grep processor | wc -l`
;;
darwin|freebsd)
HOST_NUM_CPUS=`sysctl -n hw.ncpu`
;;
windows|cygwin)
HOST_NUM_CPUS=$NUMBER_OF_PROCESSORS
;;
*) # let's play safe here
HOST_NUM_CPUS=1
esac
log2 "HOST_NUM_CPUS=$HOST_NUM_CPUS"
# If BUILD_NUM_CPUS is not already defined in your environment,
# define it as the double of HOST_NUM_CPUS. This is used to
# run Make commends in parralles, as in 'make -j$BUILD_NUM_CPUS'
#
if [ -z "$BUILD_NUM_CPUS" ] ; then
BUILD_NUM_CPUS=`expr $HOST_NUM_CPUS \* 2`
fi
log2 "BUILD_NUM_CPUS=$BUILD_NUM_CPUS"
## HOST TOOLCHAIN SUPPORT
##
# force the generation of 32-bit binaries on 64-bit systems
#
FORCE_32BIT=no
force_32bit_binaries ()
{
if [ "$HOST_ARCH" = x86_64 ] ; then
log2 "Forcing generation of 32-bit host binaries on $HOST_ARCH"
FORCE_32BIT=yes
HOST_ARCH=x86
log2 "HOST_ARCH=$HOST_ARCH"
compute_host_tag
fi
}
# On Windows, cygwin binaries will be generated by default, but
# you can force mingw ones that do not link to cygwin.dll if you
# call this function.
#
disable_cygwin ()
{
if [ $OS = cygwin ] ; then
log2 "Disabling cygwin binaries generation"
CFLAGS="$CFLAGS -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
OS=windows
HOST_OS=windows
compute_host_tag
fi
}
# Various probes are going to need to run a small C program
TMPC=/tmp/android-$$-test.c
TMPO=/tmp/android-$$-test.o
TMPE=/tmp/android-$$-test$EXE
TMPL=/tmp/android-$$-test.log
# cleanup temporary files
clean_temp ()
{
rm -f $TMPC $TMPO $TMPL $TMPE
}
# cleanup temp files then exit with an error
clean_exit ()
{
clean_temp
exit 1
}
# this function will setup the compiler and linker and check that they work as advertised
# note that you should call 'force_32bit_binaries' before this one if you want it to
# generate 32-bit binaries on 64-bit systems (that support it).
#
setup_toolchain ()
{
if [ -z "$CC" ] ; then
CC=gcc
fi
log2 "Using '$CC' as the C compiler"
# check that we can compile a trivial C program with this compiler
cat > $TMPC <<EOF
int main(void) {}
EOF
if [ "$FORCE_32BIT" = yes ] ; then
CFLAGS="$CFLAGS -m32"
LDFLAGS="$LDFLAGS -m32"
compile
if [ $? != 0 ] ; then
# sometimes, we need to also tell the assembler to generate 32-bit binaries
# this is highly dependent on your GCC installation (and no, we can't set
# this flag all the time)
CFLAGS="$CFLAGS -Wa,--32"
compile
fi
fi
compile
if [ $? != 0 ] ; then
echo "your C compiler doesn't seem to work:"
cat $TMPL
clean_exit
fi
log "CC : compiler check ok ($CC)"
# check that we can link the trivial program into an executable
if [ -z "$LD" ] ; then
LD=$CC
fi
link
if [ $? != 0 ] ; then
OLD_LD=$LD
LD=gcc
compile
link
if [ $? != 0 ] ; then
LD=$OLD_LD
echo "your linker doesn't seem to work:"
cat $TMPL
clean_exit
fi
fi
log2 "Using '$LD' as the linker"
log "LD : linker check ok ($LD)"
# check the C++ compiler
if [ -z "$CXX" ] ; then
CXX=g++
fi
if [ -z "$CXXFLAGS" ] ; then
CXXFLAGS=$CFLAGS
fi
log2 "Using '$CXX' as the C++ compiler"
cat > $TMPC <<EOF
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
EOF
compile_cpp
if [ $? != 0 ] ; then
echo "your C++ compiler doesn't seem to work"
cat $TMPL
clean_exit
fi
log "CXX : C++ compiler check ok ($CXX)"
# XXX: TODO perform AR checks
AR=ar
ARFLAGS=
}
# try to compile the current source file in $TMPC into an object
# stores the error log into $TMPL
#
compile ()
{
log2 "Object : $CC -o $TMPO -c $CFLAGS $TMPC"
$CC -o $TMPO -c $CFLAGS $TMPC 2> $TMPL
}
compile_cpp ()
{
log2 "Object : $CXX -o $TMPO -c $CXXFLAGS $TMPC"
$CXX -o $TMPO -c $CXXFLAGS $TMPC 2> $TMPL
}
# try to link the recently built file into an executable. error log in $TMPL
#
link()
{
log2 "Link : $LD -o $TMPE $TMPO $LDFLAGS"
$LD -o $TMPE $TMPO $LDFLAGS 2> $TMPL
}
# run a command
#
execute()
{
log2 "Running: $*"
$*
}
# perform a simple compile / link / run of the source file in $TMPC
compile_exec_run()
{
log2 "RunExec : $CC -o $TMPE $CFLAGS $TMPC"
compile
if [ $? != 0 ] ; then
echo "Failure to compile test program"
cat $TMPC
cat $TMPL
clean_exit
fi
link
if [ $? != 0 ] ; then
echo "Failure to link test program"
cat $TMPC
echo "------"
cat $TMPL
clean_exit
fi
$TMPE
}

View File

@@ -0,0 +1,68 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this file is included repeatedly from build/core/setup-toolchain.mk
# and is used to prepare for app-specific build rules.
#
$(call assert-defined,_app)
# the location of generated files for this app
HOST_OUT := $(NDK_APP_OUT)/$(_app)/$(HOST_TAG)
HOST_OBJS := $(HOST_OUT)/objs
TARGET_OUT := $(NDK_APP_OUT)/$(_app)/$(TARGET_ABI)
TARGET_OBJS := $(TARGET_OUT)/objs
TARGET_GDB_SETUP := $(TARGET_OUT)/setup.gdb
# ok, let's parse all Android.mk source files in order to build
# the modules for this app.
#
# Restore the APP_XXX variables just for this pass as NDK_APP_XXX
#
NDK_APP_NAME := $(_app)
NDK_APP_APPLICATION_MK := $(NDK_APP.$(_app).Application.mk)
$(foreach __name,$(NDK_APP_VARS),\
$(eval NDK_$(__name) := $(NDK_APP.$(_app).$(__name)))\
)
# set release/debug build flags
#
ifeq ($(NDK_APP_OPTIM),debug)
NDK_APP_CPPFLAGS := -O0 -g $(NDK_APP_CPPFLAGS)
else
NDK_APP_CPPFLAGS := -O2 -DNDEBUG -g $(NDK_APP_CPPFLAGS)
endif
# compute NDK_APP_DEST as the destination directory for the generated files
NDK_APP_DEST := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ABI_SUBDIR)
# make the application depend on the modules it requires
.PHONY: ndk-app-$(_app)
ndk-app-$(_app): $(NDK_APP_MODULES)
all: ndk-app-$(_app)
# free the dictionary of LOCAL_MODULE definitions
$(call modules-clear)
# now parse all Android.mk build files
#
# this will include stuff like build/core/static-library.mk and others
# for each module to be defined.
#
include sources/*/Android.mk

View File

@@ -0,0 +1,45 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this file is included repeatedly from build/core/main.mk and is used
# to setup the target toolchain for a given platform/abi combination.
#
$(call assert-defined,TARGET_TOOLCHAIN TARGET_PLATFORM TARGET_ARCH TARGET_ARCH_ABI)
$(call assert-defined,NDK_APPS)
TARGET_ABI := $(TARGET_PLATFORM)-$(TARGET_ARCH_ABI)
# setup sysroot-related variables. The SYSROOT point to a directory
# that contains all public header files for a given platform, plus
# some libraries and object files used for linking the generated
# target files properly.
#
SYSROOT := build/platforms/$(TARGET_PLATFORM)/arch-$(TARGET_ARCH_ABI)
TARGET_CRTBEGIN_STATIC_O := $(SYSROOT)/usr/lib/crtbegin_static.o
TARGET_CRTBEGIN_DYNAMIC_O := $(SYSROOT)/usr/lib/crtbegin_dynamic.o
TARGET_CRTEND_O := $(SYSROOT)/usr/lib/crtend_android.o
TARGET_PREBUILT_SHARED_LIBRARIES := libc libstdc++ libm
TARGET_PREBUILT_SHARED_LIBRARIES := $(TARGET_PREBUILT_SHARED_LIBRARIES:%=$(SYSROOT)/usr/lib/%.so)
# now call the toolchain-specific setup script
include $(NDK_TOOLCHAIN.$(TARGET_TOOLCHAIN).setup)
# For each app, compute intermediate directories and parse module sources
$(foreach _app,$(NDK_APPS),\
$(eval include $(BUILD_SYSTEM)/setup-app.mk)\
)

27
ndk/build/gmsl/README Normal file
View File

@@ -0,0 +1,27 @@
GNU Make Standard Library
-------------------------
1. Visit http://gmsl.sf.net for more details
2. To use the GMSL in your Makefile make sure that you have the files
gmsl
__gmsl
Add
include gmsl
to your Makefile(s).
3. To run the GMSL test suite have
gmsl
__gmsl
gmsl-tests
And then run
make -f gmsl-tests

854
ndk/build/gmsl/__gmsl Normal file
View File

@@ -0,0 +1,854 @@
# ----------------------------------------------------------------------------
#
# GNU Make Standard Library (GMSL)
#
# A library of functions to be used with GNU Make's $(call) that
# provides functionality not available in standard GNU Make.
#
# Copyright (c) 2005-2007 John Graham-Cumming
#
# This file is part of GMSL
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# Neither the name of the John Graham-Cumming nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# ----------------------------------------------------------------------------
# This is the GNU Make Standard Library version number as a list with
# three items: major, minor, revision
gmsl_version := 1 0 11
# Used to output warnings and error from the library, it's possible to
# disable any warnings or errors by overriding these definitions
# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS
__gmsl_name := GNU Make Standard Library
__gmsl_warning = $(warning $(__gmsl_name): $1)
__gmsl_error = $(error $(__gmsl_name): $1)
ifdef GMSL_NO_WARNINGS
__gmsl_warning :=
endif
ifdef GMSL_NO_ERRORS
__gmsl_error :=
endif
# If GMSL_TRACE is enabled then calls to the library functions are
# traced to stdout using warning messages with their arguments
ifdef GMSL_TRACE
__gmsl_tr1 = $(warning $0('$1'))
__gmsl_tr2 = $(warning $0('$1','$2'))
__gmsl_tr3 = $(warning $0('$1','$2','$3'))
else
__gmsl_tr1 :=
__gmsl_tr2 :=
__gmsl_tr3 :=
endif
# Figure out whether we have $(eval) or not (GNU Make 3.80 and above)
# if we do not then output a warning message, if we do then some
# functions will be enabled.
__gmsl_have_eval := $(false)
__gmsl_ignore := $(eval __gmsl_have_eval := $(true))
# If this is being run with Electric Cloud's emake then warn that
# their $(eval) support is incomplete.
ifdef ECLOUD_BUILD_ID
$(warning You are using Electric Cloud's emake which has incomplete $$(eval) support)
__gmsl_have_eval := $(false)
endif
# See if we have $(lastword) (GNU Make 3.81 and above)
__gmsl_have_lastword := $(lastword $(false) $(true))
# See if we have native or and and (GNU Make 3.81 and above)
__gmsl_have_or := $(if $(filter-out undefined, \
$(origin or)),$(call or,$(true),$(false)))
__gmsl_have_and := $(if $(filter-out undefined, \
$(origin and)),$(call and,$(true),$(true)))
ifneq ($(__gmsl_have_eval),$(true))
$(call __gmsl_warning,GNU Make $(MAKE_VERSION) does not support $$$$(eval): some functions disabled)
endif
# ----------------------------------------------------------------------------
# Function: gmsl_compatible
# Arguments: List containing the desired library version number (maj min rev)
# Returns: $(true) if this version of the library is compatible
# with the requested version number, otherwise $(false)
# ----------------------------------------------------------------------------
gmsl_compatible = $(strip \
$(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \
$(false), \
$(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \
$(true), \
$(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \
$(false), \
$(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \
$(true), \
$(call lte,$(word 3,$1),$(word 3,$(gmsl_version))))))))
# ###########################################################################
# LOGICAL OPERATORS
# ###########################################################################
# not is defined in gmsl
# ----------------------------------------------------------------------------
# Function: and
# Arguments: Two boolean values
# Returns: Returns $(true) if both of the booleans are true
# ----------------------------------------------------------------------------
ifneq ($(__gmsl_have_and),$(true))
and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false))
endif
# ----------------------------------------------------------------------------
# Function: or
# Arguments: Two boolean values
# Returns: Returns $(true) if either of the booleans is true
# ----------------------------------------------------------------------------
ifneq ($(__gmsl_have_or),$(true))
or = $(__gmsl_tr2)$(if $1$2,$(true),$(false))
endif
# ----------------------------------------------------------------------------
# Function: xor
# Arguments: Two boolean values
# Returns: Returns $(true) if exactly one of the booleans is true
# ----------------------------------------------------------------------------
xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false)))
# ----------------------------------------------------------------------------
# Function: nand
# Arguments: Two boolean values
# Returns: Returns value of 'not and'
# ----------------------------------------------------------------------------
nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true))
# ----------------------------------------------------------------------------
# Function: nor
# Arguments: Two boolean values
# Returns: Returns value of 'not or'
# ----------------------------------------------------------------------------
nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true))
# ----------------------------------------------------------------------------
# Function: xnor
# Arguments: Two boolean values
# Returns: Returns value of 'not xor'
# ----------------------------------------------------------------------------
xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true)))
# ###########################################################################
# LIST MANIPULATION FUNCTIONS
# ###########################################################################
# ----------------------------------------------------------------------------
# Function: first (same as LISP's car, or head)
# Arguments: 1: A list
# Returns: Returns the first element of a list
# ----------------------------------------------------------------------------
first = $(__gmsl_tr1)$(firstword $1)
# ----------------------------------------------------------------------------
# Function: last
# Arguments: 1: A list
# Returns: Returns the last element of a list
# ----------------------------------------------------------------------------
ifeq ($(__gmsl_have_lastword),$(true))
last = $(__gmsl_tr1)$(lastword $1)
else
last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1))
endif
# ----------------------------------------------------------------------------
# Function: rest (same as LISP's cdr, or tail)
# Arguments: 1: A list
# Returns: Returns the list with the first element removed
# ----------------------------------------------------------------------------
rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1)
# ----------------------------------------------------------------------------
# Function: chop
# Arguments: 1: A list
# Returns: Returns the list with the last element removed
# ----------------------------------------------------------------------------
chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1)
# ----------------------------------------------------------------------------
# Function: map
# Arguments: 1: Name of function to $(call) for each element of list
# 2: List to iterate over calling the function in 1
# Returns: The list after calling the function on each element
# ----------------------------------------------------------------------------
map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a)))
# ----------------------------------------------------------------------------
# Function: pairmap
# Arguments: 1: Name of function to $(call) for each pair of elements
# 2: List to iterate over calling the function in 1
# 3: Second list to iterate over calling the function in 1
# Returns: The list after calling the function on each pair of elements
# ----------------------------------------------------------------------------
pairmap = $(strip $(__gmsl_tr3)\
$(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \
$(call pairmap,$1,$(call rest,$2),$(call rest,$3))))
# ----------------------------------------------------------------------------
# Function: leq
# Arguments: 1: A list to compare against...
# 2: ...this list
# Returns: Returns $(true) if the two lists are identical
# ----------------------------------------------------------------------------
leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \
$(call __gmsl_list_equal,$1,$2),$(false)))
__gmsl_list_equal = $(if $(strip $1), \
$(if $(call seq,$(call first,$1),$(call first,$2)), \
$(call __gmsl_list_equal, \
$(call rest,$1), \
$(call rest,$2)), \
$(false)), \
$(true))
# ----------------------------------------------------------------------------
# Function: lne
# Arguments: 1: A list to compare against...
# 2: ...this list
# Returns: Returns $(true) if the two lists are different
# ----------------------------------------------------------------------------
lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2))
# ----------------------------------------------------------------------------
# Function: reverse
# Arguments: 1: A list to reverse
# Returns: The list with its elements in reverse order
# ----------------------------------------------------------------------------
reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \
$(call first,$1)))
# ----------------------------------------------------------------------------
# Function: uniq
# Arguments: 1: A list from which to remove repeated elements
# Returns: The list with duplicate elements removed without reordering
# ----------------------------------------------------------------------------
uniq = $(strip $(__gmsl_tr1)$(if $1,$(call uniq,$(call chop,$1)) \
$(if $(filter $(call last,$1),$(call chop,$1)),,$(call last,$1))))
# ----------------------------------------------------------------------------
# Function: length
# Arguments: 1: A list
# Returns: The number of elements in the list
# ----------------------------------------------------------------------------
length = $(__gmsl_tr1)$(words $1)
# ###########################################################################
# STRING MANIPULATION FUNCTIONS
# ###########################################################################
# Helper function that translates any GNU Make 'true' value (i.e. a
# non-empty string) to our $(true)
__gmsl_make_bool = $(if $(strip $1),$(true),$(false))
# ----------------------------------------------------------------------------
# Function: seq
# Arguments: 1: A string to compare against...
# 2: ...this string
# Returns: Returns $(true) if the two strings are identical
# ----------------------------------------------------------------------------
seq = $(__gmsl_tr2)$(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),$(false),$(true))
# ----------------------------------------------------------------------------
# Function: sne
# Arguments: 1: A string to compare against...
# 2: ...this string
# Returns: Returns $(true) if the two strings are not the same
# ----------------------------------------------------------------------------
sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2))
# ----------------------------------------------------------------------------
# Function: split
# Arguments: 1: The character to split on
# 2: A string to split
# Returns: Splits a string into a list separated by spaces at the split
# character in the first argument
# ----------------------------------------------------------------------------
split = $(__gmsl_tr2)$(strip $(subst $1, ,$2))
# ----------------------------------------------------------------------------
# Function: merge
# Arguments: 1: The character to put between fields
# 2: A list to merge into a string
# Returns: Merges a list into a single string, list elements are separated
# by the character in the first argument
# ----------------------------------------------------------------------------
merge = $(__gmsl_tr2)$(strip $(if $2, \
$(if $(call seq,1,$(words $2)), \
$2,$(call first,$2)$1$(call merge,$1,$(call rest,$2)))))
ifdef __gmsl_have_eval
# ----------------------------------------------------------------------------
# Function: tr
# Arguments: 1: The list of characters to translate from
# 2: The list of characters to translate to
# 3: The text to translate
# Returns: Returns the text after translating characters
# ----------------------------------------------------------------------------
tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \
$(eval __gmsl_t := $3) \
$(foreach c, \
$(join $(addsuffix :,$1),$2), \
$(eval __gmsl_t := \
$(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \
$(__gmsl_t))))$(__gmsl_t))
# Common character classes for use with the tr function. Each of
# these is actually a variable declaration and must be wrapped with
# $() or ${} to be used.
[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #
[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z #
[0-9] := 0 1 2 3 4 5 6 7 8 9 #
[A-F] := A B C D E F #
# ----------------------------------------------------------------------------
# Function: uc
# Arguments: 1: Text to upper case
# Returns: Returns the text in upper case
# ----------------------------------------------------------------------------
uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1)
# ----------------------------------------------------------------------------
# Function: lc
# Arguments: 1: Text to lower case
# Returns: Returns the text in lower case
# ----------------------------------------------------------------------------
lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1)
# ----------------------------------------------------------------------------
# Function: strlen
# Arguments: 1: A string
# Returns: Returns the length of the string
# ----------------------------------------------------------------------------
__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z
__gmsl_characters += 0 1 2 3 4 5 6 7 8 9
__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = +
__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? |
# Aside: if you read the above you might think that the lower-case
# letter x is missing, and that that's an error. It is missing, but
# it's not an error. __gmsl_characters is used by the strlen
# function. strlen works by transforming every character and space
# into the letter x and then counting the x's. Since there's no need
# to transform x into x I omitted it.
# This results in __gmsl_space containing just a space
__gmsl_space :=
__gmsl_space +=
strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp)))
# This results in __gmsl_newline containing just a newline
define __gmsl_newline
endef
# This results in __gmsl_tab containing a tab
__gmsl_tab := #
# ----------------------------------------------------------------------------
# Function: substr
# Arguments: 1: A string
# 2: Start position (first character is 1)
# 3: End position (inclusive)
# Returns: A substring.
# Note: The string in $1 must not contain a <20>
# ----------------------------------------------------------------------------
substr = $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),<2C> ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst <20>,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))
endif # __gmsl_have_eval
# ###########################################################################
# SET MANIPULATION FUNCTIONS
# ###########################################################################
# Sets are represented by sorted, deduplicated lists. To create a set
# from a list use set_create, or start with the empty_set and
# set_insert individual elements
# This is the empty set
empty_set :=
# ----------------------------------------------------------------------------
# Function: set_create
# Arguments: 1: A list of set elements
# Returns: Returns the newly created set
# ----------------------------------------------------------------------------
set_create = $(__gmsl_tr1)$(sort $1)
# ----------------------------------------------------------------------------
# Function: set_insert
# Arguments: 1: A single element to add to a set
# 2: A set
# Returns: Returns the set with the element added
# ----------------------------------------------------------------------------
set_insert = $(__gmsl_tr2)$(sort $1 $2)
# ----------------------------------------------------------------------------
# Function: set_remove
# Arguments: 1: A single element to remove from a set
# 2: A set
# Returns: Returns the set with the element removed
# ----------------------------------------------------------------------------
set_remove = $(__gmsl_tr2)$(filter-out $1,$2)
# ----------------------------------------------------------------------------
# Function: set_is_member
# Arguments: 1: A single element
# 2: A set
# Returns: Returns $(true) if the element is in the set
# ----------------------------------------------------------------------------
set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false))
# ----------------------------------------------------------------------------
# Function: set_union
# Arguments: 1: A set
# 2: Another set
# Returns: Returns the union of the two sets
# ----------------------------------------------------------------------------
set_union = $(__gmsl_tr2)$(sort $1 $2)
# ----------------------------------------------------------------------------
# Function: set_intersection
# Arguments: 1: A set
# 2: Another set
# Returns: Returns the intersection of the two sets
# ----------------------------------------------------------------------------
set_intersection = $(__gmsl_tr2)$(filter $1,$2)
# ----------------------------------------------------------------------------
# Function: set_is_subset
# Arguments: 1: A set
# 2: Another set
# Returns: Returns $(true) if the first set is a subset of the second
# ----------------------------------------------------------------------------
set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1)
# ----------------------------------------------------------------------------
# Function: set_equal
# Arguments: 1: A set
# 2: Another set
# Returns: Returns $(true) if the two sets are identical
# ----------------------------------------------------------------------------
set_equal = $(__gmsl_tr2)$(call seq,$1,$2)
# ###########################################################################
# ARITHMETIC LIBRARY
# ###########################################################################
# Integers a represented by lists with the equivalent number of x's.
# For example the number 4 is x x x x. The maximum integer that the
# library can handle as _input_ is __gmsl_input_int which is defined
# here as 65536
__gmsl_sixteen := x x x x x x x x x x x x x x x x
__gmsl_input_int := $(foreach a,$(__gmsl_sixteen), \
$(foreach b,$(__gmsl_sixteen), \
$(foreach c,$(__gmsl_sixteen), \
$(__gmsl_sixteen)))))
# ----------------------------------------------------------------------------
# Function: int_decode
# Arguments: 1: A number of x's representation
# Returns: Returns the integer for human consumption that is represented
# by the string of x's
# ----------------------------------------------------------------------------
int_decode = $(__gmsl_tr1)$(words $1)
# ----------------------------------------------------------------------------
# Function: int_encode
# Arguments: 1: A number in human-readable integer form
# Returns: Returns the integer encoded as a string of x's
# ----------------------------------------------------------------------------
int_encode = $(__gmsl_tr1)$(wordlist 1,$1,$(__gmsl_input_int))
# The arithmetic library functions come in two forms: one form of each
# function takes integers as arguments and the other form takes the
# encoded form (x's created by a call to int_encode). For example,
# there are two plus functions:
#
# plus Called with integer arguments and returns an integer
# int_plus Called with encoded arguments and returns an encoded result
#
# plus will be slower than int_plus because its arguments and result
# have to be translated between the x's format and integers. If doing
# a complex calculation use the int_* forms with a single encoding of
# inputs and single decoding of the output. For simple calculations
# the direct forms can be used.
# Helper function used to wrap an int_* function into a function that
# takes a pair of integers, perhaps a function and returns an integer
# result
__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3)))
__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2)))
__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3))
# ----------------------------------------------------------------------------
# Function: int_plus
# Arguments: 1: A number in x's representation
# 2: Another number in x's represntation
# Returns: Returns the sum of the two numbers in x's representation
# ----------------------------------------------------------------------------
int_plus = $(strip $(__gmsl_tr2)$1 $2)
# ----------------------------------------------------------------------------
# Function: plus (wrapped version of int_plus)
# Arguments: 1: An integer
# 2: Another integer
# Returns: Returns the sum of the two integers
# ----------------------------------------------------------------------------
plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2)
# ----------------------------------------------------------------------------
# Function: int_subtract
# Arguments: 1: A number in x's representation
# 2: Another number in x's represntation
# Returns: Returns the difference of the two numbers in x's representation,
# or outputs an error on a numeric underflow
# ----------------------------------------------------------------------------
int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \
$(filter-out xx,$(join $1,$2)), \
$(call __gmsl_warning,Subtraction underflow)))
# ----------------------------------------------------------------------------
# Function: subtract (wrapped version of int_subtract)
# Arguments: 1: An integer
# 2: Another integer
# Returns: Returns the difference of the two integers,
# or outputs an error on a numeric underflow
# ----------------------------------------------------------------------------
subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2)
# ----------------------------------------------------------------------------
# Function: int_multiply
# Arguments: 1: A number in x's representation
# 2: Another number in x's represntation
# Returns: Returns the product of the two numbers in x's representation
# ----------------------------------------------------------------------------
int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2))
# ----------------------------------------------------------------------------
# Function: multiply (wrapped version of int_multiply)
# Arguments: 1: An integer
# 2: Another integer
# Returns: Returns the product of the two integers
# ----------------------------------------------------------------------------
multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2)
# ----------------------------------------------------------------------------
# Function: int_divide
# Arguments: 1: A number in x's representation
# 2: Another number in x's represntation
# Returns: Returns the result of integer division of argument 1 divided
# by argument 2 in x's representation
# ----------------------------------------------------------------------------
int_divide = $(__gmsl_tr2)$(strip $(if $2, \
$(if $(call int_gte,$1,$2), \
x $(call int_divide,$(call int_subtract,$1,$2),$2),), \
$(call __gmsl_error,Division by zero)))
# ----------------------------------------------------------------------------
# Function: divide (wrapped version of int_divide)
# Arguments: 1: An integer
# 2: Another integer
# Returns: Returns the integer division of the first argument by the second
# ----------------------------------------------------------------------------
divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2)
# ----------------------------------------------------------------------------
# Function: int_max, int_min
# Arguments: 1: A number in x's representation
# 2: Another number in x's represntation
# Returns: Returns the maximum or minimum of its arguments in x's
# representation
# ----------------------------------------------------------------------------
int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2))
int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2)))
# ----------------------------------------------------------------------------
# Function: max, min
# Arguments: 1: An integer
# 2: Another integer
# Returns: Returns the maximum or minimum of its integer arguments
# ----------------------------------------------------------------------------
max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2)
min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2)
# ----------------------------------------------------------------------------
# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne
# Arguments: Two x's representation numbers to be compared
# Returns: $(true) or $(false)
#
# int_gt First argument greater than second argument
# int_gte First argument greater than or equal to second argument
# int_lt First argument less than second argument
# int_lte First argument less than or equal to second argument
# int_eq First argument is numerically equal to the second argument
# int_ne First argument is not numerically equal to the second argument
# ----------------------------------------------------------------------------
int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \
$(filter-out $(words $2), \
$(words $(call int_max,$1,$2))))
int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \
$(call int_gt,$1,$2)$(call int_eq,$1,$2))
int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \
$(filter-out $(words $1), \
$(words $(call int_max,$1,$2))))
int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \
$(call int_lt,$1,$2)$(call int_eq,$1,$2))
int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \
$(filter $(words $1),$(words $2)))
int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \
$(filter-out $(words $1),$(words $2)))
# ----------------------------------------------------------------------------
# Function: gt, gte, lt, lte, eq, ne
# Arguments: Two integers to be compared
# Returns: $(true) or $(false)
#
# gt First argument greater than second argument
# gte First argument greater than or equal to second argument
# lt First argument less than second argument
# lte First argument less than or equal to second argument
# eq First argument is numerically equal to the second argument
# ne First argument is not numerically equal to the second argument
# ----------------------------------------------------------------------------
gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2)
gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2)
lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2)
lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2)
eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2)
ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2)
# increment adds 1 to its argument, decrement subtracts 1. Note that
# decrement does not range check and hence will not underflow, but
# will incorrectly say that 0 - 1 = 0
# ----------------------------------------------------------------------------
# Function: int_inc
# Arguments: 1: A number in x's representation
# Returns: The number incremented by 1 in x's representation
# ----------------------------------------------------------------------------
int_inc = $(strip $(__gmsl_tr1)$1 x)
# ----------------------------------------------------------------------------
# Function: inc
# Arguments: 1: An integer
# Returns: The argument incremented by 1
# ----------------------------------------------------------------------------
inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1)
# ----------------------------------------------------------------------------
# Function: int_dec
# Arguments: 1: A number in x's representation
# Returns: The number decremented by 1 in x's representation
# ----------------------------------------------------------------------------
int_dec = $(__gmsl_tr1)$(strip $(if $(call sne,0,$(words $1)), \
$(wordlist 2,$(words $1),$1), \
$(call __gmsl_warning,Decrement underflow)))
# ----------------------------------------------------------------------------
# Function: dec
# Arguments: 1: An integer
# Returns: The argument decremented by 1
# ----------------------------------------------------------------------------
dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1)
# double doubles its argument, and halve halves it
# ----------------------------------------------------------------------------
# Function: int_double
# Arguments: 1: A number in x's representation
# Returns: The number doubled (i.e. * 2) and returned in x's representation
# ----------------------------------------------------------------------------
int_double = $(strip $(__gmsl_tr1)$1 $1)
# ----------------------------------------------------------------------------
# Function: double
# Arguments: 1: An integer
# Returns: The integer times 2
# ----------------------------------------------------------------------------
double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1)
# ----------------------------------------------------------------------------
# Function: int_halve
# Arguments: 1: A number in x's representation
# Returns: The number halved (i.e. / 2) and returned in x's representation
# ----------------------------------------------------------------------------
int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \
$(join $1,$(foreach a,$1,y x)))))
# ----------------------------------------------------------------------------
# Function: halve
# Arguments: 1: An integer
# Returns: The integer divided by 2
# ----------------------------------------------------------------------------
halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1)
ifdef __gmsl_have_eval
# ###########################################################################
# ASSOCIATIVE ARRAYS
# ###########################################################################
# ----------------------------------------------------------------------------
# Function: set
# Arguments: 1: Name of associative array
# 2: The key value to associate
# 3: The value associated with the key
# Returns: None
# ----------------------------------------------------------------------------
set = $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$2 = $3)
# ----------------------------------------------------------------------------
# Function: get
# Arguments: 1: Name of associative array
# 2: The key to retrieve
# Returns: The value stored in the array for that key
# ----------------------------------------------------------------------------
get = $(strip $(__gmsl_tr2)$(call assert_no_dollar,$0,$1$2)$(if $(filter-out undefined,$(origin __gmsl_aa_$1_$2)), \
$(__gmsl_aa_$1_$2)))
# ----------------------------------------------------------------------------
# Function: keys
# Arguments: 1: Name of associative array
# Returns: Returns a list of all defined keys in the array
# ----------------------------------------------------------------------------
keys = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_%,%, \
$(filter __gmsl_aa_$1_%,$(.VARIABLES))))
# ----------------------------------------------------------------------------
# Function: defined
# Arguments: 1: Name of associative array
# 2: The key to test
# Returns: Returns true if the key is defined (i.e. not empty)
# ----------------------------------------------------------------------------
defined = $(__gmsl_tr2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),)
endif # __gmsl_have_eval
ifdef __gmsl_have_eval
# ###########################################################################
# NAMED STACKS
# ###########################################################################
# ----------------------------------------------------------------------------
# Function: push
# Arguments: 1: Name of stack
# 2: Value to push onto the top of the stack (must not contain
# a space)
# Returns: None
# ----------------------------------------------------------------------------
push = $(__gmsl_tr2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\
$(origin __gmsl_stack_$1)),$(__gmsl_stack_$1)))
# ----------------------------------------------------------------------------
# Function: pop
# Arguments: 1: Name of stack
# Returns: Top element from the stack after removing it
# ----------------------------------------------------------------------------
pop = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \
$(call first,$(__gmsl_stack_$1)) \
$(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1)))))
# ----------------------------------------------------------------------------
# Function: peek
# Arguments: 1: Name of stack
# Returns: Top element from the stack without removing it
# ----------------------------------------------------------------------------
peek = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1))
# ----------------------------------------------------------------------------
# Function: depth
# Arguments: 1: Name of stack
# Returns: Number of items on the stack
# ----------------------------------------------------------------------------
depth = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1))
endif # __gmsl_have_eval
# ###########################################################################
# DEBUGGING FACILITIES
# ###########################################################################
# ----------------------------------------------------------------------------
# Target: gmsl-print-%
# Arguments: The % should be replaced by the name of a variable that you
# wish to print out.
# Action: Echos the name of the variable that matches the % and its value.
# For example, 'make gmsl-print-SHELL' will output the value of
# the SHELL variable
# ----------------------------------------------------------------------------
gmsl-print-%: ; @echo $* = $($*)
# ----------------------------------------------------------------------------
# Function: assert
# Arguments: 1: A boolean that must be true or the assertion will fail
# 2: The message to print with the assertion
# Returns: None
# ----------------------------------------------------------------------------
assert = $(if $1,,$(call __gmsl_error,Assertion failure: $2))
# ----------------------------------------------------------------------------
# Function: assert_exists
# Arguments: 1: Name of file that must exist, if it is missing an assertion
# will be generated
# Returns: None
# ----------------------------------------------------------------------------
assert_exists = $(call assert,$(wildcard $1),file '$1' missing)
# ----------------------------------------------------------------------------
# Function: assert_no_dollar
# Arguments: 1: Name of a function being executd
# 2: Arguments to check
# Returns: None
# ----------------------------------------------------------------------------
assert_no_dollar = $(call assert,$(call not,$(findstring $$,$2)),$1 called with a dollar sign in argument)

89
ndk/build/gmsl/gmsl Normal file
View File

@@ -0,0 +1,89 @@
# ----------------------------------------------------------------------------
#
# GNU Make Standard Library (GMSL)
#
# A library of functions to be used with GNU Make's $(call) that
# provides functionality not available in standard GNU Make.
#
# Copyright (c) 2005-2008 John Graham-Cumming
#
# This file is part of GMSL
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# Neither the name of the John Graham-Cumming nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# ----------------------------------------------------------------------------
# Determine if the library has already been included and if so don't
# bother including it again
ifndef __gmsl_included
# Standard definitions for true and false. true is any non-empty
# string, false is an empty string. These are intended for use with
# $(if).
true := T
false :=
# ----------------------------------------------------------------------------
# Function: not
# Arguments: 1: A boolean value
# Returns: Returns the opposite of the arg. (true -> false, false -> true)
# ----------------------------------------------------------------------------
not = $(if $1,$(false),$(true))
# Prevent reinclusion of the library
__gmsl_included := $(true)
# Try to determine where this file is located. If the caller did
# include /foo/gmsl then extract the /foo/ so that __gmsl gets
# included transparently
ifneq ($(MAKEFILE_LIST),)
__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
# If there are any spaces in the path in __gmsl_root then give up
ifeq (1,$(words $(__gmsl_root)))
__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root))
else
__gmsl_root :=
endif
include $(__gmsl_root)__gmsl
else
include __gmsl
endif
endif # __gmsl_included

647
ndk/build/gmsl/gmsl-tests Normal file
View File

@@ -0,0 +1,647 @@
# ----------------------------------------------------------------------------
#
# GNU Make Standard Library (GMSL) Test Suite
#
# Test suite for the GMSL
#
# Copyright (c) 2005-2007 John Graham-Cumming
#
# This file is part of GMSL
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# Neither the name of the John Graham-Cumming nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# ----------------------------------------------------------------------------
.PHONY: all
all:
@echo
@echo Test Summary
@echo ------------
@echo "$(call int_decode,$(passed)) tests passed; $(call int_decode,$(failed)) tests failed"
include gmsl
passed :=
failed :=
ECHO := /bin/echo
start_test = $(shell $(ECHO) -n "Testing '$1': " >&2)$(eval current_test := OK)
stop_test = $(shell $(ECHO) " $(current_test)" >&2)
test_pass = .$(eval passed := $(call int_inc,$(passed)))
test_fail = X$(eval failed := $(call int_inc,$(failed)))$(eval current_test := ERROR '$1' != '$2')
test_assert = $(if $(filter undefined,$(origin 2)),$(eval 2 :=))$(shell $(ECHO) -n $(if $(call seq,$1,$2),$(call test_pass,$1,$2),$(call test_fail,$1,$2)) >&2)
$(call start_test,not)
$(call test_assert,$(call not,$(true)),$(false))
$(call test_assert,$(call not,$(false)),$(true))
$(call stop_test)
$(call start_test,or)
$(call test_assert,$(call or,$(true),$(true)),$(true))
$(call test_assert,$(call or,$(true),$(false)),$(true))
$(call test_assert,$(call or,$(false),$(true)),$(true))
$(call test_assert,$(call or,$(false),$(false)),$(false))
$(call stop_test)
$(call start_test,and)
$(call test_assert,$(call and,$(true),$(true)),$(true))
$(call test_assert,$(call and,$(true),$(false)),$(false))
$(call test_assert,$(call and,$(false),$(true)),$(false))
$(call test_assert,$(call and,$(false),$(false)),$(false))
$(call stop_test)
$(call start_test,xor)
$(call test_assert,$(call xor,$(true),$(true)),$(false))
$(call test_assert,$(call xor,$(true),$(false)),$(true))
$(call test_assert,$(call xor,$(false),$(true)),$(true))
$(call test_assert,$(call xor,$(false),$(false)),$(false))
$(call stop_test)
$(call start_test,nand)
$(call test_assert,$(call nand,$(true),$(true)),$(false))
$(call test_assert,$(call nand,$(true),$(false)),$(true))
$(call test_assert,$(call nand,$(false),$(true)),$(true))
$(call test_assert,$(call nand,$(false),$(false)),$(true))
$(call stop_test)
$(call start_test,nor)
$(call test_assert,$(call nor,$(true),$(true)),$(false))
$(call test_assert,$(call nor,$(true),$(false)),$(false))
$(call test_assert,$(call nor,$(false),$(true)),$(false))
$(call test_assert,$(call nor,$(false),$(false)),$(true))
$(call stop_test)
$(call start_test,xnor)
$(call test_assert,$(call xnor,$(true),$(true)),$(true))
$(call test_assert,$(call xnor,$(true),$(false)),$(false))
$(call test_assert,$(call xnor,$(false),$(true)),$(false))
$(call test_assert,$(call xnor,$(false),$(false)),$(true))
$(call stop_test)
$(call start_test,first)
$(call test_assert,$(call first,1 2 3),1)
$(call test_assert,$(call first,1),1)
$(call test_assert,$(call first,),)
$(call stop_test)
$(call start_test,last)
$(call test_assert,$(call last,1 2 3),3)
$(call test_assert,$(call last,1),1)
$(call test_assert,$(call last,),)
$(call stop_test)
$(call start_test,rest)
$(call test_assert,$(call rest,1 2 3),2 3)
$(call test_assert,$(call rest,1),)
$(call test_assert,$(call rest,),)
$(call stop_test)
$(call start_test,chop)
$(call test_assert,$(call chop,1 2 3),1 2)
$(call test_assert,$(call chop,1 2 3 4),1 2 3)
$(call test_assert,$(call chop,1),)
$(call test_assert,$(call chop,),)
$(call stop_test)
$(call start_test,length)
$(call test_assert,$(call length,1 2 3),3)
$(call test_assert,$(call length,1 2 3 4),4)
$(call test_assert,$(call length,1),1)
$(call test_assert,$(call length,),0)
$(call stop_test)
$(call start_test,map)
$(call test_assert,$(call map,origin,__undefined map MAKE),undefined file default)
$(call test_assert,$(call map,origin,),)
$(call stop_test)
joinem = $1$2
$(call start_test,pairmap)
$(call test_assert,$(call pairmap,addsuffix,2 1 3,a b c),a2 b1 c3)
$(call test_assert,$(call pairmap,addprefix,2 1 3,a b c d),2a 1b 3c d)
$(call test_assert,$(call pairmap,addprefix,2 1 3 4,a b c),2a 1b 3c)
$(call test_assert,$(call pairmap,joinem,2 1 3 4,a b c),2a 1b 3c 4)
$(call stop_test)
$(call start_test,seq)
$(call test_assert,$(call seq,abc,abc),T)
$(call test_assert,$(call seq,x,),)
$(call test_assert,$(call seq,,x),)
$(call test_assert,$(call seq,x,x),T)
$(call test_assert,$(call seq,a%c,abc),)
$(call test_assert,$(call seq,abc,a%c),)
$(call test_assert,$(call seq,abc,ABC),)
$(call test_assert,$(call seq,abc,),)
$(call test_assert,$(call seq,,),T)
$(call test_assert,$(call seq,a b c,a b c),T)
$(call test_assert,$(call seq,aa% bb% cc,aa% bb% cc),T)
$(call test_assert,$(call seq,aa% bb% cc,aa% bb cc),)
$(call test_assert,$(call seq,aa% bb% cc,xx yy zz),)
$(call stop_test)
$(call start_test,sne)
$(call test_assert,$(call sne,abc,abc),)
$(call test_assert,$(call sne,x,),T)
$(call test_assert,$(call sne,,x),T)
$(call test_assert,$(call sne,x,x),)
$(call test_assert,$(call sne,abc,ABC),T)
$(call test_assert,$(call sne,abc,),T)
$(call test_assert,$(call sne,,),)
$(call test_assert,$(call sne,a b c,a b c),)
$(call test_assert,$(call sne,aa% bb% cc,aa% bb% cc),)
$(call test_assert,$(call sne,aa% bb% cc,aa% bb cc),T)
$(call stop_test)
$(call start_test,strlen)
$(call test_assert,$(call strlen,),0)
$(call test_assert,$(call strlen,a),1)
$(call test_assert,$(call strlen,a b),3)
$(call test_assert,$(call strlen,a ),2)
$(call test_assert,$(call strlen, a),2)
$(call test_assert,$(call strlen, ),2)
$(call test_assert,$(call strlen, ),3)
$(call test_assert,$(call strlen, ),4)
$(call stop_test)
$(call start_test,substr)
$(call test_assert,$(call substr,xyz,1,1),x)
$(call test_assert,$(call substr,xyz,1,2),xy)
$(call test_assert,$(call substr,xyz,2,3),yz)
$(call test_assert,$(call substr,some string,1,1),s)
$(call test_assert,$(call substr,some string,1,2),so)
$(call test_assert,$(call substr,some string,1,3),som)
$(call test_assert,$(call substr,some string,1,4),some)
$(call test_assert,$(call substr,some string,1,5),some )
$(call test_assert,$(call substr,some string,1,6),some s)
$(call test_assert,$(call substr,some string,5,5), )
$(call test_assert,$(call substr,some string,5,6), s)
$(call test_assert,$(call substr,some string,5,7), st)
$(call test_assert,$(call substr,some string,5,8), str)
$(call test_assert,$(call substr,some string,1,100),some string)
$(call stop_test)
$(call start_test,lc)
$(call test_assert,$(call lc,The Quick Brown Fox),the quick brown fox)
$(call test_assert,$(call lc,the1 quick2 brown3 fox4),the1 quick2 brown3 fox4)
$(call test_assert,$(call lc,The_),the_)
$(call test_assert,$(call lc,),)
$(call stop_test)
$(call start_test,uc)
$(call test_assert,$(call uc,The Quick Brown Fox),THE QUICK BROWN FOX)
$(call test_assert,$(call uc,the1 quick2 brown3 fox4),THE1 QUICK2 BROWN3 FOX4)
$(call test_assert,$(call uc,The_),THE_)
$(call test_assert,$(call uc,),)
$(call stop_test)
$(call start_test,tr)
$(call test_assert,$(call tr,A B C,1 2 3,CAPITAL),31PIT1L)
$(call test_assert,$(call tr,a b c,1 2 3,CAPITAL),CAPITAL)
$(call test_assert,$(call tr,E L I,3 1 1,I AM ELITE),1 AM 311T3)
$(call stop_test)
$(call start_test,leq)
$(call test_assert,$(call leq,1 2 3,1 2 3),T)
$(call test_assert,$(call leq,1 2 3,1 2 3 4),)
$(call test_assert,$(call leq,1 2 3 4,1 2 3),)
$(call test_assert,$(call leq,1,1),T)
$(call test_assert,$(call leq,,),T)
$(call stop_test)
$(call start_test,lne)
$(call test_assert,$(call lne,1 2 3,1 2 3),)
$(call test_assert,$(call lne,1 2 3,1 2 3 4),T)
$(call test_assert,$(call lne,1 2 3 4,1 2 3),T)
$(call test_assert,$(call lne,1,1),)
$(call test_assert,$(call lne,,),)
$(call stop_test)
$(call start_test,empty_set)
$(call test_assert,$(empty_set),)
$(call test_assert,$(empty_set),$(call set_create,))
$(call stop_test)
$(call start_test,set_create)
$(call test_assert,$(call set_create,),)
$(call test_assert,$(call set_create,1 2 2 3),1 2 3)
$(call test_assert,$(call set_create,2 1 1 2 2 3),1 2 3)
$(call test_assert,$(call set_create,1),1)
$(call stop_test)
$(call start_test,set_insert)
$(call test_assert,$(call set_insert,1,$(empty_set)),1)
$(call test_assert,$(call set_insert,1,$(call set_create,1)),1)
$(call test_assert,$(call set_insert,1,$(call set_create,1 2)),1 2)
$(call test_assert,$(call set_insert,0,$(call set_create,1 2)),0 1 2)
$(call stop_test)
$(call start_test,set_remove)
$(call test_assert,$(call set_remove,1,$(empty_set)),$(empty_set))
$(call test_assert,$(call set_remove,1,$(call set_create,1 2)),2)
$(call test_assert,$(call set_remove,1,$(call set_create,1 11 2)),11 2)
$(call test_assert,$(call set_remove,0,$(call set_create,1 2)),1 2)
$(call stop_test)
$(call start_test,set_is_member)
$(call test_assert,$(call set_is_member,1,$(empty_set)),)
$(call test_assert,$(call set_is_member,1,$(call set_create,2 3)),)
$(call test_assert,$(call set_is_member,1,$(call set_create,1 2 3)),T)
$(call test_assert,$(call set_is_member,1,$(call set_create,1)),T)
$(call stop_test)
$(call start_test,set_union)
$(call test_assert,$(call set_union,,),)
$(call test_assert,$(call set_union,1 2,),1 2)
$(call test_assert,$(call set_union,,3 4),3 4)
$(call test_assert,$(call set_union,1 2,3 4),1 2 3 4)
$(call test_assert,$(call set_union,1 2 3,3 4 5),1 2 3 4 5)
$(call stop_test)
$(call start_test,set_intersection)
$(call test_assert,$(call set_intersection,,),)
$(call test_assert,$(call set_intersection,1 2,),)
$(call test_assert,$(call set_intersection,,3 4),)
$(call test_assert,$(call set_intersection,1 2,3 4),)
$(call test_assert,$(call set_intersection,1 2 3 4,3 4 5),3 4)
$(call stop_test)
$(call start_test,set_is_subset)
$(call test_assert,$(call set_is_subset,,),T)
$(call test_assert,$(call set_is_subset,1 2,),)
$(call test_assert,$(call set_is_subset,,3 4),T)
$(call test_assert,$(call set_is_subset,1 2,3 4),)
$(call test_assert,$(call set_is_subset,1 2,1 2 3 4 5),T)
$(call test_assert,$(call set_is_subset,1 2,1 2),T)
$(call test_assert,$(call set_is_subset,1 2,1 3 4 5),)
$(call stop_test)
$(call start_test,set_equal)
$(call test_assert,$(call set_equal,,),T)
$(call test_assert,$(call set_equal,1,),)
$(call test_assert,$(call set_equal,,1),)
$(call test_assert,$(call set_equal,1,1),T)
$(call test_assert,$(call set_equal,1 2,),)
$(call test_assert,$(call set_equal,,1 2),)
$(call test_assert,$(call set_equal,1 2,1 2 3),)
$(call stop_test)
$(call start_test,int_encode)
$(call test_assert,$(call int_encode,0),)
$(call test_assert,$(call int_encode,1),x)
$(call test_assert,$(call int_encode,2),x x)
$(call test_assert,$(call int_encode,10),x x x x x x x x x x)
$(call stop_test)
$(call start_test,int_decode)
$(call test_assert,$(call int_decode,),0)
$(call test_assert,$(call int_decode,x),1)
$(call test_assert,$(call int_decode,x x),2)
$(call test_assert,$(call int_decode,x x x x x x x x x x),10)
$(call stop_test)
$(call start_test,int_plus)
$(call test_assert,$(call int_plus,$(call int_encode,3),$(call int_encode,4)),$(call int_encode,7))
$(call test_assert,$(call int_plus,$(call int_encode,0),$(call int_encode,4)),$(call int_encode,4))
$(call test_assert,$(call int_plus,$(call int_encode,3),$(call int_encode,0)),$(call int_encode,3))
$(call test_assert,$(call int_plus,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0))
$(call test_assert,$(call int_plus,$(call int_encode,1),$(call int_encode,0)),$(call int_encode,1))
$(call stop_test)
$(call start_test,plus)
$(call test_assert,$(call plus,3,4),7)
$(call test_assert,$(call plus,4,3),7)
$(call test_assert,$(call plus,0,4),4)
$(call test_assert,$(call plus,3,0),3)
$(call test_assert,$(call plus,0,0),0)
$(call stop_test)
__gmsl_warning = $1
$(call start_test,int_subtract)
$(call test_assert,$(call int_subtract,$(call int_encode,3),$(call int_encode,4)),Subtraction underflow)
$(call test_assert,$(call int_subtract,$(call int_encode,4),$(call int_encode,3)),$(call int_encode,1))
$(call test_assert,$(call int_subtract,$(call int_encode,3),$(call int_encode,0)),$(call int_encode,3))
$(call test_assert,$(call int_subtract,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0))
$(call test_assert,$(call int_subtract,$(call int_encode,1),$(call int_encode,0)),$(call int_encode,1))
$(call stop_test)
__gmsl_warning = x x x x x x x x x x
$(call start_test,subtract)
$(call test_assert,$(call subtract,3,4),10)
$(call test_assert,$(call subtract,4,3),1)
$(call test_assert,$(call subtract,3,0),3)
$(call test_assert,$(call subtract,0,0),0)
$(call stop_test)
$(call start_test,int_multiply)
$(call test_assert,$(call int_multiply,$(call int_encode,3),$(call int_encode,4)),$(call int_encode,12))
$(call test_assert,$(call int_multiply,$(call int_encode,4),$(call int_encode,3)),$(call int_encode,12))
$(call test_assert,$(call int_multiply,$(call int_encode,3),$(call int_encode,0)),$(call int_encode,0))
$(call test_assert,$(call int_multiply,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0))
$(call test_assert,$(call int_multiply,$(call int_encode,1),$(call int_encode,0)),$(call int_encode,0))
$(call stop_test)
$(call start_test,multiply)
$(call test_assert,$(call multiply,3,4),12)
$(call test_assert,$(call multiply,4,3),12)
$(call test_assert,$(call multiply,3,0),0)
$(call test_assert,$(call multiply,0,3),0)
$(call test_assert,$(call multiply,0,0),0)
$(call stop_test)
__gmsl_error = $1
$(call start_test,int_divide)
$(call test_assert,$(call int_divide,$(call int_encode,3),$(call int_encode,4)),$(call int_encode,0))
$(call test_assert,$(call int_divide,$(call int_encode,4),$(call int_encode,3)),$(call int_encode,1))
$(call test_assert,$(call int_divide,$(call int_encode,31),$(call int_encode,3)),$(call int_encode,10))
$(call test_assert,$(call int_divide,$(call int_encode,30),$(call int_encode,3)),$(call int_encode,10))
$(call test_assert,$(call int_divide,$(call int_encode,29),$(call int_encode,3)),$(call int_encode,9))
$(call test_assert,$(call int_divide,$(call int_encode,0),$(call int_encode,1)),$(call int_encode,0))
$(call test_assert,$(call int_divide,$(call int_encode,1),$(call int_encode,0)),Division by zero)
$(call stop_test)
__gmsl_error = x x x x x x x x x x
$(call start_test,divide)
$(call test_assert,$(call divide,3,4),0)
$(call test_assert,$(call divide,4,3),1)
$(call test_assert,$(call divide,21,2),10)
$(call test_assert,$(call divide,20,2),10)
$(call test_assert,$(call divide,19,2),9)
$(call test_assert,$(call divide,1,0),10)
$(call stop_test)
$(call start_test,associative array)
$(call test_assert,$(call get,myarray,key1),)
$(call set,myarray,key1,value1)
$(call test_assert,$(call get,myarray,key1),value1)
$(call test_assert,$(call get,myarray,key2),)
$(call test_assert,$(call get,myarray1,key1),)
$(call test_assert,$(call defined,myarray,key1),T)
$(call test_assert,$(call defined,myarray,key2),)
$(call test_assert,$(call defined,myarray1,key1),)
$(call set,myarray,key2,value2)
$(call test_assert,$(call keys,myarray),key1 key2)
$(call test_assert,$(call keys,myarray1),)
$(call stop_test)
$(call start_test,named stack)
$(call test_assert,$(call pop,mystack),)
$(call test_assert,$(call push,mystack,e2))
$(call push,mystack,e1)
$(call test_assert,$(call pop,mystack),e1)
$(call test_assert,$(call pop,mystack),e2)
$(call push,mystack,f3)
$(call push,mystack,f1)
$(call test_assert,$(call pop,mystack),f1)
$(call push,mystack,f2)
$(call test_assert,$(call peek,mystack),f2)
$(call test_assert,$(call depth,mystack),2)
$(call test_assert,$(call pop,mystack),f2)
$(call test_assert,$(call depth,mystack),1)
$(call test_assert,$(call pop,myotherstack),)
$(call stop_test)
$(call start_test,reverse)
$(call test_assert,$(call reverse,),)
$(call test_assert,$(call reverse,1),1)
$(call test_assert,$(call reverse,1 2),2 1)
$(call test_assert,$(call reverse,1 2 3),3 2 1)
$(call stop_test)
$(call start_test,uniq)
$(call test_assert,$(call uniq,),)
$(call test_assert,$(call uniq,a),a)
$(call test_assert,$(call uniq,a a),a)
$(call test_assert,$(call uniq,a aa),a aa)
$(call test_assert,$(call uniq,a aa a),a aa)
$(call test_assert,$(call uniq,a b ba ab b a a ba a),a b ba ab)
$(call stop_test)
c:=,
$(call start_test,split)
$(call test_assert,$(call split,$c,comma$cseparated$cstring),comma separated string)
$(call test_assert,$(call split,*,star*field*record),star field record)
$(call test_assert,$(call split,*,star*),star)
$(call test_assert,$(call split,*,star*field),star field)
$(call test_assert,$(call split,*,star****field),star field)
$(call test_assert,$(call split,*,),)
$(call stop_test)
$(call start_test,merge)
$(call test_assert,$(call merge,$c,list of things),list$cof$cthings)
$(call test_assert,$(call merge,*,list of things),list*of*things)
$(call test_assert,$(call merge,*,list),list)
$(call test_assert,$(call merge,*,),)
$(call stop_test)
$(call start_test,int_max)
$(call test_assert,$(call int_max,$(call int_encode,2),$(call int_encode,1)),$(call int_encode,2))
$(call test_assert,$(call int_max,$(call int_encode,1),$(call int_encode,2)),$(call int_encode,2))
$(call test_assert,$(call int_max,$(call int_encode,2),$(call int_encode,0)),$(call int_encode,2))
$(call test_assert,$(call int_max,$(call int_encode,0),$(call int_encode,2)),$(call int_encode,2))
$(call test_assert,$(call int_max,$(call int_encode,2),$(call int_encode,2)),$(call int_encode,2))
$(call test_assert,$(call int_max,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0))
$(call stop_test)
$(call start_test,max)
$(call test_assert,$(call max,2,1),2)
$(call test_assert,$(call max,1,2),2)
$(call test_assert,$(call max,2,0),2)
$(call test_assert,$(call max,0,2),2)
$(call test_assert,$(call max,2,2),2)
$(call test_assert,$(call max,0,0),0)
$(call stop_test)
$(call start_test,int_min)
$(call test_assert,$(call int_min,$(call int_encode,2),$(call int_encode,1)),$(call int_encode,1))
$(call test_assert,$(call int_min,$(call int_encode,1),$(call int_encode,2)),$(call int_encode,1))
$(call test_assert,$(call int_min,$(call int_encode,2),$(call int_encode,0)),$(call int_encode,0))
$(call test_assert,$(call int_min,$(call int_encode,0),$(call int_encode,2)),$(call int_encode,0))
$(call test_assert,$(call int_min,$(call int_encode,2),$(call int_encode,2)),$(call int_encode,2))
$(call test_assert,$(call int_min,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0))
$(call stop_test)
$(call start_test,min)
$(call test_assert,$(call min,2,1),1)
$(call test_assert,$(call min,1,2),1)
$(call test_assert,$(call min,2,0),0)
$(call test_assert,$(call min,0,2),0)
$(call test_assert,$(call min,2,2),2)
$(call test_assert,$(call min,0,0),0)
$(call stop_test)
__gmsl_error = $1
$(call start_test,assert functions)
$(call test_assert,$(call assert,$(true),ignore),)
$(call test_assert,$(call assert,$(false),failed),Assertion failure: failed)
$(call test_assert,$(call assert_exists,gmsl-tests),)
$(call test_assert,$(call assert_exists,MISSING-gmsl-tests),Assertion failure: file 'MISSING-gmsl-tests' missing)
$(call stop_test)
$(call start_test,int_inc)
$(call test_assert,$(call int_inc,$(call int_encode,0)),$(call int_encode,1))
$(call test_assert,$(call int_inc,$(call int_encode,1)),$(call int_encode,2))
$(call test_assert,$(call int_inc,$(call int_encode,4)),$(call int_encode,5))
$(call test_assert,$(call int_inc,$(call int_encode,10)),$(call int_encode,11))
$(call stop_test)
$(call start_test,inc)
$(call test_assert,$(call inc,0),1)
$(call test_assert,$(call inc,1),2)
$(call test_assert,$(call inc,4),5)
$(call test_assert,$(call inc,10),11)
$(call stop_test)
__gmsl_warning = $1
$(call start_test,int_dec)
$(call test_assert,$(call int_dec,$(call int_encode,0)),Decrement underflow)
$(call test_assert,$(call int_dec,$(call int_encode,1)),$(call int_encode,0))
$(call test_assert,$(call int_dec,$(call int_encode,4)),$(call int_encode,3))
$(call test_assert,$(call int_dec,$(call int_encode,10)),$(call int_encode,9))
$(call stop_test)
__gmsl_warning = x x x x x x x x x x
$(call start_test,dec)
$(call test_assert,$(call dec,0),10)
$(call test_assert,$(call dec,1),0)
$(call test_assert,$(call dec,4),3)
$(call test_assert,$(call dec,10),9)
$(call stop_test)
$(call start_test,int_double)
$(call test_assert,$(call int_double,$(call int_encode,0)),$(call int_encode,0))
$(call test_assert,$(call int_double,$(call int_encode,1)),$(call int_encode,2))
$(call test_assert,$(call int_double,$(call int_encode,4)),$(call int_encode,8))
$(call stop_test)
$(call start_test,double)
$(call test_assert,$(call double,0),0)
$(call test_assert,$(call double,1),2)
$(call test_assert,$(call double,4),8)
$(call stop_test)
$(call start_test,int_halve)
$(call test_assert,$(call int_halve,$(call int_encode,0)),$(call int_encode,0))
$(call test_assert,$(call int_halve,$(call int_encode,2)),$(call int_encode,1))
$(call test_assert,$(call int_halve,$(call int_encode,8)),$(call int_encode,4))
$(call test_assert,$(call int_halve,$(call int_encode,7)),$(call int_encode,3))
$(call stop_test)
$(call start_test,halve)
$(call test_assert,$(call halve,0),0)
$(call test_assert,$(call halve,2),1)
$(call test_assert,$(call halve,8),4)
$(call test_assert,$(call halve,7),3)
$(call stop_test)
$(call start_test,gt)
$(call test_assert,$(call gt,2,3),)
$(call test_assert,$(call gt,3,2),$(true))
$(call test_assert,$(call gt,2,2),)
$(call stop_test)
$(call start_test,gte)
$(call test_assert,$(call gte,2,3),)
$(call test_assert,$(call gte,3,2),$(true))
$(call test_assert,$(call gte,2,2),$(true))
$(call stop_test)
$(call start_test,lt)
$(call test_assert,$(call lt,2,3),$(true))
$(call test_assert,$(call lt,3,2),)
$(call test_assert,$(call lt,2,2),)
$(call stop_test)
$(call start_test,lte)
$(call test_assert,$(call lte,2,3),$(true))
$(call test_assert,$(call lte,3,2),)
$(call test_assert,$(call lte,2,2),$(true))
$(call stop_test)
$(call start_test,eq)
$(call test_assert,$(call eq,2,3),)
$(call test_assert,$(call eq,3,2),)
$(call test_assert,$(call eq,2,2),$(true))
$(call stop_test)
$(call start_test,ne)
$(call test_assert,$(call ne,2,3),$(true))
$(call test_assert,$(call ne,3,2),$(true))
$(call test_assert,$(call ne,2,2),)
$(call stop_test)
$(call start_test,int_gt)
$(call test_assert,$(call int_gt,$(call int_encode,2),$(call int_encode,3)),)
$(call test_assert,$(call int_gt,$(call int_encode,3),$(call int_encode,2)),$(true))
$(call test_assert,$(call int_gt,$(call int_encode,2),$(call int_encode,2)),)
$(call stop_test)
$(call start_test,int_gte)
$(call test_assert,$(call int_gte,$(call int_encode,2),$(call int_encode,3)),)
$(call test_assert,$(call int_gte,$(call int_encode,3),$(call int_encode,2)),$(true))
$(call test_assert,$(call int_gte,$(call int_encode,2),$(call int_encode,2)),$(true))
$(call stop_test)
$(call start_test,int_lt)
$(call test_assert,$(call int_lt,$(call int_encode,2),$(call int_encode,3)),$(true))
$(call test_assert,$(call int_lt,$(call int_encode,3),$(call int_encode,2)),)
$(call test_assert,$(call int_lt,$(call int_encode,2),$(call int_encode,2)),)
$(call stop_test)
$(call start_test,int_lte)
$(call test_assert,$(call int_lte,$(call int_encode,2),$(call int_encode,3)),$(true))
$(call test_assert,$(call int_lte,$(call int_encode,3),$(call int_encode,2)),)
$(call test_assert,$(call int_lte,$(call int_encode,2),$(call int_encode,2)),$(true))
$(call stop_test)
$(call start_test,int_eq)
$(call test_assert,$(call int_eq,$(call int_encode,2),$(call int_encode,3)),)
$(call test_assert,$(call int_eq,$(call int_encode,3),$(call int_encode,2)),)
$(call test_assert,$(call int_eq,$(call int_encode,2),$(call int_encode,2)),$(true))
$(call stop_test)
$(call start_test,int_ne)
$(call test_assert,$(call int_ne,$(call int_encode,2),$(call int_encode,3)),$(true))
$(call test_assert,$(call int_ne,$(call int_encode,3),$(call int_encode,2)),$(true))
$(call test_assert,$(call int_ne,$(call int_encode,2),$(call int_encode,2)),)
$(call stop_test)
$(call start_test,gmsl_compatible)
$(call test_assert,$(call gmsl_compatible,$(gmsl_version)),$(true))
$(call test_assert,$(call gmsl_compatible,0 9 0),$(true))
$(call test_assert,$(call gmsl_compatible,0 0 1),$(true))
$(call test_assert,$(call gmsl_compatible,0 0 0),$(true))
$(call test_assert,$(call gmsl_compatible,2 0 0),)
$(call test_assert,$(call gmsl_compatible,1 1 0),)
$(call test_assert,$(call gmsl_compatible,1 0 8),$(true))
$(call test_assert,$(call gmsl_compatible,1 0 8),$(true))
$(call test_assert,$(call gmsl_compatible,1 0 10),$(true))
$(call test_assert,$(call gmsl_compatible,1 0 11),$(true))
$(call test_assert,$(call gmsl_compatible,1 0 12),)
$(call stop_test)

687
ndk/build/gmsl/index.html Normal file
View File

@@ -0,0 +1,687 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>GNU Make Standard Library</title></head>
<body>
<h1>GNU Make Standard Library</h1>
The GNU Make Standard Library (GMSL) is a collection of functions
implemented using native GNU Make functionality that provide list and
string manipulation, integer arithmetic, associative arrays, stacks,
and debugging facilities.&nbsp; The GMSL is released under the BSD License.<br>
<br>
<a href="http://sourceforge.net/projects/gmsl/">[Project Page]</a> <a href="http://sourceforge.net/project/showfiles.php?group_id=129887">[Download]</a>
<a href="http://sourceforge.net/forum/forum.php?forum_id=443916">[Discussion
Forum]</a><br>
<h2>Using GMSL</h2>
The two files needed are <span style="font-family: monospace;">gmsl</span>
and <span style="font-family: monospace;">__gmsl</span>.&nbsp; To
include the GMSL in your Makefile do<br>
<pre style="margin-left: 40px;">include gmsl</pre>
<span style="font-family: monospace;">gmsl</span> automatically includes<span style="font-family: monospace;"> __gmsl</span>.&nbsp; To check that
you have the right version of <span style="font-family: monospace;">gmsl</span>
use the <span style="font-family: monospace;">gmsl_compatible</span>
function (see
below). The current version is <span style="font-family: monospace;">1
0 11</span>.<br>
<br>
The GMSL package also includes a test suite for GMSL.&nbsp; Just run <span style="font-family: monospace;">make -f gmsl-tests</span>.<br>
<h2>Logical Operators</h2>GMSL has boolean $(true) (a non-empty string)
and $(false) (an empty string).&nbsp; The following operators can be
used with those variables.<br>
<br>
<hr style="width: 100%; height: 2px;"><span style="font-weight: bold;">not</span><br>
<br>
<span style="font-family: monospace;">Arguments: A boolean value</span><br style="font-family: monospace;">
<span style="font-family: monospace;">Returns:&nbsp;&nbsp; Returns $(true) if the boolean is $(false) and vice versa</span><br style="font-family: monospace;">
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;"></span><span style="font-weight: bold;">and</span><br>
<br>
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
<span style="font-family: monospace;">Returns:&nbsp;&nbsp; Returns $(true) if both of the booleans are true</span><br style="font-family: monospace;">
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">or</span><br>
<br>
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
<span style="font-family: monospace;">Returns:&nbsp;&nbsp; Returns $(true) if either of the booleans is true</span><br style="font-family: monospace;">
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">xor</span><br style="font-weight: bold;">
<br>
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
<span style="font-family: monospace;">Returns:&nbsp;&nbsp; Returns $(true) if exactly one of the booleans is true</span><br style="font-family: monospace;">
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">nand</span><br>
<br>
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
<span style="font-family: monospace;">Returns:&nbsp;&nbsp; Returns value of 'not and'</span><br style="font-family: monospace;">
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">nor</span><br>
<br>
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
<span style="font-family: monospace;">Returns:&nbsp;&nbsp; Returns value of 'not or'</span><br style="font-family: monospace;">
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">xnor</span><br>
<br>
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
<span style="font-family: monospace;">Returns:&nbsp;&nbsp; Returns value of 'not xor'</span><br style="font-family: monospace;">
<hr style="width: 100%; height: 2px; font-family: monospace;">
<h2>List Manipulation Functions</h2>
&nbsp;A list is a string of characters; the list separator is a space.<br>
<br>
<hr style="width: 100%; height: 2px;"><b>first</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the first element of a list<br>
</span>
<hr><b>last</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the last element of a list<br>
</span>
<hr><b>rest</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the list with the first element
removed<br>
</span>
<hr><b>chop</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the list with the last element removed<br>
</span>
<hr><b>map</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of function to
$(call) for each element of list<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: List to
iterate over calling the function in 1<br>
Returns:&nbsp;&nbsp;&nbsp;The list after calling the function on each
element<br>
</span>
<hr><b>pairmap</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of function to
$(call) for each pair of elements<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: List to
iterate over calling the function in 1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3: Second
list to iterate over calling the function in 1<br>
Returns:&nbsp;&nbsp;&nbsp;The list after calling the function on each
pair of elements<br>
</span>
<hr><b>leq</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list to compare
against...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: ...this
list<br>
Returns:&nbsp;&nbsp;&nbsp;Returns $(true) if the two lists are identical<br>
</span>
<hr><b>lne</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list to compare
against...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: ...this
list<br>
Returns:&nbsp;&nbsp;&nbsp;Returns $(true) if the two lists are different<br>
</span>
<hr><b>reverse</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list to reverse<br>
Returns:&nbsp;&nbsp;&nbsp;The list with its elements in reverse order<br>
</span>
<hr><b>uniq</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list to deduplicate<br>
Returns:&nbsp;&nbsp;&nbsp;The list with elements in order without duplicates<br>
</span>
<hr><b>length</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list<br>
Returns:&nbsp;&nbsp;&nbsp;The number of elements in the list<br>
</span>
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
<h2>String Manipulation Functions</h2>
A string is any sequence of characters.<br>
<br>
<hr style="width: 100%; height: 2px;"><b>seq</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A string to compare
against...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: ...this
string<br>
Returns:&nbsp;&nbsp;&nbsp;Returns $(true) if the two strings are
identical<br>
</span>
<hr><b>sne</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A string to compare
against...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: ...this
string<br>
Returns:&nbsp;&nbsp;&nbsp;Returns $(true) if the two strings are not
the same<br>
</span>
<hr><b>strlen</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A string<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the length of the string<br>
</span>
<hr><b>substr</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A string<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Start offset (first character is 1)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3: Ending offset (inclusive)<br>Returns:&nbsp;&nbsp;&nbsp;Returns a substring<br>
</span>
<hr><b>split</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: The character to
split on<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: A
string to split<br>
Returns:&nbsp;&nbsp;&nbsp;Splits a string into a list separated by
spaces at the split<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; character
in the first argument<br>
</span>
<hr><b>merge</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: The character to
put between fields<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: A list
to merge into a string<br>
Returns:&nbsp;&nbsp;&nbsp;Merges a list into a single string, list
elements are separated<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; by the
character in the first argument<br>
</span>
<hr><b>tr</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: The list of
characters to translate from <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: The
list of characters to translate to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3: The
text to translate<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the text after translating characters<br>
</span>
<hr><b>uc</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Text to upper case<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the text in upper case<br>
</span>
<hr><b>lc</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Text to lower case<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the text in lower case<br>
</span>
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
<h2>Set Manipulation Functions</h2>
Sets are represented by sorted, deduplicated lists. To create a set
from a list use <span style="font-family:
monospace;">set_create</span>, or start with the <span
style="font-family: monospace;">empty_set</span> and <span
style="font-family: monospace;">set_insert</span> individual elements.
The empty set is defined as <span style="font-family:
monospace;">empty_set</span>.<p>
<hr><b>set_create</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A list of set elements<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the newly created set<br>
</span>
<hr><b>set_insert</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A single element to add to a set<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2: A set<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the set with the element added<br>
</span>
<hr><b>set_remove</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A single element to remove from a set<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2: A set<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the set with the element removed<br>
</span>
<hr><b>set_is_member</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A single element<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2: A set<br>
Returns:&nbsp;&nbsp;&nbsp;Returns $(true) if the element is in the set<br>
</span>
<hr><b>set_union</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A set<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2: Another set<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the union of the two sets<br>
</span>
<hr><b>set_intersection</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A set<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2: Another set<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the intersection of the two sets<br>
</span>
<hr><b>set_is_subset</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A set<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2: Another set<br>
Returns:&nbsp;&nbsp;&nbsp;Returns $(true) if the first set is a subset of the second<br>
</span>
<hr><b>set_equal</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A set<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2: Another set<br>
Returns:&nbsp;&nbsp;&nbsp;Returns $(true) if the two sets are identical<br>
</span>
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
<h2>Integer Arithmetic Functions</h2>
Integers are represented by lists with the equivalent number of
x's.&nbsp; For example the number 4 is x x x x.&nbsp; The maximum
integer that the library can handle as <span style="font-style: italic;">input</span> (i.e. as the argument to a
call to <span style="font-family: monospace;">int_encode</span>) is
65536. There is no limit on integer size for internal computations or
output.<br>
<br>
The arithmetic library functions come in two forms: one form of each
function takes integers as arguments and the other form takes the
encoded form (x's created by a call to <span style="font-family: monospace;">int_encode</span>).&nbsp; For example,
there are two plus functions: <span style="font-family: monospace;">plus</span>
(called with integer arguments and returns an integer) and <span style="font-family: monospace;">int_plus</span> (called with encoded
arguments and returns an encoded result).<br>
<br>
<span style="font-family: monospace;">plus</span> will be slower than <span style="font-family: monospace;">int_plus</span> because its arguments
and result have to be translated between the x's format and
integers.&nbsp; If doing a complex calculation use the <span style="font-family: monospace;">int_*</span> forms with a single
encoding of inputs and single decoding of the output.&nbsp; For simple
calculations the direct forms can be used.<br>
<br>
<hr style="width: 100%; height: 2px;"><b>int_decode</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number of x's
representation<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the integer for human consumption
that is represented<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; by the
string of x's<br>
</span>
<hr><b>int_encode</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in
human-readable integer form<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the integer encoded as a string of x's<br>
</span>
<hr><b>int_plus</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
number in x's represntation<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the sum of the two numbers in x's
representation<br>
</span>
<hr><b>plus (wrapped version of int_plus)</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
integer<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the sum of the two integers<br>
</span>
<hr><b>int_subtract</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
number in x's represntation<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the difference of the two numbers in
x's representation,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or outputs
an error on a numeric underflow<br>
</span>
<hr><b>subtract (wrapped version of int_subtract)</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
integer<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the difference of the two integers,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or outputs
an error on a numeric underflow<br>
</span>
<hr><b>int_multiply</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
number in x's represntation<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the product of the two numbers in x's
representation<br>
</span>
<hr><b>multiply (wrapped version of int_multiply)</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
integer<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the product of the two integers<br>
</span>
<hr><b>int_divide</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
number in x's represntation<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the result of integer division of
argument 1 divided<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; by
argument 2 in x's representation<br>
</span>
<hr><b>divide (wrapped version of int_divide)</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
integer<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the integer division of the first
argument by the second<br>
</span>
<hr><b>int_max, int_min</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
number in x's represntation<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the maximum or minimum of its
arguments in x's<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
representation<br>
</span>
<hr><b>max, min</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Another
integer<br>
Returns:&nbsp;&nbsp;&nbsp;Returns the maximum or minimum of its integer
arguments<br>
</span>
<hr><b>int_gt, int_gte, int_lt, int_lte, int_eq, int_ne</b><br>
<br>
<span style="font-family: monospace;">Arguments: Two x's representation
numbers to be compared<br>
Returns:&nbsp;&nbsp;&nbsp;$(true) or $(false)<br>
<br>
int_gt First argument greater than second argument<br>
int_gte First argument greater than or equal to second argument<br>
int_lt First argument less than second argument <br>
int_lte First argument less than or equal to second argument<br>
int_eq First argument is numerically equal to the second argument<br>
int_ne First argument is not numerically equal to the second argument<br>
</span>
<hr><b>gt, gte, lt, lte, eq, ne</b><br>
<br>
<span style="font-family: monospace;">Arguments: Two integers to be
compared<br>
Returns:&nbsp;&nbsp;&nbsp;$(true) or $(false)<br>
<br>
gt First argument greater than second argument<br>
gte First argument greater than or equal to second argument<br>
lt First argument less than second argument <br>
lte First argument less than or equal to second argument<br>
eq First argument is numerically equal to the second argument<br>
ne First argument is not numerically equal to the second argument<br>
</span>
increment adds 1 to its argument, decrement subtracts 1. Note that<br>
decrement does not range check and hence will not underflow, but<br>
will incorrectly say that 0 - 1 = 0<br>
<hr><b>int_inc</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
Returns:&nbsp;&nbsp;&nbsp;The number incremented by 1 in x's
representation<br>
</span>
<hr><b>inc</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
Returns:&nbsp;&nbsp;&nbsp;The argument incremented by 1<br>
</span>
<hr><b>int_dec</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
Returns:&nbsp;&nbsp;&nbsp;The number decremented by 1 in x's
representation<br>
</span>
<hr><b>dec</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
Returns:&nbsp;&nbsp;&nbsp;The argument decremented by 1<br>
</span>
<hr><b>int_double</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
Returns:&nbsp;&nbsp;&nbsp;The number doubled (i.e. * 2) and returned in
x's representation<br>
</span>
<hr><b>double</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
Returns:&nbsp;&nbsp;&nbsp;The integer times 2<br>
</span>
<hr><b>int_halve</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A number in x's
representation<br>
Returns:&nbsp;&nbsp;&nbsp;The number halved (i.e. / 2) and returned in
x's representation<br>
</span>
<hr><b>halve</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: An integer<br>
Returns:&nbsp;&nbsp;&nbsp;The integer divided by 2<br>
</span>
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
<h2>Associative Arrays</h2>
An associate array maps a key value (a string with no spaces in it) to
a single value (any string).&nbsp;&nbsp;&nbsp; <br>
<b><br>
</b>
<hr style="width: 100%; height: 2px;"><b>set</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of associative
array<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: The key
value to associate<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3: The
value associated with the key<br>
Returns:&nbsp;&nbsp;&nbsp;None<br>
</span>
<hr><b>get</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of associative
array<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: The key
to retrieve<br>
Returns:&nbsp;&nbsp;&nbsp;The value stored in the array for that key<br>
</span>
<hr><b>keys</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of associative
array<br>
Returns:&nbsp;&nbsp;&nbsp;Returns a list of all defined keys in the
array<br>
</span>
<hr><b>defined</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of associative
array<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: The key
to test<br>
Returns:&nbsp;&nbsp;&nbsp;Returns true if the key is defined (i.e. not
empty)<br>
</span>
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
<h2>Named Stacks</h2>
A stack is an ordered list of strings (with no spaces in them).<br>
<br>
<hr style="width: 100%; height: 2px;"><b>push</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of stack<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: Value
to push onto the top of the stack (must not contain<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a space)<br>
Returns:&nbsp;&nbsp;&nbsp;None<br>
</span>
<hr><b>pop</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of stack<br>
Returns:&nbsp;&nbsp;&nbsp;Top element from the stack after removing it<br>
</span>
<hr><b>peek</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of stack<br>
Returns:&nbsp;&nbsp;&nbsp;Top element from the stack without removing it<br>
</span>
<hr><b>depth</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of stack<br>
Returns:&nbsp;&nbsp;&nbsp;Number of items on the stack<br>
</span>
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
<h2>Miscellaneous and Debugging Facilities</h2>
GMSL defines the following constants; all are accessed as normal GNU
Make variables by wrapping them in <span style="font-family: monospace;">$()</span> or <span style="font-family: monospace;">${}</span>.<br>
<br>
<table style="text-align: left;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td><span style="font-style: italic;">Constant</span><br>
</td>
<td><span style="font-style: italic;">Value</span><br>
</td>
<td><span style="font-style: italic;">Purpose</span><br>
</td>
</tr>
<tr>
<td><span style="font-family: monospace;">true</span><br>
</td>
<td><span style="font-family: monospace;">T</span><br>
</td>
<td>Boolean for <span style="font-family: monospace;">$(if)</span>
and return from&nbsp; GMSL functions<br>
</td>
</tr>
<tr>
<td><span style="font-family: monospace;">false</span><br>
</td>
<td><br>
</td>
<td>Boolean for <span style="font-family: monospace;">$(if)</span>
and return from GMSL functions<br>
</td>
</tr>
<tr>
<td><span style="font-family: monospace;">gmsl_version</span><br>
</td>
<td><span style="font-family: monospace;">1 0 0</span><br>
</td>
<td>GMSL version number as list: major minor revision<br>
</td>
</tr>
</tbody>
</table>
<span style="font-weight: bold;"><br>
gmsl_compatible</span><span style="font-family: monospace;"><br>
<br>
Arguments: List containing the desired library version number (maj min
rev)<br>
</span><span style="font-family: monospace;">Returns:&nbsp;&nbsp;
$(true) if this version of the library is compatible<br>
</span><span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
with the requested version number, otherwise $(false)</span>
<hr><b>gmsl-print-% (target not a function)</b><br>
<br>
<span style="font-family: monospace;">Arguments: The % should be
replaced by the name of a variable that you<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wish to
print out.<br>
Action:&nbsp;&nbsp;&nbsp; Echos the name of the variable that matches
the % and its value.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For
example, 'make gmsl-print-SHELL' will output the value of<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the SHELL
variable<br>
</span>
<hr><b>assert</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: A boolean that must
be true or the assertion will fail<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2: The
message to print with the assertion<br>
Returns:&nbsp;&nbsp;&nbsp;None<br>
</span>
<hr><b>assert_exists</b><br>
<br>
<span style="font-family: monospace;">Arguments: 1: Name of file that
must exist, if it is missing an assertion<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; will be
generated<br>
Returns:&nbsp;&nbsp;&nbsp;None<br>
</span>
<hr style="width: 100%; height: 2px;"><br>
GMSL has a number of environment variables (or command-line overrides)
that control various bits of functionality:<br>
<br>
<table style="text-align: left;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td><span style="font-style: italic;">Variable</span><br>
</td>
<td><span style="font-style: italic;">Purpose</span><br>
</td>
</tr>
<tr>
<td><span style="font-family: monospace;">GMSL_NO_WARNINGS</span><br>
</td>
<td>If set prevents GMSL from outputting warning messages:
artithmetic functions generate underflow warnings.<br>
</td>
</tr>
<tr>
<td><span style="font-family: monospace;">GMSL_NO_ERRORS</span><br>
</td>
<td>If set prevents GMSL from generating fatal errors: division
by zero or failed assertions are fatal.<br>
</td>
</tr>
<tr>
<td><span style="font-family: monospace;">GMSL_TRACE</span><br>
</td>
<td>Enables function tracing.&nbsp; Calls to GMSL functions will
result in name and arguments being traced.<br>
</td>
</tr>
</tbody>
</table>
<span style="font-family: monospace;"></span><br>
<hr>
Copyright (c) 2005-2006 <a href="http://www.jgc.org/">John Graham-Cumming</a>.<br>
<hr style="width: 100%; height: 2px;">
<table style="width: 100%; text-align: left;" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 50%;">John Graham-Cumming's work on this
project was sponsored by <a href="http://www.electric-cloud.com/">Electric
Cloud, Inc</a>.<br>
<a href="http://www.electric-cloud.com/"><img alt="" src="http://gmsl.sf.net/ec_logo.gif" style="border: 0px solid ; width: 223px; height: 47px;"></a><br>
</td>
<td align="right">
<p><a href="http://sourceforge.net/"><img src="http://sourceforge.net/sflogo.php?group_id=129887&amp;type=1" alt="SourceForge.net Logo" border="0" height="31" width="88"></a></p>
</td>
</tr>
</tbody>
</table>
</body></html>

99
ndk/build/host-setup.sh Executable file
View File

@@ -0,0 +1,99 @@
#!/bin/sh
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# A shell script used to configure the host-specific parts of the NDK
# build system. This will create out/host/config-host.make based on
# your host system and additionnal command-line options.
#
# include common function and variable definitions
source `dirname $0`/core/ndk-common.sh
OUT_DIR=out
HOST_CONFIG=$OUT_DIR/host/config.mk
## Build configuration file support
## you must define $config_mk before calling this function
##
create_config_mk ()
{
# create the directory if needed
local config_dir
config_mk=${config_mk:-$HOST_CONFIG}
config_dir=`dirname $config_mk`
mkdir -p $config_dir 2> $TMPL
if [ $? != 0 ] ; then
echo "Can't create directory for host config file: $config_dir"
exit 1
fi
# re-create the start of the configuration file
log "Generate : $config_mk"
echo "# This file was autogenerated by $PROGNAME. Do not edit !" > $config_mk
}
add_config ()
{
echo "$1" >> $config_mk
}
echo "Detecting host toolchain."
echo ""
setup_toolchain
create_config_mk
add_config "HOST_OS := $HOST_OS"
add_config "HOST_ARCH := $HOST_ARCH"
add_config "HOST_TAG := $HOST_TAG"
add_config "HOST_CC := $CC"
add_config "HOST_CFLAGS := $CFLAGS"
add_config "HOST_CXX := $CXX"
add_config "HOST_CXXFLAGS := $CXXFLAGS"
add_config "HOST_LD := $LD"
add_config "HOST_LDFLAGS := $LDFLAGS"
add_config "HOST_AR := $AR"
add_config "HOST_ARFLAGS := $ARFLAGS"
## Check that the toolchains we need are installed
## Otherwise, instruct the user to download them from the web site
TOOLCHAINS=arm-eabi-4.2.1
for tc in $TOOLCHAINS; do
echo "Toolchain : Checking for $tc prebuilt binaries"
COMPILER_PATTERN=$ANDROID_NDK_ROOT/build/prebuilt/$HOST_TAG/$tc/bin/*-gcc
COMPILERS=`ls $COMPILER_PATTERN 2> /dev/null`
if [ -z $COMPILERS ] ; then
echo ""
echo "ERROR:"
echo "It seems you do not have the prebuilt $tc toolchain binaries."
echo "Please go to the official Android NDK web site and download the"
echo "appropriate toolchain package for your platform ($HOST_TAG)."
echo "See http://developer.android.com/ndk/1.5/index.html"
echo ""
echo "ABORTING."
echo ""
exit 1
fi
done
echo ""
echo "Host setup complete. Please read docs/OVERVIEW.TXT if you don't know what to do."
echo ""

View File

@@ -0,0 +1 @@
../../../common/include/alloca.h

View File

@@ -0,0 +1,217 @@
/*-
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/arm/fenv.h,v 1.5 2005/03/16 19:03:45 das Exp $
*/
#ifndef _FENV_H_
#define _FENV_H_
#include <sys/_types.h>
typedef __uint32_t fenv_t;
typedef __uint32_t fexcept_t;
/* Exception flags */
#define FE_INVALID 0x0001
#define FE_DIVBYZERO 0x0002
#define FE_OVERFLOW 0x0004
#define FE_UNDERFLOW 0x0008
#define FE_INEXACT 0x0010
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
/* Rounding modes */
#define FE_TONEAREST 0x0000
#define FE_TOWARDZERO 0x0001
#define FE_UPWARD 0x0002
#define FE_DOWNWARD 0x0003
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
FE_UPWARD | FE_TOWARDZERO)
__BEGIN_DECLS
/* Default floating-point environment */
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
/* We need to be able to map status flag positions to mask flag positions */
#define _FPUSW_SHIFT 16
#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
#ifdef ARM_HARD_FLOAT
#define __rfs(__fpsr) __asm __volatile("rfs %0" : "=r" (*(__fpsr)))
#define __wfs(__fpsr) __asm __volatile("wfs %0" : : "r" (__fpsr))
#else
#define __rfs(__fpsr)
#define __wfs(__fpsr)
#endif
static __inline int
feclearexcept(int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__fpsr &= ~__excepts;
__wfs(__fpsr);
return (0);
}
static __inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
*__flagp = __fpsr & __excepts;
return (0);
}
static __inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__fpsr &= ~__excepts;
__fpsr |= *__flagp & __excepts;
__wfs(__fpsr);
return (0);
}
static __inline int
feraiseexcept(int __excepts)
{
fexcept_t __ex = __excepts;
fesetexceptflag(&__ex, __excepts); /* XXX */
return (0);
}
static __inline int
fetestexcept(int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
return (__fpsr & __excepts);
}
static __inline int
fegetround(void)
{
/*
* Apparently, the rounding mode is specified as part of the
* instruction format on ARM, so the dynamic rounding mode is
* indeterminate. Some FPUs may differ.
*/
return (-1);
}
static __inline int
fesetround(int __round)
{
return (-1);
}
static __inline int
fegetenv(fenv_t *__envp)
{
__rfs(__envp);
return (0);
}
static __inline int
feholdexcept(fenv_t *__envp)
{
fenv_t __env;
__rfs(&__env);
*__envp = __env;
__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
__wfs(__env);
return (0);
}
static __inline int
fesetenv(const fenv_t *__envp)
{
__wfs(*__envp);
return (0);
}
static __inline int
feupdateenv(const fenv_t *__envp)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__wfs(*__envp);
feraiseexcept(__fpsr & FE_ALL_EXCEPT);
return (0);
}
#if __BSD_VISIBLE
static __inline int
feenableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
__rfs(&__old_fpsr);
__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
__wfs(__new_fpsr);
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
static __inline int
fedisableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
__rfs(&__old_fpsr);
__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
__wfs(__new_fpsr);
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
static __inline int
fegetexcept(void)
{
fenv_t __fpsr;
__rfs(&__fpsr);
return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
}
#endif /* __BSD_VISIBLE */
__END_DECLS
#endif /* !_FENV_H_ */

View File

@@ -0,0 +1 @@
../../../../common/include/arpa/inet.h

View File

@@ -0,0 +1 @@
../../../../common/include/arpa/nameser.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/4level-fixup.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/audit_dir_write.h

View File

@@ -0,0 +1 @@
../../../../../common/include/asm-generic/bitops/__ffs.h

View File

@@ -0,0 +1 @@
../../../../../common/include/asm-generic/bitops/atomic.h

View File

@@ -0,0 +1 @@
../../../../../common/include/asm-generic/bitops/ffz.h

View File

@@ -0,0 +1 @@
../../../../../common/include/asm-generic/bitops/find.h

View File

@@ -0,0 +1 @@
../../../../../common/include/asm-generic/bitops/fls.h

View File

@@ -0,0 +1 @@
../../../../../common/include/asm-generic/bitops/fls64.h

View File

@@ -0,0 +1 @@
../../../../../common/include/asm-generic/bitops/le.h

View File

@@ -0,0 +1 @@
../../../../../common/include/asm-generic/bitops/non-atomic.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/bug.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/cputime.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/emergency-restart.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/errno-base.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/errno.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/fcntl.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/futex.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/ioctl.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/ipc.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/local.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/memory_model.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/mman.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/mutex-xchg.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/percpu.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/pgtable-nopud.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/pgtable.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/poll.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/resource.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/sections.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/siginfo.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/signal.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/tlb.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/topology.h

View File

@@ -0,0 +1 @@
../../../../common/include/asm-generic/xor.h

View File

@@ -0,0 +1,42 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ARM_A_OUT_H__
#define __ARM_A_OUT_H__
#include <linux/personality.h>
#include <asm/types.h>
struct exec
{
__u32 a_info;
__u32 a_text;
__u32 a_data;
__u32 a_bss;
__u32 a_syms;
__u32 a_entry;
__u32 a_trsize;
__u32 a_drsize;
};
#define N_TXTADDR(a) (0x00008000)
#define N_TRSIZE(a) ((a).a_trsize)
#define N_DRSIZE(a) ((a).a_drsize)
#define N_SYMSIZE(a) ((a).a_syms)
#define M_ARM 103
#ifndef LIBRARY_START_TEXT
#define LIBRARY_START_TEXT (0x00c00000)
#endif
#endif

View File

@@ -0,0 +1,27 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARCH_OMAP_PERSEUS2_H
#define __ASM_ARCH_OMAP_PERSEUS2_H
#include <asm/arch/fpga.h>
#ifndef OMAP_SDRAM_DEVICE
#define OMAP_SDRAM_DEVICE D256M_1X16_4B
#endif
#define MAXIRQNUM IH_BOARD_BASE
#define MAXFIQNUM MAXIRQNUM
#define MAXSWINUM MAXIRQNUM
#define NR_IRQS (MAXIRQNUM + 1)
#endif

View File

@@ -0,0 +1,163 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef _OMAP_BOARD_H
#define _OMAP_BOARD_H
#include <linux/types.h>
#include <asm/arch/gpio-switch.h>
#define OMAP_TAG_CLOCK 0x4f01
#define OMAP_TAG_MMC 0x4f02
#define OMAP_TAG_SERIAL_CONSOLE 0x4f03
#define OMAP_TAG_USB 0x4f04
#define OMAP_TAG_LCD 0x4f05
#define OMAP_TAG_GPIO_SWITCH 0x4f06
#define OMAP_TAG_UART 0x4f07
#define OMAP_TAG_FBMEM 0x4f08
#define OMAP_TAG_STI_CONSOLE 0x4f09
#define OMAP_TAG_CAMERA_SENSOR 0x4f0a
#define OMAP_TAG_BT 0x4f0b
#define OMAP_TAG_BOOT_REASON 0x4f80
#define OMAP_TAG_FLASH_PART 0x4f81
#define OMAP_TAG_VERSION_STR 0x4f82
struct omap_clock_config {
u8 system_clock_type;
};
struct omap_mmc_conf {
unsigned enabled:1;
unsigned nomux:1;
unsigned cover:1;
unsigned wire4:1;
s16 power_pin;
s16 switch_pin;
s16 wp_pin;
};
struct omap_mmc_config {
struct omap_mmc_conf mmc[2];
};
struct omap_serial_console_config {
u8 console_uart;
u32 console_speed;
};
struct omap_sti_console_config {
unsigned enable:1;
u8 channel;
};
struct omap_camera_sensor_config {
u16 reset_gpio;
int (*power_on)(void * data);
int (*power_off)(void * data);
};
struct omap_usb_config {
unsigned register_host:1;
unsigned register_dev:1;
u8 otg;
u8 hmc_mode;
u8 rwc;
u8 pins[3];
};
struct omap_lcd_config {
char panel_name[16];
char ctrl_name[16];
s16 nreset_gpio;
u8 data_lines;
};
struct device;
struct fb_info;
struct omap_backlight_config {
int default_intensity;
int (*set_power)(struct device *dev, int state);
int (*check_fb)(struct fb_info *fb);
};
struct omap_fbmem_config {
u32 start;
u32 size;
};
struct omap_pwm_led_platform_data {
const char *name;
int intensity_timer;
int blink_timer;
void (*set_power)(struct omap_pwm_led_platform_data *self, int on_off);
};
struct omap_gpio_switch_config {
char name[12];
u16 gpio;
int flags:4;
int type:4;
int key_code:24;
};
struct omap_uart_config {
unsigned int enabled_uarts;
};
struct omap_flash_part_config {
char part_table[0];
};
struct omap_boot_reason_config {
char reason_str[12];
};
struct omap_version_config {
char component[12];
char version[12];
};
struct omap_board_config_entry {
u16 tag;
u16 len;
u8 data[0];
};
struct omap_board_config_kernel {
u16 tag;
const void *data;
};
struct omap_bluetooth_config {
u8 chip_type;
u8 bt_uart;
u8 bd_addr[6];
u8 bt_sysclk;
int bt_wakeup_gpio;
int host_wakeup_gpio;
int reset_gpio;
};
#define omap_get_config(tag, type) ((const type *) __omap_get_config((tag), sizeof(type), 0))
#define omap_get_nr_config(tag, type, nr) ((const type *) __omap_get_config((tag), sizeof(type), (nr)))
#endif

View File

@@ -0,0 +1,57 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARCH_OMAP_CPU_H
#define __ASM_ARCH_OMAP_CPU_H
#define omap2_cpu_rev() ((system_rev >> 8) & 0x0f)
#undef MULTI_OMAP1
#undef MULTI_OMAP2
#undef OMAP_NAME
#define GET_OMAP_CLASS (system_rev & 0xff)
#define IS_OMAP_CLASS(class, id) static inline int is_omap ##class (void) { return (GET_OMAP_CLASS == (id)) ? 1 : 0; }
#define GET_OMAP_SUBCLASS ((system_rev >> 20) & 0x0fff)
#define IS_OMAP_SUBCLASS(subclass, id) static inline int is_omap ##subclass (void) { return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; }
#define cpu_is_omap7xx() 0
#define cpu_is_omap15xx() 0
#define cpu_is_omap16xx() 0
#define cpu_is_omap24xx() 0
#define cpu_is_omap242x() 0
#define cpu_is_omap243x() 0
#ifdef MULTI_OMAP1
#else
#endif
#define GET_OMAP_TYPE ((system_rev >> 16) & 0xffff)
#define IS_OMAP_TYPE(type, id) static inline int is_omap ##type (void) { return (GET_OMAP_TYPE == (id)) ? 1 : 0; }
#define cpu_is_omap310() 0
#define cpu_is_omap730() 0
#define cpu_is_omap1510() 0
#define cpu_is_omap1610() 0
#define cpu_is_omap5912() 0
#define cpu_is_omap1611() 0
#define cpu_is_omap1621() 0
#define cpu_is_omap1710() 0
#define cpu_is_omap2420() 0
#define cpu_is_omap2422() 0
#define cpu_is_omap2423() 0
#define cpu_is_omap2430() 0
#ifdef MULTI_OMAP1
#else
#endif
#define cpu_class_is_omap1() (cpu_is_omap730() || cpu_is_omap15xx() || cpu_is_omap16xx())
#define cpu_class_is_omap2() cpu_is_omap24xx()
#endif

View File

@@ -0,0 +1,318 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARCH_DMA_H
#define __ASM_ARCH_DMA_H
#define OMAP_DMA_BASE (0xfffed800)
#define OMAP_DMA_GCR (OMAP_DMA_BASE + 0x400)
#define OMAP_DMA_GSCR (OMAP_DMA_BASE + 0x404)
#define OMAP_DMA_GRST (OMAP_DMA_BASE + 0x408)
#define OMAP_DMA_HW_ID (OMAP_DMA_BASE + 0x442)
#define OMAP_DMA_PCH2_ID (OMAP_DMA_BASE + 0x444)
#define OMAP_DMA_PCH0_ID (OMAP_DMA_BASE + 0x446)
#define OMAP_DMA_PCH1_ID (OMAP_DMA_BASE + 0x448)
#define OMAP_DMA_PCHG_ID (OMAP_DMA_BASE + 0x44a)
#define OMAP_DMA_PCHD_ID (OMAP_DMA_BASE + 0x44c)
#define OMAP_DMA_CAPS_0_U (OMAP_DMA_BASE + 0x44e)
#define OMAP_DMA_CAPS_0_L (OMAP_DMA_BASE + 0x450)
#define OMAP_DMA_CAPS_1_U (OMAP_DMA_BASE + 0x452)
#define OMAP_DMA_CAPS_1_L (OMAP_DMA_BASE + 0x454)
#define OMAP_DMA_CAPS_2 (OMAP_DMA_BASE + 0x456)
#define OMAP_DMA_CAPS_3 (OMAP_DMA_BASE + 0x458)
#define OMAP_DMA_CAPS_4 (OMAP_DMA_BASE + 0x45a)
#define OMAP_DMA_PCH2_SR (OMAP_DMA_BASE + 0x460)
#define OMAP_DMA_PCH0_SR (OMAP_DMA_BASE + 0x480)
#define OMAP_DMA_PCH1_SR (OMAP_DMA_BASE + 0x482)
#define OMAP_DMA_PCHD_SR (OMAP_DMA_BASE + 0x4c0)
#define OMAP24XX_DMA_BASE (L4_24XX_BASE + 0x56000)
#define OMAP_DMA4_REVISION (OMAP24XX_DMA_BASE + 0x00)
#define OMAP_DMA4_GCR_REG (OMAP24XX_DMA_BASE + 0x78)
#define OMAP_DMA4_IRQSTATUS_L0 (OMAP24XX_DMA_BASE + 0x08)
#define OMAP_DMA4_IRQSTATUS_L1 (OMAP24XX_DMA_BASE + 0x0c)
#define OMAP_DMA4_IRQSTATUS_L2 (OMAP24XX_DMA_BASE + 0x10)
#define OMAP_DMA4_IRQSTATUS_L3 (OMAP24XX_DMA_BASE + 0x14)
#define OMAP_DMA4_IRQENABLE_L0 (OMAP24XX_DMA_BASE + 0x18)
#define OMAP_DMA4_IRQENABLE_L1 (OMAP24XX_DMA_BASE + 0x1c)
#define OMAP_DMA4_IRQENABLE_L2 (OMAP24XX_DMA_BASE + 0x20)
#define OMAP_DMA4_IRQENABLE_L3 (OMAP24XX_DMA_BASE + 0x24)
#define OMAP_DMA4_SYSSTATUS (OMAP24XX_DMA_BASE + 0x28)
#define OMAP_DMA4_CAPS_0 (OMAP24XX_DMA_BASE + 0x64)
#define OMAP_DMA4_CAPS_2 (OMAP24XX_DMA_BASE + 0x6c)
#define OMAP_DMA4_CAPS_3 (OMAP24XX_DMA_BASE + 0x70)
#define OMAP_DMA4_CAPS_4 (OMAP24XX_DMA_BASE + 0x74)
#define OMAP_LOGICAL_DMA_CH_COUNT 32
#define OMAP_DMA_CCR_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x80)
#define OMAP_DMA_CLNK_CTRL_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x84)
#define OMAP_DMA_CICR_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x88)
#define OMAP_DMA_CSR_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x8c)
#define OMAP_DMA_CSDP_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x90)
#define OMAP_DMA_CEN_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x94)
#define OMAP_DMA_CFN_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x98)
#define OMAP_DMA_CSEI_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xa4)
#define OMAP_DMA_CSFI_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xa8)
#define OMAP_DMA_CDEI_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xac)
#define OMAP_DMA_CDFI_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xb0)
#define OMAP_DMA_CSAC_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xb4)
#define OMAP_DMA_CDAC_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xb8)
#define OMAP1_DMA_CSSA_L_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x08)
#define OMAP1_DMA_CSSA_U_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x0a)
#define OMAP1_DMA_CDSA_L_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x0c)
#define OMAP1_DMA_CDSA_U_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x0e)
#define OMAP1_DMA_COLOR_L_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x20)
#define OMAP1_DMA_CCR2_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x24)
#define OMAP1_DMA_COLOR_U_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x22)
#define OMAP1_DMA_LCH_CTRL_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x2a)
#define OMAP2_DMA_CSSA_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x9c)
#define OMAP2_DMA_CDSA_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xa0)
#define OMAP2_DMA_CCEN_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xbc)
#define OMAP2_DMA_CCFN_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xc0)
#define OMAP2_DMA_COLOR_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0xc4)
#define OMAP_DMA_NO_DEVICE 0
#define OMAP_DMA_MCSI1_TX 1
#define OMAP_DMA_MCSI1_RX 2
#define OMAP_DMA_I2C_RX 3
#define OMAP_DMA_I2C_TX 4
#define OMAP_DMA_EXT_NDMA_REQ 5
#define OMAP_DMA_EXT_NDMA_REQ2 6
#define OMAP_DMA_UWIRE_TX 7
#define OMAP_DMA_MCBSP1_TX 8
#define OMAP_DMA_MCBSP1_RX 9
#define OMAP_DMA_MCBSP3_TX 10
#define OMAP_DMA_MCBSP3_RX 11
#define OMAP_DMA_UART1_TX 12
#define OMAP_DMA_UART1_RX 13
#define OMAP_DMA_UART2_TX 14
#define OMAP_DMA_UART2_RX 15
#define OMAP_DMA_MCBSP2_TX 16
#define OMAP_DMA_MCBSP2_RX 17
#define OMAP_DMA_UART3_TX 18
#define OMAP_DMA_UART3_RX 19
#define OMAP_DMA_CAMERA_IF_RX 20
#define OMAP_DMA_MMC_TX 21
#define OMAP_DMA_MMC_RX 22
#define OMAP_DMA_NAND 23
#define OMAP_DMA_IRQ_LCD_LINE 24
#define OMAP_DMA_MEMORY_STICK 25
#define OMAP_DMA_USB_W2FC_RX0 26
#define OMAP_DMA_USB_W2FC_RX1 27
#define OMAP_DMA_USB_W2FC_RX2 28
#define OMAP_DMA_USB_W2FC_TX0 29
#define OMAP_DMA_USB_W2FC_TX1 30
#define OMAP_DMA_USB_W2FC_TX2 31
#define OMAP_DMA_CRYPTO_DES_IN 32
#define OMAP_DMA_SPI_TX 33
#define OMAP_DMA_SPI_RX 34
#define OMAP_DMA_CRYPTO_HASH 35
#define OMAP_DMA_CCP_ATTN 36
#define OMAP_DMA_CCP_FIFO_NOT_EMPTY 37
#define OMAP_DMA_CMT_APE_TX_CHAN_0 38
#define OMAP_DMA_CMT_APE_RV_CHAN_0 39
#define OMAP_DMA_CMT_APE_TX_CHAN_1 40
#define OMAP_DMA_CMT_APE_RV_CHAN_1 41
#define OMAP_DMA_CMT_APE_TX_CHAN_2 42
#define OMAP_DMA_CMT_APE_RV_CHAN_2 43
#define OMAP_DMA_CMT_APE_TX_CHAN_3 44
#define OMAP_DMA_CMT_APE_RV_CHAN_3 45
#define OMAP_DMA_CMT_APE_TX_CHAN_4 46
#define OMAP_DMA_CMT_APE_RV_CHAN_4 47
#define OMAP_DMA_CMT_APE_TX_CHAN_5 48
#define OMAP_DMA_CMT_APE_RV_CHAN_5 49
#define OMAP_DMA_CMT_APE_TX_CHAN_6 50
#define OMAP_DMA_CMT_APE_RV_CHAN_6 51
#define OMAP_DMA_CMT_APE_TX_CHAN_7 52
#define OMAP_DMA_CMT_APE_RV_CHAN_7 53
#define OMAP_DMA_MMC2_TX 54
#define OMAP_DMA_MMC2_RX 55
#define OMAP_DMA_CRYPTO_DES_OUT 56
#define OMAP24XX_DMA_NO_DEVICE 0
#define OMAP24XX_DMA_XTI_DMA 1
#define OMAP24XX_DMA_EXT_DMAREQ0 2
#define OMAP24XX_DMA_EXT_DMAREQ1 3
#define OMAP24XX_DMA_GPMC 4
#define OMAP24XX_DMA_GFX 5
#define OMAP24XX_DMA_DSS 6
#define OMAP24XX_DMA_VLYNQ_TX 7
#define OMAP24XX_DMA_CWT 8
#define OMAP24XX_DMA_AES_TX 9
#define OMAP24XX_DMA_AES_RX 10
#define OMAP24XX_DMA_DES_TX 11
#define OMAP24XX_DMA_DES_RX 12
#define OMAP24XX_DMA_SHA1MD5_RX 13
#define OMAP24XX_DMA_EXT_DMAREQ2 14
#define OMAP24XX_DMA_EXT_DMAREQ3 15
#define OMAP24XX_DMA_EXT_DMAREQ4 16
#define OMAP24XX_DMA_EAC_AC_RD 17
#define OMAP24XX_DMA_EAC_AC_WR 18
#define OMAP24XX_DMA_EAC_MD_UL_RD 19
#define OMAP24XX_DMA_EAC_MD_UL_WR 20
#define OMAP24XX_DMA_EAC_MD_DL_RD 21
#define OMAP24XX_DMA_EAC_MD_DL_WR 22
#define OMAP24XX_DMA_EAC_BT_UL_RD 23
#define OMAP24XX_DMA_EAC_BT_UL_WR 24
#define OMAP24XX_DMA_EAC_BT_DL_RD 25
#define OMAP24XX_DMA_EAC_BT_DL_WR 26
#define OMAP24XX_DMA_I2C1_TX 27
#define OMAP24XX_DMA_I2C1_RX 28
#define OMAP24XX_DMA_I2C2_TX 29
#define OMAP24XX_DMA_I2C2_RX 30
#define OMAP24XX_DMA_MCBSP1_TX 31
#define OMAP24XX_DMA_MCBSP1_RX 32
#define OMAP24XX_DMA_MCBSP2_TX 33
#define OMAP24XX_DMA_MCBSP2_RX 34
#define OMAP24XX_DMA_SPI1_TX0 35
#define OMAP24XX_DMA_SPI1_RX0 36
#define OMAP24XX_DMA_SPI1_TX1 37
#define OMAP24XX_DMA_SPI1_RX1 38
#define OMAP24XX_DMA_SPI1_TX2 39
#define OMAP24XX_DMA_SPI1_RX2 40
#define OMAP24XX_DMA_SPI1_TX3 41
#define OMAP24XX_DMA_SPI1_RX3 42
#define OMAP24XX_DMA_SPI2_TX0 43
#define OMAP24XX_DMA_SPI2_RX0 44
#define OMAP24XX_DMA_SPI2_TX1 45
#define OMAP24XX_DMA_SPI2_RX1 46
#define OMAP24XX_DMA_UART1_TX 49
#define OMAP24XX_DMA_UART1_RX 50
#define OMAP24XX_DMA_UART2_TX 51
#define OMAP24XX_DMA_UART2_RX 52
#define OMAP24XX_DMA_UART3_TX 53
#define OMAP24XX_DMA_UART3_RX 54
#define OMAP24XX_DMA_USB_W2FC_TX0 55
#define OMAP24XX_DMA_USB_W2FC_RX0 56
#define OMAP24XX_DMA_USB_W2FC_TX1 57
#define OMAP24XX_DMA_USB_W2FC_RX1 58
#define OMAP24XX_DMA_USB_W2FC_TX2 59
#define OMAP24XX_DMA_USB_W2FC_RX2 60
#define OMAP24XX_DMA_MMC1_TX 61
#define OMAP24XX_DMA_MMC1_RX 62
#define OMAP24XX_DMA_MS 63
#define OMAP24XX_DMA_EXT_DMAREQ5 64
#define OMAP1510_DMA_LCD_BASE (0xfffedb00)
#define OMAP1510_DMA_LCD_CTRL (OMAP1510_DMA_LCD_BASE + 0x00)
#define OMAP1510_DMA_LCD_TOP_F1_L (OMAP1510_DMA_LCD_BASE + 0x02)
#define OMAP1510_DMA_LCD_TOP_F1_U (OMAP1510_DMA_LCD_BASE + 0x04)
#define OMAP1510_DMA_LCD_BOT_F1_L (OMAP1510_DMA_LCD_BASE + 0x06)
#define OMAP1510_DMA_LCD_BOT_F1_U (OMAP1510_DMA_LCD_BASE + 0x08)
#define OMAP1610_DMA_LCD_BASE (0xfffee300)
#define OMAP1610_DMA_LCD_CSDP (OMAP1610_DMA_LCD_BASE + 0xc0)
#define OMAP1610_DMA_LCD_CCR (OMAP1610_DMA_LCD_BASE + 0xc2)
#define OMAP1610_DMA_LCD_CTRL (OMAP1610_DMA_LCD_BASE + 0xc4)
#define OMAP1610_DMA_LCD_TOP_B1_L (OMAP1610_DMA_LCD_BASE + 0xc8)
#define OMAP1610_DMA_LCD_TOP_B1_U (OMAP1610_DMA_LCD_BASE + 0xca)
#define OMAP1610_DMA_LCD_BOT_B1_L (OMAP1610_DMA_LCD_BASE + 0xcc)
#define OMAP1610_DMA_LCD_BOT_B1_U (OMAP1610_DMA_LCD_BASE + 0xce)
#define OMAP1610_DMA_LCD_TOP_B2_L (OMAP1610_DMA_LCD_BASE + 0xd0)
#define OMAP1610_DMA_LCD_TOP_B2_U (OMAP1610_DMA_LCD_BASE + 0xd2)
#define OMAP1610_DMA_LCD_BOT_B2_L (OMAP1610_DMA_LCD_BASE + 0xd4)
#define OMAP1610_DMA_LCD_BOT_B2_U (OMAP1610_DMA_LCD_BASE + 0xd6)
#define OMAP1610_DMA_LCD_SRC_EI_B1 (OMAP1610_DMA_LCD_BASE + 0xd8)
#define OMAP1610_DMA_LCD_SRC_FI_B1_L (OMAP1610_DMA_LCD_BASE + 0xda)
#define OMAP1610_DMA_LCD_SRC_EN_B1 (OMAP1610_DMA_LCD_BASE + 0xe0)
#define OMAP1610_DMA_LCD_SRC_FN_B1 (OMAP1610_DMA_LCD_BASE + 0xe4)
#define OMAP1610_DMA_LCD_LCH_CTRL (OMAP1610_DMA_LCD_BASE + 0xea)
#define OMAP1610_DMA_LCD_SRC_FI_B1_U (OMAP1610_DMA_LCD_BASE + 0xf4)
#define OMAP1_DMA_TOUT_IRQ (1 << 0)
#define OMAP_DMA_DROP_IRQ (1 << 1)
#define OMAP_DMA_HALF_IRQ (1 << 2)
#define OMAP_DMA_FRAME_IRQ (1 << 3)
#define OMAP_DMA_LAST_IRQ (1 << 4)
#define OMAP_DMA_BLOCK_IRQ (1 << 5)
#define OMAP1_DMA_SYNC_IRQ (1 << 6)
#define OMAP2_DMA_PKT_IRQ (1 << 7)
#define OMAP2_DMA_TRANS_ERR_IRQ (1 << 8)
#define OMAP2_DMA_SECURE_ERR_IRQ (1 << 9)
#define OMAP2_DMA_SUPERVISOR_ERR_IRQ (1 << 10)
#define OMAP2_DMA_MISALIGNED_ERR_IRQ (1 << 11)
#define OMAP_DMA_DATA_TYPE_S8 0x00
#define OMAP_DMA_DATA_TYPE_S16 0x01
#define OMAP_DMA_DATA_TYPE_S32 0x02
#define OMAP_DMA_SYNC_ELEMENT 0x00
#define OMAP_DMA_SYNC_FRAME 0x01
#define OMAP_DMA_SYNC_BLOCK 0x02
#define OMAP_DMA_PORT_EMIFF 0x00
#define OMAP_DMA_PORT_EMIFS 0x01
#define OMAP_DMA_PORT_OCP_T1 0x02
#define OMAP_DMA_PORT_TIPB 0x03
#define OMAP_DMA_PORT_OCP_T2 0x04
#define OMAP_DMA_PORT_MPUI 0x05
#define OMAP_DMA_AMODE_CONSTANT 0x00
#define OMAP_DMA_AMODE_POST_INC 0x01
#define OMAP_DMA_AMODE_SINGLE_IDX 0x02
#define OMAP_DMA_AMODE_DOUBLE_IDX 0x03
enum {
OMAP_LCD_DMA_B1_TOP,
OMAP_LCD_DMA_B1_BOTTOM,
OMAP_LCD_DMA_B2_TOP,
OMAP_LCD_DMA_B2_BOTTOM
};
enum omap_dma_burst_mode {
OMAP_DMA_DATA_BURST_DIS = 0,
OMAP_DMA_DATA_BURST_4,
OMAP_DMA_DATA_BURST_8,
OMAP_DMA_DATA_BURST_16,
};
enum omap_dma_color_mode {
OMAP_DMA_COLOR_DIS = 0,
OMAP_DMA_CONSTANT_FILL,
OMAP_DMA_TRANSPARENT_COPY
};
enum omap_dma_write_mode {
OMAP_DMA_WRITE_NON_POSTED = 0,
OMAP_DMA_WRITE_POSTED,
OMAP_DMA_WRITE_LAST_NON_POSTED
};
struct omap_dma_channel_params {
int data_type;
int elem_count;
int frame_count;
int src_port;
int src_amode;
unsigned long src_start;
int src_ei;
int src_fi;
int dst_port;
int dst_amode;
unsigned long dst_start;
int dst_ei;
int dst_fi;
int trigger;
int sync_mode;
int src_or_dst_synch;
int ie;
};
#endif

View File

@@ -0,0 +1,160 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARCH_OMAP_FPGA_H
#define __ASM_ARCH_OMAP_FPGA_H
#define omap1510_fpga_init_irq() (0)
#define fpga_read(reg) __raw_readb(reg)
#define fpga_write(val, reg) __raw_writeb(val, reg)
#define H2P2_DBG_FPGA_BASE 0xE8000000
#define H2P2_DBG_FPGA_SIZE SZ_4K
#define H2P2_DBG_FPGA_START 0x04000000
#define H2P2_DBG_FPGA_ETHR_START (H2P2_DBG_FPGA_START + 0x300)
#define H2P2_DBG_FPGA_FPGA_REV (H2P2_DBG_FPGA_BASE + 0x10)
#define H2P2_DBG_FPGA_BOARD_REV (H2P2_DBG_FPGA_BASE + 0x12)
#define H2P2_DBG_FPGA_GPIO (H2P2_DBG_FPGA_BASE + 0x14)
#define H2P2_DBG_FPGA_LEDS (H2P2_DBG_FPGA_BASE + 0x16)
#define H2P2_DBG_FPGA_MISC_INPUTS (H2P2_DBG_FPGA_BASE + 0x18)
#define H2P2_DBG_FPGA_LAN_STATUS (H2P2_DBG_FPGA_BASE + 0x1A)
#define H2P2_DBG_FPGA_LAN_RESET (H2P2_DBG_FPGA_BASE + 0x1C)
struct h2p2_dbg_fpga {
u16 smc91x[8];
u16 fpga_rev;
u16 board_rev;
u16 gpio_outputs;
u16 leds;
u16 misc_inputs;
u16 lan_status;
u16 lan_reset;
u16 reserved0;
u16 ps2_data;
u16 ps2_ctrl;
};
#define H2P2_DBG_FPGA_LED_GREEN (1 << 15)
#define H2P2_DBG_FPGA_LED_AMBER (1 << 14)
#define H2P2_DBG_FPGA_LED_RED (1 << 13)
#define H2P2_DBG_FPGA_LED_BLUE (1 << 12)
#define H2P2_DBG_FPGA_LOAD_METER (1 << 0)
#define H2P2_DBG_FPGA_LOAD_METER_SIZE 11
#define H2P2_DBG_FPGA_LOAD_METER_MASK ((1 << H2P2_DBG_FPGA_LOAD_METER_SIZE) - 1)
#define H2P2_DBG_FPGA_P2_LED_TIMER (1 << 0)
#define H2P2_DBG_FPGA_P2_LED_IDLE (1 << 1)
#define OMAP1510_FPGA_BASE 0xE8000000
#define OMAP1510_FPGA_SIZE SZ_4K
#define OMAP1510_FPGA_START 0x08000000
#define OMAP1510_FPGA_REV_LOW (OMAP1510_FPGA_BASE + 0x0)
#define OMAP1510_FPGA_REV_HIGH (OMAP1510_FPGA_BASE + 0x1)
#define OMAP1510_FPGA_LCD_PANEL_CONTROL (OMAP1510_FPGA_BASE + 0x2)
#define OMAP1510_FPGA_LED_DIGIT (OMAP1510_FPGA_BASE + 0x3)
#define INNOVATOR_FPGA_HID_SPI (OMAP1510_FPGA_BASE + 0x4)
#define OMAP1510_FPGA_POWER (OMAP1510_FPGA_BASE + 0x5)
#define OMAP1510_FPGA_ISR_LO (OMAP1510_FPGA_BASE + 0x6)
#define OMAP1510_FPGA_ISR_HI (OMAP1510_FPGA_BASE + 0x7)
#define OMAP1510_FPGA_IMR_LO (OMAP1510_FPGA_BASE + 0x8)
#define OMAP1510_FPGA_IMR_HI (OMAP1510_FPGA_BASE + 0x9)
#define OMAP1510_FPGA_HOST_RESET (OMAP1510_FPGA_BASE + 0xa)
#define OMAP1510_FPGA_RST (OMAP1510_FPGA_BASE + 0xb)
#define OMAP1510_FPGA_AUDIO (OMAP1510_FPGA_BASE + 0xc)
#define OMAP1510_FPGA_DIP (OMAP1510_FPGA_BASE + 0xe)
#define OMAP1510_FPGA_FPGA_IO (OMAP1510_FPGA_BASE + 0xf)
#define OMAP1510_FPGA_UART1 (OMAP1510_FPGA_BASE + 0x14)
#define OMAP1510_FPGA_UART2 (OMAP1510_FPGA_BASE + 0x15)
#define OMAP1510_FPGA_OMAP1510_STATUS (OMAP1510_FPGA_BASE + 0x16)
#define OMAP1510_FPGA_BOARD_REV (OMAP1510_FPGA_BASE + 0x18)
#define OMAP1510P1_PPT_DATA (OMAP1510_FPGA_BASE + 0x100)
#define OMAP1510P1_PPT_STATUS (OMAP1510_FPGA_BASE + 0x101)
#define OMAP1510P1_PPT_CONTROL (OMAP1510_FPGA_BASE + 0x102)
#define OMAP1510_FPGA_TOUCHSCREEN (OMAP1510_FPGA_BASE + 0x204)
#define INNOVATOR_FPGA_INFO (OMAP1510_FPGA_BASE + 0x205)
#define INNOVATOR_FPGA_LCD_BRIGHT_LO (OMAP1510_FPGA_BASE + 0x206)
#define INNOVATOR_FPGA_LCD_BRIGHT_HI (OMAP1510_FPGA_BASE + 0x207)
#define INNOVATOR_FPGA_LED_GRN_LO (OMAP1510_FPGA_BASE + 0x208)
#define INNOVATOR_FPGA_LED_GRN_HI (OMAP1510_FPGA_BASE + 0x209)
#define INNOVATOR_FPGA_LED_RED_LO (OMAP1510_FPGA_BASE + 0x20a)
#define INNOVATOR_FPGA_LED_RED_HI (OMAP1510_FPGA_BASE + 0x20b)
#define INNOVATOR_FPGA_CAM_USB_CONTROL (OMAP1510_FPGA_BASE + 0x20c)
#define INNOVATOR_FPGA_EXP_CONTROL (OMAP1510_FPGA_BASE + 0x20d)
#define INNOVATOR_FPGA_ISR2 (OMAP1510_FPGA_BASE + 0x20e)
#define INNOVATOR_FPGA_IMR2 (OMAP1510_FPGA_BASE + 0x210)
#define OMAP1510_FPGA_ETHR_START (OMAP1510_FPGA_START + 0x300)
#define OMAP1510_FPGA_RESET_VALUE 0x42
#define OMAP1510_FPGA_PCR_IF_PD0 (1 << 7)
#define OMAP1510_FPGA_PCR_COM2_EN (1 << 6)
#define OMAP1510_FPGA_PCR_COM1_EN (1 << 5)
#define OMAP1510_FPGA_PCR_EXP_PD0 (1 << 4)
#define OMAP1510_FPGA_PCR_EXP_PD1 (1 << 3)
#define OMAP1510_FPGA_PCR_48MHZ_CLK (1 << 2)
#define OMAP1510_FPGA_PCR_4MHZ_CLK (1 << 1)
#define OMAP1510_FPGA_PCR_RSRVD_BIT0 (1 << 0)
#define OMAP1510_FPGA_HID_SCLK (1<<0)
#define OMAP1510_FPGA_HID_MOSI (1<<1)
#define OMAP1510_FPGA_HID_nSS (1<<2)
#define OMAP1510_FPGA_HID_nHSUS (1<<3)
#define OMAP1510_FPGA_HID_MISO (1<<4)
#define OMAP1510_FPGA_HID_ATN (1<<5)
#define OMAP1510_FPGA_HID_rsrvd (1<<6)
#define OMAP1510_FPGA_HID_RESETn (1<<7)
#define OMAP1510_INT_FPGA (IH_GPIO_BASE + 13)
#define OMAP1510_IH_FPGA_BASE IH_BOARD_BASE
#define OMAP1510_INT_FPGA_ATN (OMAP1510_IH_FPGA_BASE + 0)
#define OMAP1510_INT_FPGA_ACK (OMAP1510_IH_FPGA_BASE + 1)
#define OMAP1510_INT_FPGA2 (OMAP1510_IH_FPGA_BASE + 2)
#define OMAP1510_INT_FPGA3 (OMAP1510_IH_FPGA_BASE + 3)
#define OMAP1510_INT_FPGA4 (OMAP1510_IH_FPGA_BASE + 4)
#define OMAP1510_INT_FPGA5 (OMAP1510_IH_FPGA_BASE + 5)
#define OMAP1510_INT_FPGA6 (OMAP1510_IH_FPGA_BASE + 6)
#define OMAP1510_INT_FPGA7 (OMAP1510_IH_FPGA_BASE + 7)
#define OMAP1510_INT_FPGA8 (OMAP1510_IH_FPGA_BASE + 8)
#define OMAP1510_INT_FPGA9 (OMAP1510_IH_FPGA_BASE + 9)
#define OMAP1510_INT_FPGA10 (OMAP1510_IH_FPGA_BASE + 10)
#define OMAP1510_INT_FPGA11 (OMAP1510_IH_FPGA_BASE + 11)
#define OMAP1510_INT_FPGA12 (OMAP1510_IH_FPGA_BASE + 12)
#define OMAP1510_INT_ETHER (OMAP1510_IH_FPGA_BASE + 13)
#define OMAP1510_INT_FPGAUART1 (OMAP1510_IH_FPGA_BASE + 14)
#define OMAP1510_INT_FPGAUART2 (OMAP1510_IH_FPGA_BASE + 15)
#define OMAP1510_INT_FPGA_TS (OMAP1510_IH_FPGA_BASE + 16)
#define OMAP1510_INT_FPGA17 (OMAP1510_IH_FPGA_BASE + 17)
#define OMAP1510_INT_FPGA_CAM (OMAP1510_IH_FPGA_BASE + 18)
#define OMAP1510_INT_FPGA_RTC_A (OMAP1510_IH_FPGA_BASE + 19)
#define OMAP1510_INT_FPGA_RTC_B (OMAP1510_IH_FPGA_BASE + 20)
#define OMAP1510_INT_FPGA_CD (OMAP1510_IH_FPGA_BASE + 21)
#define OMAP1510_INT_FPGA22 (OMAP1510_IH_FPGA_BASE + 22)
#define OMAP1510_INT_FPGA23 (OMAP1510_IH_FPGA_BASE + 23)
#endif

View File

@@ -0,0 +1,37 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARCH_OMAP_GPIO_SWITCH_H
#define __ASM_ARCH_OMAP_GPIO_SWITCH_H
#include <linux/types.h>
#define OMAP_GPIO_SWITCH_TYPE_COVER 0x0000
#define OMAP_GPIO_SWITCH_TYPE_CONNECTION 0x0001
#define OMAP_GPIO_SWITCH_TYPE_ACTIVITY 0x0002
#define OMAP_GPIO_SWITCH_FLAG_INVERTED 0x0001
#define OMAP_GPIO_SWITCH_FLAG_OUTPUT 0x0002
struct omap_gpio_switch {
const char *name;
s16 gpio;
unsigned flags:4;
unsigned type:4;
u16 debounce_rising;
u16 debounce_falling;
void (* notify)(void *data, int state);
void *notify_data;
};
#endif

View File

@@ -0,0 +1,49 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARCH_OMAP_GPIO_H
#define __ASM_ARCH_OMAP_GPIO_H
#include <asm/hardware.h>
#include <asm/arch/irqs.h>
#include <asm/io.h>
#define OMAP_MPUIO_BASE (void __iomem *)0xfffb5000
#define OMAP_MPUIO_INPUT_LATCH 0x00
#define OMAP_MPUIO_OUTPUT 0x04
#define OMAP_MPUIO_IO_CNTL 0x08
#define OMAP_MPUIO_KBR_LATCH 0x10
#define OMAP_MPUIO_KBC 0x14
#define OMAP_MPUIO_GPIO_EVENT_MODE 0x18
#define OMAP_MPUIO_GPIO_INT_EDGE 0x1c
#define OMAP_MPUIO_KBD_INT 0x20
#define OMAP_MPUIO_GPIO_INT 0x24
#define OMAP_MPUIO_KBD_MASKIT 0x28
#define OMAP_MPUIO_GPIO_MASKIT 0x2c
#define OMAP_MPUIO_GPIO_DEBOUNCING 0x30
#define OMAP_MPUIO_LATCH 0x34
#define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr))
#define OMAP_GPIO_IS_MPUIO(nr) ((nr) >= OMAP_MAX_GPIO_LINES)
#define OMAP_GPIO_IRQ(nr) (OMAP_GPIO_IS_MPUIO(nr) ? IH_MPUIO_BASE + ((nr) & 0x0f) : IH_GPIO_BASE + (nr))
struct omap_machine_gpio_bank {
int start;
int end;
void (*set_gpio_direction)(int gpio, int is_input);
void (*set_gpio_dataout)(int gpio, int enable);
int (*get_gpio_datain)(int gpio);
};
#endif

View File

@@ -0,0 +1,157 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARCH_OMAP_HARDWARE_H
#define __ASM_ARCH_OMAP_HARDWARE_H
#include <asm/sizes.h>
#ifndef __ASSEMBLER__
#include <asm/types.h>
#include <asm/arch/cpu.h>
#endif
#include <asm/arch/io.h>
#include <asm/arch/serial.h>
#define OMAP_MPU_TIMER1_BASE (0xfffec500)
#define OMAP_MPU_TIMER2_BASE (0xfffec600)
#define OMAP_MPU_TIMER3_BASE (0xfffec700)
#define MPU_TIMER_FREE (1 << 6)
#define MPU_TIMER_CLOCK_ENABLE (1 << 5)
#define MPU_TIMER_AR (1 << 1)
#define MPU_TIMER_ST (1 << 0)
#define CLKGEN_REG_BASE (0xfffece00)
#define ARM_CKCTL (CLKGEN_REG_BASE + 0x0)
#define ARM_IDLECT1 (CLKGEN_REG_BASE + 0x4)
#define ARM_IDLECT2 (CLKGEN_REG_BASE + 0x8)
#define ARM_EWUPCT (CLKGEN_REG_BASE + 0xC)
#define ARM_RSTCT1 (CLKGEN_REG_BASE + 0x10)
#define ARM_RSTCT2 (CLKGEN_REG_BASE + 0x14)
#define ARM_SYSST (CLKGEN_REG_BASE + 0x18)
#define ARM_IDLECT3 (CLKGEN_REG_BASE + 0x24)
#define CK_RATEF 1
#define CK_IDLEF 2
#define CK_ENABLEF 4
#define CK_SELECTF 8
#define SETARM_IDLE_SHIFT
#define DPLL_CTL (0xfffecf00)
#define DSP_CONFIG_REG_BASE (0xe1008000)
#define DSP_CKCTL (DSP_CONFIG_REG_BASE + 0x0)
#define DSP_IDLECT1 (DSP_CONFIG_REG_BASE + 0x4)
#define DSP_IDLECT2 (DSP_CONFIG_REG_BASE + 0x8)
#define DSP_RSTCT2 (DSP_CONFIG_REG_BASE + 0x14)
#define ULPD_REG_BASE (0xfffe0800)
#define ULPD_IT_STATUS (ULPD_REG_BASE + 0x14)
#define ULPD_SETUP_ANALOG_CELL_3 (ULPD_REG_BASE + 0x24)
#define ULPD_CLOCK_CTRL (ULPD_REG_BASE + 0x30)
#define DIS_USB_PVCI_CLK (1 << 5)
#define USB_MCLK_EN (1 << 4)
#define ULPD_SOFT_REQ (ULPD_REG_BASE + 0x34)
#define SOFT_UDC_REQ (1 << 4)
#define SOFT_USB_CLK_REQ (1 << 3)
#define SOFT_DPLL_REQ (1 << 0)
#define ULPD_DPLL_CTRL (ULPD_REG_BASE + 0x3c)
#define ULPD_STATUS_REQ (ULPD_REG_BASE + 0x40)
#define ULPD_APLL_CTRL (ULPD_REG_BASE + 0x4c)
#define ULPD_POWER_CTRL (ULPD_REG_BASE + 0x50)
#define ULPD_SOFT_DISABLE_REQ_REG (ULPD_REG_BASE + 0x68)
#define DIS_MMC2_DPLL_REQ (1 << 11)
#define DIS_MMC1_DPLL_REQ (1 << 10)
#define DIS_UART3_DPLL_REQ (1 << 9)
#define DIS_UART2_DPLL_REQ (1 << 8)
#define DIS_UART1_DPLL_REQ (1 << 7)
#define DIS_USB_HOST_DPLL_REQ (1 << 6)
#define ULPD_SDW_CLK_DIV_CTRL_SEL (ULPD_REG_BASE + 0x74)
#define ULPD_CAM_CLK_CTRL (ULPD_REG_BASE + 0x7c)
#define OMAP_MPU_WATCHDOG_BASE (0xfffec800)
#define OMAP_WDT_TIMER (OMAP_MPU_WATCHDOG_BASE + 0x0)
#define OMAP_WDT_LOAD_TIM (OMAP_MPU_WATCHDOG_BASE + 0x4)
#define OMAP_WDT_READ_TIM (OMAP_MPU_WATCHDOG_BASE + 0x4)
#define OMAP_WDT_TIMER_MODE (OMAP_MPU_WATCHDOG_BASE + 0x8)
#define MOD_CONF_CTRL_0 0xfffe1080
#define MOD_CONF_CTRL_1 0xfffe1110
#define FUNC_MUX_CTRL_0 0xfffe1000
#define FUNC_MUX_CTRL_1 0xfffe1004
#define FUNC_MUX_CTRL_2 0xfffe1008
#define COMP_MODE_CTRL_0 0xfffe100c
#define FUNC_MUX_CTRL_3 0xfffe1010
#define FUNC_MUX_CTRL_4 0xfffe1014
#define FUNC_MUX_CTRL_5 0xfffe1018
#define FUNC_MUX_CTRL_6 0xfffe101C
#define FUNC_MUX_CTRL_7 0xfffe1020
#define FUNC_MUX_CTRL_8 0xfffe1024
#define FUNC_MUX_CTRL_9 0xfffe1028
#define FUNC_MUX_CTRL_A 0xfffe102C
#define FUNC_MUX_CTRL_B 0xfffe1030
#define FUNC_MUX_CTRL_C 0xfffe1034
#define FUNC_MUX_CTRL_D 0xfffe1038
#define PULL_DWN_CTRL_0 0xfffe1040
#define PULL_DWN_CTRL_1 0xfffe1044
#define PULL_DWN_CTRL_2 0xfffe1048
#define PULL_DWN_CTRL_3 0xfffe104c
#define PULL_DWN_CTRL_4 0xfffe10ac
#define FUNC_MUX_CTRL_E 0xfffe1090
#define FUNC_MUX_CTRL_F 0xfffe1094
#define FUNC_MUX_CTRL_10 0xfffe1098
#define FUNC_MUX_CTRL_11 0xfffe109c
#define FUNC_MUX_CTRL_12 0xfffe10a0
#define PU_PD_SEL_0 0xfffe10b4
#define PU_PD_SEL_1 0xfffe10b8
#define PU_PD_SEL_2 0xfffe10bc
#define PU_PD_SEL_3 0xfffe10c0
#define PU_PD_SEL_4 0xfffe10c4
#define OMAP_TIMER32K_BASE 0xFFFBC400
#define TIPB_PUBLIC_CNTL_BASE 0xfffed300
#define MPU_PUBLIC_TIPB_CNTL (TIPB_PUBLIC_CNTL_BASE + 0x8)
#define TIPB_PRIVATE_CNTL_BASE 0xfffeca00
#define MPU_PRIVATE_TIPB_CNTL (TIPB_PRIVATE_CNTL_BASE + 0x8)
#define MPUI_BASE (0xfffec900)
#define MPUI_CTRL (MPUI_BASE + 0x0)
#define MPUI_DEBUG_ADDR (MPUI_BASE + 0x4)
#define MPUI_DEBUG_DATA (MPUI_BASE + 0x8)
#define MPUI_DEBUG_FLAG (MPUI_BASE + 0xc)
#define MPUI_STATUS_REG (MPUI_BASE + 0x10)
#define MPUI_DSP_STATUS (MPUI_BASE + 0x14)
#define MPUI_DSP_BOOT_CONFIG (MPUI_BASE + 0x18)
#define MPUI_DSP_API_CONFIG (MPUI_BASE + 0x1c)
#define OMAP_LPG1_BASE 0xfffbd000
#define OMAP_LPG2_BASE 0xfffbd800
#define OMAP_LPG1_LCR (OMAP_LPG1_BASE + 0x00)
#define OMAP_LPG1_PMR (OMAP_LPG1_BASE + 0x04)
#define OMAP_LPG2_LCR (OMAP_LPG2_BASE + 0x00)
#define OMAP_LPG2_PMR (OMAP_LPG2_BASE + 0x04)
#define OMAP_PWL_BASE 0xfffb5800
#define OMAP_PWL_ENABLE (OMAP_PWL_BASE + 0x00)
#define OMAP_PWL_CLK_ENABLE (OMAP_PWL_BASE + 0x04)
#include "omap730.h"
#include "omap1510.h"
#include "omap24xx.h"
#include "omap16xx.h"
#ifndef __ASSEMBLER__
#endif
#endif

View File

@@ -0,0 +1,54 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARM_ARCH_IO_H
#define __ASM_ARM_ARCH_IO_H
#include <asm/hardware.h>
#define IO_SPACE_LIMIT 0xffffffff
#define __io(a) ((void __iomem *)(PCIO_BASE + (a)))
#define __mem_pci(a) (a)
#define PCIO_BASE 0
#ifndef __ASSEMBLER__
#define omap_readb(a) (*(volatile unsigned char *)IO_ADDRESS(a))
#define omap_readw(a) (*(volatile unsigned short *)IO_ADDRESS(a))
#define omap_readl(a) (*(volatile unsigned int *)IO_ADDRESS(a))
#define omap_writeb(v,a) (*(volatile unsigned char *)IO_ADDRESS(a) = (v))
#define omap_writew(v,a) (*(volatile unsigned short *)IO_ADDRESS(a) = (v))
#define omap_writel(v,a) (*(volatile unsigned int *)IO_ADDRESS(a) = (v))
typedef struct { volatile u16 offset[256]; } __regbase16;
#define __REGV16(vaddr) ((__regbase16 *)((vaddr)&~0xff)) ->offset[((vaddr)&0xff)>>1]
#define __REG16(paddr) __REGV16(io_p2v(paddr))
typedef struct { volatile u8 offset[4096]; } __regbase8;
#define __REGV8(vaddr) ((__regbase8 *)((vaddr)&~4095)) ->offset[((vaddr)&4095)>>0]
#define __REG8(paddr) __REGV8(io_p2v(paddr))
typedef struct { volatile u32 offset[4096]; } __regbase32;
#define __REGV32(vaddr) ((__regbase32 *)((vaddr)&~4095)) ->offset[((vaddr)&4095)>>2]
#define __REG32(paddr) __REGV32(io_p2v(paddr))
#else
#define __REG8(paddr) io_p2v(paddr)
#define __REG16(paddr) io_p2v(paddr)
#define __REG32(paddr) io_p2v(paddr)
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More