OSDN Git Service

Fix toybox_vendor dependencies again.
[android-x86/external-toybox.git] / Android.mk
index 7e49a6f..a2cfe5f 100644 (file)
@@ -44,9 +44,7 @@ LOCAL_PATH := $(call my-dir)
 #  # If you just want to use it as "toybox x" rather than "x", you can stop now.
 #  # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
 
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
+common_SRC_FILES := \
     lib/args.c \
     lib/dirtree.c \
     lib/getmountlist.c \
@@ -81,6 +79,7 @@ LOCAL_SRC_FILES := \
     toys/lsb/sync.c \
     toys/lsb/umount.c \
     toys/net/ifconfig.c \
+    toys/net/microcom.c \
     toys/net/netcat.c \
     toys/net/netstat.c \
     toys/net/rfkill.c \
@@ -89,9 +88,9 @@ LOCAL_SRC_FILES := \
     toys/other/base64.c \
     toys/other/blkid.c \
     toys/other/blockdev.c \
-    toys/other/bzcat.c \
     toys/other/chcon.c \
     toys/other/chroot.c \
+    toys/other/chrt.c \
     toys/other/clear.c \
     toys/other/dos2unix.c \
     toys/other/fallocate.c \
@@ -107,6 +106,7 @@ LOCAL_SRC_FILES := \
     toys/other/losetup.c \
     toys/other/lsattr.c \
     toys/other/lsmod.c \
+    toys/other/lspci.c \
     toys/other/lsusb.c \
     toys/other/makedevs.c \
     toys/other/mkswap.c \
@@ -122,7 +122,6 @@ LOCAL_SRC_FILES := \
     toys/other/realpath.c \
     toys/other/rev.c \
     toys/other/rmmod.c \
-    toys/other/setfattr.c \
     toys/other/setsid.c \
     toys/other/stat.c \
     toys/other/swapoff.c \
@@ -139,12 +138,15 @@ LOCAL_SRC_FILES := \
     toys/other/which.c \
     toys/other/xxd.c \
     toys/other/yes.c \
-    toys/pending/chrt.c \
     toys/pending/dd.c \
+    toys/pending/diff.c \
     toys/pending/expr.c \
     toys/pending/getfattr.c \
+    toys/pending/gzip.c \
     toys/pending/lsof.c \
+    toys/pending/modprobe.c \
     toys/pending/more.c \
+    toys/pending/setfattr.c \
     toys/pending/tar.c \
     toys/pending/tr.c \
     toys/pending/traceroute.c \
@@ -203,13 +205,17 @@ LOCAL_SRC_FILES := \
     toys/posix/ulimit.c \
     toys/posix/uname.c \
     toys/posix/uniq.c \
+    toys/posix/uudecode.c \
+    toys/posix/uuencode.c \
     toys/posix/wc.c \
     toys/posix/xargs.c \
 
-LOCAL_CFLAGS += \
+common_CFLAGS := \
     -std=c99 \
     -Os \
     -Wno-char-subscripts \
+    -Wno-gnu-variable-sized-type-not-at-end \
+    -Wno-missing-field-initializers \
     -Wno-sign-compare \
     -Wno-string-plus-int \
     -Wno-uninitialized \
@@ -218,34 +224,25 @@ LOCAL_CFLAGS += \
     -ffunction-sections -fdata-sections \
     -fno-asynchronous-unwind-tables \
 
-toybox_upstream_version := $(shell awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary) {print ary[1]}' $(LOCAL_PATH)/main.c)
-toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
+toybox_upstream_version := $(shell sed 's/#define.*TOYBOX_VERSION.*"\(.*\)"/\1/p;d' $(LOCAL_PATH)/main.c)
 
-toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
-LOCAL_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"'
+toybox_version := $(toybox_upstream_version)-android
 
-LOCAL_CLANG := true
+toybox_libraries := liblog libselinux libcutils libcrypto libz
 
