Makefile revision bcfad872188d993efc8d1da4b79058b69e43f019
1# Makefile for toybox. 2# Copyright 2006 Rob Landley <rob@landley.net> 3 4CFLAGS = -Wall -Wundef -Wno-char-subscripts -Os 5CC = $(CROSS_COMPILE)gcc $(CFLAGS) -funsigned-char 6STRIP = $(CROSS_COMPILE)strip 7HOST_CC = gcc $(CFLAGS) -funsigned-char 8 9all: toybox 10 11.PHONY: clean 12 13include kconfig/Makefile 14 15.config: Config.in toys/Config.in 16 17# The long and roundabout sed is to make old versions of sed happy. New ones 18# have '\n' so can replace one line with two without all the branches and 19# mucking about with hold space. 20gen_config.h: .config 21 sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \ 22 -e 't notset' -e 'b tryisset' -e ':notset' \ 23 -e 'h' -e 's/.*/#define CFG_& 0/p' \ 24 -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \ 25 -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \ 26 -e 'h' -e 's/.*/#define CFG_& 1/p' \ 27 -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' $< > $@ 28 29# Development targets 30baseline: toybox_unstripped 31 @cp toybox_unstripped toybox_old 32 33bloatcheck: toybox_old toybox_unstripped 34 @scripts/bloat-o-meter toybox_old toybox_unstripped 35 36# Actual build 37 38toyfiles = main.c toys/*.c lib/*.c 39toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h lib/lib.h toys.h 40 $(CC) $(CFLAGS) -I . $(toyfiles) -o toybox_unstripped \ 41 -ffunction-sections -fdata-sections -Wl,--gc-sections #\ 42 #2>&1 | sed -n -e '/may be used uninitialized/{s/.*/\n/;h;b};1{x;b};: print;=;p;x;/\n/b thing;p;: thing;${x;p}' >&2 43 44toybox: toybox_unstripped 45 $(STRIP) toybox_unstripped -o toybox 46 47instlist: toybox 48 $(HOST_CC) -I . scripts/install.c -o instlist 49 50install_flat: instlist 51 @mkdir -p $(PREFIX)/ 52 @cp toybox $(PREFIX)/ 53 @for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done 54 55clean:: 56 rm -f toybox toybox_old toybox_unstripped gen_config.h instlist 57 58distclean: clean 59 rm -f .config* 60 61help:: 62 @echo ' baseline - Create busybox_old for use by bloatcheck.' 63 @echo ' bloatcheck - Report size differences between old and current versions' 64