blob: 7c7dd087a78777e8f19aa806c2ee944886ceb4c1 [file] [log] [blame]
Rob Landley401ae8f2006-11-01 22:26:25 -05001# Makefile for toybox.
2# Copyright 2006 Rob Landley <rob@landley.net>
landleyc5621502006-09-28 17:18:51 -04003
Rob Landley401ae8f2006-11-01 22:26:25 -05004CFLAGS = -Wall -Os -s
5CC = $(CROSS_COMPILE)gcc $(CFLAGS)
6HOST_CC = gcc $(CFLAGS)
7
8all: toybox
9
10.PHONY: clean
11
12include 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.
17gen_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
28toyfiles = main.c toys/*.c lib/*.c
29toybox: gen_config.h $(toyfiles)
30 $(CC) -Wall -Os -s -funsigned-char $(CFLAGS) -I . \
31 $(toyfiles) -o toybox
32
33clean::
34 rm -f toybox gen_config.h
35
36distclean: clean
37 rm -f .config