xref: /aosp_15_r20/external/toybox/Makefile (revision cf5a6c84e2b8763fc1a7db14496fd4742913b199)
1# Makefile for toybox.
2# Copyright 2006 Rob Landley <[email protected]>
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 such called through "make".
7
8HOSTCC?=cc
9
10export CROSS_COMPILE CFLAGS OPTIMIZE LDOPTIMIZE CC HOSTCC V STRIP ASAN
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_example list_pending root run_root
22.SUFFIXES: # Disable legacy behavior
23
24include kconfig/Makefile
25-include .singlemake
26
27$(KCONFIG_CONFIG): $(KCONFIG_TOP)
28	@if [ -e "$(KCONFIG_CONFIG)" ]; then $(MAKE) silentoldconfig; \
29	else echo "Not configured (run '$(MAKE) defconfig' or '$(MAKE) menuconfig')";\
30	exit 1; fi
31
32$(KCONFIG_TOP): generated/Config.in generated/Config.probed
33generated/Config.probed: generated/Config.in
34generated/Config.in: toys/*/*.c scripts/genconfig.sh
35	scripts/genconfig.sh
36
37# Development targets
38baseline: generated/unstripped/toybox
39	@cp generated/unstripped/toybox generated/unstripped/toybox_old
40
41bloatcheck: generated/unstripped/toybox_old generated/unstripped/toybox
42	@scripts/probes/bloatcheck generated/unstripped/toybox_old generated/unstripped/toybox
43
44install_flat: toybox
45	scripts/install.sh --symlink --force
46
47install_airlock: toybox
48	scripts/install.sh --symlink --force --airlock
49
50install: toybox
51	scripts/install.sh --long --symlink --force
52
53uninstall_flat:
54	scripts/install.sh --uninstall
55
56uninstall:
57	scripts/install.sh --long --uninstall
58
59change:
60	scripts/change.sh
61
62root_clean:
63	@rm -rf root
64	@echo root cleaned
65
66clean::
67	@chmod -fR 700 generated 2>/dev/null || true
68	@rm -rf toybox generated change install .singleconfig*
69	@echo cleaned
70
71# If singlemake was in generated/ "make clean; make test_ls" wouldn't work.
72distclean: clean root_clean
73	@rm -f toybox* .config* .singlemake
74	@echo removed .config
75
76tests: ASAN=1
77tests: toybox
78	scripts/test.sh
79
80root:
81	mkroot/mkroot.sh $(MAKEFLAGS)
82
83run_root:
84	cd root/"$${CROSS:-host}" && ./run-qemu.sh
85
86help::
87	@cat scripts/help.txt
88