OSDN Git Service

toybox: kill colors
[android-x86/external-toybox.git] / Android.mk
index 165945c..2e9906d 100644 (file)
@@ -16,7 +16,6 @@
 
 LOCAL_PATH := $(call my-dir)
 
-
 common_cflags := \
     -std=c99 \
     -Os \
@@ -29,8 +28,11 @@ common_cflags := \
     -ffunction-sections -fdata-sections \
     -fno-asynchronous-unwind-tables \
 
-toybox_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
-common_cflags  += -DTOYBOX_VERSION='"$(toybox_version)"'
+toybox_upstream_version := $(shell grep -o 'TOYBOX_VERSION.*\".*\"' $(LOCAL_PATH)/main.c | cut -d'"' -f2)
+toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
+
+toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
+common_cflags += -DTOYBOX_VERSION='"$(toybox_version)"'
 
 #
 # To update:
@@ -54,8 +56,7 @@ common_cflags  += -DTOYBOX_VERSION='"$(toybox_version)"'
 # To add a toy:
 #
 
-#  make menuconfig
-#  # (Select the toy you want to add.)
+#  Edit .config to enable the toy you want to add.
 #  make clean && make  # Regenerate the generated files.
 #  # Edit LOCAL_SRC_FILES below to add the toy.
 #  # If you just want to use it as "toybox x" rather than "x", you can stop now.
@@ -80,10 +81,13 @@ LOCAL_SRC_FILES := \
     toys/android/getenforce.c \
     toys/android/getprop.c \
     toys/android/load_policy.c \
+    toys/android/log.c \
     toys/android/restorecon.c \
     toys/android/runcon.c \
+    toys/android/sendevent.c \
     toys/android/setenforce.c \
     toys/android/setprop.c \
+    toys/android/start.c \
     toys/lsb/dmesg.c \
     toys/lsb/hostname.c \
     toys/lsb/killall.c \
@@ -95,6 +99,11 @@ LOCAL_SRC_FILES := \
     toys/lsb/seq.c \
     toys/lsb/sync.c \
     toys/lsb/umount.c \
+    toys/net/ifconfig.c \
+    toys/net/netcat.c \
+    toys/net/netstat.c \
+    toys/net/rfkill.c \
+    toys/net/tunctl.c \
     toys/other/acpi.c \
     toys/other/base64.c \
     toys/other/blkid.c \
@@ -111,20 +120,19 @@ LOCAL_SRC_FILES := \
     toys/other/fsfreeze.c \
     toys/other/help.c \
     toys/other/hwclock.c \
-    toys/other/ifconfig.c \
     toys/other/inotifyd.c \
     toys/other/insmod.c \
     toys/other/ionice.c \
     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 \
     toys/other/modinfo.c \
     toys/other/mountpoint.c \
     toys/other/nbd_client.c \
-    toys/other/netcat.c \
     toys/other/partprobe.c \
     toys/other/pivot_root.c \
     toys/other/pmap.c \
@@ -135,13 +143,12 @@ LOCAL_SRC_FILES := \
     toys/other/realpath.c \
     toys/other/reset.c \
     toys/other/rev.c \
-    toys/other/rfkill.c \
     toys/other/rmmod.c \
+    toys/other/setfattr.c \
     toys/other/setsid.c \
     toys/other/stat.c \
     toys/other/swapoff.c \
     toys/other/swapon.c \
-    toys/other/switch_root.c \
     toys/other/sysctl.c \
     toys/other/tac.c \
     toys/other/taskset.c \
@@ -155,15 +162,16 @@ LOCAL_SRC_FILES := \
     toys/other/xxd.c \
     toys/other/yes.c \
     toys/pending/arp.c \
+    toys/pending/chrt.c \
     toys/pending/dd.c \
     toys/pending/diff.c \
     toys/pending/expr.c \
     toys/pending/fdisk.c \
     toys/pending/ftpget.c \
+    toys/pending/getfattr.c \
     toys/pending/host.c \
     toys/pending/lsof.c \
     toys/pending/more.c \
-    toys/pending/netstat.c \
     toys/pending/resize.c \
     toys/pending/route.c \
     toys/pending/tar.c \
@@ -192,6 +200,7 @@ LOCAL_SRC_FILES := \
     toys/posix/env.c \
     toys/posix/expand.c \
     toys/posix/false.c \
+    toys/posix/file.c \
     toys/posix/find.c \
     toys/posix/grep.c \
     toys/posix/head.c \
@@ -224,6 +233,7 @@ LOCAL_SRC_FILES := \
     toys/posix/touch.c \
     toys/posix/true.c \
     toys/posix/tty.c \
