Home | History | Annotate | Download | only in toybox
      1 #
      2 # Copyright (C) 2014 The Android Open Source Project
      3 #
      4 # Licensed under the Apache License, Version 2.0 (the "License");
      5 # you may not use this file except in compliance with the License.
      6 # You may obtain a copy of the License at
      7 #
      8 #      http://www.apache.org/licenses/LICENSE-2.0
      9 #
     10 # Unless required by applicable law or agreed to in writing, software
     11 # distributed under the License is distributed on an "AS IS" BASIS,
     12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     15 #
     16 
     17 LOCAL_PATH := $(call my-dir)
     18 
     19 #
     20 # To update:
     21 #
     22 
     23 #  git remote add toybox https://github.com/landley/toybox.git
     24 #  git fetch toybox
     25 #  git merge toybox/master
     26 #  mm -j32
     27 #  # (Make any necessary Android.mk changes and test the new toybox.)
     28 #  repo upload .
     29 #  git push aosp HEAD:refs/for/master  # Push to gerrit for review.
     30 #  git push aosp HEAD:master  # Push directly, avoiding gerrit.
     31 #
     32 #  # Now commit any necessary Android.mk changes like normal:
     33 #  repo start post-sync .
     34 #  git commit -a
     35 
     36 
     37 #
     38 # To add a toy:
     39 #
     40 
     41 #  Edit .config to enable the toy you want to add.
     42 #  make clean && make  # Regenerate the generated files.
     43 #  # Edit LOCAL_SRC_FILES below to add the toy.
     44 #  # If you just want to use it as "toybox x" rather than "x", you can stop now.
     45 #  # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
     46 
     47 common_SRC_FILES := \
     48     lib/args.c \
     49     lib/dirtree.c \
     50     lib/getmountlist.c \
     51     lib/help.c \
     52     lib/interestingtimes.c \
     53     lib/lib.c \
     54     lib/linestack.c \
     55     lib/llist.c \
     56     lib/net.c \
     57     lib/portability.c \
     58     lib/xwrap.c \
     59     main.c \
     60     toys/android/getenforce.c \
     61     toys/android/getprop.c \
     62     toys/android/load_policy.c \
     63     toys/android/log.c \
     64     toys/android/restorecon.c \
     65     toys/android/runcon.c \
     66     toys/android/sendevent.c \
     67     toys/android/setenforce.c \
     68     toys/android/setprop.c \
     69     toys/android/start.c \
     70     toys/lsb/hostname.c \
     71     toys/lsb/killall.c \
     72     toys/lsb/md5sum.c \
     73     toys/lsb/mknod.c \
     74     toys/lsb/mktemp.c \
     75     toys/lsb/mount.c \
     76     toys/lsb/pidof.c \
     77     toys/lsb/seq.c \
     78     toys/lsb/sync.c \
     79     toys/lsb/umount.c \
     80     toys/net/ifconfig.c \
     81     toys/net/microcom.c \
     82     toys/net/netcat.c \
     83     toys/net/netstat.c \
     84     toys/net/rfkill.c \
     85     toys/net/tunctl.c \
     86     toys/other/acpi.c \
     87     toys/other/base64.c \
     88     toys/other/blkid.c \
     89     toys/other/blockdev.c \
     90     toys/other/chcon.c \
     91     toys/other/chroot.c \
     92     toys/other/clear.c \
     93     toys/other/dos2unix.c \
     94     toys/other/fallocate.c \
     95     toys/other/flock.c \
     96     toys/other/free.c \
     97     toys/other/freeramdisk.c \
     98     toys/other/fsfreeze.c \
     99     toys/other/help.c \
    100     toys/other/hwclock.c \
    101     toys/other/inotifyd.c \
    102     toys/other/insmod.c \
    103     toys/other/ionice.c \
    104     toys/other/losetup.c \
    105     toys/other/lsattr.c \
    106     toys/other/lsmod.c \
    107     toys/other/lsusb.c \
    108     toys/other/makedevs.c \
    109     toys/other/mkswap.c \
    110     toys/other/modinfo.c \
    111     toys/other/mountpoint.c \
    112     toys/other/nbd_client.c \
    113     toys/other/partprobe.c \
    114     toys/other/pivot_root.c \
    115     toys/other/pmap.c \
    116     toys/other/printenv.c \
    117     toys/other/pwdx.c \
    118     toys/other/readlink.c \
    119     toys/other/realpath.c \
    120     toys/other/rev.c \
    121     toys/other/rmmod.c \
    122     toys/other/setsid.c \
    123     toys/other/stat.c \
    124     toys/other/swapoff.c \
    125     toys/other/swapon.c \
    126     toys/other/sysctl.c \
    127     toys/other/tac.c \
    128     toys/other/taskset.c \
    129     toys/other/timeout.c \
    130     toys/other/truncate.c \
    131     toys/other/uptime.c \
    132     toys/other/usleep.c \
    133     toys/other/vconfig.c \
    134     toys/other/vmstat.c \
    135     toys/other/which.c \
    136     toys/other/xxd.c \
    137     toys/other/yes.c \
    138     toys/pending/chrt.c \
    139     toys/pending/dd.c \
    140     toys/pending/dmesg.c \
    141     toys/pending/expr.c \
    142     toys/pending/getfattr.c \
    143     toys/pending/lsof.c \
    144     toys/pending/modprobe.c \
    145     toys/pending/more.c \
    146     toys/pending/setfattr.c \
    147     toys/pending/tar.c \
    148     toys/pending/tr.c \
    149     toys/pending/traceroute.c \
    150     toys/posix/basename.c \
    151     toys/posix/cal.c \
    152     toys/posix/cat.c \
    153     toys/posix/chgrp.c \
    154     toys/posix/chmod.c \
    155     toys/posix/cksum.c \
    156     toys/posix/cmp.c \
    157     toys/posix/comm.c \
    158     toys/posix/cp.c \
    159     toys/posix/cpio.c \
    160     toys/posix/cut.c \
    161     toys/posix/date.c \
    162     toys/posix/df.c \
    163     toys/posix/dirname.c \
    164     toys/posix/du.c \
    165     toys/posix/echo.c \
    166     toys/posix/env.c \
    167     toys/posix/expand.c \
    168     toys/posix/false.c \
    169     toys/posix/file.c \
    170     toys/posix/find.c \
    171     toys/posix/grep.c \
    172     toys/posix/head.c \
    173     toys/posix/id.c \
    174     toys/posix/kill.c \
    175     toys/posix/ln.c \
    176     toys/posix/ls.c \
    177     toys/posix/mkdir.c \
    178     toys/posix/mkfifo.c \
    179     toys/posix/nice.c \
    180     toys/posix/nl.c \
    181     toys/posix/nohup.c \
    182     toys/posix/od.c \
    183     toys/posix/paste.c \
    184     toys/posix/patch.c \
    185     toys/posix/printf.c \
    186     toys/posix/ps.c \
    187     toys/posix/pwd.c \
    188     toys/posix/renice.c \
    189     toys/posix/rm.c \
    190     toys/posix/rmdir.c \
    191     toys/posix/sed.c \
    192     toys/posix/sleep.c \
    193     toys/posix/sort.c \
    194     toys/posix/split.c \
    195     toys/posix/strings.c \
    196     toys/posix/tail.c \
    197     toys/posix/tee.c \
    198     toys/posix/time.c \
    199     toys/posix/touch.c \
    200     toys/posix/true.c \
    201     toys/posix/tty.c \
    202     toys/posix/ulimit.c \
    203     toys/posix/uname.c \
    204     toys/posix/uniq.c \
    205     toys/posix/uudecode.c \
    206     toys/posix/uuencode.c \
    207     toys/posix/wc.c \
    208     toys/posix/xargs.c \
    209 
    210 common_CFLAGS := \
    211     -std=c99 \
    212     -Os \
    213     -Wno-char-subscripts \
    214     -Wno-sign-compare \
    215     -Wno-string-plus-int \
    216     -Wno-uninitialized \
    217     -Wno-unused-parameter \
    218     -funsigned-char \
    219     -ffunction-sections -fdata-sections \
    220     -fno-asynchronous-unwind-tables \
    221 
    222 toybox_upstream_version := $(shell awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary) {print ary[1]}' $(LOCAL_PATH)/main.c)
    223 toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
    224 
    225 toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
    226 
    227 common_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"'
    228 
    229 ############################################
    230 # toybox for /system
    231 include $(CLEAR_VARS)
    232 
    233 LOCAL_SRC_FILES := $(common_SRC_FILES)
    234 
    235 LOCAL_CFLAGS := $(common_CFLAGS)
    236 
    237 LOCAL_CLANG := true
    238 
    239 LOCAL_SHARED_LIBRARIES := liblog libcutils libselinux libcrypto
    240 
    241 # This doesn't actually prevent us from dragging in libc++ at runtime
    242 # because libnetd_client.so is C++.
    243 LOCAL_CXX_STL := none
    244 
    245 LOCAL_MODULE := toybox
    246 
    247 # dupes: dd
    248 # useless?: freeramdisk fsfreeze install makedevs mkfifo nbd-client
    249 #           partprobe pivot_root pwdx rev rfkill vconfig
    250 # prefer BSD netcat instead?: nc netcat
    251 # prefer efs2progs instead?: blkid chattr lsattr
    252 
    253 ALL_TOOLS := \
    254     acpi \
    255     base64 \
    256     basename \
    257     blockdev \
    258     cal \
    259     cat \
    260     chcon \
    261     chgrp \
    262     chmod \
    263     chown \
    264     chroot \
    265     chrt \
    266     cksum \
    267     clear \
    268     comm \
    269     cmp \
    270     cp \
    271     cpio \
    272     cut \
    273     date \
    274     df \
    275     dirname \
    276     dmesg \
    277     dos2unix \
    278     du \
    279     echo \
    280     env \
    281     expand \
    282     expr \
    283     fallocate \
    284     false \
    285     file \
    286     find \
    287     flock \
    288     free \
    289     getenforce \
    290     getprop \
    291     groups \
    292     head \
    293     hostname \
    294     hwclock \
    295     id \
    296     ifconfig \
    297     inotifyd \
    298     insmod \
    299     ionice \
    300     iorenice \
    301     kill \
    302     killall \
    303     load_policy \
    304     ln \
    305     log \
    306     logname \
    307     losetup \
    308     ls \
    309     lsmod \
    310     lsof \
    311     lsusb \
    312     md5sum \
    313     mkdir \
    314     mknod \
    315     mkswap \
    316     mktemp \
    317     microcom \
    318     modinfo \
    319     modprobe \
    320     more \
    321     mount \
    322     mountpoint \
    323     mv \
    324     netstat \
    325     nice \
    326     nl \
    327     nohup \
    328     od \
    329     paste \
    330     patch \
    331     pgrep \
    332     pidof \
    333     pkill \
    334     pmap \
    335     printenv \
    336     printf \
    337     ps \
    338     pwd \
    339     readlink \
    340     realpath \
    341     renice \
    342     restorecon \
    343     rm \
    344     rmdir \
    345     rmmod \
    346     runcon \
    347     sed \
    348     sendevent \
    349     seq \
    350     setenforce \
    351     setprop \
    352     setsid \
    353     sha1sum \
    354     sha224sum \
    355     sha256sum \
    356     sha384sum \
    357     sha512sum \
    358     sleep \
    359     sort \
    360     split \
    361     start \
    362     stat \
    363     stop \
    364     strings \
    365     swapoff \
    366     swapon \
    367     sync \
    368     sysctl \
    369     tac \
    370     tail \
    371     tar \
    372     taskset \
    373     tee \
    374     time \
    375     timeout \
    376     top \
    377     touch \
    378     tr \
    379     true \
    380     truncate \
    381     tty \
    382     ulimit \
    383     umount \
    384     uname \
    385     uniq \
    386     unix2dos \
    387     uptime \
    388     usleep \
    389     uudecode \
    390     uuencode \
    391     vmstat \
    392     wc \
    393     which \
    394     whoami \
    395     xargs \
    396     xxd \
    397     yes \
    398 
    399 # Install the symlinks.
    400 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
    401 
    402 include $(BUILD_EXECUTABLE)
    403 
    404 ifeq ($(PRODUCT_FULL_TREBLE),true)
    405 ############################################
    406 # static version to be installed in /vendor
    407 #
    408 include $(CLEAR_VARS)
    409 
    410 LOCAL_SRC_FILES := $(common_SRC_FILES)
    411 
    412 LOCAL_CFLAGS := $(common_CFLAGS)
    413 
    414 LOCAL_CLANG := true
    415 
    416 LOCAL_STATIC_LIBRARIES := liblog libcutils libselinux libcrypto libm libc
    417 
    418 # libc++_static is needed by static liblog
    419 LOCAL_CXX_STL := libc++_static
    420 
    421 LOCAL_VENDOR_MODULE := true
    422 
    423 LOCAL_MODULE := toybox_vendor
    424 
    425 LOCAL_MODULE_TAGS := optional
    426 
    427 LOCAL_FORCE_STATIC_EXECUTABLE := true
    428 
    429 # Install the symlinks.
    430 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(TARGET_OUT_VENDOR_EXECUTABLES)/$(t);)
    431 
    432 include $(BUILD_EXECUTABLE)
    433 endif
    434 
    435 ############################################
    436 # static version to be installed in recovery
    437 
    438 include $(CLEAR_VARS)
    439 
    440 LOCAL_SRC_FILES := $(common_SRC_FILES)
    441 
    442 LOCAL_CFLAGS := $(common_CFLAGS)
    443 
    444 LOCAL_CLANG := true
    445 
    446 LOCAL_STATIC_LIBRARIES := liblog libcutils libselinux libcrypto libm libc
    447 
    448 # libc++_static is needed by static liblog
    449 LOCAL_CXX_STL := libc++_static
    450 
    451 LOCAL_MODULE := toybox_static
    452 
    453 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
    454 
    455 LOCAL_FORCE_STATIC_EXECUTABLE := true
    456 
    457 ALL_TOOLS := \
    458     modprobe \
    459 
    460 # Install the symlinks.
    461 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);)
    462 
    463 include $(BUILD_EXECUTABLE)
    464