1# Makefile for toybox.
2# Copyright 2006 Rob Landley <rob@landley.net>
3
4# If people set these on the make command line, use 'em
5# Note that CC defaults to "cc" so the one in configure doesn't get
6# used when scripts/make.sh and care called through "make".
7
8HOSTCC?=cc
9
10export CROSS_COMPILE CFLAGS OPTIMIZE LDOPTIMIZE CC HOSTCC V STRIP
11
12all: toybox
13
14KCONFIG_CONFIG ?= .config
15
16toybox generated/unstripped/toybox: $(KCONFIG_CONFIG) *.[ch] lib/*.[ch] toys/*/*.c scripts/*.sh Config.in
17	scripts/make.sh
18
19.PHONY: clean distclean baseline bloatcheck install install_flat \
20	uninstall uninstall_flat tests help change \
21	list list_working list_pending root run_root
22
23include kconfig/Makefile
24-include .singlemake
25
26$(KCONFIG_CONFIG): $(KCONFIG_TOP)
27	@if [ -e "$(KCONFIG_CONFIG)" ]; then make silentoldconfig; \
28	else echo "Not configured (run 'make defconfig' or 'make menuconfig')";\
29	exit 1; fi
30
31$(KCONFIG_TOP): generated/Config.in generated/Config.probed
32generated/Config.probed: generated/Config.in
33generated/Config.in: toys/*/*.c scripts/genconfig.sh
34	scripts/genconfig.sh
35
36# Development targets
37baseline: generated/unstripped/toybox
38	@cp generated/unstripped/toybox generated/unstripped/toybox_old
39
40bloatcheck: generated/unstripped/toybox_old generated/unstripped/toybox
41	@scripts/bloatcheck generated/unstripped/toybox_old generated/unstripped/toybox
42
43install_flat:
44	scripts/install.sh --symlink --force
45
46install_airlock:
47	scripts/install.sh --symlink --force --airlock
48
49install:
50	scripts/install.sh --long --symlink --force
51
52uninstall_flat:
53	scripts/install.sh --uninstall
54
55uninstall:
56	scripts/install.sh --long --uninstall
57
58change:
59	scripts/change.sh
60
61root_clean:
62	@rm -rf root
63	@echo root cleaned
64
65clean::
66	@chmod -fR 700 generated || true
67	@rm -rf toybox generated change .singleconfig*
68	@echo cleaned
69
70# If singlemake was in generated/ "make clean; make test_ls" wouldn't work.
71distclean: clean root_clean
72	@rm -f toybox* .config* .singlemake
73	@echo removed .config
74
75tests:
76	scripts/test.sh
77
78root:
79	scripts/mkroot.sh $(MAKEFLAGS)
80
81run_root:
82	cd root/"$${CROSS:-host}" && ./qemu-*.sh
83
84help::
85	@cat scripts/help.txt
86