1 # Copyright © 2010, 2012, 2013
2 # Thorsten Glaser <tg@mirbsd.org>
3 # This file is provided under the same terms as mksh.
5 # Helper script to let src/Build.sh generate Makefrag.inc
6 # which we in turn use in the manual creation of Android.mk
8 # This script is supposed to be run from/inside AOSP by the
9 # porter of mksh to Android (and only manually).
11 if test x"$1" = x"-t"; then
32 eval $_vn=\"\$$_vn '$*"'
40 # The definitions below were generated by examining the
41 # output of the following command:
42 # make showcommands out/target/product/generic/system/bin/mksh 2>&1 | tee log
44 # They are only used to let Build.sh find the compiler, header
45 # files, linker and libraries to generate Makefrag.inc (similar
46 # to what GNU autotools’ configure scripts do), and never used
47 # during the real build process. We need this to port mksh to
48 # the Android platform and it is crucial these are as close as
49 # possible to the values used later. (You also must example the
50 # results gathered from Makefrag.inc to see they are the same
51 # across all Android platforms, or add appropriate ifdefs.)
52 # Since we no longer use the NDK, AOSP has to have been
53 # built before using this script.
55 CC=$ANDROID_TOOLCHAIN/*-gcc
57 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)
60 -isystem $aospdir/bionic/libc/arch-$target_arch/include \
61 -isystem $aospdir/bionic/libc/include \
62 -isystem $aospdir/bionic/libc/kernel/uapi \
63 -isystem $aospdir/bionic/libc/kernel/uapi/asm-$target_arch \
64 -isystem $aospdir/bionic/libm/include \
65 -isystem $aospdir/bionic/libm/include/$target_arch \
67 -include $aospdir/build/core/combo/include/arch/linux-$target_arch/AndroidConfig.h \
68 -I$aospdir/build/core/combo/include/arch/linux-$target_arch/ \
69 -DANDROID -DNDEBUG -UDEBUG
80 -Werror=format-security \
82 -Wno-unused-but-set-variable \
84 -fno-strict-volatile-bitfields \
93 -Werror=non-virtual-dtor \
95 -Werror=sequence-point \
99 -frerun-cse-after-loop \
102 -fomit-frame-pointer \
109 -Wl,-dynamic-linker,/system/bin/linker \
115 -Wl,--warn-shared-textrel \
116 -Wl,--fatal-warnings \
118 $ANDROID_PRODUCT_OUT/obj/lib/crtbegin_dynamic.o
120 -L$ANDROID_PRODUCT_OUT/obj/lib \
121 -Wl,-rpath-link=$ANDROID_PRODUCT_OUT/obj/lib \
122 -Wl,--no-whole-archive \
123 $ANDROID_PRODUCT_OUT/obj/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a \
125 $ANDROID_PRODUCT_OUT/obj/lib/crtend_android.o
128 ### Flags used by test builds
129 if test $mkmfmode = 1; then
130 addvar CPPFLAGS '-DMKSHRC_PATH=\"/system/etc/mkshrc\"'
131 addvar CPPFLAGS '-DMKSH_DEFAULT_EXECSHELL=\"/system/bin/sh\"'
132 addvar CPPFLAGS '-DMKSH_DEFAULT_TMPDIR=\"/data/local\"'
136 # Let the shell free all memory upon exiting
137 addvar CPPFLAGS -DDEBUG_LEAKS
138 # UTF-8 works nowadays
139 addvar CPPFLAGS -DMKSH_ASSUME_UTF8
140 # Reduce filedescriptor usage
141 addvar CPPFLAGS -DMKSH_CONSERVATIVE_FDS
142 # Leave out RCS ID strings from the binary
143 addvar CPPFLAGS -DMKSH_DONT_EMIT_IDSTRING
144 # No getpwnam() calls (affects "cd ~username/" only)
145 addvar CPPFLAGS -DMKSH_NOPWNAM
146 # Leave out the ulimit builtin
147 #addvar CPPFLAGS -DMKSH_NO_LIMITS
148 # Compile an extra small mksh (optional)
149 #addvar CPPFLAGS -DMKSH_SMALL
151 # Set target platform
154 # Android-x86 does not have helper functions for ProPolice SSP
155 # and AOSP adds the flags by itself (same for warning flags)
156 HAVE_CAN_FNOSTRICTALIASING=0
157 HAVE_CAN_FSTACKPROTECTORALL=0
159 export HAVE_CAN_FNOSTRICTALIASING HAVE_CAN_FSTACKPROTECTORALL HAVE_CAN_WALL
161 # even the idea of persistent history on a phone is funny
162 HAVE_PERSISTENT_HISTORY=0; export HAVE_PERSISTENT_HISTORY
165 export CC CPPFLAGS CFLAGS LDFLAGS LIBS TARGET_OS
166 sh ../src/Build.sh $args
168 test x"$args" = x"-r" && exit $rv
169 test x0 = x"$rv" && mv -f Makefrag.inc ../