Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
[PATCH] support ndk-build
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Jun 23, 2018
1 parent e5e089c commit 70a51fd
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 27 deletions.
11 changes: 1 addition & 10 deletions archival/libarchive/Kbuild.src
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ COMMON_FILES:= \
find_list_entry.o \
init_handle.o

DPKG_FILES:= \
unpack_ar_archive.o \
filter_accept_list_reassign.o \
unsafe_prefix.o \
get_header_ar.o \
get_header_tar.o \
get_header_tar_gz.o \
get_header_tar_bz2.o \
get_header_tar_lzma.o \
get_header_tar_xz.o \
DPKG_FILES:=

INSERT

Expand Down
1 change: 1 addition & 0 deletions include/libbb.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifndef LIBBB_H
#define LIBBB_H 1

#include "autoconf.h"
#include "platform.h"

#include <ctype.h>
Expand Down
12 changes: 11 additions & 1 deletion include/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
#ifndef BB_PLATFORM_H
#define BB_PLATFORM_H 1

/* Check for NDK version */
#ifdef __ANDROID__
# include <android/api-level.h>
# ifdef __ANDROID_NDK__
# include <android/ndk-version.h>
# endif
#endif

/* Convenience macros to test the version of gcc. */
#undef __GNUC_PREREQ
Expand Down Expand Up @@ -120,7 +127,7 @@
* (-DFAST_FUNC= )
*/
#ifndef FAST_FUNC
# if __GNUC_PREREQ(3,0) && defined(i386)
# if !defined(__ANDROID__) && __GNUC_PREREQ(3,0) && defined(i386)
/* stdcall makes callee to pop arguments from stack, not caller */
# define FAST_FUNC __attribute__((regparm(3),stdcall))
/* #elif ... - add your favorite arch today! */
Expand Down Expand Up @@ -528,6 +535,9 @@ typedef unsigned smalluint;
# else
# undef HAVE_WAIT3
# endif
# if __NDK_MAJOR__ >= 17
# define HAVE_GETLINE 1
# endif
# undef HAVE_MEMPCPY
# undef HAVE_STRCHRNUL
# undef HAVE_STRVERSCMP
Expand Down
5 changes: 4 additions & 1 deletion libbb/cfsetspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
//kbuild:lib-$(CONFIG_MICROCOM) += cfsetspeed.o
//kbuild:lib-$(CONFIG_GETTY) += cfsetspeed.o

#include "libbb.h"

#include <termios.h>
#include <errno.h>
#include <stddef.h>
Expand Down Expand Up @@ -138,7 +140,7 @@ static const struct speed_struct speeds[] =
#endif
};


# if __ANDROID_API__ < 21 && __NDK_MAJOR__ < 16
/* Set both the input and output baud rates stored in *TERMIOS_P to SPEED. */
int
cfsetspeed (struct termios *termios_p, speed_t speed)
Expand All @@ -163,3 +165,4 @@ cfsetspeed (struct termios *termios_p, speed_t speed)

return -1;
}
#endif
2 changes: 1 addition & 1 deletion libbb/getopt32.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
#include "libbb.h"
#if ENABLE_LONG_OPTS
# include <getopt.h>
#endif
#include "libbb.h"

//kbuild:lib-y += getopt32.o

Expand Down
2 changes: 1 addition & 1 deletion libbb/missing_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int semop(int semid, struct sembuf *sops, unsigned nsops)
return syscall(__NR_semop, semid, sops, nsops);
}

