OSDN Git Service

Don't close stdin when loopfiles reads "-".
[android-x86/external-toybox.git] / Makefile
index 2c797a4..711d624 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,81 +1,84 @@
 # Makefile for toybox.
 # Copyright 2006 Rob Landley <rob@landley.net>
 
-CFLAGS  := $(CFLAGS) -Wall -Wundef -Wno-char-subscripts
-CCFLAGS = $(CFLAGS) -funsigned-char
-OPTIMIZE = -Os -ffunction-sections -fdata-sections -Wl,--gc-sections
-CC      = $(CROSS_COMPILE)gcc
-STRIP   = $(CROSS_COMPILE)strip
-HOSTCC  = gcc
+# 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".
 
-# A synonym.
-CROSS_COMPILE = $(CROSS)
+HOSTCC?=cc
 
-all: toybox
+export CROSS_COMPILE CFLAGS OPTIMIZE LDOPTIMIZE CC HOSTCC V
 
-.PHONY: clean
+all: toybox
 
-include kconfig/Makefile
+KCONFIG_CONFIG ?= .config
 
-# defconfig is the "maximum sane config"; allyesconfig minus debugging and such.
-#defconfig: allyesconfig
-#      @sed -i -r -e "s/^(CONFIG_TOYBOX_(DEBUG|FREE))=.*/# \1 is not set/" .config
+toybox_stuff: $(KCONFIG_CONFIG) *.[ch] lib/*.[ch] toys/*.h toys/*/*.c scripts/*.sh
 
-.config: Config.in toys/Config.in
+toybox generated/unstripped/toybox: toybox_stuff
+       scripts/make.sh
 
-# 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' $< > $@
+.PHONY: clean distclean baseline bloatcheck install install_flat \
+       uinstall uninstall_flat tests help toybox_stuff change \
+       list list_working list_pending
 
-# Development targets
-baseline: toybox_unstripped
-       @cp toybox_unstripped toybox_old
+include kconfig/Makefile
+-include .singlemake
 
-bloatcheck: toybox_old toybox_unstripped
-       @scripts/bloat-o-meter toybox_old toybox_unstripped
+$(KCONFIG_CONFIG): $(KCONFIG_TOP)
+$(KCONFIG_TOP): generated/Config.in
+generated/Config.in: toys/*/*.c scripts/genconfig.sh
+       scripts/genconfig.sh
 
-# Get list of .c files to compile, including toys/*.c files from .config
-toyfiles = main.c lib/*.c \
-       $(shell scripts/cfg2files.sh < .config | sed 's@\(.*\)@toys/\1.c@')
+# Development targets
+baseline: generated/unstripped/toybox
+       @cp generated/unstripped/toybox generated/unstripped/toybox_old
 
-toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h toys/help.h lib/*.h toys.h
-       $(CC) $(CCFLAGS) -I . $(toyfiles) -o toybox_unstripped $(OPTIMIZE)
+bloatcheck: toybox_old generated/unstripped/toybox
+       @scripts/bloatcheck generated/unstripped/toybox_old generated/unstripped/toybox
 
-toybox: toybox_unstripped
-       $(STRIP) toybox_unstripped -o toybox
+install_flat:
+       scripts/install.sh --symlink --force
 
-toys/help.c: toys/help.h
+install:
+       scripts/install.sh --long --symlink --force
 
-toys/help.h: Config.in toys/Config.in scripts/config2help.py
-       scripts/config2help.py Config.in > toys/help.h
+uninstall_flat:
+       scripts/install.sh --uninstall
 
-instlist: toybox
-       $(HOSTCC) $(CCFLAGS) -I . scripts/install.c -o instlist
+uninstall:
+       scripts/install.sh --long --uninstall
 
-install_flat: instlist
-       @mkdir -p $(PREFIX)/
-       @cp toybox $(PREFIX)/
-       @for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done
+change:
+       scripts/change.sh
 
 clean::
-       rm -f toybox toybox_unstripped gen_config.h instlist
+       rm -rf toybox generated change .singleconfig*
 
 distclean: clean
-       rm -f toybox_old .config* toys/help.h
-
-test: tests
+       rm -f toybox_old .config* .singlemake
 
 tests:
-       scripts/testall.sh
+       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  ''