2002-04-12 12:05:57 +00:00
|
|
|
# Rules.make for busybox
|
|
|
|
#
|
2005-11-29 02:53:52 +00:00
|
|
|
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
2002-04-12 12:05:57 +00:00
|
|
|
#
|
2005-11-29 02:53:52 +00:00
|
|
|
# Licensed under GPLv2, see the file LICENSE in this tarball for details.
|
2002-04-12 12:05:57 +00:00
|
|
|
#
|
|
|
|
|
2005-11-29 02:52:25 +00:00
|
|
|
# Pull in the user's busybox configuration
|
|
|
|
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
|
|
|
|
-include $(top_builddir)/.config
|
|
|
|
endif
|
|
|
|
|
2002-12-05 08:41:41 +00:00
|
|
|
#--------------------------------------------------------
|
2002-04-12 12:05:57 +00:00
|
|
|
PROG := busybox
|
2005-10-13 10:40:18 +00:00
|
|
|
MAJOR_VERSION :=1
|
|
|
|
MINOR_VERSION :=1
|
2006-01-19 09:22:39 +00:00
|
|
|
SUBLEVEL_VERSION:=1
|
|
|
|
EXTRAVERSION :=-pre0
|
2005-10-13 10:40:18 +00:00
|
|
|
VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
|
2002-04-12 12:05:57 +00:00
|
|
|
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
|
|
|
|
|
|
|
|
2002-12-05 08:41:41 +00:00
|
|
|
#--------------------------------------------------------
|
2002-04-12 12:05:57 +00:00
|
|
|
# With a modern GNU make(1) (highly recommended, that's what all the
|
|
|
|
# developers use), all of the following configuration values can be
|
|
|
|
# overridden at the command line. For example:
|
2005-10-05 07:40:46 +00:00
|
|
|
# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
|
2002-12-05 08:41:41 +00:00
|
|
|
#--------------------------------------------------------
|
2002-04-12 12:05:57 +00:00
|
|
|
|
2002-12-05 08:41:41 +00:00
|
|
|
# If you are running a cross compiler, you will want to set 'CROSS'
|
|
|
|
# to something more interesting... Target architecture is determined
|
|
|
|
# by asking the CC compiler what arch it compiles things for, so unless
|
|
|
|
# your compiler is broken, you should not need to specify TARGET_ARCH
|
2003-11-05 11:34:26 +00:00
|
|
|
CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
|
|
|
|
CC = $(CROSS)gcc
|
|
|
|
AR = $(CROSS)ar
|
|
|
|
AS = $(CROSS)as
|
|
|
|
LD = $(CROSS)ld
|
|
|
|
NM = $(CROSS)nm
|
|
|
|
STRIP = $(CROSS)strip
|
|
|
|
CPP = $(CC) -E
|
2004-10-08 07:46:08 +00:00
|
|
|
# MAKEFILES = $(top_builddir)/.config
|
2005-10-13 10:40:18 +00:00
|
|
|
RM = rm
|
|
|
|
RM_F = $(RM) -f
|
|
|
|
LN = ln
|
|
|
|
LN_S = $(LN) -s
|
|
|
|
MKDIR = mkdir
|
|
|
|
MKDIR_P = $(MKDIR) -p
|
|
|
|
MV = mv
|
|
|
|
CP = cp
|
|
|
|
|
2002-04-12 12:05:57 +00:00
|
|
|
|
2002-12-05 08:41:41 +00:00
|
|
|
# What OS are you compiling busybox for? This allows you to include
|
|
|
|
# OS specific things, syscall overrides, etc.
|
2003-11-05 11:34:26 +00:00
|
|
|
TARGET_OS=linux
|
2002-12-05 08:41:41 +00:00
|
|
|
|
|
|
|
# Select the compiler needed to build binaries for your development system
|
2003-11-05 11:34:26 +00:00
|
|
|
HOSTCC = gcc
|
2002-12-16 21:55:39 +00:00
|
|
|
HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
|
2002-04-12 12:05:57 +00:00
|
|
|
|
2004-03-15 08:29:22 +00:00
|
|
|
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
|
2003-01-14 09:12:39 +00:00
|
|
|
LC_ALL:= C
|
|
|
|
|
2002-12-05 08:41:41 +00:00
|
|
|
# If you want to add some simple compiler switches (like -march=i686),
|
|
|
|
# especially from the command line, use this instead of CFLAGS directly.
|
|
|
|
# For optimization overrides, it's better still to set OPTIMIZATION.
|
|
|
|
CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
|
2004-03-15 08:29:22 +00:00
|
|
|
|
2002-04-12 12:05:57 +00:00
|
|
|
# To compile vs some other alternative libc, you may need to use/adjust
|
|
|
|
# the following lines to meet your needs...
|
|
|
|
#
|
|
|
|
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
|
|
|
|
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
|
|
|
|
# using the compatible RPMs (compat-*) at http://www.redhat.com !
|
|
|
|
#LIBCDIR:=/usr/i386-glibc20-linux
|
|
|
|
#
|
2003-07-22 08:56:01 +00:00
|
|
|
# For other libraries, you are on your own. But these may (or may not) help...
|
2002-04-12 12:05:57 +00:00
|
|
|
#LDFLAGS+=-nostdlib
|
|
|
|
#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
|
2005-12-01 17:01:43 +00:00
|
|
|
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
|
2002-04-12 12:05:57 +00:00
|
|
|
#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
|
|
|
|
2002-12-16 21:55:39 +00:00
|
|
|
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
|
2006-01-15 14:04:57 +00:00
|
|
|
CFLAGS+=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)
|
|
|
|
|
2005-07-27 01:09:24 +00:00
|
|
|
ARFLAGS=cru
|
2002-04-12 12:05:57 +00:00
|
|
|
|
2005-12-13 11:52:46 +00:00
|
|
|
|
|
|
|
# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
|
|
|
|
# get the CC MAJOR/MINOR version
|
|
|
|
CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
|
|
|
|
CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
|
|
|
|
|
2002-12-05 08:41:41 +00:00
|
|
|
#--------------------------------------------------------
|
2005-09-26 16:01:43 +00:00
|
|
|
export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
|
2003-11-05 11:34:26 +00:00
|
|
|
ifeq ($(strip $(TARGET_ARCH)),)
|
2005-07-28 19:38:52 +00:00
|
|
|
TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
|
2002-06-23 04:50:49 +00:00
|
|
|
-e 's/i.86/i386/' \
|
|
|
|
-e 's/sparc.*/sparc/' \
|
|
|
|
-e 's/arm.*/arm/g' \
|
|
|
|
-e 's/m68k.*/m68k/' \
|
|
|
|
-e 's/ppc/powerpc/g' \
|
|
|
|
-e 's/v850.*/v850/g' \
|
|
|
|
-e 's/sh[234]/sh/' \
|
2002-12-05 08:41:41 +00:00
|
|
|
-e 's/mips-.*/mips/' \
|
|
|
|
-e 's/mipsel-.*/mipsel/' \
|
|
|
|
-e 's/cris.*/cris/' \
|
|
|
|
)
|
2003-11-05 11:34:26 +00:00
|
|
|
endif
|
2002-12-05 08:41:41 +00:00
|
|
|
|
2002-10-30 06:55:37 +00:00
|
|
|
# A nifty macro to make testing gcc features easier
|
2005-07-28 22:26:25 +00:00
|
|
|
check_gcc=$(shell \
|
|
|
|
if [ "$(1)" != "" ]; then \
|
|
|
|
if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
|
|
|
|
then echo "$(1)"; else echo "$(2)"; fi \
|
|
|
|
fi)
|
2002-06-23 04:50:49 +00:00
|
|
|
|
2005-07-28 22:14:35 +00:00
|
|
|
# Setup some shortcuts so that silent mode is silent like it should be
|
|
|
|
ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
|
|
|
|
export MAKE_IS_SILENT=n
|
|
|
|
SECHO=@echo
|
|
|
|
else
|
|
|
|
export MAKE_IS_SILENT=y
|
|
|
|
SECHO=-@false
|
|
|
|
endif
|
|
|
|
|
2006-01-23 13:47:36 +00:00
|
|
|
#CFLAGS+=$(call check_gcc,-funsigned-char,)
|
2005-12-13 11:52:46 +00:00
|
|
|
|
2006-01-15 14:04:57 +00:00
|
|
|
CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,)
|
|
|
|
|
2002-06-23 04:50:49 +00:00
|
|
|
#--------------------------------------------------------
|
|
|
|
# Arch specific compiler optimization stuff should go here.
|
|
|
|
# Unless you want to override the defaults, do not set anything
|
|
|
|
# for OPTIMIZATION...
|
|
|
|
|
|
|
|
# use '-Os' optimization if available, else use -O2
|
2005-07-28 22:26:25 +00:00
|
|
|
OPTIMIZATION:=$(call check_gcc,-Os,-O2)
|
2002-06-23 04:50:49 +00:00
|
|
|
|
2006-01-15 14:04:57 +00:00
|
|
|
ifeq ($(CONFIG_BUILD_AT_ONCE),y)
|
|
|
|
# gcc 2.95 exits with 0 for "unrecognized option"
|
|
|
|
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
|
2006-01-24 18:25:51 +00:00
|
|
|
OPTIMIZATION+=$(call check_gcc,--combine,)
|
2006-01-15 14:04:57 +00:00
|
|
|
endif
|
|
|
|
OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
|
|
|
|
PROG_CFLAGS+=$(call check_gcc,-fwhole-program,)
|
|
|
|
endif # CONFIG_BUILD_AT_ONCE
|
|
|
|
|
2002-06-23 04:50:49 +00:00
|
|
|
# Some nice architecture specific optimizations
|
|
|
|
ifeq ($(strip $(TARGET_ARCH)),arm)
|
|
|
|
OPTIMIZATION+=-fstrict-aliasing
|
2006-01-15 14:04:57 +00:00
|
|
|
OPTIMIZATION+=$(call check_gcc,-msingle-pic-base,)
|
2002-06-23 04:50:49 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(strip $(TARGET_ARCH)),i386)
|
2003-07-22 08:56:01 +00:00
|
|
|
OPTIMIZATION+=$(call check_gcc,-march=i386,)
|
2006-01-15 14:04:57 +00:00
|
|
|
# gcc-4.0 and older seem to suffer from these
|
|
|
|
ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
|
2002-10-30 06:55:37 +00:00
|
|
|
OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
|
|
|
|
OPTIMIZATION+=$(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,\
|
|
|
|
-malign-functions=0 -malign-jumps=0 -malign-loops=0)
|
2006-01-15 14:04:57 +00:00
|
|
|
endif # gcc-4.0 and older
|
|
|
|
|
|
|
|
# gcc-4.1 and beyond seem to benefit from these
|
|
|
|
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
|
|
|
|
# turn off flags which hurt -Os
|
|
|
|
OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
|
|
|
|
OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
|
|
|
|
OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
|
|
|
|
|
|
|
|
OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,)
|
|
|
|
endif # gcc-4.1 and beyond
|
2002-06-23 04:50:49 +00:00
|
|
|
endif
|
2005-07-28 22:26:25 +00:00
|
|
|
OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer
|
2002-06-23 04:50:49 +00:00
|
|
|
|
2002-04-12 12:05:57 +00:00
|
|
|
#
|
|
|
|
#--------------------------------------------------------
|
|
|
|
# If you're going to do a lot of builds with a non-vanilla configuration,
|
|
|
|
# it makes sense to adjust parameters above, so you can type "make"
|
|
|
|
# by itself, instead of following it by the same half-dozen overrides
|
|
|
|
# every time. The stuff below, on the other hand, is probably less
|
|
|
|
# prone to casual user adjustment.
|
2004-03-15 08:29:22 +00:00
|
|
|
#
|
2002-04-12 12:05:57 +00:00
|
|
|
|
2003-07-22 22:15:21 +00:00
|
|
|
ifeq ($(strip $(CONFIG_LFS)),y)
|
2002-04-12 12:05:57 +00:00
|
|
|
# For large file summit support
|
2002-09-22 12:09:44 +00:00
|
|
|
CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
|
2002-04-12 12:05:57 +00:00
|
|
|
endif
|
2003-07-22 22:15:21 +00:00
|
|
|
ifeq ($(strip $(CONFIG_DMALLOC)),y)
|
2002-04-12 12:05:57 +00:00
|
|
|
# For testing mem leaks with dmalloc
|
|
|
|
CFLAGS+=-DDMALLOC
|
|
|
|
LIBRARIES:=-ldmalloc
|
|
|
|
else
|
2003-07-22 22:15:21 +00:00
|
|
|
ifeq ($(strip $(CONFIG_EFENCE)),y)
|
2002-04-12 12:05:57 +00:00
|
|
|
LIBRARIES:=-lefence
|
|
|
|
endif
|
|
|
|
endif
|
2003-07-22 22:15:21 +00:00
|
|
|
ifeq ($(strip $(CONFIG_DEBUG)),y)
|
2002-04-12 12:05:57 +00:00
|
|
|
CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
|
|
|
|
LDFLAGS +=-Wl,-warn-common
|
|
|
|
STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
|
|
|
|
else
|
2003-03-07 17:27:51 +00:00
|
|
|
CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
|
2006-01-15 14:04:57 +00:00
|
|
|
LDFLAGS += -Wl,-warn-common -Wl,--sort-common
|
2005-07-31 22:11:33 +00:00
|
|
|
STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
|
2002-04-12 12:05:57 +00:00
|
|
|
endif
|
2003-07-22 22:15:21 +00:00
|
|
|
ifeq ($(strip $(CONFIG_STATIC)),y)
|
2002-04-12 12:05:57 +00:00
|
|
|
LDFLAGS += --static
|
2006-01-15 14:04:57 +00:00
|
|
|
#else
|
|
|
|
# LIBRARIES += -ldl
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
|
|
|
|
CFLAGS_PIC:= -fPIC #-DPIC
|
2001-10-24 05:26:42 +00:00
|
|
|
endif
|
|
|
|
|
2005-10-05 07:40:46 +00:00
|
|
|
ifeq ($(strip $(CONFIG_SELINUX)),y)
|
|
|
|
LIBRARIES += -lselinux
|
|
|
|
endif
|
|
|
|
|
2002-10-26 10:17:24 +00:00
|
|
|
ifeq ($(strip $(PREFIX)),)
|
2002-04-12 12:05:57 +00:00
|
|
|
PREFIX:=`pwd`/_install
|
|
|
|
endif
|
2001-10-24 05:26:42 +00:00
|
|
|
|
2002-04-12 12:05:57 +00:00
|
|
|
# Additional complications due to support for pristine source dir.
|
|
|
|
# Include files in the build directory should take precedence over
|
2005-10-05 07:40:46 +00:00
|
|
|
# the copy in top_srcdir, both during the compilation phase and the
|
2002-04-12 12:05:57 +00:00
|
|
|
# shell script that finds the list of object files.
|
|
|
|
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
2005-10-05 07:40:46 +00:00
|
|
|
|
2001-10-24 05:26:42 +00:00
|
|
|
|
2002-04-12 12:05:57 +00:00
|
|
|
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
|
|
|
|
CFLAGS += $(CROSS_CFLAGS)
|
|
|
|
ifdef BB_INIT_SCRIPT
|
|
|
|
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
2001-10-24 05:26:42 +00:00
|
|
|
endif
|
|
|
|
|
2002-04-12 12:05:57 +00:00
|
|
|
# Put user-supplied flags at the end, where they
|
|
|
|
# have a chance of winning.
|
|
|
|
CFLAGS += $(CFLAGS_EXTRA)
|
2001-10-24 05:26:42 +00:00
|
|
|
|
2005-12-15 07:25:54 +00:00
|
|
|
#------------------------------------------------------------
|
|
|
|
# Installation options
|
|
|
|
ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y)
|
|
|
|
INSTALL_OPTS=--hardlinks
|
|
|
|
endif
|
|
|
|
ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y)
|
|
|
|
INSTALL_OPTS=--symlinks
|
|
|
|
endif
|
|
|
|
ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
|
|
|
|
INSTALL_OPTS=
|
|
|
|
endif
|
|
|
|
|
2002-04-12 12:05:57 +00:00
|
|
|
.PHONY: dummy
|