-LOCAL_SHARED_LIBRARIES := libcutils libselinux libcrypto
+common_CFLAGS += -DTOYBOX_VERSION=\"$(toybox_version)\"
 
-# This doesn't actually prevent us from dragging in libc++ at runtime
-# because libnetd_client.so is C++.
-LOCAL_CXX_STL := none
-
-LOCAL_MODULE := toybox
-
-# dupes: dd
-# useless?: freeramdisk fsfreeze install makedevs mkfifo nbd-client
-#           partprobe pivot_root pwdx rev rfkill vconfig
-# prefer BSD netcat instead?: nc netcat
-# prefer efs2progs instead?: blkid chattr lsattr
+# not usable on Android?: freeramdisk fsfreeze install makedevs nbd-client
+#                         partprobe pivot_root pwdx rev rfkill vconfig
+# currently prefer BSD system/core/toolbox: dd
+# currently prefer BSD external/netcat: nc netcat
+# currently prefer external/efs2progs: blkid chattr lsattr
 
 ALL_TOOLS := \
     acpi \
     base64 \
     basename \
     blockdev \
-    bzcat \
     cal \
     cat \
     chcon \
@@ -253,6 +250,7 @@ ALL_TOOLS := \
     chmod \
     chown \
     chroot \
+    chrt \
     cksum \
     clear \
     comm \
@@ -262,6 +260,7 @@ ALL_TOOLS := \
     cut \
     date \
     df \
+    diff \
     dirname \
     dmesg \
     dos2unix \
@@ -279,6 +278,8 @@ ALL_TOOLS := \
     getenforce \
     getprop \
     groups \
+    gunzip \
+    gzip \
     head \
     hostname \
     hwclock \
@@ -298,13 +299,17 @@ ALL_TOOLS := \
     ls \
     lsmod \
     lsof \
+    lspci \
     lsusb \
     md5sum \
     mkdir \
+    mkfifo \
     mknod \
     mkswap \
     mktemp \
+    microcom \
     modinfo \
+    modprobe \
     more \
     mount \
     mountpoint \
@@ -374,6 +379,8 @@ ALL_TOOLS := \
     unix2dos \
     uptime \
     usleep \
+    uudecode \
+    uuencode \
     vmstat \
     wc \
     which \
@@ -381,8 +388,50 @@ ALL_TOOLS := \
     xargs \
     xxd \
     yes \
+    zcat \
+
+############################################
+# toybox for /system
+############################################
 
-# Install the symlinks.
+include $(CLEAR_VARS)
+LOCAL_MODULE := toybox
+LOCAL_SRC_FILES := $(common_SRC_FILES)
+LOCAL_CFLAGS := $(common_CFLAGS)
+LOCAL_SHARED_LIBRARIES := $(toybox_libraries)
+# This doesn't actually prevent us from dragging in libc++ at runtime
+# because libnetd_client.so is C++.
+LOCAL_CXX_STL := none
 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
+include $(BUILD_EXECUTABLE)
+
+############################################
+# toybox for /vendor
+############################################
 
+include $(CLEAR_VARS)
+LOCAL_MODULE := toybox_vendor
+LOCAL_VENDOR_MODULE := true
+LOCAL_SRC_FILES := $(common_SRC_FILES)
+LOCAL_CFLAGS := $(common_CFLAGS)
+LOCAL_STATIC_LIBRARIES := libcutils libcrypto libz
+LOCAL_SHARED_LIBRARIES := libselinux_vendor liblog
+LOCAL_MODULE_TAGS := optional
+LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(TARGET_OUT_VENDOR_EXECUTABLES)/$(t);)
+include $(BUILD_EXECUTABLE)
+
+############################################
+# static version to be installed in recovery
+############################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := toybox_static
+LOCAL_SRC_FILES := $(common_SRC_FILES)
+LOCAL_CFLAGS := $(common_CFLAGS)
+LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
+# libc++_static is needed by static liblog
+LOCAL_CXX_STL := libc++_static
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);)
 include $(BUILD_EXECUTABLE)