# if __ANDROID_API__ < 21
# if __ANDROID_API__ < 21 && __NDK_MAJOR__ < 16
int tcdrain(int fd)
{
return ioctl(fd, TCSBRK, 1);
Expand Down
6 changes: 5 additions & 1 deletion libbb/semctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
// syscall used by syslogd, ipcrm, ipcs
//kbuild:lib-y += semctl.o

#include "libbb.h"
#include <sys/syscall.h> /* For __NR_xxx definitions */
#include <stdarg.h>
#ifdef __NDK_MAJOR__ < 16
#include <sys/sem.h>
#else
#include <linux/sem.h>
#include "libbb.h"
#endif

#ifndef __NR_semctl
#define __NR_semctl 66
Expand Down
1 change: 1 addition & 0 deletions networking/ether-wake.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@

#include "libbb.h"
#include <netpacket/packet.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <netinet/if_ether.h>
#include <linux/if.h>
Expand Down
1 change: 1 addition & 0 deletions networking/ether_aton_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <ctype.h>
#include <sys/types.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <netinet/if_ether.h>

Expand Down
1 change: 1 addition & 0 deletions networking/ether_ntoa_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
02111-1307 USA. */

#include <stdio.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <netinet/if_ether.h>

Expand Down
1 change: 1 addition & 0 deletions networking/libiproute/libnetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* in linux/[rt]netlink.h. 2.6.19 seems to be ok, though */
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/if_ether.h>

PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN

Expand Down
3 changes: 2 additions & 1 deletion networking/traceroute.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@

#define TRACEROUTE_SO_DEBUG 0

#include "libbb.h"

#include <net/if.h>
#include <arpa/inet.h>
#include <netinet/in.h>
Expand All @@ -316,7 +318,6 @@
# endif
#endif

#include "libbb.h"
#include "inet_common.h"

#ifndef IPPROTO_ICMP
Expand Down
2 changes: 2 additions & 0 deletions networking/udhcp/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

#include "libbb.h"
#include "common_bufsiz.h"
#include <net/ethernet.h>
#include <netinet/udp.h>
#include <netinet/ip.h>
#include <linux/if_ether.h>

PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN

Expand Down
2 changes: 2 additions & 0 deletions networking/udhcp/dhcpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
#include <netinet/ether.h>
#include <syslog.h>

#ifdef __NDK_VERSION__ < 17
#include "../ether_port.h"
#endif

#include "common.h"
#include "dhcpc.h"
Expand Down
1 change: 1 addition & 0 deletions networking/zcip.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "libbb.h"
#include "common_bufsiz.h"
#include <netinet/ether.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <linux/sockios.h>
Expand Down
6 changes: 3 additions & 3 deletions shell/glob.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <sys/cdefs.h>
//#include <sys/_types.h>

#ifndef _SIZE_T_DECLARED
#if !defined(_SIZE_T_DECLARED) && !defined(__ANDROID__)
typedef __size_t size_t;
#define _SIZE_T_DECLARED
#endif
Expand All @@ -74,7 +74,7 @@ typedef struct {
int (*gl_stat)(const char *, struct stat *);
} glob_t;

#if __POSIX_VISIBLE >= 199209
#if __POSIX_VISIBLE >= 199209 || defined(__ANDROID__)
/* Believed to have been introduced in 1003.2-1992 */
#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
Expand All @@ -91,7 +91,7 @@ typedef struct {
#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */
#endif /* __POSIX_VISIBLE >= 199209 */

#if __BSD_VISIBLE
#if __BSD_VISIBLE || defined(__ANDROID__)
#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
Expand Down
2 changes: 1 addition & 1 deletion util-linux/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@
//usage: " esac\n"
//usage: "done\n"

#include "libbb.h"
#if ENABLE_FEATURE_GETOPT_LONG
# include <getopt.h>
#endif
#include "libbb.h"

/* NON_OPT is the code that is returned when a non-option is found in '+'
mode */
Expand Down
6 changes: 6 additions & 0 deletions util-linux/ipcrm.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@
/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */
/* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */
#include <sys/ipc.h>
#if __NDK_MAJOR__ < 16
#include <linux/shm.h>
#include <linux/msg.h>
#include <linux/sem.h>
#else
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/sem.h>
#endif

#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) || \
defined(__ANDROID__)
Expand Down
14 changes: 10 additions & 4 deletions util-linux/ipcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@

//kbuild:lib-$(CONFIG_IPCS) += ipcs.o

#include "libbb.h"

/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */
/* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */
/* X/OPEN tells us to use <sys/{types,ipc,shm}.h> for shmctl() */
#include <sys/types.h>
#include <sys/ipc.h>
#include <linux/sem.h>
#include <linux/msg.h>
#if __NDK_MAJOR__ < 16
#include <linux/shm.h>

#include "libbb.h"
#include <linux/msg.h>
#include <linux/sem.h>
#else
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/sem.h>
#endif

/*-------------------------------------------------------------------*/
/* SHM_DEST and SHM_LOCKED are defined in kernel headers,
Expand Down
3 changes: 2 additions & 1 deletion util-linux/setpriv.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
// --selinux-label <label> set SELinux label
// --apparmor-profile <pr> set AppArmor profile

#include "libbb.h"

#if ENABLE_FEATURE_SETPRIV_CAPABILITIES
#include <linux/capability.h>
// #include <sys/capability.h>
Expand All @@ -90,7 +92,6 @@ extern int capget(cap_user_header_t header, const cap_user_data_t data);
// This way, libcap needs not be installed in build environment.
#endif
#include <sys/prctl.h>
#include "libbb.h"

#ifndef PR_CAPBSET_READ
#define PR_CAPBSET_READ 23
Expand Down
4 changes: 2 additions & 2 deletions util-linux/switch_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
//kbuild:lib-$(CONFIG_SWITCH_ROOT) += switch_root.o
//kbuild:lib-$(CONFIG_RUN_INIT) += switch_root.o

#include "libbb.h"

#include <sys/vfs.h>
#include <sys/mount.h>
#if ENABLE_RUN_INIT
Expand All @@ -50,8 +52,6 @@ extern int capget(cap_user_header_t header, const cap_user_data_t data);
// This way, libcap needs not be installed in build environment.
#endif

#include "libbb.h"

// Make up for header deficiencies
#ifndef RAMFS_MAGIC
# define RAMFS_MAGIC ((unsigned)0x858458f6)
Expand Down

0 comments on commit 70a51fd

Please sign in to comment.