Home | History | Annotate | Download | only in mksh
      1 # Copyright  2010
      2 #	Thorsten Glaser <t.glaser (at] tarent.de>
      3 # This file is provided under the same terms as mksh.
      4 #-
      5 # Helper script to let src/Build.sh generate Makefrag.inc
      6 # which we in turn use in the manual creation of Android.mk
      7 #
      8 # This script is supposed to be run from/inside AOSP by the
      9 # porter of mksh to Android (and only manually).
     10 
     11 cd "$(dirname "$0")"
     12 srcdir=$(pwd)
     13 rm -rf tmp
     14 mkdir tmp
     15 cd ../../..
     16 aospdir=$(pwd)
     17 cd $srcdir/tmp
     18 
     19 addvar() {
     20 	_vn=$1; shift
     21 
     22 	eval $_vn=\"\$$_vn '$*"'
     23 }
     24 
     25 CFLAGS=
     26 CPPFLAGS=
     27 LDFLAGS=
     28 LIBS=
     29 
     30 # The definitions below were generated by examining the
     31 # output of the following command:
     32 # make showcommands out/target/product/generic/system/bin/mksh 2>&1 | tee log
     33 #
     34 # They are only used to let Build.sh find the compiler, header
     35 # files, linker and libraries to generate Makefrag.inc (similar
     36 # to what GNU autotools configure scripts do), and never used
     37 # during the real build process. We need this to port mksh to
     38 # the Android platform and it is crucial these are as close as
     39 # possible to the values used later. (You also must example the
     40 # results gathered from Makefrag.inc to see they are the same
     41 # across all Android platforms, or add appropriate ifdefs.)
     42 # Since we no longer use the NDK, the AOSP has to have been
     43 # built before using this script (targetting generic/emulator).
     44 
     45 CC=$aospdir/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gcc
     46 addvar CPPFLAGS -I$aospdir/system/core/include \
     47     -I$aospdir/hardware/libhardware/include \
     48     -I$aospdir/system/core/include \
     49     -I$aospdir/hardware/libhardware/include \
     50     -I$aospdir/hardware/libhardware_legacy/include \
     51     -I$aospdir/hardware/ril/include \
     52     -I$aospdir/libnativehelper/include \
     53     -I$aospdir/frameworks/base/include \
     54     -I$aospdir/frameworks/base/opengl/include \
     55     -I$aospdir/external/skia/include \
     56     -I$aospdir/out/target/product/generic/obj/include \
     57     -I$aospdir/bionic/libc/arch-arm/include \
     58     -I$aospdir/bionic/libc/include \
     59     -I$aospdir/bionic/libstdc++/include \
     60     -I$aospdir/bionic/libc/kernel/common \
     61     -I$aospdir/bionic/libc/kernel/arch-arm \
     62     -I$aospdir/bionic/libm/include \
     63     -I$aospdir/bionic/libm/include/arch/arm \
     64     -I$aospdir/bionic/libthread_db/include \
     65     -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
     66     -I$aospdir/system/core/include/arch/linux-arm/ \
     67     -include $aospdir/system/core/include/arch/linux-arm/AndroidConfig.h \
     68     -DANDROID -DNDEBUG -UDEBUG
     69 addvar CFLAGS -fno-exceptions -Wno-multichar -msoft-float -fpic \
     70     -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums \
     71     -march=armv5te -mtune=xscale -mthumb-interwork -fmessage-length=0 \
     72     -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type \
     73     -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point \
     74     -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once \
     75     -fgcse-after-reload -frerun-cse-after-loop -frename-registers -mthumb \
     76     -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64
     77 addvar LDFLAGS -nostdlib -Bdynamic -Wl,-T,$aospdir/build/core/armelf.x \
     78     -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections \
     79     -Wl,-z,nocopyreloc -Wl,--no-undefined \
     80     $aospdir/out/target/product/generic/obj/lib/crtbegin_dynamic.o
     81 addvar LIBS -L$aospdir/out/target/product/generic/obj/lib \
     82     -Wl,-rpath-link=$aospdir/out/target/product/generic/obj/lib -lc \
     83     $aospdir/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/interwork/libgcc.a \
     84     $aospdir/out/target/product/generic/obj/lib/crtend_android.o
     85 
     86 
     87 ### Override flags
     88 # We dont even *support* UTF-8 by default 
     89 addvar CPPFLAGS -DMKSH_ASSUME_UTF8=0
     90 # No getpwnam() calls (affects "cd ~username/" only)
     91 addvar CPPFLAGS -DMKSH_NOPWNAM
     92 # Compile an extra small mksh (optional)
     93 #addvar CPPFLAGS -DMKSH_SMALL
     94 # Leave out the ulimit builtin
     95 #addvar CPPFLAGS -DMKSH_NO_LIMITS
     96 
     97 # Set target platform
     98 TARGET_OS=Linux
     99 # Building with -std=c99 or -std=gnu99 clashes with Bionic headers
    100 HAVE_CAN_STDG99=0
    101 HAVE_CAN_STDC99=0
    102 export HAVE_CAN_STDG99 HAVE_CAN_STDC99
    103 
    104 # Android-x86 does not have helper functions for ProPolice SSP
    105 # and AOSP adds the flags by itself (same for warning flags)
    106 HAVE_CAN_FNOSTRICTALIASING=0
    107 HAVE_CAN_FSTACKPROTECTORALL=0
    108 HAVE_CAN_WALL=0
    109 export HAVE_CAN_FNOSTRICTALIASING HAVE_CAN_FSTACKPROTECTORALL HAVE_CAN_WALL
    110 
    111 # disable the mknod(8) built-in to get rid of needing setmode.c
    112 HAVE_MKNOD=0; export HAVE_MKNOD
    113 
    114 # even the idea of persistent history on a phone is funny
    115 HAVE_PERSISTENT_HISTORY=0; export HAVE_PERSISTENT_HISTORY
    116 
    117 # ... and run it!
    118 export CC CPPFLAGS CFLAGS LDFLAGS LIBS TARGET_OS
    119 sh ../src/Build.sh -M
    120 rv=$?
    121 test x0 = x"$rv" && mv -f Makefrag.inc ../
    122 cd ..
    123 rm -rf tmp
    124 exit $rv
    125