Rob Landley | 401ae8f | 2006-11-01 22:26:25 -0500 | [diff] [blame^] | 1 | # Makefile for toybox. |
| 2 | # Copyright 2006 Rob Landley <rob@landley.net> |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 3 | |
Rob Landley | 401ae8f | 2006-11-01 22:26:25 -0500 | [diff] [blame^] | 4 | CFLAGS = -Wall -Os -s |
| 5 | CC = $(CROSS_COMPILE)gcc $(CFLAGS) |
| 6 | HOST_CC = gcc $(CFLAGS) |
| 7 | |
| 8 | all: toybox |
| 9 | |
| 10 | .PHONY: clean |
| 11 | |
| 12 | include kconfig/Makefile |
| 13 | |
| 14 | # The long and roundabout sed is to make old versions of sed happy. New ones |
| 15 | # have '\n' so can replace one line with two without all the branches and |
| 16 | # mucking about with hold space. |
| 17 | gen_config.h: .config |
| 18 | sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \ |
| 19 | -e 't notset' -e 'b tryisset' -e ':notset' \ |
| 20 | -e 'h' -e 's/.*/#define CFG_& 0/p' \ |
| 21 | -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \ |
| 22 | -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \ |
| 23 | -e 'h' -e 's/.*/#define CFG_& 1/p' \ |
| 24 | -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' $< > $@ |
| 25 | |
| 26 | # Actual build |
| 27 | |
| 28 | toyfiles = main.c toys/*.c lib/*.c |
| 29 | toybox: gen_config.h $(toyfiles) |
| 30 | $(CC) -Wall -Os -s -funsigned-char $(CFLAGS) -I . \ |
| 31 | $(toyfiles) -o toybox |
| 32 | |
| 33 | clean:: |
| 34 | rm -f toybox gen_config.h |
| 35 | |
| 36 | distclean: clean |
| 37 | rm -f .config |