blob: ceaae90fb4e5e5079ecf9b842374f4ae7d461677 [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-Fischer825ff342007-06-07 12:57:03 +000031 source-check
Bernhard Reutner-Fischer9e250352006-12-02 19:01:10 +000032
33# $(shell find . -name *_defconfig |sed 's/.*\///')
Eric Andersen2d523c22004-10-09 01:06:03 +000034
35# Pull in the user's configuration file
36ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
37-include $(TOPDIR).config
38endif
39
40ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
Eric Andersenffde94b2001-12-22 00:56:11 +000041
Bernhard Reutner-Fischer99cf7292007-02-12 13:38:06 +000042# cc-option
43# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
44# sets -march=winchip-c6 if supported else falls back to -march=i586
45# without checking the latter.
46cc-option = $(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
47 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
48
Peter Korsgaard2c649042007-06-19 15:19:27 +000049#############################################################
50#
51# Hide troublesome environment variables from sub processes
52#
53#############################################################
54unexport CROSS_COMPILE
55unexport ARCH
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000056
57#############################################################
58#
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000059# Setup the proper filename extensions for the host
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000060#
61##############################################################
62ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000063HOST_EXEEXT:=
64HOST_LIBEXT:=.a
65HOST_SHREXT:=.so
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000066endif
67ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000068HOST_EXEEXT:=
69HOST_LIBEXT:=.a
70HOST_SHREXT:=.dylib
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000071endif
72ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000073HOST_EXEEXT:=.exe
74HOST_LIBEXT:=.lib
75HOST_SHREXT:=.dll
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000076endif
77ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000078HOST_EXEEXT:=.exe
79HOST_LIBEXT:=.lib
80HOST_SHREXT:=.dll
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000081endif
82
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000083# The preferred type of libs we build for the target
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000084ifeq ($(BR2_PREFER_STATIC_LIB),y)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000085LIBTGTEXT=.a
Bernhard Reutner-Fischer80277842007-06-20 11:26:36 +000086#PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000087else
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000088LIBTGTEXT=.so
Bernhard Reutner-Fischer80277842007-06-20 11:26:36 +000089#PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000090endif
Bernhard Reutner-Fischer80277842007-06-20 11:26:36 +000091PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000092
93
Eric Andersen08782ae2002-04-26 11:45:55 +000094#############################################################
95#
Eric Andersen2d523c22004-10-09 01:06:03 +000096# The list of stuff to build for the target toolchain
97# along with the packages to build for the target.
Eric Andersen08782ae2002-04-26 11:45:55 +000098#
Eric Andersen2d523c22004-10-09 01:06:03 +000099##############################################################
"Steven J. Hill"02f71aa2007-02-06 18:19:38 +0000100ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
Eric Andersen98bc6da2006-07-18 23:43:58 +0000101TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
"Steven J. Hill"02f71aa2007-02-06 18:19:38 +0000102else
103TARGETS:=uclibc
104endif
Eric Andersen2d523c22004-10-09 01:06:03 +0000105include toolchain/Makefile.in
Eric Andersen2d523c22004-10-09 01:06:03 +0000106include package/Makefile.in
Eric Andersen27bc59d2003-01-17 04:31:36 +0000107
Eric Andersen08782ae2002-04-26 11:45:55 +0000108#############################################################
109#
Eric Andersenef407d32004-01-29 23:21:00 +0000110# You should probably leave this stuff alone unless you know
Eric Andersen08782ae2002-04-26 11:45:55 +0000111# what you are doing.
112#
113#############################################################
Manuel Novoa III d632d422003-11-01 05:34:41 +0000114
Eric Andersenffde94b2001-12-22 00:56:11 +0000115all: world
116
Eric Andersen2d523c22004-10-09 01:06:03 +0000117# In this section, we need .config
118include .config.cmd
119
Eric Andersend06645d2005-02-10 03:06:39 +0000120# We also need the various per-package makefiles, which also add
121# each selected package to TARGETS if that package was selected
122# in the .config file.
123include toolchain/*/*.mk
124include package/*/*.mk
Eric Andersend06645d2005-02-10 03:06:39 +0000125
Eric Andersen79f5f1e2005-02-17 03:00:29 +0000126# target stuff is last so it can override anything else
127include target/Makefile.in
128
Eric Andersen08782ae2002-04-26 11:45:55 +0000129TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
Eric Andersena5c23542003-02-19 08:56:04 +0000130TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
Eric Andersen08782ae2002-04-26 11:45:55 +0000131TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
Eric Andersenffde94b2001-12-22 00:56:11 +0000132
Bernhard Reutner-Fischer6e2823c2006-11-17 15:43:51 +0000133world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
Bernhard Reutner-Fischer870cb9e2006-11-17 11:21:23 +0000134dirs: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR)
Eric Andersenffde94b2001-12-22 00:56:11 +0000135
Bernhard Reutner-Fischer870cb9e2006-11-17 11:21:23 +0000136.PHONY: all world dirs clean dirclean distclean source $(TARGETS) \
Eric Andersen747b16d2004-12-11 10:33:19 +0000137 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
138 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
Jon Nelsonc79e9982002-01-05 20:26:15 +0000139
Eric Andersen08782ae2002-04-26 11:45:55 +0000140#############################################################
141#
Eric Andersenef407d32004-01-29 23:21:00 +0000142# staging and target directories do NOT list these as
Mike Frysingerd99c31c2006-05-26 01:18:09 +0000143# dependencies anywhere else
Eric Andersen08782ae2002-04-26 11:45:55 +0000144#
145#############################################################
Bernhard Reutner-Fischer8d583fc2007-01-30 00:58:18 +0000146$(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR):
147 @mkdir -p $@
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000148
Eric Andersen08782ae2002-04-26 11:45:55 +0000149$(STAGING_DIR):
"Steven J. Hill"9c865d72007-05-07 03:56:47 +0000150 @mkdir -p $(STAGING_DIR)/bin
Eric Andersenbf387232004-12-11 10:35:18 +0000151 @mkdir -p $(STAGING_DIR)/lib
Bernhard Reutner-Fischer7e0c8902007-06-24 12:27:08 +0000152ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
Bernhard Reutner-Fischer80277842007-06-20 11:26:36 +0000153 @mkdir -p $(STAGING_DIR)/usr/lib
154else
155 @ln -snf . $(STAGING_DIR)/usr
156 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
Eric Andersen3da708e2007-01-10 06:55:27 +0000157 @ln -snf ../lib $(STAGING_DIR)/usr/lib
Bernhard Reutner-Fischer80277842007-06-20 11:26:36 +0000158 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
159endif
160 @mkdir -p $(STAGING_DIR)/usr/include
Eric Andersen08782ae2002-04-26 11:45:55 +0000161
162$(TARGET_DIR):
Eric Andersena4c685f2006-11-15 21:00:07 +0000163 mkdir -p $(TARGET_DIR)
Eric Andersenba70f942006-11-15 06:52:00 +0000164 if [ -d "$(TARGET_SKELETON)" ] ; then \
165 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
Eric Andersenbb15c222005-02-17 18:21:20 +0000166 fi;
Eric Andersen5418a922006-04-07 22:42:15 +0000167 touch $(STAGING_DIR)/.fakeroot.00000
Eric Andersenbb15c222005-02-17 18:21:20 +0000168 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
169 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
Eric Andersenffde94b2001-12-22 00:56:11 +0000170
Bernhard Reutner-Fischer73be7f92007-04-06 16:36:48 +0000171source: $(TARGETS_SOURCE) $(HOST_SOURCE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000172
Bernhard Reutner-Fischer825ff342007-06-07 12:57:03 +0000173.config.check: dependencies
174 $(SED) '/BR2_WGET/s/\"$$/ --spider\"/g' .config
175 touch $@
176
177_source-check: .config.check
178 $(MAKE) source
179
Eric Andersen08782ae2002-04-26 11:45:55 +0000180#############################################################
181#
182# Cleanup and misc junk
183#
184#############################################################
185clean: $(TARGETS_CLEAN)
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000186 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000187
Eric Andersen08782ae2002-04-26 11:45:55 +0000188dirclean: $(TARGETS_DIRCLEAN)
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000189 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000190
Eric Andersen08782ae2002-04-26 11:45:55 +0000191distclean:
Mike Frysinger5bc1f0c2005-09-09 02:49:10 +0000192ifeq ($(DL_DIR),$(BASE_DIR)/dl)
193 rm -rf $(DL_DIR)
194endif
195 rm -rf $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
Bernhard Reutner-Fischerb5136192007-01-19 18:00:49 +0000196 $(MAKE) -C $(CONFIG) clean
Eric Andersenffde94b2001-12-22 00:56:11 +0000197
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000198sourceball:
Eric Andersen08782ae2002-04-26 11:45:55 +0000199 rm -rf $(BUILD_DIR)
200 set -e; \
201 cd ..; \
202 rm -f buildroot.tar.bz2; \
203 tar -cvf buildroot.tar buildroot; \
204 bzip2 -9 buildroot.tar; \
Eric Andersen2d523c22004-10-09 01:06:03 +0000205
206
207else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
208
209all: menuconfig
210
211# configuration
212# ---------------------------------------------------------------------------
213
214$(CONFIG)/conf:
215 $(MAKE) -C $(CONFIG) conf
216 -@if [ ! -f .config ] ; then \
217 cp $(CONFIG_DEFCONFIG) .config; \
218 fi
219$(CONFIG)/mconf:
220 $(MAKE) -C $(CONFIG) ncurses conf mconf
221 -@if [ ! -f .config ] ; then \
222 cp $(CONFIG_DEFCONFIG) .config; \
223 fi
224
225menuconfig: $(CONFIG)/mconf
226 @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
227
228config: $(CONFIG)/conf
229 @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
230
231oldconfig: $(CONFIG)/conf
232 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
233
234randconfig: $(CONFIG)/conf
235 @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
236
237allyesconfig: $(CONFIG)/conf
Bernhard Reutner-Fischer825ff342007-06-07 12:57:03 +0000238 cp $(CONFIG_DEFCONFIG) .config
239 @$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
Eric Andersen2d523c22004-10-09 01:06:03 +0000240 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
Eric Andersen2d523c22004-10-09 01:06:03 +0000241
242allnoconfig: $(CONFIG)/conf
243 @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
244
245defconfig: $(CONFIG)/conf
246 @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
247
Bernhard Reutner-Fischer825ff342007-06-07 12:57:03 +0000248# check if download URLs are outdated
249source-check: allyesconfig
250 $(MAKE) _source-check
251
Eric Andersen2d523c22004-10-09 01:06:03 +0000252#############################################################
253#
254# Cleanup and misc junk
255#
256#############################################################
257clean:
258 rm -f .config .config.old .config.cmd .tmpconfig.h
259 - $(MAKE) -C $(CONFIG) clean
260
261distclean: clean
262 rm -rf sources/*
263
264endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
265
Bernhard Reutner-Fischerba2e7e02007-06-25 10:56:13 +0000266%_defconfig: $(CONFIG)/conf
267 cp $(shell find ./target/ -name $@) .config
268 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
269
270
Eric Andersen2d523c22004-10-09 01:06:03 +0000271.PHONY: dummy subdirs release distclean clean config oldconfig \
Eric Andersenf3ccf312005-04-27 08:09:58 +0000272 menuconfig tags check test depend defconfig
Eric Andersen2d523c22004-10-09 01:06:03 +0000273
274