Home | History | Annotate | Download | only in toolbox
      1 LOCAL_PATH:= $(call my-dir)
      2 
      3 
      4 common_cflags := \
      5     -Werror -Wno-unused-parameter -Wno-unused-const-variable \
      6     -I$(LOCAL_PATH)/upstream-netbsd/include/ \
      7     -include bsd-compatibility.h \
      8 
      9 
     10 include $(CLEAR_VARS)
     11 LOCAL_SRC_FILES := \
     12     upstream-netbsd/bin/dd/args.c \
     13     upstream-netbsd/bin/dd/conv.c \
     14     upstream-netbsd/bin/dd/dd.c \
     15     upstream-netbsd/bin/dd/dd_hostops.c \
     16     upstream-netbsd/bin/dd/misc.c \
     17     upstream-netbsd/bin/dd/position.c \
     18     upstream-netbsd/lib/libc/gen/getbsize.c \
     19     upstream-netbsd/lib/libc/gen/humanize_number.c \
     20     upstream-netbsd/lib/libc/stdlib/strsuftoll.c \
     21     upstream-netbsd/lib/libc/string/swab.c \
     22     upstream-netbsd/lib/libutil/raise_default_signal.c
     23 LOCAL_CFLAGS += $(common_cflags) -Dmain=dd_main -DNO_CONV
     24 LOCAL_MODULE := libtoolbox_dd
     25 include $(BUILD_STATIC_LIBRARY)
     26 
     27 
     28 include $(CLEAR_VARS)
     29 
     30 BSD_TOOLS := \
     31     dd \
     32 
     33 OUR_TOOLS := \
     34     getevent \
     35     iftop \
     36     ioctl \
     37     log \
     38     nandread \
     39     newfs_msdos \
     40     ps \
     41     prlimit \
     42     sendevent \
     43     start \
     44     stop \
     45     top \
     46 
     47 ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS)
     48 
     49 LOCAL_SRC_FILES := \
     50     start_stop.cpp \
     51     toolbox.c \
     52     $(patsubst %,%.c,$(OUR_TOOLS)) \
     53 
     54 LOCAL_CFLAGS += $(common_cflags)
     55 LOCAL_CONLYFLAGS += -std=gnu99
     56 
     57 LOCAL_SHARED_LIBRARIES := \
     58     libcutils \
     59     libselinux \
     60 
     61 LOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS))
     62 
     63 LOCAL_MODULE := toolbox
     64 
     65 # Install the symlinks.
     66 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toolbox $(TARGET_OUT)/bin/$(t);)
     67 
     68 # Including this will define $(intermediates).
     69 #
     70 include $(BUILD_EXECUTABLE)
     71 
     72 $(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
     73 
     74 TOOLS_H := $(intermediates)/tools.h
     75 $(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
     76 $(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
     77 $(TOOLS_H): $(LOCAL_PATH)/Android.mk
     78 $(TOOLS_H):
     79 	$(transform-generated-source)
     80 
     81 $(LOCAL_PATH)/getevent.c: $(intermediates)/input.h-labels.h
     82 
     83 UAPI_INPUT_EVENT_CODES_H := bionic/libc/kernel/uapi/linux/input-event-codes.h
     84 INPUT_H_LABELS_H := $(intermediates)/input.h-labels.h
     85 $(INPUT_H_LABELS_H): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
     86 # The PRIVATE_CUSTOM_TOOL line uses = to evaluate the output path late.
     87 # We copy the input path so it can't be accidentally modified later.
     88 $(INPUT_H_LABELS_H): PRIVATE_UAPI_INPUT_EVENT_CODES_H := $(UAPI_INPUT_EVENT_CODES_H)
     89 $(INPUT_H_LABELS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/generate-input.h-labels.py $(PRIVATE_UAPI_INPUT_EVENT_CODES_H) > $@
     90 # The dependency line though gets evaluated now, so the PRIVATE_ copy doesn't exist yet,
     91 # and the original can't yet have been modified, so this is both sufficient and necessary.
     92 $(INPUT_H_LABELS_H): $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/generate-input.h-labels.py $(UAPI_INPUT_EVENT_CODES_H)
     93 $(INPUT_H_LABELS_H):
     94 	$(transform-generated-source)
     95 
     96 # We only want 'r' on userdebug and eng builds.
     97 include $(CLEAR_VARS)
     98 LOCAL_SRC_FILES := r.c
     99 LOCAL_CFLAGS += $(common_cflags)
    100 LOCAL_MODULE := r
    101 LOCAL_MODULE_TAGS := debug
    102 include $(BUILD_EXECUTABLE)
    103 
    104 
    105 # We build BSD grep separately, so it can provide egrep and fgrep too.
    106 include $(CLEAR_VARS)
    107 LOCAL_SRC_FILES := \
    108     upstream-netbsd/usr.bin/grep/fastgrep.c \
    109     upstream-netbsd/usr.bin/grep/file.c \
    110     upstream-netbsd/usr.bin/grep/grep.c \
    111     upstream-netbsd/usr.bin/grep/queue.c \
    112     upstream-netbsd/usr.bin/grep/util.c
    113 LOCAL_CFLAGS += $(common_cflags)
    114 LOCAL_MODULE := grep
    115 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,egrep fgrep,ln -sf grep $(TARGET_OUT)/bin/$(t);)
    116 include $(BUILD_EXECUTABLE)
    117