Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 1 | # Makefile for buildroot2 |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 2 | # |
Eric Andersen | 15b26ae | 2005-02-07 22:19:26 +0000 | [diff] [blame] | 3 | # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 4 | # |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 5 | # This program is free software; you can redistribute it and/or modify |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 6 | # 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 Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 9 | # |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 13 | # General Public License for more details. |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 14 | # |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 15 | # 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 Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 19 | |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 20 | #-------------------------------------------------------------- |
| 21 | # Just run 'make menuconfig', configure stuff, then run 'make'. |
| 22 | # You shouldn't need to mess with anything beyond this point... |
| 23 | #-------------------------------------------------------------- |
| 24 | TOPDIR=./ |
| 25 | CONFIG_CONFIG_IN = Config.in |
| 26 | CONFIG_DEFCONFIG = .defconfig |
| 27 | CONFIG = package/config |
| 28 | |
| 29 | noconfig_targets := menuconfig config oldconfig randconfig \ |
"Steven J. Hill" | 0c1e709 | 2006-06-22 02:24:08 +0000 | [diff] [blame] | 30 | defconfig allyesconfig allnoconfig release tags \ |
Bernhard Reutner-Fischer | 9e25035 | 2006-12-02 19:01:10 +0000 | [diff] [blame] | 31 | |
| 32 | # $(shell find . -name *_defconfig |sed 's/.*\///') |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 33 | |
| 34 | # Pull in the user's configuration file |
| 35 | ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) |
| 36 | -include $(TOPDIR).config |
| 37 | endif |
| 38 | |
| 39 | ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y) |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 40 | |
Bernhard Reutner-Fischer | 99cf729 | 2007-02-12 13:38:06 +0000 | [diff] [blame] | 41 | # 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. |
| 45 | cc-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-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 48 | |
| 49 | ############################################################# |
| 50 | # |
Bernhard Reutner-Fischer | c6e43c9 | 2007-06-02 11:22:17 +0000 | [diff] [blame^] | 51 | # Setup the proper filename extensions for the host |
Bernhard Reutner-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 52 | # |
| 53 | ############################################################## |
| 54 | ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),) |
Bernhard Reutner-Fischer | c6e43c9 | 2007-06-02 11:22:17 +0000 | [diff] [blame^] | 55 | HOST_EXEEXT:= |
| 56 | HOST_LIBEXT:=.a |
| 57 | HOST_SHREXT:=.so |
Bernhard Reutner-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 58 | endif |
| 59 | ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),) |
Bernhard Reutner-Fischer | c6e43c9 | 2007-06-02 11:22:17 +0000 | [diff] [blame^] | 60 | HOST_EXEEXT:= |
| 61 | HOST_LIBEXT:=.a |
| 62 | HOST_SHREXT:=.dylib |
Bernhard Reutner-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 63 | endif |
| 64 | ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),) |
Bernhard Reutner-Fischer | c6e43c9 | 2007-06-02 11:22:17 +0000 | [diff] [blame^] | 65 | HOST_EXEEXT:=.exe |
| 66 | HOST_LIBEXT:=.lib |
| 67 | HOST_SHREXT:=.dll |
Bernhard Reutner-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 68 | endif |
| 69 | ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),) |
Bernhard Reutner-Fischer | c6e43c9 | 2007-06-02 11:22:17 +0000 | [diff] [blame^] | 70 | HOST_EXEEXT:=.exe |
| 71 | HOST_LIBEXT:=.lib |
| 72 | HOST_SHREXT:=.dll |
Bernhard Reutner-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 73 | endif |
| 74 | |
Bernhard Reutner-Fischer | c6e43c9 | 2007-06-02 11:22:17 +0000 | [diff] [blame^] | 75 | # The preferred type of libs we build for the target |
Bernhard Reutner-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 76 | ifeq ($(BR2_PREFER_STATIC_LIB),y) |
Bernhard Reutner-Fischer | c6e43c9 | 2007-06-02 11:22:17 +0000 | [diff] [blame^] | 77 | LIBTGTEXT=.a |
Bernhard Reutner-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 78 | else |
Bernhard Reutner-Fischer | c6e43c9 | 2007-06-02 11:22:17 +0000 | [diff] [blame^] | 79 | LIBTGTEXT=.so |
Bernhard Reutner-Fischer | 7dcbbfb | 2007-06-02 09:05:40 +0000 | [diff] [blame] | 80 | endif |
| 81 | |
| 82 | |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 83 | ############################################################# |
| 84 | # |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 85 | # The list of stuff to build for the target toolchain |
| 86 | # along with the packages to build for the target. |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 87 | # |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 88 | ############################################################## |
"Steven J. Hill" | 02f71aa | 2007-02-06 18:19:38 +0000 | [diff] [blame] | 89 | ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y) |
Eric Andersen | 98bc6da | 2006-07-18 23:43:58 +0000 | [diff] [blame] | 90 | TARGETS:=uclibc-configured binutils gcc uclibc-target-utils |
"Steven J. Hill" | 02f71aa | 2007-02-06 18:19:38 +0000 | [diff] [blame] | 91 | else |
| 92 | TARGETS:=uclibc |
| 93 | endif |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 94 | include toolchain/Makefile.in |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 95 | include package/Makefile.in |
Eric Andersen | 27bc59d | 2003-01-17 04:31:36 +0000 | [diff] [blame] | 96 | |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 97 | ############################################################# |
| 98 | # |
Eric Andersen | ef407d3 | 2004-01-29 23:21:00 +0000 | [diff] [blame] | 99 | # You should probably leave this stuff alone unless you know |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 100 | # what you are doing. |
| 101 | # |
| 102 | ############################################################# |
Manuel Novoa III | d632d42 | 2003-11-01 05:34:41 +0000 | [diff] [blame] | 103 | |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 104 | all: world |
| 105 | |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 106 | # In this section, we need .config |
| 107 | include .config.cmd |
| 108 | |
Eric Andersen | d06645d | 2005-02-10 03:06:39 +0000 | [diff] [blame] | 109 | # 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. |
| 112 | include toolchain/*/*.mk |
| 113 | include package/*/*.mk |
Eric Andersen | d06645d | 2005-02-10 03:06:39 +0000 | [diff] [blame] | 114 | |
Eric Andersen | 79f5f1e | 2005-02-17 03:00:29 +0000 | [diff] [blame] | 115 | # target stuff is last so it can override anything else |
| 116 | include target/Makefile.in |
| 117 | |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 118 | TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS)) |
Eric Andersen | a5c2354 | 2003-02-19 08:56:04 +0000 | [diff] [blame] | 119 | TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS)) |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 120 | TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS)) |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 121 | |
Bernhard Reutner-Fischer | 6e2823c | 2006-11-17 15:43:51 +0000 | [diff] [blame] | 122 | world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS) |
Bernhard Reutner-Fischer | 870cb9e | 2006-11-17 11:21:23 +0000 | [diff] [blame] | 123 | dirs: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 124 | |
Bernhard Reutner-Fischer | 870cb9e | 2006-11-17 11:21:23 +0000 | [diff] [blame] | 125 | .PHONY: all world dirs clean dirclean distclean source $(TARGETS) \ |
Eric Andersen | 747b16d | 2004-12-11 10:33:19 +0000 | [diff] [blame] | 126 | $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \ |
| 127 | $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR) |
Jon Nelson | c79e998 | 2002-01-05 20:26:15 +0000 | [diff] [blame] | 128 | |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 129 | ############################################################# |
| 130 | # |
Eric Andersen | ef407d3 | 2004-01-29 23:21:00 +0000 | [diff] [blame] | 131 | # staging and target directories do NOT list these as |
Mike Frysinger | d99c31c | 2006-05-26 01:18:09 +0000 | [diff] [blame] | 132 | # dependencies anywhere else |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 133 | # |
| 134 | ############################################################# |
Bernhard Reutner-Fischer | 8d583fc | 2007-01-30 00:58:18 +0000 | [diff] [blame] | 135 | $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR): |
| 136 | @mkdir -p $@ |
Manuel Novoa III | 3ad3d8a | 2004-09-03 00:49:43 +0000 | [diff] [blame] | 137 | |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 138 | $(STAGING_DIR): |
"Steven J. Hill" | 9c865d7 | 2007-05-07 03:56:47 +0000 | [diff] [blame] | 139 | @mkdir -p $(STAGING_DIR)/bin |
Eric Andersen | bf38723 | 2004-12-11 10:35:18 +0000 | [diff] [blame] | 140 | @mkdir -p $(STAGING_DIR)/lib |
| 141 | @mkdir -p $(STAGING_DIR)/include |
Eric Andersen | 3da708e | 2007-01-10 06:55:27 +0000 | [diff] [blame] | 142 | @mkdir -p $(STAGING_DIR)/usr |
Eric Andersen | bf38723 | 2004-12-11 10:35:18 +0000 | [diff] [blame] | 143 | @mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME) |
"Steven J. Hill" | 4b2ebdb | 2007-04-28 17:09:44 +0000 | [diff] [blame] | 144 | @ln -snf ../include $(STAGING_DIR)/usr/include |
Eric Andersen | 3da708e | 2007-01-10 06:55:27 +0000 | [diff] [blame] | 145 | @ln -snf ../lib $(STAGING_DIR)/usr/lib |
Eric Andersen | 74ad4e1 | 2005-04-15 02:19:11 +0000 | [diff] [blame] | 146 | @ln -snf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 147 | |
| 148 | $(TARGET_DIR): |
Eric Andersen | a4c685f | 2006-11-15 21:00:07 +0000 | [diff] [blame] | 149 | mkdir -p $(TARGET_DIR) |
Eric Andersen | ba70f94 | 2006-11-15 06:52:00 +0000 | [diff] [blame] | 150 | if [ -d "$(TARGET_SKELETON)" ] ; then \ |
| 151 | cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \ |
Eric Andersen | bb15c22 | 2005-02-17 18:21:20 +0000 | [diff] [blame] | 152 | fi; |
Eric Andersen | 5418a92 | 2006-04-07 22:42:15 +0000 | [diff] [blame] | 153 | touch $(STAGING_DIR)/.fakeroot.00000 |
Eric Andersen | bb15c22 | 2005-02-17 18:21:20 +0000 | [diff] [blame] | 154 | -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf |
| 155 | -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 156 | |
Bernhard Reutner-Fischer | 73be7f9 | 2007-04-06 16:36:48 +0000 | [diff] [blame] | 157 | source: $(TARGETS_SOURCE) $(HOST_SOURCE) |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 158 | |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 159 | ############################################################# |
| 160 | # |
| 161 | # Cleanup and misc junk |
| 162 | # |
| 163 | ############################################################# |
| 164 | clean: $(TARGETS_CLEAN) |
Manuel Novoa III | 3ad3d8a | 2004-09-03 00:49:43 +0000 | [diff] [blame] | 165 | rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 166 | |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 167 | dirclean: $(TARGETS_DIRCLEAN) |
Manuel Novoa III | 3ad3d8a | 2004-09-03 00:49:43 +0000 | [diff] [blame] | 168 | rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 169 | |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 170 | distclean: |
Mike Frysinger | 5bc1f0c | 2005-09-09 02:49:10 +0000 | [diff] [blame] | 171 | ifeq ($(DL_DIR),$(BASE_DIR)/dl) |
| 172 | rm -rf $(DL_DIR) |
| 173 | endif |
| 174 | rm -rf $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE) |
Bernhard Reutner-Fischer | b513619 | 2007-01-19 18:00:49 +0000 | [diff] [blame] | 175 | $(MAKE) -C $(CONFIG) clean |
Eric Andersen | ffde94b | 2001-12-22 00:56:11 +0000 | [diff] [blame] | 176 | |
Manuel Novoa III | 3ad3d8a | 2004-09-03 00:49:43 +0000 | [diff] [blame] | 177 | sourceball: |
Eric Andersen | 08782ae | 2002-04-26 11:45:55 +0000 | [diff] [blame] | 178 | 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 Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 184 | |
| 185 | |
| 186 | else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y) |
| 187 | |
| 188 | all: 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 | |
| 204 | menuconfig: $(CONFIG)/mconf |
| 205 | @$(CONFIG)/mconf $(CONFIG_CONFIG_IN) |
| 206 | |
| 207 | config: $(CONFIG)/conf |
| 208 | @$(CONFIG)/conf $(CONFIG_CONFIG_IN) |
| 209 | |
| 210 | oldconfig: $(CONFIG)/conf |
| 211 | @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN) |
| 212 | |
| 213 | randconfig: $(CONFIG)/conf |
| 214 | @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN) |
| 215 | |
| 216 | allyesconfig: $(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 | |
| 221 | allnoconfig: $(CONFIG)/conf |
| 222 | @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN) |
| 223 | |
| 224 | defconfig: $(CONFIG)/conf |
| 225 | @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN) |
| 226 | |
"Steven J. Hill" | 0c1e709 | 2006-06-22 02:24:08 +0000 | [diff] [blame] | 227 | %_defconfig: $(CONFIG)/conf |
| 228 | cp $(shell find . -name $@) .config |
| 229 | @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN) |
| 230 | |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 231 | ############################################################# |
| 232 | # |
| 233 | # Cleanup and misc junk |
| 234 | # |
| 235 | ############################################################# |
| 236 | clean: |
| 237 | rm -f .config .config.old .config.cmd .tmpconfig.h |
| 238 | - $(MAKE) -C $(CONFIG) clean |
| 239 | |
| 240 | distclean: clean |
| 241 | rm -rf sources/* |
| 242 | |
| 243 | endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y) |
| 244 | |
| 245 | .PHONY: dummy subdirs release distclean clean config oldconfig \ |
Eric Andersen | f3ccf31 | 2005-04-27 08:09:58 +0000 | [diff] [blame] | 246 | menuconfig tags check test depend defconfig |
Eric Andersen | 2d523c2 | 2004-10-09 01:06:03 +0000 | [diff] [blame] | 247 | |
| 248 | |