blob: 12851444f705852196e094ceb482a2f29515f462 [file] [log] [blame]
Eric Andersen2d523c22004-10-09 01:06:03 +00001# Makefile for buildroot2
Eric Andersenffde94b2001-12-22 00:56:11 +00002#
Eric Andersen15b26ae2005-02-07 22:19:26 +00003# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
Eric Andersenffde94b2001-12-22 00:56:11 +00004#
Eric Andersen08782ae2002-04-26 11:45:55 +00005# This program is free software; you can redistribute it and/or modify
Eric Andersen2d523c22004-10-09 01:06:03 +00006# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
Eric Andersenffde94b2001-12-22 00:56:11 +00009#
Eric Andersen2d523c22004-10-09 01:06:03 +000010# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
Eric Andersen08782ae2002-04-26 11:45:55 +000012# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Eric Andersen2d523c22004-10-09 01:06:03 +000013# General Public License for more details.
Eric Andersenffde94b2001-12-22 00:56:11 +000014#
Eric Andersen2d523c22004-10-09 01:06:03 +000015# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
Eric Andersenffde94b2001-12-22 00:56:11 +000019
Eric Andersen2d523c22004-10-09 01:06:03 +000020#--------------------------------------------------------------
21# Just run 'make menuconfig', configure stuff, then run 'make'.
22# You shouldn't need to mess with anything beyond this point...
23#--------------------------------------------------------------
24TOPDIR=./
25CONFIG_CONFIG_IN = Config.in
26CONFIG_DEFCONFIG = .defconfig
27CONFIG = package/config
28
29noconfig_targets := menuconfig config oldconfig randconfig \
"Steven J. Hill"0c1e7092006-06-22 02:24:08 +000030 defconfig allyesconfig allnoconfig release tags \
Bernhard Reutner-Fischer9e250352006-12-02 19:01:10 +000031
32# $(shell find . -name *_defconfig |sed 's/.*\///')
Eric Andersen2d523c22004-10-09 01:06:03 +000033
34# Pull in the user's configuration file
35ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
36-include $(TOPDIR).config
37endif
38
39ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
Eric Andersenffde94b2001-12-22 00:56:11 +000040
Bernhard Reutner-Fischer99cf7292007-02-12 13:38:06 +000041# cc-option
42# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
43# sets -march=winchip-c6 if supported else falls back to -march=i586
44# without checking the latter.
45cc-option = $(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
46 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
47
Eric Andersen08782ae2002-04-26 11:45:55 +000048#############################################################
49#
Eric Andersen2d523c22004-10-09 01:06:03 +000050# The list of stuff to build for the target toolchain
51# along with the packages to build for the target.
Eric Andersen08782ae2002-04-26 11:45:55 +000052#
Eric Andersen2d523c22004-10-09 01:06:03 +000053##############################################################
"Steven J. Hill"02f71aa2007-02-06 18:19:38 +000054ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
Eric Andersen98bc6da2006-07-18 23:43:58 +000055TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
"Steven J. Hill"02f71aa2007-02-06 18:19:38 +000056else
57TARGETS:=uclibc
58endif
Eric Andersen2d523c22004-10-09 01:06:03 +000059include toolchain/Makefile.in
Eric Andersen2d523c22004-10-09 01:06:03 +000060include package/Makefile.in
Eric Andersen27bc59d2003-01-17 04:31:36 +000061
Eric Andersen08782ae2002-04-26 11:45:55 +000062#############################################################
63#
Eric Andersenef407d32004-01-29 23:21:00 +000064# You should probably leave this stuff alone unless you know
Eric Andersen08782ae2002-04-26 11:45:55 +000065# what you are doing.
66#
67#############################################################
Manuel Novoa III d632d422003-11-01 05:34:41 +000068
Eric Andersencb7d5b82003-09-14 11:38:35 +000069
Eric Andersenffde94b2001-12-22 00:56:11 +000070
71all: world
72
Eric Andersen2d523c22004-10-09 01:06:03 +000073# In this section, we need .config
74include .config.cmd
75
Eric Andersend06645d2005-02-10 03:06:39 +000076# We also need the various per-package makefiles, which also add
77# each selected package to TARGETS if that package was selected
78# in the .config file.
79include toolchain/*/*.mk
80include package/*/*.mk
Eric Andersend06645d2005-02-10 03:06:39 +000081
Eric Andersen79f5f1e2005-02-17 03:00:29 +000082# target stuff is last so it can override anything else
83include target/Makefile.in
84
Eric Andersen08782ae2002-04-26 11:45:55 +000085TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
Eric Andersena5c23542003-02-19 08:56:04 +000086TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
Eric Andersen08782ae2002-04-26 11:45:55 +000087TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
Eric Andersenffde94b2001-12-22 00:56:11 +000088
Bernhard Reutner-Fischer6e2823c2006-11-17 15:43:51 +000089world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
Bernhard Reutner-Fischer870cb9e2006-11-17 11:21:23 +000090dirs: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR)
Eric Andersenffde94b2001-12-22 00:56:11 +000091
Bernhard Reutner-Fischer870cb9e2006-11-17 11:21:23 +000092.PHONY: all world dirs clean dirclean distclean source $(TARGETS) \
Eric Andersen747b16d2004-12-11 10:33:19 +000093 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
94 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
Jon Nelsonc79e9982002-01-05 20:26:15 +000095
Eric Andersen08782ae2002-04-26 11:45:55 +000096#############################################################
97#
Eric Andersenef407d32004-01-29 23:21:00 +000098# staging and target directories do NOT list these as
Mike Frysingerd99c31c2006-05-26 01:18:09 +000099# dependencies anywhere else
Eric Andersen08782ae2002-04-26 11:45:55 +0000100#
101#############################################################
Bernhard Reutner-Fischer8d583fc2007-01-30 00:58:18 +0000102$(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR):
103 @mkdir -p $@
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000104
Eric Andersen08782ae2002-04-26 11:45:55 +0000105$(STAGING_DIR):
"Steven J. Hill"9c865d72007-05-07 03:56:47 +0000106 @mkdir -p $(STAGING_DIR)/bin
Eric Andersenbf387232004-12-11 10:35:18 +0000107 @mkdir -p $(STAGING_DIR)/lib
108 @mkdir -p $(STAGING_DIR)/include
Eric Andersen3da708e2007-01-10 06:55:27 +0000109 @mkdir -p $(STAGING_DIR)/usr
Eric Andersenbf387232004-12-11 10:35:18 +0000110 @mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
"Steven J. Hill"4b2ebdb2007-04-28 17:09:44 +0000111 @ln -snf ../include $(STAGING_DIR)/usr/include
Eric Andersen3da708e2007-01-10 06:55:27 +0000112 @ln -snf ../lib $(STAGING_DIR)/usr/lib
Eric Andersen74ad4e12005-04-15 02:19:11 +0000113 @ln -snf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
Eric Andersen08782ae2002-04-26 11:45:55 +0000114
115$(TARGET_DIR):
Eric Andersena4c685f2006-11-15 21:00:07 +0000116 mkdir -p $(TARGET_DIR)
Eric Andersenba70f942006-11-15 06:52:00 +0000117 if [ -d "$(TARGET_SKELETON)" ] ; then \
118 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
Eric Andersenbb15c222005-02-17 18:21:20 +0000119 fi;
Eric Andersen5418a922006-04-07 22:42:15 +0000120 touch $(STAGING_DIR)/.fakeroot.00000
Eric Andersenbb15c222005-02-17 18:21:20 +0000121 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
122 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
Eric Andersenffde94b2001-12-22 00:56:11 +0000123
Bernhard Reutner-Fischer73be7f92007-04-06 16:36:48 +0000124source: $(TARGETS_SOURCE) $(HOST_SOURCE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000125
Eric Andersen08782ae2002-04-26 11:45:55 +0000126#############################################################
127#
128# Cleanup and misc junk
129#
130#############################################################
131clean: $(TARGETS_CLEAN)
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000132 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000133
Eric Andersen08782ae2002-04-26 11:45:55 +0000134dirclean: $(TARGETS_DIRCLEAN)
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000135 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000136
Eric Andersen08782ae2002-04-26 11:45:55 +0000137distclean:
Mike Frysinger5bc1f0c2005-09-09 02:49:10 +0000138ifeq ($(DL_DIR),$(BASE_DIR)/dl)
139 rm -rf $(DL_DIR)
140endif
141 rm -rf $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
Bernhard Reutner-Fischerb5136192007-01-19 18:00:49 +0000142 $(MAKE) -C $(CONFIG) clean
Eric Andersenffde94b2001-12-22 00:56:11 +0000143
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000144sourceball:
Eric Andersen08782ae2002-04-26 11:45:55 +0000145 rm -rf $(BUILD_DIR)
146 set -e; \
147 cd ..; \
148 rm -f buildroot.tar.bz2; \
149 tar -cvf buildroot.tar buildroot; \
150 bzip2 -9 buildroot.tar; \
Eric Andersen2d523c22004-10-09 01:06:03 +0000151
152
153else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
154
155all: menuconfig
156
157# configuration
158# ---------------------------------------------------------------------------
159
160$(CONFIG)/conf:
161 $(MAKE) -C $(CONFIG) conf
162 -@if [ ! -f .config ] ; then \
163 cp $(CONFIG_DEFCONFIG) .config; \
164 fi
165$(CONFIG)/mconf:
166 $(MAKE) -C $(CONFIG) ncurses conf mconf
167 -@if [ ! -f .config ] ; then \
168 cp $(CONFIG_DEFCONFIG) .config; \
169 fi
170
171menuconfig: $(CONFIG)/mconf
172 @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
173
174config: $(CONFIG)/conf
175 @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
176
177oldconfig: $(CONFIG)/conf
178 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
179
180randconfig: $(CONFIG)/conf
181 @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
182
183allyesconfig: $(CONFIG)/conf
184 #@$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
185 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
186 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
187
188allnoconfig: $(CONFIG)/conf
189 @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
190
191defconfig: $(CONFIG)/conf
192 @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
193
"Steven J. Hill"0c1e7092006-06-22 02:24:08 +0000194%_defconfig: $(CONFIG)/conf
195 cp $(shell find . -name $@) .config
196 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
197
Eric Andersen2d523c22004-10-09 01:06:03 +0000198#############################################################
199#
200# Cleanup and misc junk
201#
202#############################################################
203clean:
204 rm -f .config .config.old .config.cmd .tmpconfig.h
205 - $(MAKE) -C $(CONFIG) clean
206
207distclean: clean
208 rm -rf sources/*
209
210endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
211
212.PHONY: dummy subdirs release distclean clean config oldconfig \
Eric Andersenf3ccf312005-04-27 08:09:58 +0000213 menuconfig tags check test depend defconfig
Eric Andersen2d523c22004-10-09 01:06:03 +0000214
215