2006-11-01 19:26:25 -08:00
|
|
|
# Makefile for toybox.
|
|
|
|
# Copyright 2006 Rob Landley <rob@landley.net>
|
2006-09-28 14:18:51 -07:00
|
|
|
|
2007-09-04 21:02:58 -07:00
|
|
|
CFLAGS := $(CFLAGS) -Wall -Wundef -Wno-char-subscripts
|
2007-05-29 13:26:47 -07:00
|
|
|
CCFLAGS = $(CFLAGS) -funsigned-char
|
2007-09-04 21:02:58 -07:00
|
|
|
OPTIMIZE = -Os -ffunction-sections -fdata-sections -Wl,--gc-sections
|
2007-05-29 13:26:47 -07:00
|
|
|
CC = $(CROSS_COMPILE)gcc
|
2006-11-26 15:47:14 -08:00
|
|
|
STRIP = $(CROSS_COMPILE)strip
|
2007-05-29 13:26:47 -07:00
|
|
|
HOSTCC = gcc
|
2006-11-01 19:26:25 -08:00
|
|
|
|
2007-06-07 12:19:00 -07:00
|
|
|
# A synonym.
|
|
|
|
CROSS_COMPILE = $(CROSS)
|
|
|
|
|
2006-11-01 19:26:25 -08:00
|
|
|
all: toybox
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
include kconfig/Makefile
|
|
|
|
|
2007-01-31 11:37:01 -08:00
|
|
|
# defconfig is the "maximum sane config"; allyesconfig minus debugging and such.
|
2007-06-17 22:09:00 -07:00
|
|
|
#defconfig: allyesconfig
|
|
|
|
# @sed -i -r -e "s/^(CONFIG_TOYBOX_(DEBUG|FREE))=.*/# \1 is not set/" .config
|
2007-01-31 11:37:01 -08:00
|
|
|
|
2006-11-02 16:50:02 -08:00
|
|
|
.config: Config.in toys/Config.in
|
|
|
|
|
2006-11-01 19:26:25 -08:00
|
|
|
# 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' $< > $@
|
|
|
|
|
2006-11-26 15:47:14 -08:00
|
|
|
# Development targets
|
|
|
|
baseline: toybox_unstripped
|
|
|
|
@cp toybox_unstripped toybox_old
|
|
|
|
|
|
|
|
bloatcheck: toybox_old toybox_unstripped
|
|
|
|
@scripts/bloat-o-meter toybox_old toybox_unstripped
|
|
|
|
|
2007-06-17 22:09:00 -07:00
|
|
|
# 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@')
|
2006-11-01 19:26:25 -08:00
|
|
|
|
2007-11-25 08:54:29 -08:00
|
|
|
toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h toys/help.h toys/*.h lib/*.h toys.h
|
2007-09-04 21:02:58 -07:00
|
|
|
$(CC) $(CCFLAGS) -I . $(toyfiles) -o toybox_unstripped $(OPTIMIZE)
|
2006-11-01 19:26:25 -08:00
|
|
|
|
2006-11-26 15:47:14 -08:00
|
|
|
toybox: toybox_unstripped
|
|
|
|
$(STRIP) toybox_unstripped -o toybox
|
2007-01-31 11:18:05 -08:00
|
|
|
|
2007-08-29 06:10:01 -07:00
|
|
|
toys/help.c: toys/help.h
|
|
|
|
|
|
|
|
toys/help.h: Config.in toys/Config.in scripts/config2help.py
|
|
|
|
scripts/config2help.py Config.in > toys/help.h
|
|
|
|
|
2007-01-31 11:18:05 -08:00
|
|
|
instlist: toybox
|
2007-05-29 13:26:47 -07:00
|
|
|
$(HOSTCC) $(CCFLAGS) -I . scripts/install.c -o instlist
|
2007-01-31 11:18:05 -08:00
|
|
|
|
|
|
|
install_flat: instlist
|
|
|
|
@mkdir -p $(PREFIX)/
|
|
|
|
@cp toybox $(PREFIX)/
|
|
|
|
@for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done
|
|
|
|
|
2006-11-01 19:26:25 -08:00
|
|
|
clean::
|
2007-11-05 22:35:26 -08:00
|
|
|
rm -f toybox toybox_unstripped gen_config.h instlist
|
2006-11-01 19:26:25 -08:00
|
|
|
|
|
|
|
distclean: clean
|
2007-11-12 17:24:52 -08:00
|
|
|
rm -f toybox_old .config* toys/help.h
|
2006-11-26 15:47:14 -08:00
|
|
|
|
2007-06-17 22:09:00 -07:00
|
|
|
test: tests
|
|
|
|
|
|
|
|
tests:
|
|
|
|
scripts/testall.sh
|
|
|
|
|
2006-11-26 15:47:14 -08:00
|
|
|
help::
|
|
|
|
@echo ' baseline - Create busybox_old for use by bloatcheck.'
|
|
|
|
@echo ' bloatcheck - Report size differences between old and current versions'
|