blob: 77435e3bd85fa6701a6246dcfb3bd2f598de71b9 [file] [log] [blame]
Eric Andersen85208e22002-04-12 12:05:57 +00001# Rules.make for busybox
Eric Andersen4bcdd722001-10-24 05:26:42 +00002#
Mike Frysinger5a5d0fa2005-11-29 02:53:52 +00003# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
Eric Andersen85208e22002-04-12 12:05:57 +00004#
Mike Frysinger5a5d0fa2005-11-29 02:53:52 +00005# Licensed under GPLv2, see the file LICENSE in this tarball for details.
Eric Andersen4bcdd722001-10-24 05:26:42 +00006#
7
Mike Frysinger004ad112005-11-29 02:52:25 +00008# Pull in the user's busybox configuration
9ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
10-include $(top_builddir)/.config
11endif
12
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000013ifeq ($(HAVE_DOT_CONFIG),y)
14rules-mak-rules:=0
15endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000016
Eric Andersenc9f20d92002-12-05 08:41:41 +000017#--------------------------------------------------------
Eric Andersen85208e22002-04-12 12:05:57 +000018PROG := busybox
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000019MAJOR_VERSION :=1
20MINOR_VERSION :=1
Bernhard Reutner-Fischerb565a122006-01-19 09:22:39 +000021SUBLEVEL_VERSION:=1
22EXTRAVERSION :=-pre0
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000023VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
Eric Andersen85208e22002-04-12 12:05:57 +000024BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
Eric Andersen4bcdd722001-10-24 05:26:42 +000025
26
Eric Andersenc9f20d92002-12-05 08:41:41 +000027#--------------------------------------------------------
Eric Andersen85208e22002-04-12 12:05:57 +000028# With a modern GNU make(1) (highly recommended, that's what all the
29# developers use), all of the following configuration values can be
30# overridden at the command line. For example:
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000031# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
Eric Andersenc9f20d92002-12-05 08:41:41 +000032#--------------------------------------------------------
Eric Andersen4bcdd722001-10-24 05:26:42 +000033
Eric Andersenc9f20d92002-12-05 08:41:41 +000034# If you are running a cross compiler, you will want to set 'CROSS'
35# to something more interesting... Target architecture is determined
36# by asking the CC compiler what arch it compiles things for, so unless
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000037# your compiler is broken, you should not need to specify __TARGET_ARCH
Eric Andersen5912acb2003-11-05 11:34:26 +000038CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000039#")
Eric Andersen5912acb2003-11-05 11:34:26 +000040CC = $(CROSS)gcc
41AR = $(CROSS)ar
42AS = $(CROSS)as
43LD = $(CROSS)ld
44NM = $(CROSS)nm
45STRIP = $(CROSS)strip
46CPP = $(CC) -E
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000047SED ?= sed
48AWK ?= awk
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000049
Eric Andersen85208e22002-04-12 12:05:57 +000050
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000051ifdef PACKAGE_BE_VERBOSE
52PACKAGE_BE_VERBOSE := $(shell echo $(PACKAGE_BE_VERBOSE) | $(SED) "s/[[:alpha:]]*//g")
53endif
54
55# for make V=3 and above make $(shell) invocations verbose
56ifeq ($(if $(strip $(PACKAGE_BE_VERBOSE)),$(shell test $(PACKAGE_BE_VERBOSE) -gt 2 ; echo $$?),1),0)
57 SHELL+=-x
58 MKDEP_ARGS:=-w
59endif
60
Eric Andersenc9f20d92002-12-05 08:41:41 +000061# What OS are you compiling busybox for? This allows you to include
62# OS specific things, syscall overrides, etc.
Eric Andersen5912acb2003-11-05 11:34:26 +000063TARGET_OS=linux
Eric Andersen85208e22002-04-12 12:05:57 +000064
Eric Andersenc9f20d92002-12-05 08:41:41 +000065# Select the compiler needed to build binaries for your development system
Eric Andersen5912acb2003-11-05 11:34:26 +000066HOSTCC = gcc
Robert Griebl53f133a2002-12-16 21:55:39 +000067HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
Eric Andersenc9f20d92002-12-05 08:41:41 +000068
Eric Andersenc7bda1c2004-03-15 08:29:22 +000069# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
Eric Andersen85d9d802003-01-14 09:12:39 +000070LC_ALL:= C
71
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000072# initialize flags here
73CFLAGS:=
74CFLAGS_COMBINE:=
75CFLAGS_PIC:=
76LD_FLAGS:=
77LIB_LDFLAGS:=
78PROG_LDFLAGS:=
79PROG_CFLAGS:=
80OPTIMIZATIONS:=
81
Eric Andersenc9f20d92002-12-05 08:41:41 +000082# If you want to add some simple compiler switches (like -march=i686),
83# especially from the command line, use this instead of CFLAGS directly.
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000084# For optimization overrides, it's better still to set OPTIMIZATIONS.
Eric Andersenc9f20d92002-12-05 08:41:41 +000085CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000086#")
Eric Andersenc7bda1c2004-03-15 08:29:22 +000087
Eric Andersen85208e22002-04-12 12:05:57 +000088# To compile vs some other alternative libc, you may need to use/adjust
89# the following lines to meet your needs...
90#
91# If you are using Red Hat 6.x with the compatible RPMs (for developing under
92# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
93# using the compatible RPMs (compat-*) at http://www.redhat.com !
94#LIBCDIR:=/usr/i386-glibc20-linux
95#
Eric Andersen0a14c9f2003-07-22 08:56:01 +000096# For other libraries, you are on your own. But these may (or may not) help...
Eric Andersen85208e22002-04-12 12:05:57 +000097#LDFLAGS+=-nostdlib
98#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
Rob Landley4a070d12005-12-01 17:01:43 +000099#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
Eric Andersen85208e22002-04-12 12:05:57 +0000100#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
101
Robert Griebl53f133a2002-12-16 21:55:39 +0000102WARNINGS=-Wall -Wstrict-prototypes -Wshadow
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000103CFLAGS+=-I$(top_builddir)/include -I$(top_srcdir)/include
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000104
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000105ARFLAGS=cru
Eric Andersen85208e22002-04-12 12:05:57 +0000106
Bernhard Reutner-Fischere0b87782005-12-13 11:52:46 +0000107
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000108
109# Get the CC MAJOR/MINOR version
Bernhard Reutner-Fischere0b87782005-12-13 11:52:46 +0000110# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
Bernhard Reutner-Fischere0b87782005-12-13 11:52:46 +0000111CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
112CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
113
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000114# Note: spaces are significant here!
115# Check if CC version is equal to given MAJOR,MINOR. Returns empty if false.
116define cc_eq
117$(shell [ $(CC_MAJOR) -eq $(1) -a $(CC_MINOR) -eq $(2) ] && echo y)
118endef
119# Check if CC version is greater or equal than given MAJOR,MINOR
120define cc_ge
121$(shell [ $(CC_MAJOR) -ge $(1) -a $(CC_MINOR) -ge $(2) ] && echo y)
122endef
123# Check if CC version is less or equal than given MAJOR,MINOR
124define cc_le
125$(shell [ $(CC_MAJOR) -le $(1) -a $(CC_MINOR) -le $(2) ] && echo y)
126endef
127
128# Workaround bugs in make-3.80 for eval in conditionals
129define is_eq
130$(shell [ $(1) = $(2) ] 2> /dev/null && echo y)
131endef
132define is_neq
133$(shell [ $(1) != $(2) ] 2> /dev/null && echo y)
134endef
135
Eric Andersenc9f20d92002-12-05 08:41:41 +0000136#--------------------------------------------------------
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +0000137export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000138
139# TARGET_ARCH and TARGET_MACH will be passed verbatim to CC with recent
140# versions of make, so we use __TARGET_ARCH here.
141# Current builtin rules looks like that:
142# COMPILE.s = $(AS) $(ASFLAGS) $(TARGET_MACH)
143# COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
144
145ifeq ($(strip $(__TARGET_ARCH)),)
146__TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000147 -e 's/i.86/i386/' \
148 -e 's/sparc.*/sparc/' \
149 -e 's/arm.*/arm/g' \
150 -e 's/m68k.*/m68k/' \
151 -e 's/ppc/powerpc/g' \
152 -e 's/v850.*/v850/g' \
153 -e 's/sh[234]/sh/' \
Eric Andersenc9f20d92002-12-05 08:41:41 +0000154 -e 's/mips-.*/mips/' \
155 -e 's/mipsel-.*/mipsel/' \
156 -e 's/cris.*/cris/' \
157 )
Eric Andersen5912acb2003-11-05 11:34:26 +0000158endif
Eric Andersenc9f20d92002-12-05 08:41:41 +0000159
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000160CFLAGS+=$(call check_gcc,CFLAGS,-funsigned-char,)
161CFLAGS+=$(call check_gcc,CFLAGS,-mmax-stack-frame=256,)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000162
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000163#--------------------------------------------------------
164# Arch specific compiler optimization stuff should go here.
165# Unless you want to override the defaults, do not set anything
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000166# for OPTIMIZATIONS...
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000167
168# use '-Os' optimization if available, else use -O2
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000169OPTIMIZATIONS+=$(call check_gcc,OPTIMIZATIONS,-Os,-O2)
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000170
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000171# gcc 2.95 exits with 0 for "unrecognized option"
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000172CFLAGS_COMBINE+=$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000173 $(if $(call cc_ge,3,0),\
174 $(call check_gcc,CFLAGS_COMBINE,--combine,)))
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000175
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000176OPTIMIZATIONS+=$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000177 $(call check_gcc,OPTIMIZATIONS,-funit-at-a-time,))
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000178
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000179# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000180#PROG_CFLAGS+=$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000181# $(call check_gcc,PROG_CFLAGS,-fwhole-program,))
182
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000183LIB_LDFLAGS+=$(call check_ld,LIB_LDFLAGS,--enable-new-dtags,)
184#LIB_LDFLAGS+=$(call check_ld,LIB_LDFLAGS,--reduce-memory-overheads,)
185#LIB_LDFLAGS+=$(call check_ld,LIB_LDFLAGS,--as-needed,)
186#LIB_LDFLAGS+=$(call check_ld,LIB_LDFLAGS,--warn-shared-textrel,)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000187
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000188PROG_LDFLAGS+=$(call check_ld,PROG_LDFLAGS,--gc-sections,)
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000189
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000190# Some nice architecture specific optimizations
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000191ifeq ($(__TARGET_ARCH),arm)
192 OPTIMIZATIONS+=-fstrict-aliasing
193endif # arm
194
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000195OPTIMIZATIONS+=$(if $(call is_eq,$(__TARGET_ARCH),i386),\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000196 $(call check_gcc,OPTIMIZATIONS,-march=i386,))
197
Bernhard Reutner-Fischerd9969ea2006-03-03 20:31:33 +0000198# gcc-4.0 and older seem to benefit from these
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000199OPTIMIZATIONS+=$(if $(call cc_le,4,0),\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000200 $(call check_gcc,OPTIMIZATIONS,-mpreferred-stack-boundary=2,)\
Rob Landleyc05dda42006-03-03 17:57:50 +0000201 $(call check_gcc,OPTIMIZATIONS,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000202 -malign-functions=0 -malign-jumps=0 -malign-loops=0))
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000203
204# gcc-4.1 and beyond seem to benefit from these
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000205# turn off flags which hurt -Os
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000206OPTIMIZATIONS+=$(if $(call cc_ge,4,1),\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000207 $(call check_gcc,OPTIMIZATIONS,-fno-tree-loop-optimize,)\
208 $(call check_gcc,OPTIMIZATIONS,-fno-tree-dominator-opts,)\
209 $(call check_gcc,OPTIMIZATIONS,-fno-strength-reduce,)\
210\
211 $(call check_gcc,OPTIMIZATIONS,-fno-branch-count-reg,))
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000212
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000213OPTIMIZATIONS+=$(call check_gcc,OPTIMIZATIONS,-fomit-frame-pointer,)
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000214
Eric Andersen85208e22002-04-12 12:05:57 +0000215#
216#--------------------------------------------------------
217# If you're going to do a lot of builds with a non-vanilla configuration,
218# it makes sense to adjust parameters above, so you can type "make"
219# by itself, instead of following it by the same half-dozen overrides
220# every time. The stuff below, on the other hand, is probably less
221# prone to casual user adjustment.
Eric Andersenc7bda1c2004-03-15 08:29:22 +0000222#
Eric Andersen85208e22002-04-12 12:05:57 +0000223
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000224ifeq ($(CONFIG_LFS),y)
Eric Andersen85208e22002-04-12 12:05:57 +0000225 # For large file summit support
Eric Andersenecfa2902002-09-22 12:09:44 +0000226 CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
Eric Andersen85208e22002-04-12 12:05:57 +0000227endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000228ifeq ($(CONFIG_DMALLOC),y)
Eric Andersen85208e22002-04-12 12:05:57 +0000229 # For testing mem leaks with dmalloc
230 CFLAGS+=-DDMALLOC
231 LIBRARIES:=-ldmalloc
Eric Andersen85208e22002-04-12 12:05:57 +0000232else
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000233 ifeq ($(CONFIG_EFENCE),y)
Eric Andersen85208e22002-04-12 12:05:57 +0000234 LIBRARIES:=-lefence
Eric Andersen85208e22002-04-12 12:05:57 +0000235 endif
236endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000237
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000238LDFLAGS+=$(if $(call is_eq,$(CONFIG_DEBUG),y),$(call check_ld,LDFLAGS,--warn-common,)$(call check_ld,LDFLAGS,--sort-common,))
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000239ifeq ($(CONFIG_DEBUG),y)
Eric Andersen85208e22002-04-12 12:05:57 +0000240 CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
Eric Andersen85208e22002-04-12 12:05:57 +0000241 STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
242else
Eric Andersenbae7c1a2003-03-07 17:27:51 +0000243 CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
Mike Frysinger1c1655a2005-07-31 22:11:33 +0000244 STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
Eric Andersen85208e22002-04-12 12:05:57 +0000245endif
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000246PROG_CFLAGS+=$(if $(call is_eq,$(CONFIG_STATIC),y),\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000247 $(call check_gcc,PROG_CFLAGS,-static,))
248
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000249CFLAGS_SHARED+=$(call check_gcc,CFLAGS_SHARED,-shared,)
Bernhard Reutner-Fischer81b94962006-01-31 11:29:22 +0000250LIB_CFLAGS+=$(CFLAGS_SHARED)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000251
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000252CFLAGS_PIC+=$(if $(call is_eq,$(CONFIG_BUILD_LIBBUSYBOX),y),\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000253 $(call check_gcc,CFLAGS_PIC,-fPIC,))
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000254LIB_CFLAGS+=$(CFLAGS_PIC)
Eric Andersen85208e22002-04-12 12:05:57 +0000255
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000256ifeq ($(CONFIG_SELINUX),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000257 LIBRARIES += -lselinux
258endif
259
Eric Andersen12f834c2002-10-26 10:17:24 +0000260ifeq ($(strip $(PREFIX)),)
Eric Andersen85208e22002-04-12 12:05:57 +0000261 PREFIX:=`pwd`/_install
262endif
263
Eric Andersen85208e22002-04-12 12:05:57 +0000264CFLAGS += $(CROSS_CFLAGS)
265ifdef BB_INIT_SCRIPT
266 CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
267endif
268
269# Put user-supplied flags at the end, where they
270# have a chance of winning.
271CFLAGS += $(CFLAGS_EXTRA)
Eric Andersen4bcdd722001-10-24 05:26:42 +0000272
Rob Landleye0c418e2005-12-15 07:25:54 +0000273#------------------------------------------------------------
274# Installation options
275ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y)
276INSTALL_OPTS=--hardlinks
277endif
278ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y)
279INSTALL_OPTS=--symlinks
280endif
281ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
282INSTALL_OPTS=
283endif
284
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000285
286#------------------------------------------------------------
287# object extensions
288
289# object potentially used in shared object
290ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
291# single-object extension
292os:=.os
293# multi-object extension
294om:=.osm
295else
296os:=.o
297om:=.om
298endif
299
Mike Frysingerb38673f2006-02-02 01:41:53 +0000300#------------------------------------------------------------
301# Make the output nice and tight
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000302
303# for make V=2 and above, do print directory
304ifneq ($(shell test -n "$(strip $(PACKAGE_BE_VERBOSE))" && test $(PACKAGE_BE_VERBOSE) -gt 1 ; echo $$?),0)
305 MAKEFLAGS += --no-print-directory
306endif
307
308export MAKEOVERRIDES
Mike Frysingerb38673f2006-02-02 01:41:53 +0000309export MAKE_IS_SILENT=n
310ifneq ($(findstring s,$(MAKEFLAGS)),)
311export MAKE_IS_SILENT=y
Mike Frysingerb38673f2006-02-02 01:41:53 +0000312DISP := sil
313Q := @
314else
315ifneq ($(V)$(VERBOSE),)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000316DISP := ver
317Q :=
318else
Mike Frysingerb38673f2006-02-02 01:41:53 +0000319DISP := pur
320Q := @
321endif
322endif
323
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000324define show_objs
325 $(subst $(top_builddir)/,,$(subst ../,,$@))
326endef
327pur_disp_compile.c = @echo " "CC $(show_objs) ;
328pur_disp_compile.h = @echo " "HOSTCC $(show_objs) ;
329pur_disp_strip = @echo " "STRIP $(show_objs) ;
330pur_disp_link = @echo " "LINK $(show_objs) ;
331pur_disp_link.h = @echo " "HOSTLINK $(show_objs) ;
332pur_disp_ar = @echo " "AR $(ARFLAGS) $(show_objs) ;
333pur_disp_gen = @echo " "GEN $@ ;
334pur_disp_doc = @echo " "DOC $(subst docs/,,$@) ;
335pur_disp_bin = @echo " "BIN $(show_objs) ;
336sil_disp_compile.c = @
337sil_disp_compile.h = @
338sil_disp_strip = @
339sil_disp_link = @
340sil_disp_link.h = @
341sil_disp_ar = @
342sil_disp_gen = @
343sil_disp_doc = @
344sil_disp_bin = @
345ver_disp_compile.c =
346ver_disp_compile.h =
347ver_disp_strip =
348ver_disp_link =
349ver_disp_link.h =
350ver_disp_ar =
351ver_disp_gen =
352ver_disp_doc =
353ver_disp_bin =
Mike Frysingerb38673f2006-02-02 01:41:53 +0000354disp_compile.c = $($(DISP)_disp_compile.c)
355disp_compile.h = $($(DISP)_disp_compile.h)
356disp_strip = $($(DISP)_disp_strip)
357disp_link = $($(DISP)_disp_link)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000358disp_link.h = $($(DISP)_disp_link.h)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000359disp_ar = $($(DISP)_disp_ar)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000360disp_gen = $($(DISP)_disp_gen)
361disp_doc = $($(DISP)_disp_doc)
362disp_bin = $($(DISP)_disp_bin)
363# CFLAGS-dir == $(CFLAGS-$(notdir $(@D)))
364# CFLAGS-dir-file.o == $(CFLAGS-$(notdir $(@D))-$(notdir $(@F)))
365# CFLAGS-dir-file.c == $(CFLAGS-$(notdir $(<D))-$(notdir $(<F)))
366# all prerequesites == $(foreach fil,$^,$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(fil))))-$(notdir $(fil))))
367cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I$(srcdir) -c -o $@ $< \
368 $(foreach f,$^,$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \
369 $(CFLAGS-$(notdir $(@D))-$(notdir $(@F))) \
370 $(CFLAGS-$(notdir $(@D)))
371cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
Mike Frysingerb38673f2006-02-02 01:41:53 +0000372cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
373cmd_strip = $(STRIPCMD) $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000374cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I$(srcdir) $(LDFLAGS)
375cmd_link.h = $(HOSTCC) $(HOSTCFLAGS) $(HOST_LDFLAGS) $^ -o $@
Mike Frysingerb38673f2006-02-02 01:41:53 +0000376cmd_ar = $(AR) $(ARFLAGS) $@ $^
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000377compile.c = $(disp_compile.c) $(cmd_compile.c)
378compile.m = $(disp_compile.c) $(cmd_compile.m)
379compile.h = $(disp_compile.h) $(cmd_compile.h)
380do_strip = $(disp_strip) $(cmd_strip)
381do_link = $(disp_link) $(cmd_link)
382do_link.h = $(disp_link.h) $(cmd_link.h)
383do_ar = $(disp_ar) $(cmd_ar)
384
385ifdef rules-mak-rules
386.SUFFIXES: .c .S .o .os .om .osm .oS .so .a .s .i .E
387
388# generic rules
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000389%.o: ; $(compile.c)
390%.os: ; $(compile.c) $(CFLAGS_PIC)
391%.om: ; $(compile.m)
392%.osm: ; $(compile.m) $(CFLAGS_PIC)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000393%.a: ; $(do_ar)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000394
395endif # rules-mak-rules
Mike Frysingerb38673f2006-02-02 01:41:53 +0000396
Eric Andersen85208e22002-04-12 12:05:57 +0000397.PHONY: dummy
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000398