OSDN Git Service

Make mksh's mkmf.sh target-agnostic.
authorElliott Hughes <enh@google.com>
Tue, 12 Aug 2014 22:39:09 +0000 (15:39 -0700)
committerElliott Hughes <enh@google.com>
Mon, 6 Oct 2014 20:55:38 +0000 (13:55 -0700)
This isn't much, but it's a step in the right direction. Really we should
probably generate a trivial Android.mk for building the .c files used by
the mksh equivalent of a configure script.

Bug: 17814343

(cherry picked from commit 0e7ec748185584bdc70285c9001d1c992b649127)

Change-Id: Ibce6616acfe560c4dfec1e27c51d45b9dce8456e

Makefrag.inc
mkmf.sh

index 403281f..4866e94 100644 (file)
@@ -8,11 +8,11 @@ OBJS_BP=       lalloc.o eval.o exec.o expr.o funcs.o histrap.o jobs.o lex.o main.o mi
 INDSRCS=       emacsfn.h rlimits.opt sh.h sh_flags.opt var_spec.h
 NONSRCS_INST=  dot.mkshrc $(MAN)
 NONSRCS_NOINST=        Build.sh Makefile Rebuild.sh check.pl check.t test.sh
-CC=            /huge-ssd/lmp-dev/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-gcc
-CFLAGS=                 -fno-exceptions -Wno-multichar -msoft-float -fpic -fPIE -ffunction-sections -fdata-sections -funwind-tables -fstack-protector -Wa,--noexecstack -Werror=format-security -fno-short-enums -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -Wno-unused-but-set-variable -fno-builtin-sin -fno-strict-volatile-bitfields -Wno-psabi -mthumb-interwork -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -g -Wstrict-aliasing=2 -fgcse-after-reload -frerun-cse-after-loop -frename-registers -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fwrapv
-CPPFLAGS=      -I. -I'../src'  -I/huge-ssd/lmp-dev/libnativehelper/include/nativehelper -isystem /huge-ssd/lmp-dev/system/core/include -isystem /huge-ssd/lmp-dev/hardware/libhardware/include -isystem /huge-ssd/lmp-dev/hardware/libhardware_legacy/include -isystem /huge-ssd/lmp-dev/hardware/ril/include -isystem /huge-ssd/lmp-dev/libnativehelper/include -isystem /huge-ssd/lmp-dev/frameworks/native/include -isystem /huge-ssd/lmp-dev/frameworks/native/opengl/include -isystem /huge-ssd/lmp-dev/frameworks/av/include -isystem /huge-ssd/lmp-dev/frameworks/base/include -isystem /huge-ssd/lmp-dev/external/skia/include -isystem /huge-ssd/lmp-dev/out/target/product/hammerhead/obj/include -isystem /huge-ssd/lmp-dev/bionic/libc/arch-arm/include -isystem /huge-ssd/lmp-dev/bionic/libc/include -isystem /huge-ssd/lmp-dev/bionic/libstdc++/include -isystem /huge-ssd/lmp-dev/bionic/libc/kernel/uapi -isystem /huge-ssd/lmp-dev/bionic/libc/kernel/uapi/asm-arm -isystem /huge-ssd/lmp-dev/bionic/libm/include -isystem /huge-ssd/lmp-dev/bionic/libm/include/arm -isystem /huge-ssd/lmp-dev/bionic/libthread_db/include -D_FORTIFY_SOURCE=2 -include /huge-ssd/lmp-dev/build/core/combo/include/arch/linux-arm/AndroidConfig.h -I/huge-ssd/lmp-dev/build/core/combo/include/arch/linux-arm/ -DANDROID -DNDEBUG -UDEBUG -DDEBUG_LEAKS -DMKSH_ASSUME_UTF8 -DMKSH_CONSERVATIVE_FDS -DMKSH_DONT_EMIT_IDSTRING -DMKSH_NOPWNAM -DMKSH_BUILDSH -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN -DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_PURE=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_TIME_H=1 -DHAVE_TIME_H=1 -DHAVE_BOTH_TIME_H=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 -DHAVE_CAN_INTTYPES=1 -DHAVE_CAN_UCBINTS=1 -DHAVE_CAN_INT8TYPE=1 -DHAVE_CAN_UCBINT8=1 -DHAVE_RLIM_T=1 -DHAVE_SIG_T=1 -DHAVE_SYS_ERRLIST=0 -DHAVE_SYS_SIGNAME=1 -DHAVE_SYS_SIGLIST=1 -DHAVE_FLOCK=1 -DHAVE_LOCK_FCNTL=1 -DHAVE_GETRUSAGE=1 -DHAVE_GETSID=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_KILLPG=1 -DHAVE_MEMMOVE=1 -DHAVE_MKNOD=0 -DHAVE_MMAP=1 -DHAVE_NICE=1 -DHAVE_REVOKE=0 -DHAVE_SETLOCALE_CTYPE=0 -DHAVE_LANGINFO_CODESET=0 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRERROR=1 -DHAVE_STRSIGNAL=0 -DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_ERRLIST_DECL=0 -DHAVE_SYS_SIGLIST_DECL=1 -DHAVE_PERSISTENT_HISTORY=0 -DMKSH_BUILD_R=501
-LDFLAGS=        -nostdlib -Bdynamic -fPIE -pie -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--icf=safe -Wl,--fix-cortex-a8 -Wl,--no-undefined /huge-ssd/lmp-dev/out/target/product/hammerhead/obj/lib/crtbegin_dynamic.o
-LIBS=           -L/huge-ssd/lmp-dev/out/target/product/hammerhead/obj/lib -Wl,-rpath-link=/huge-ssd/lmp-dev/out/target/product/hammerhead/obj/lib -Wl,--no-whole-archive /huge-ssd/lmp-dev/out/target/product/hammerhead/obj/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a -lc /huge-ssd/lmp-dev/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8/bin/../lib/gcc/arm-linux-androideabi/4.8/armv7-a/libgcc.a /huge-ssd/lmp-dev/out/target/product/hammerhead/obj/lib/crtend_android.o
+CC=            /huge-ssd/aosp-arm64/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/*-gcc
+CFLAGS=                 -fno-exceptions -Wno-multichar -fpic -fPIE -ffunction-sections -fdata-sections -funwind-tables -fstack-protector -Wa,--noexecstack -Werror=format-security -fno-short-enums -Wno-unused-but-set-variable -fno-builtin-sin -fno-strict-volatile-bitfields -Wno-psabi -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -g -Wstrict-aliasing=2 -fgcse-after-reload -frerun-cse-after-loop -frename-registers -Os -fomit-frame-pointer -fno-strict-aliasing -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fstack-protector-strong -fwrapv
+CPPFLAGS=      -I. -I'../src'  -isystem /huge-ssd/aosp-arm64/bionic/libc/arch-arm64/include -isystem /huge-ssd/aosp-arm64/bionic/libc/include -isystem /huge-ssd/aosp-arm64/bionic/libc/kernel/uapi -isystem /huge-ssd/aosp-arm64/bionic/libc/kernel/uapi/asm-arm64 -isystem /huge-ssd/aosp-arm64/bionic/libm/include -isystem /huge-ssd/aosp-arm64/bionic/libm/include/arm64 -D_FORTIFY_SOURCE=2 -include /huge-ssd/aosp-arm64/build/core/combo/include/arch/linux-arm64/AndroidConfig.h -I/huge-ssd/aosp-arm64/build/core/combo/include/arch/linux-arm64/ -DANDROID -DNDEBUG -UDEBUG -DDEBUG_LEAKS -DMKSH_ASSUME_UTF8 -DMKSH_CONSERVATIVE_FDS -DMKSH_DONT_EMIT_IDSTRING -DMKSH_NOPWNAM -DMKSH_BUILDSH -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN -DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_PURE=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_TIME_H=1 -DHAVE_TIME_H=1 -DHAVE_BOTH_TIME_H=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 -DHAVE_CAN_INTTYPES=1 -DHAVE_CAN_UCBINTS=1 -DHAVE_CAN_INT8TYPE=1 -DHAVE_CAN_UCBINT8=1 -DHAVE_RLIM_T=1 -DHAVE_SIG_T=1 -DHAVE_SYS_ERRLIST=0 -DHAVE_SYS_SIGNAME=1 -DHAVE_SYS_SIGLIST=1 -DHAVE_FLOCK=1 -DHAVE_LOCK_FCNTL=1 -DHAVE_GETRUSAGE=1 -DHAVE_GETSID=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_KILLPG=1 -DHAVE_MEMMOVE=1 -DHAVE_MKNOD=0 -DHAVE_MMAP=1 -DHAVE_NICE=1 -DHAVE_REVOKE=0 -DHAVE_SETLOCALE_CTYPE=0 -DHAVE_LANGINFO_CODESET=0 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRERROR=1 -DHAVE_STRSIGNAL=0 -DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_ERRLIST_DECL=0 -DHAVE_SYS_SIGLIST_DECL=1 -DHAVE_PERSISTENT_HISTORY=0 -DMKSH_BUILD_R=501
+LDFLAGS=        -nostdlib -Bdynamic -fPIE -pie -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined /huge-ssd/aosp-arm64/out/target/product/generic_arm64/obj/lib/crtbegin_dynamic.o
+LIBS=           -L/huge-ssd/aosp-arm64/out/target/product/generic_arm64/obj/lib -Wl,-rpath-link=/huge-ssd/aosp-arm64/out/target/product/generic_arm64/obj/lib -Wl,--no-whole-archive /huge-ssd/aosp-arm64/out/target/product/generic_arm64/obj/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a -lc /huge-ssd/aosp-arm64/out/target/product/generic_arm64/obj/lib/crtend_android.o
 
 .depend $(OBJS_BP): rlimits.gen sh_flags.gen
 rlimits.gen: ../src/Build.sh ../src/rlimits.opt
diff --git a/mkmf.sh b/mkmf.sh
index 193dae2..fafa34b 100644 (file)
--- a/mkmf.sh
+++ b/mkmf.sh
@@ -52,36 +52,24 @@ LIBS=
 # Since we no longer use the NDK, AOSP has to have been
 # built before using this script.
 
-CC=$aospdir/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-gcc
+CC=$ANDROID_TOOLCHAIN/*-gcc
+
+target_arch=$(cd $ANDROID_BUILD_TOP; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core make --no-print-directory -f build/core/config.mk dumpvar-TARGET_ARCH)
+
 addvar CPPFLAGS \
-    -I$aospdir/libnativehelper/include/nativehelper \
-    -isystem $aospdir/system/core/include \
-    -isystem $aospdir/hardware/libhardware/include \
-    -isystem $aospdir/hardware/libhardware_legacy/include \
-    -isystem $aospdir/hardware/ril/include \
-    -isystem $aospdir/libnativehelper/include \
-    -isystem $aospdir/frameworks/native/include \
-    -isystem $aospdir/frameworks/native/opengl/include \
-    -isystem $aospdir/frameworks/av/include \
-    -isystem $aospdir/frameworks/base/include \
-    -isystem $aospdir/external/skia/include \
-    -isystem $ANDROID_PRODUCT_OUT/obj/include \
-    -isystem $aospdir/bionic/libc/arch-arm/include \
+    -isystem $aospdir/bionic/libc/arch-$target_arch/include \
     -isystem $aospdir/bionic/libc/include \
-    -isystem $aospdir/bionic/libstdc++/include \
     -isystem $aospdir/bionic/libc/kernel/uapi \
-    -isystem $aospdir/bionic/libc/kernel/uapi/asm-arm \
+    -isystem $aospdir/bionic/libc/kernel/uapi/asm-$target_arch \
     -isystem $aospdir/bionic/libm/include \
-    -isystem $aospdir/bionic/libm/include/arm \
-    -isystem $aospdir/bionic/libthread_db/include \
+    -isystem $aospdir/bionic/libm/include/$target_arch \
     -D_FORTIFY_SOURCE=2 \
-    -include $aospdir/build/core/combo/include/arch/linux-arm/AndroidConfig.h \
-    -I$aospdir/build/core/combo/include/arch/linux-arm/ \
+    -include $aospdir/build/core/combo/include/arch/linux-$target_arch/AndroidConfig.h \
+    -I$aospdir/build/core/combo/include/arch/linux-$target_arch/ \
     -DANDROID -DNDEBUG -UDEBUG
 addvar CFLAGS \
     -fno-exceptions \
     -Wno-multichar \
-    -msoft-float \
     -fpic \
     -fPIE \
     -ffunction-sections \
@@ -91,14 +79,10 @@ addvar CFLAGS \
     -Wa,--noexecstack \
     -Werror=format-security \
     -fno-short-enums \
-    -march=armv7-a \
-    -mfloat-abi=softfp \
-    -mfpu=vfpv3-d16 \
     -Wno-unused-but-set-variable \
     -fno-builtin-sin \
     -fno-strict-volatile-bitfields \
     -Wno-psabi \
-    -mthumb-interwork \
     -fmessage-length=0 \
     -W \
     -Wall \
@@ -114,7 +98,6 @@ addvar CFLAGS \
     -fgcse-after-reload \
     -frerun-cse-after-loop \
     -frename-registers \
-    -mthumb \
     -Os \
     -fomit-frame-pointer \
     -fno-strict-aliasing
@@ -131,8 +114,6 @@ addvar LDFLAGS \
     -Wl,-z,now \
     -Wl,--warn-shared-textrel \
     -Wl,--fatal-warnings \
-    -Wl,--icf=safe \
-    -Wl,--fix-cortex-a8 \
     -Wl,--no-undefined \
     $ANDROID_PRODUCT_OUT/obj/lib/crtbegin_dynamic.o
 addvar LIBS \
@@ -141,7 +122,6 @@ addvar LIBS \
     -Wl,--no-whole-archive \
     $ANDROID_PRODUCT_OUT/obj/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a \
     -lc \
-    $aospdir/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8/bin/../lib/gcc/arm-linux-androideabi/4.8/armv7-a/libgcc.a \
     $ANDROID_PRODUCT_OUT/obj/lib/crtend_android.o