blob: 69d24870c408df6f2057afa13b2f1fd7ac485f4d [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 Landley5b39d5c2015-10-04 08:44:17 -05004# 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".
Rob Landley12235782015-10-05 20:47:49 -05007
8HOSTCC?=cc
9
Francesco Valla5efc1672018-06-02 16:09:22 +020010export CROSS_COMPILE CFLAGS OPTIMIZE LDOPTIMIZE CC HOSTCC V STRIP
Rob Landley5b39d5c2015-10-04 08:44:17 -050011
Rob Landley401ae8f2006-11-01 22:26:25 -050012all: toybox
13
Rob Landleyd04dc1f2013-08-30 01:53:31 -050014KCONFIG_CONFIG ?= .config
Rob Landley62390fd2014-11-28 16:49:46 -060015
Rob Landley48ac4c62018-03-23 19:39:02 -050016toybox_stuff: $(KCONFIG_CONFIG) *.[ch] lib/*.[ch] toys/*/*.c scripts/*.sh
Rob Landley62390fd2014-11-28 16:49:46 -060017
Rob Landleya8d0d132016-03-23 03:25:37 -050018toybox generated/unstripped/toybox: toybox_stuff
Rob Landley28964802008-01-19 17:08:39 -060019 scripts/make.sh
20
Rob Landleybf081b92008-03-28 00:40:57 -050021.PHONY: clean distclean baseline bloatcheck install install_flat \
Rob Landleya8d0d132016-03-23 03:25:37 -050022 uinstall uninstall_flat tests help toybox_stuff change \
Rob Landley0b3e7562019-08-22 14:34:45 -050023 list list_working list_pending root run_root
Rob Landley401ae8f2006-11-01 22:26:25 -050024
25include kconfig/Makefile
Rob Landley712e43e2016-02-07 18:15:53 -060026-include .singlemake
Rob Landley401ae8f2006-11-01 22:26:25 -050027
Rob Landley62390fd2014-11-28 16:49:46 -060028$(KCONFIG_CONFIG): $(KCONFIG_TOP)
Patrick Oppenlander656ad3c2019-08-02 16:35:16 +100029 @if [ -e "$(KCONFIG_CONFIG)" ]; then make silentoldconfig; \
Rob Landleyc9571602018-10-27 10:54:18 -050030 else echo "Not configured (run 'make defconfig' or 'make menuconfig')";\
31 exit 1; fi
32
33$(KCONFIG_TOP): generated/Config.in generated/Config.probed
Patrick Oppenlandere25a8472019-08-02 16:35:43 +100034generated/Config.probed: generated/Config.in
Rob Landley3a9241a2012-08-25 14:25:22 -050035generated/Config.in: toys/*/*.c scripts/genconfig.sh
Rob Landley28964802008-01-19 17:08:39 -060036 scripts/genconfig.sh
Rob Landleyde05a702007-01-31 14:37:01 -050037
Rob Landleycd2edfd2006-11-26 18:47:14 -050038# Development targets
Rob Landleya8d0d132016-03-23 03:25:37 -050039baseline: generated/unstripped/toybox
40 @cp generated/unstripped/toybox generated/unstripped/toybox_old
Rob Landleycd2edfd2006-11-26 18:47:14 -050041
Rob Landley8d677212017-12-19 16:16:31 -060042bloatcheck: generated/unstripped/toybox_old generated/unstripped/toybox
Rob Landleya8d0d132016-03-23 03:25:37 -050043 @scripts/bloatcheck generated/unstripped/toybox_old generated/unstripped/toybox
Rob Landleycd2edfd2006-11-26 18:47:14 -050044
Rob Landley9a64b8d2016-02-03 22:33:04 -060045install_flat:
Rob Landley05fbd1e2008-03-28 00:09:31 -050046 scripts/install.sh --symlink --force
47
Rob Landley6c3188c2016-10-02 22:41:55 -050048install_airlock:
49 scripts/install.sh --symlink --force --airlock
50
Rob Landley05fbd1e2008-03-28 00:09:31 -050051install:
52 scripts/install.sh --long --symlink --force
Rob Landleybcfad872007-01-31 14:18:05 -050053
Rob Landleydf07fb72016-02-10 23:27:55 -060054uninstall_flat:
Rob Landleybf081b92008-03-28 00:40:57 -050055 scripts/install.sh --uninstall
56
57uninstall:
58 scripts/install.sh --long --uninstall
59
Rob Landley5eb44752015-02-07 17:19:38 -060060change:
Rob Landley45962a72015-02-14 01:08:15 -060061 scripts/change.sh
Rob Landley62390fd2014-11-28 16:49:46 -060062
Rob Landley7a582252019-09-07 00:30:59 -050063root_clean:
Rob Landley0b3e7562019-08-22 14:34:45 -050064 @rm -rf root
Rob Landley7a582252019-09-07 00:30:59 -050065 @echo root cleaned
66
67clean::
Rob Landley35666e72019-10-11 12:28:05 -050068 @rm -rf toybox generated change .singleconfig* cross-log-*.*
Rob Landley0b3e7562019-08-22 14:34:45 -050069 @echo cleaned
70
Rob Landley8cc325d2016-09-04 18:07:12 -050071# If singlemake was in generated/ "make clean; make test_ls" wouldn't work.
Rob Landley7a582252019-09-07 00:30:59 -050072distclean: clean root_clean
73 @rm -f toybox* .config* .singlemake
Rob Landley0b3e7562019-08-22 14:34:45 -050074 @echo removed .config
Rob Landleycd2edfd2006-11-26 18:47:14 -050075
Rob Landleye35f2b82007-06-18 01:09:00 -040076tests:
Rob Landley9d243a22008-03-28 00:44:44 -050077 scripts/test.sh
Rob Landleye35f2b82007-06-18 01:09:00 -040078
Rob Landley0b3e7562019-08-22 14:34:45 -050079root:
80 scripts/mkroot.sh $(MAKEFLAGS)
81
82run_root:
83 C=$$(basename "$$CROSS_COMPILE" | sed 's/-.*//'); \
Rob Landley7a582252019-09-07 00:30:59 -050084 cd root/"$${C:-host}" && ./qemu-*.sh $(MAKEFLAGS) || exit 1
Rob Landley0b3e7562019-08-22 14:34:45 -050085
Rob Landleycd2edfd2006-11-26 18:47:14 -050086help::
Rob Landleye1d68f52018-01-10 10:54:11 -060087 @cat scripts/help.txt