blob: dff5fbf8ec3d84d46642555fbce12f6a66918019 [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
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000048
49#############################################################
50#
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000051# Setup the proper filename extensions for the host
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000052#
53##############################################################
54ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000055HOST_EXEEXT:=
56HOST_LIBEXT:=.a
57HOST_SHREXT:=.so
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000058endif
59ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000060HOST_EXEEXT:=
61HOST_LIBEXT:=.a
62HOST_SHREXT:=.dylib
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000063endif
64ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000065HOST_EXEEXT:=.exe
66HOST_LIBEXT:=.lib
67HOST_SHREXT:=.dll
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000068endif
69ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000070HOST_EXEEXT:=.exe
71HOST_LIBEXT:=.lib
72HOST_SHREXT:=.dll
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000073endif
74
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000075# The preferred type of libs we build for the target
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000076ifeq ($(BR2_PREFER_STATIC_LIB),y)
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000077LIBTGTEXT=.a
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000078else
Bernhard Reutner-Fischerc6e43c92007-06-02 11:22:17 +000079LIBTGTEXT=.so
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +000080endif
81
82
Eric Andersen08782ae2002-04-26 11:45:55 +000083#############################################################
84#
Eric Andersen2d523c22004-10-09 01:06:03 +000085# The list of stuff to build for the target toolchain
86# along with the packages to build for the target.
Eric Andersen08782ae2002-04-26 11:45:55 +000087#
Eric Andersen2d523c22004-10-09 01:06:03 +000088##############################################################
"Steven J. Hill"02f71aa2007-02-06 18:19:38 +000089ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
Eric Andersen98bc6da2006-07-18 23:43:58 +000090TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
"Steven J. Hill"02f71aa2007-02-06 18:19:38 +000091else
92TARGETS:=uclibc
93endif
Eric Andersen2d523c22004-10-09 01:06:03 +000094include toolchain/Makefile.in
Eric Andersen2d523c22004-10-09 01:06:03 +000095include package/Makefile.in
Eric Andersen27bc59d2003-01-17 04:31:36 +000096
Eric Andersen08782ae2002-04-26 11:45:55 +000097#############################################################
98#
Eric Andersenef407d32004-01-29 23:21:00 +000099# You should probably leave this stuff alone unless you know
Eric Andersen08782ae2002-04-26 11:45:55 +0000100# what you are doing.
101#
102#############################################################
Manuel Novoa III d632d422003-11-01 05:34:41 +0000103
Eric Andersenffde94b2001-12-22 00:56:11 +0000104all: world
105
Eric Andersen2d523c22004-10-09 01:06:03 +0000106# In this section, we need .config
107include .config.cmd
108
Eric Andersend06645d2005-02-10 03:06:39 +0000109# We also need the various per-package makefiles, which also add
110# each selected package to TARGETS if that package was selected
111# in the .config file.
112include toolchain/*/*.mk
113include package/*/*.mk
Eric Andersend06645d2005-02-10 03:06:39 +0000114
Eric Andersen79f5f1e2005-02-17 03:00:29 +0000115# target stuff is last so it can override anything else
116include target/Makefile.in
117
Eric Andersen08782ae2002-04-26 11:45:55 +0000118TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
Eric Andersena5c23542003-02-19 08:56:04 +0000119TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
Eric Andersen08782ae2002-04-26 11:45:55 +0000120TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
Eric Andersenffde94b2001-12-22 00:56:11 +0000121
Bernhard Reutner-Fischer6e2823c2006-11-17 15:43:51 +0000122world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
Bernhard Reutner-Fischer870cb9e2006-11-17 11:21:23 +0000123dirs: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR)
Eric Andersenffde94b2001-12-22 00:56:11 +0000124
Bernhard Reutner-Fischer870cb9e2006-11-17 11:21:23 +0000125.PHONY: all world dirs clean dirclean distclean source $(TARGETS) \
Eric Andersen747b16d2004-12-11 10:33:19 +0000126 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
127 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
Jon Nelsonc79e9982002-01-05 20:26:15 +0000128
Eric Andersen08782ae2002-04-26 11:45:55 +0000129#############################################################
130#
Eric Andersenef407d32004-01-29 23:21:00 +0000131# staging and target directories do NOT list these as
Mike Frysingerd99c31c2006-05-26 01:18:09 +0000132# dependencies anywhere else
Eric Andersen08782ae2002-04-26 11:45:55 +0000133#
134#############################################################
Bernhard Reutner-Fischer8d583fc2007-01-30 00:58:18 +0000135$(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR):
136 @mkdir -p $@
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000137
Eric Andersen08782ae2002-04-26 11:45:55 +0000138$(STAGING_DIR):
"Steven J. Hill"9c865d72007-05-07 03:56:47 +0000139 @mkdir -p $(STAGING_DIR)/bin
Eric Andersenbf387232004-12-11 10:35:18 +0000140 @mkdir -p $(STAGING_DIR)/lib
141 @mkdir -p $(STAGING_DIR)/include
Eric Andersen3da708e2007-01-10 06:55:27 +0000142 @mkdir -p $(STAGING_DIR)/usr
Eric Andersenbf387232004-12-11 10:35:18 +0000143 @mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
"Steven J. Hill"4b2ebdb2007-04-28 17:09:44 +0000144 @ln -snf ../include $(STAGING_DIR)/usr/include
Eric Andersen3da708e2007-01-10 06:55:27 +0000145 @ln -snf ../lib $(STAGING_DIR)/usr/lib
Eric Andersen74ad4e12005-04-15 02:19:11 +0000146 @ln -snf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
Eric Andersen08782ae2002-04-26 11:45:55 +0000147
148$(TARGET_DIR):
Eric Andersena4c685f2006-11-15 21:00:07 +0000149 mkdir -p $(TARGET_DIR)
Eric Andersenba70f942006-11-15 06:52:00 +0000150 if [ -d "$(TARGET_SKELETON)" ] ; then \
151 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
Eric Andersenbb15c222005-02-17 18:21:20 +0000152 fi;
Eric Andersen5418a922006-04-07 22:42:15 +0000153 touch $(STAGING_DIR)/.fakeroot.00000
Eric Andersenbb15c222005-02-17 18:21:20 +0000154 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
155 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
Eric Andersenffde94b2001-12-22 00:56:11 +0000156
Bernhard Reutner-Fischer73be7f92007-04-06 16:36:48 +0000157source: $(TARGETS_SOURCE) $(HOST_SOURCE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000158
Eric Andersen08782ae2002-04-26 11:45:55 +0000159#############################################################
160#
161# Cleanup and misc junk
162#
163#############################################################
164clean: $(TARGETS_CLEAN)
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000165 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000166
Eric Andersen08782ae2002-04-26 11:45:55 +0000167dirclean: $(TARGETS_DIRCLEAN)
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000168 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000169
Eric Andersen08782ae2002-04-26 11:45:55 +0000170distclean:
Mike Frysinger5bc1f0c2005-09-09 02:49:10 +0000171ifeq ($(DL_DIR),$(BASE_DIR)/dl)
172 rm -rf $(DL_DIR)
173endif
174 rm -rf $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
Bernhard Reutner-Fischerb5136192007-01-19 18:00:49 +0000175 $(MAKE) -C $(CONFIG) clean
Eric Andersenffde94b2001-12-22 00:56:11 +0000176
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000177sourceball:
Eric Andersen08782ae2002-04-26 11:45:55 +0000178 rm -rf $(BUILD_DIR)
179 set -e; \
180 cd ..; \
181 rm -f buildroot.tar.bz2; \
182 tar -cvf buildroot.tar buildroot; \
183 bzip2 -9 buildroot.tar; \
Eric Andersen2d523c22004-10-09 01:06:03 +0000184
185
186else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
187
188all: menuconfig
189
190# configuration
191# ---------------------------------------------------------------------------
192
193$(CONFIG)/conf:
194 $(MAKE) -C $(CONFIG) conf
195 -@if [ ! -f .config ] ; then \
196 cp $(CONFIG_DEFCONFIG) .config; \
197 fi
198$(CONFIG)/mconf:
199 $(MAKE) -C $(CONFIG) ncurses conf mconf
200 -@if [ ! -f .config ] ; then \
201 cp $(CONFIG_DEFCONFIG) .config; \
202 fi
203
204menuconfig: $(CONFIG)/mconf
205 @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
206
207config: $(CONFIG)/conf
208 @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
209
210oldconfig: $(CONFIG)/conf
211 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
212
213randconfig: $(CONFIG)/conf
214 @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
215
216allyesconfig: $(CONFIG)/conf
217 #@$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
218 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
219 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
220
221allnoconfig: $(CONFIG)/conf
222 @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
223
224defconfig: $(CONFIG)/conf
225 @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
226
"Steven J. Hill"0c1e7092006-06-22 02:24:08 +0000227%_defconfig: $(CONFIG)/conf
228 cp $(shell find . -name $@) .config
229 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
230
Eric Andersen2d523c22004-10-09 01:06:03 +0000231#############################################################
232#
233# Cleanup and misc junk
234#
235#############################################################
236clean:
237 rm -f .config .config.old .config.cmd .tmpconfig.h
238 - $(MAKE) -C $(CONFIG) clean
239
240distclean: clean
241 rm -rf sources/*
242
243endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
244
245.PHONY: dummy subdirs release distclean clean config oldconfig \
Eric Andersenf3ccf312005-04-27 08:09:58 +0000246 menuconfig tags check test depend defconfig
Eric Andersen2d523c22004-10-09 01:06:03 +0000247
248