OSDN Git Service

Switch to toybox sendevent.
[android-x86/external-toybox.git] / Makefile
index 9e74187..711d624 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,53 +1,84 @@
 # Makefile for toybox.
 # Copyright 2006 Rob Landley <rob@landley.net>
 
-CFLAGS  = -Wall -Wundef -Os
-CC      = $(CROSS_COMPILE)gcc $(CFLAGS) -funsigned-char
-STRIP   = $(CROSS_COMPILE)strip
-HOST_CC = gcc $(CFLAGS) -funsigned-char
+# If people set these on the make command line, use 'em
+# Note that CC defaults to "cc" so the one in configure doesn't get
+# used when scripts/make.sh and care called through "make".
+
+HOSTCC?=cc
+
+export CROSS_COMPILE CFLAGS OPTIMIZE LDOPTIMIZE CC HOSTCC V
 
 all: toybox
 
-.PHONY: clean
+KCONFIG_CONFIG ?= .config
 
-include kconfig/Makefile
+toybox_stuff: $(KCONFIG_CONFIG) *.[ch] lib/*.[ch] toys/*.h toys/*/*.c scripts/*.sh
+
+toybox generated/unstripped/toybox: toybox_stuff
+       scripts/make.sh
+
+.PHONY: clean distclean baseline bloatcheck install install_flat \
+       uinstall uninstall_flat tests help toybox_stuff change \
+       list list_working list_pending
 
-.config: Config.in toys/Config.in
+include kconfig/Makefile
+-include .singlemake
 
-# The long and roundabout sed is to make old versions of sed happy.  New ones
-# have '\n' so can replace one line with two without all the branches and
-# mucking about with hold space.
-gen_config.h: .config
-       sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \
-         -e 't notset' -e 'b tryisset' -e ':notset' \
-         -e 'h' -e 's/.*/#define CFG_& 0/p' \
-         -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \
-         -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \
-         -e 'h' -e 's/.*/#define CFG_& 1/p' \
-         -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' $< > $@
+$(KCONFIG_CONFIG): $(KCONFIG_TOP)
+$(KCONFIG_TOP): generated/Config.in
+generated/Config.in: toys/*/*.c scripts/genconfig.sh
+       scripts/genconfig.sh
 
 # Development targets
-baseline: toybox_unstripped
-       @cp toybox_unstripped toybox_old
+baseline: generated/unstripped/toybox
+       @cp generated/unstripped/toybox generated/unstripped/toybox_old
+
+bloatcheck: toybox_old generated/unstripped/toybox
+       @scripts/bloatcheck generated/unstripped/toybox_old generated/unstripped/toybox
+
+install_flat:
+       scripts/install.sh --symlink --force
 
-bloatcheck: toybox_old toybox_unstripped
-       @scripts/bloat-o-meter toybox_old toybox_unstripped
+install:
+       scripts/install.sh --long --symlink --force
 
-# Actual build
+uninstall_flat:
+       scripts/install.sh --uninstall
 
-toyfiles = main.c toys/*.c lib/*.c
-toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h lib/lib.h toys.h
-       $(CC) $(CFLAGS) -I . $(toyfiles) -o toybox_unstripped \
-               -ffunction-sections -fdata-sections -Wl,--gc-sections
+uninstall:
+       scripts/install.sh --long --uninstall
+
+change:
+       scripts/change.sh
 
-toybox: toybox_unstripped
-       $(STRIP) toybox_unstripped -o toybox
 clean::
-       rm -f toybox gen_config.h
+       rm -rf toybox generated change .singleconfig*
 
 distclean: clean
-       rm -f .config
+       rm -f toybox_old .config* .singlemake
+
+tests:
+       scripts/test.sh
 
 help::
-       @echo  '  baseline        - Create busybox_old for use by bloatcheck.'
+       @echo  '  toybox          - Build toybox.'
+       @echo  '  COMMANDNAME     - Build individual toybox command as a standalone binary.'
+       @echo  '  list            - List COMMANDNAMEs you can build standalone.'
+       @echo  '  list_pending    - List unfinished COMMANDNAMEs out of toys/pending.'
+       @echo  '  change          - Build each command standalone under change/.'
+       @echo  '  baseline        - Create toybox_old for use by bloatcheck.'
        @echo  '  bloatcheck      - Report size differences between old and current versions'
+       @echo  '  test_COMMAND    - Run tests for COMMAND (test_ps, test_cat, etc.)'
+       @echo  '  tests           - Run test suite against all compiled commands.'
+       @echo  '                    export TEST_HOST=1 to test host command, VERBOSE=1'
+       @echo  '                    to show diff, VERBOSE=fail to stop after first failure.'
+       @echo  '  clean           - Delete temporary files.'
+       @echo  "  distclean       - Delete everything that isn't shipped."
+       @echo  '  install_flat    - Install toybox into $$PREFIX directory.'
+       @echo  '  install         - Install toybox into subdirectories of $$PREFIX.'
+       @echo  '  uninstall_flat  - Remove toybox from $$PREFIX directory.'
+       @echo  '  uninstall       - Remove toybox from subdirectories of $$PREFIX.'
+       @echo  ''
+       @echo  'example: CFLAGS="--static" CROSS_COMPILE=armv5l- make defconfig toybox install'
+       @echo  ''