3 # Customize these parameters according to your environment
4 ANDROID_NDK
="${HOME}/bin/android-ndk-r6b"
7 if [ ! -d "${ANDROID_NDK}" ]; then
8 echo "Android NDK not found in ${ANDROID_NDK}, please edit $0 to fix it."
12 if [ ! -e "${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh" ]; then
13 echo "Your Android NDK is not compatible (make-standalone-toolchain.sh not found)."
14 echo "Android NDK r6b is known to work."
18 # Extract the Android toolchain from NDK
19 ANDROID_PLATFORM
="android-3"
22 ${ANDROID_NDK}/build
/tools
/make-standalone-toolchain.sh \
23 --ndk-dir="${ANDROID_NDK}" \
24 --platform="${ANDROID_PLATFORM}" \
25 --install-dir="${OUT}/toolchain" \
27 # Remove resolv.h because it is quite unusable as is
28 rm ${OUT}/toolchain
/sysroot
/usr
/include
/resolv.h
30 # Create configure script
34 # Create config.h and Makefile
40 CC
="${OUT}/toolchain/bin/arm-linux-androideabi-gcc" \
43 # Replace misconfigured values in config.h and enable PTY functions
44 mv config.h config.old
46 |
sed 's/CRDLY_SHIFT.*/CRDLY_SHIFT 9/' \
47 |
sed 's/TABDLY_SHIFT.*/TABDLY_SHIFT 11/' \
48 |
sed 's/CSIZE_SHIFT.*/CSIZE_SHIFT 4/' \
49 |
sed 's/\/\* #undef HAVE_OPENPTY \*\//#define HAVE_OPENPTY 1/' \
50 |
sed 's/\/\* #undef HAVE_GRANTPT \*\//#define HAVE_GRANTPT 1/' \
53 # Enable openpty() in Makefile
54 mv Makefile Makefile.old
55 cat Makefile.old |
sed 's/error.c/error.c openpty.c/' > Makefile
59 /* Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
60 This file is part of the GNU C Library.
61 Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
63 The GNU C Library is free software; you can redistribute it and/or
64 modify it under the terms of the GNU Lesser General Public
65 License as published by the Free Software Foundation; either
66 version 2.1 of the License, or (at your option) any later version.
68 The GNU C Library is distributed in the hope that it will be useful,
69 but WITHOUT ANY WARRANTY; without even the implied warranty of
70 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
71 Lesser General Public License for more details.
73 You should have received a copy of the GNU Lesser General Public
74 License along with the GNU C Library; if not, write to the Free
75 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
85 #include <sys/types.h>
86 #include <sys/ioctl.h>
88 #define _PATH_DEVPTMX "/dev/ptmx"
90 int openpty (int *amaster, int *aslave, char *name, struct termios *termp,
96 master = open(_PATH_DEVPTMX, O_RDWR);
103 if (unlockpt(master))
106 if (ptsname_r(master, buf, sizeof buf))
109 slave = open(buf, O_RDWR | O_NOCTTY);
113 /* XXX Should we ignore errors here? */
115 tcsetattr(slave, TCSAFLUSH, termp);
117 ioctl(slave, TIOCSWINSZ, winp);
136 echo "Build finished, socat has been generated successfuly in out/socat"