+    toys/posix/ulimit.c \
     toys/posix/uname.c \
     toys/posix/uniq.c \
     toys/posix/wc.c \
@@ -232,6 +242,8 @@ LOCAL_SRC_FILES := \
 LOCAL_CFLAGS := $(common_cflags)
 LOCAL_CLANG := true
 
+LOCAL_STATIC_LIBRARIES := libselinux libcrypto_static
+
 # This doesn't actually prevent us from dragging in libc++ at runtime
 # because libnetd_client.so is C++.
 LOCAL_CXX_STL := none
@@ -256,7 +268,7 @@ include $(BUILD_HOST_EXECUTABLE)
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := main.c
 LOCAL_STATIC_LIBRARIES := libtoybox
-LOCAL_SHARED_LIBRARIES := libcutils libselinux
+LOCAL_SHARED_LIBRARIES := libcutils libselinux libcrypto
 LOCAL_CFLAGS := $(common_cflags)
 LOCAL_CXX_STL := none
 LOCAL_CLANG := true
@@ -266,32 +278,30 @@ LOCAL_MODULE := toybox
 TOYBOX_INSTLIST := $(HOST_OUT_EXECUTABLES)/toybox-instlist
 LOCAL_ADDITIONAL_DEPENDENCIES := toybox_links
 
-# we still want a link for ls/ps, but the toolbox version needs to
+# we still want a link for ps, but the toolbox version needs to
 # stick around for compatibility reasons, for now.
-TOYS_FOR_XBIN := ls ps
+TOYS_FOR_XBIN := ps
 
 # skip links for these toys in the system image, they already have
 # a full-blown counterpart. we still want them for the recovery
 # image though.
-TOYS_WITHOUT_LINKS := blkid
+TOYS_WITHOUT_LINKS := blkid traceroute6
 
 include $(BUILD_EXECUTABLE)
 
-toybox_links: $(TOYBOX_INSTLIST) toybox
-toybox_links: TOY_LIST=$(shell $(TOYBOX_INSTLIST))
+toybox_links: $(TOYBOX_INSTLIST)
 toybox_links: TOYBOX_BINARY := $(TARGET_OUT)/bin/toybox
 toybox_links:
-       @echo -e ${CL_CYN}"Generate Toybox links:"${CL_RST} $(TOY_LIST)
-       @mkdir -p $(TARGET_OUT)/bin
-       @mkdir -p $(TARGET_OUT)/xbin
-       $(hide) $(foreach t,$(filter-out $(TOYS_FOR_XBIN) $(TOYS_WITHOUT_LINKS),$(TOY_LIST)),ln -sf toybox $(TARGET_OUT_EXECUTABLES)/$(t);)
-       $(hide) $(foreach t,$(TOYS_FOR_XBIN),ln -sf /system/bin/toybox $(TARGET_OUT_OPTIONAL_EXECUTABLES)/$(t);)
+       @echo -e "Generate Toybox links:" $$($(TOYBOX_INSTLIST))
+       @mkdir -p $(TARGET_OUT_EXECUTABLES) $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+       $(hide) $(TOYBOX_INSTLIST) | grep -vFx -f <(tr ' ' '\n' <<< '$(TOYS_FOR_XBIN) $(TOYS_WITHOUT_LINKS)') | xargs -I'{}' ln -sf toybox '$(TARGET_OUT_EXECUTABLES)/{}'
+       $(hide) tr ' ' '\n' <<< '$(TOYS_FOR_XBIN)' | xargs -I'{}' ln -sf ../bin/toybox '$(TARGET_OUT_OPTIONAL_EXECUTABLES)/{}'
 
 
 # This is used by the recovery system
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := main.c
-LOCAL_WHOLE_STATIC_LIBRARIES := libtoybox
+LOCAL_WHOLE_STATIC_LIBRARIES := libselinux libtoybox
 LOCAL_CFLAGS := $(common_cflags)
 LOCAL_CFLAGS += -Dmain=toybox_driver
 LOCAL_CXX_STL := none
@@ -311,6 +321,7 @@ LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
 LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_STEM := toybox
-LOCAL_STATIC_LIBRARIES := libc libtoybox libcutils libselinux libmincrypt
+LOCAL_PACK_MODULE_RELOCATIONS := false
+LOCAL_STATIC_LIBRARIES := libc libtoybox libcutils libselinux libcrypto_static liblog
 LOCAL_FORCE_STATIC_EXECUTABLE := true
 include $(BUILD_EXECUTABLE)