blob: 51c9baeab48304191b1844c09fbf1d5da78bca65 [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 ($(MAKELEVEL),0)
14ifeq ($(HAVE_DOT_CONFIG),y)
15rules-mak-rules:=0
16endif
17endif
18
Eric Andersenc9f20d92002-12-05 08:41:41 +000019#--------------------------------------------------------
Eric Andersen85208e22002-04-12 12:05:57 +000020PROG := busybox
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000021MAJOR_VERSION :=1
22MINOR_VERSION :=1
Bernhard Reutner-Fischerb565a122006-01-19 09:22:39 +000023SUBLEVEL_VERSION:=1
24EXTRAVERSION :=-pre0
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000025VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
Eric Andersen85208e22002-04-12 12:05:57 +000026BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
Eric Andersen4bcdd722001-10-24 05:26:42 +000027
28
Eric Andersenc9f20d92002-12-05 08:41:41 +000029#--------------------------------------------------------
Eric Andersen85208e22002-04-12 12:05:57 +000030# With a modern GNU make(1) (highly recommended, that's what all the
31# developers use), all of the following configuration values can be
32# overridden at the command line. For example:
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000033# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
Eric Andersenc9f20d92002-12-05 08:41:41 +000034#--------------------------------------------------------
Eric Andersen4bcdd722001-10-24 05:26:42 +000035
Eric Andersenc9f20d92002-12-05 08:41:41 +000036# If you are running a cross compiler, you will want to set 'CROSS'
37# to something more interesting... Target architecture is determined
38# by asking the CC compiler what arch it compiles things for, so unless
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000039# your compiler is broken, you should not need to specify __TARGET_ARCH
Eric Andersen5912acb2003-11-05 11:34:26 +000040CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000041#")
Eric Andersen5912acb2003-11-05 11:34:26 +000042CC = $(CROSS)gcc
43AR = $(CROSS)ar
44AS = $(CROSS)as
45LD = $(CROSS)ld
46NM = $(CROSS)nm
47STRIP = $(CROSS)strip
48CPP = $(CC) -E
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000049SED ?= sed
50AWK ?= awk
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000051
Eric Andersen85208e22002-04-12 12:05:57 +000052
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000053ifdef PACKAGE_BE_VERBOSE
54PACKAGE_BE_VERBOSE := $(shell echo $(PACKAGE_BE_VERBOSE) | $(SED) "s/[[:alpha:]]*//g")
55endif
56
57# for make V=3 and above make $(shell) invocations verbose
58ifeq ($(if $(strip $(PACKAGE_BE_VERBOSE)),$(shell test $(PACKAGE_BE_VERBOSE) -gt 2 ; echo $$?),1),0)
59 SHELL+=-x
60 MKDEP_ARGS:=-w
61endif
62
Eric Andersenc9f20d92002-12-05 08:41:41 +000063# What OS are you compiling busybox for? This allows you to include
64# OS specific things, syscall overrides, etc.
Eric Andersen5912acb2003-11-05 11:34:26 +000065TARGET_OS=linux
Eric Andersen85208e22002-04-12 12:05:57 +000066
Eric Andersenc9f20d92002-12-05 08:41:41 +000067# Select the compiler needed to build binaries for your development system
Eric Andersen5912acb2003-11-05 11:34:26 +000068HOSTCC = gcc
Robert Griebl53f133a2002-12-16 21:55:39 +000069HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
Eric Andersenc9f20d92002-12-05 08:41:41 +000070
Eric Andersenc7bda1c2004-03-15 08:29:22 +000071# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
Eric Andersen85d9d802003-01-14 09:12:39 +000072LC_ALL:= C
73
Eric Andersenc9f20d92002-12-05 08:41:41 +000074# If you want to add some simple compiler switches (like -march=i686),
75# especially from the command line, use this instead of CFLAGS directly.
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000076# For optimization overrides, it's better still to set OPTIMIZATIONS.
Eric Andersenc9f20d92002-12-05 08:41:41 +000077CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000078#")
Eric Andersenc7bda1c2004-03-15 08:29:22 +000079
Eric Andersen85208e22002-04-12 12:05:57 +000080# To compile vs some other alternative libc, you may need to use/adjust
81# the following lines to meet your needs...
82#
83# If you are using Red Hat 6.x with the compatible RPMs (for developing under
84# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
85# using the compatible RPMs (compat-*) at http://www.redhat.com !
86#LIBCDIR:=/usr/i386-glibc20-linux
87#
Eric Andersen0a14c9f2003-07-22 08:56:01 +000088# For other libraries, you are on your own. But these may (or may not) help...
Eric Andersen85208e22002-04-12 12:05:57 +000089#LDFLAGS+=-nostdlib
90#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
Rob Landley4a070d12005-12-01 17:01:43 +000091#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
Eric Andersen85208e22002-04-12 12:05:57 +000092#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
93
Robert Griebl53f133a2002-12-16 21:55:39 +000094WARNINGS=-Wall -Wstrict-prototypes -Wshadow
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000095CFLAGS+=-I$(top_builddir)/include -I$(top_srcdir)/include
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +000096
Bernhard Reutner-Fischerc8e278f2006-03-02 18:13:05 +000097ARFLAGS=cruP
Eric Andersen85208e22002-04-12 12:05:57 +000098
Bernhard Reutner-Fischere0b87782005-12-13 11:52:46 +000099
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000100
101# Get the CC MAJOR/MINOR version
Bernhard Reutner-Fischere0b87782005-12-13 11:52:46 +0000102# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
Bernhard Reutner-Fischere0b87782005-12-13 11:52:46 +0000103CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
104CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
105
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000106# Note: spaces are significant here!
107# Check if CC version is equal to given MAJOR,MINOR. Returns empty if false.
108define cc_eq
109$(shell [ $(CC_MAJOR) -eq $(1) -a $(CC_MINOR) -eq $(2) ] && echo y)
110endef
111# Check if CC version is greater or equal than given MAJOR,MINOR
112define cc_ge
113$(shell [ $(CC_MAJOR) -ge $(1) -a $(CC_MINOR) -ge $(2) ] && echo y)
114endef
115# Check if CC version is less or equal than given MAJOR,MINOR
116define cc_le
117$(shell [ $(CC_MAJOR) -le $(1) -a $(CC_MINOR) -le $(2) ] && echo y)
118endef
119
120# Workaround bugs in make-3.80 for eval in conditionals
121define is_eq
122$(shell [ $(1) = $(2) ] 2> /dev/null && echo y)
123endef
124define is_neq
125$(shell [ $(1) != $(2) ] 2> /dev/null && echo y)
126endef
127
Eric Andersenc9f20d92002-12-05 08:41:41 +0000128#--------------------------------------------------------
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +0000129export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000130
131# TARGET_ARCH and TARGET_MACH will be passed verbatim to CC with recent
132# versions of make, so we use __TARGET_ARCH here.
133# Current builtin rules looks like that:
134# COMPILE.s = $(AS) $(ASFLAGS) $(TARGET_MACH)
135# COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
136
137ifeq ($(strip $(__TARGET_ARCH)),)
138__TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000139 -e 's/i.86/i386/' \
140 -e 's/sparc.*/sparc/' \
141 -e 's/arm.*/arm/g' \
142 -e 's/m68k.*/m68k/' \
143 -e 's/ppc/powerpc/g' \
144 -e 's/v850.*/v850/g' \
145 -e 's/sh[234]/sh/' \
Eric Andersenc9f20d92002-12-05 08:41:41 +0000146 -e 's/mips-.*/mips/' \
147 -e 's/mipsel-.*/mipsel/' \
148 -e 's/cris.*/cris/' \
149 )
Eric Andersen5912acb2003-11-05 11:34:26 +0000150endif
Eric Andersenc9f20d92002-12-05 08:41:41 +0000151
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000152$(call check_gcc,CFLAGS,-funsigned-char,)
153$(call check_gcc,CFLAGS,-mmax-stack-frame=256,)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000154
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000155#--------------------------------------------------------
156# Arch specific compiler optimization stuff should go here.
157# Unless you want to override the defaults, do not set anything
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000158# for OPTIMIZATIONS...
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000159
160# use '-Os' optimization if available, else use -O2
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000161$(call check_gcc,OPTIMIZATIONS,-Os,-O2)
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000162
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000163# gcc 2.95 exits with 0 for "unrecognized option"
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000164$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\
165 $(if $(call cc_ge,3,0),\
166 $(call check_gcc,CFLAGS_COMBINE,--combine,)))
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000167
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000168$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\
169 $(call check_gcc,OPTIMIZATIONS,-funit-at-a-time,))
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000170
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000171# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
172#$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\
173# $(call check_gcc,PROG_CFLAGS,-fwhole-program,))
174
175$(call check_ld,LIB_LDFLAGS,--enable-new-dtags,)
176#$(call check_ld,LIB_LDFLAGS,--reduce-memory-overheads,)
177#$(call check_ld,LIB_LDFLAGS,--as-needed,)
178#$(call check_ld,LIB_LDFLAGS,--warn-shared-textrel,)
179
180$(call check_ld,PROG_LDFLAGS,--gc-sections,)
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000181
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000182# Some nice architecture specific optimizations
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000183ifeq ($(__TARGET_ARCH),arm)
184 OPTIMIZATIONS+=-fstrict-aliasing
185endif # arm
186
187$(if $(call is_eq,$(__TARGET_ARCH),i386),\
188 $(call check_gcc,OPTIMIZATIONS,-march=i386,))
189
Bernhard Reutner-Fischerd9969ea2006-03-03 20:31:33 +0000190# gcc-4.0 and older seem to benefit from these
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000191$(if $(call cc_le,4,0),\
192 $(call check_gcc,OPTIMIZATIONS,-mpreferred-stack-boundary=2,)\
Rob Landleyc05dda42006-03-03 17:57:50 +0000193 $(call check_gcc,OPTIMIZATIONS,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000194 -malign-functions=0 -malign-jumps=0 -malign-loops=0))
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000195
196# gcc-4.1 and beyond seem to benefit from these
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000197# turn off flags which hurt -Os
198$(if $(call cc_ge,4,1),\
199 $(call check_gcc,OPTIMIZATIONS,-fno-tree-loop-optimize,)\
200 $(call check_gcc,OPTIMIZATIONS,-fno-tree-dominator-opts,)\
201 $(call check_gcc,OPTIMIZATIONS,-fno-strength-reduce,)\
202\
203 $(call check_gcc,OPTIMIZATIONS,-fno-branch-count-reg,))
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000204
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000205$(call check_gcc,OPTIMIZATIONS,-fomit-frame-pointer,)
Eric Andersen5b0f9e42002-06-23 04:50:49 +0000206
Eric Andersen85208e22002-04-12 12:05:57 +0000207#
208#--------------------------------------------------------
209# If you're going to do a lot of builds with a non-vanilla configuration,
210# it makes sense to adjust parameters above, so you can type "make"
211# by itself, instead of following it by the same half-dozen overrides
212# every time. The stuff below, on the other hand, is probably less
213# prone to casual user adjustment.
Eric Andersenc7bda1c2004-03-15 08:29:22 +0000214#
Eric Andersen85208e22002-04-12 12:05:57 +0000215
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000216ifeq ($(CONFIG_LFS),y)
Eric Andersen85208e22002-04-12 12:05:57 +0000217 # For large file summit support
Eric Andersenecfa2902002-09-22 12:09:44 +0000218 CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
Eric Andersen85208e22002-04-12 12:05:57 +0000219endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000220ifeq ($(CONFIG_DMALLOC),y)
Eric Andersen85208e22002-04-12 12:05:57 +0000221 # For testing mem leaks with dmalloc
222 CFLAGS+=-DDMALLOC
223 LIBRARIES:=-ldmalloc
Eric Andersen85208e22002-04-12 12:05:57 +0000224else
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000225 ifeq ($(CONFIG_EFENCE),y)
Eric Andersen85208e22002-04-12 12:05:57 +0000226 LIBRARIES:=-lefence
Eric Andersen85208e22002-04-12 12:05:57 +0000227 endif
228endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000229
230$(if $(call is_eq,$(CONFIG_DEBUG),y),\
231 $(call check_ld,LDFLAGS,--warn-common,),\
232 $(call check_ld,LDFLAGS,--warn-common,)$(call check_ld,LDFLAGS,--sort-common,))
233ifeq ($(CONFIG_DEBUG),y)
Eric Andersen85208e22002-04-12 12:05:57 +0000234 CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
Eric Andersen85208e22002-04-12 12:05:57 +0000235 STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
236else
Eric Andersenbae7c1a2003-03-07 17:27:51 +0000237 CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
Mike Frysinger1c1655a2005-07-31 22:11:33 +0000238 STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
Eric Andersen85208e22002-04-12 12:05:57 +0000239endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000240$(if $(call is_eq,$(CONFIG_STATIC),y),\
241 $(call check_gcc,PROG_CFLAGS,-static,))
242
243$(call check_gcc,CFLAGS_SHARED,-shared,)
Bernhard Reutner-Fischer81b94962006-01-31 11:29:22 +0000244LIB_CFLAGS+=$(CFLAGS_SHARED)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000245
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000246$(if $(call is_eq,$(CONFIG_BUILD_LIBBUSYBOX),y),\
247 $(call check_gcc,CFLAGS_PIC,-fPIC,))
Eric Andersen85208e22002-04-12 12:05:57 +0000248
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000249ifeq ($(CONFIG_SELINUX),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000250 LIBRARIES += -lselinux
251endif
252
Eric Andersen12f834c2002-10-26 10:17:24 +0000253ifeq ($(strip $(PREFIX)),)
Eric Andersen85208e22002-04-12 12:05:57 +0000254 PREFIX:=`pwd`/_install
255endif
256
Eric Andersen85208e22002-04-12 12:05:57 +0000257CFLAGS += $(CROSS_CFLAGS)
258ifdef BB_INIT_SCRIPT
259 CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
260endif
261
262# Put user-supplied flags at the end, where they
263# have a chance of winning.
264CFLAGS += $(CFLAGS_EXTRA)
Eric Andersen4bcdd722001-10-24 05:26:42 +0000265
Rob Landleye0c418e2005-12-15 07:25:54 +0000266#------------------------------------------------------------
267# Installation options
268ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y)
269INSTALL_OPTS=--hardlinks
270endif
271ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y)
272INSTALL_OPTS=--symlinks
273endif
274ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
275INSTALL_OPTS=
276endif
277
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000278
279#------------------------------------------------------------
280# object extensions
281
282# object potentially used in shared object
283ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
284# single-object extension
285os:=.os
286# multi-object extension
287om:=.osm
288else
289os:=.o
290om:=.om
291endif
292
Mike Frysingerb38673f2006-02-02 01:41:53 +0000293#------------------------------------------------------------
294# Make the output nice and tight
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000295
296# for make V=2 and above, do print directory
297ifneq ($(shell test -n "$(strip $(PACKAGE_BE_VERBOSE))" && test $(PACKAGE_BE_VERBOSE) -gt 1 ; echo $$?),0)
298 MAKEFLAGS += --no-print-directory
299endif
300
301export MAKEOVERRIDES
Mike Frysingerb38673f2006-02-02 01:41:53 +0000302export MAKE_IS_SILENT=n
303ifneq ($(findstring s,$(MAKEFLAGS)),)
304export MAKE_IS_SILENT=y
Mike Frysingerb38673f2006-02-02 01:41:53 +0000305DISP := sil
306Q := @
307else
308ifneq ($(V)$(VERBOSE),)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000309DISP := ver
310Q :=
311else
Mike Frysingerb38673f2006-02-02 01:41:53 +0000312DISP := pur
313Q := @
314endif
315endif
316
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000317define show_objs
318 $(subst $(top_builddir)/,,$(subst ../,,$@))
319endef
320pur_disp_compile.c = @echo " "CC $(show_objs) ;
321pur_disp_compile.h = @echo " "HOSTCC $(show_objs) ;
322pur_disp_strip = @echo " "STRIP $(show_objs) ;
323pur_disp_link = @echo " "LINK $(show_objs) ;
324pur_disp_link.h = @echo " "HOSTLINK $(show_objs) ;
325pur_disp_ar = @echo " "AR $(ARFLAGS) $(show_objs) ;
326pur_disp_gen = @echo " "GEN $@ ;
327pur_disp_doc = @echo " "DOC $(subst docs/,,$@) ;
328pur_disp_bin = @echo " "BIN $(show_objs) ;
329sil_disp_compile.c = @
330sil_disp_compile.h = @
331sil_disp_strip = @
332sil_disp_link = @
333sil_disp_link.h = @
334sil_disp_ar = @
335sil_disp_gen = @
336sil_disp_doc = @
337sil_disp_bin = @
338ver_disp_compile.c =
339ver_disp_compile.h =
340ver_disp_strip =
341ver_disp_link =
342ver_disp_link.h =
343ver_disp_ar =
344ver_disp_gen =
345ver_disp_doc =
346ver_disp_bin =
Mike Frysingerb38673f2006-02-02 01:41:53 +0000347disp_compile.c = $($(DISP)_disp_compile.c)
348disp_compile.h = $($(DISP)_disp_compile.h)
349disp_strip = $($(DISP)_disp_strip)
350disp_link = $($(DISP)_disp_link)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000351disp_link.h = $($(DISP)_disp_link.h)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000352disp_ar = $($(DISP)_disp_ar)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000353disp_gen = $($(DISP)_disp_gen)
354disp_doc = $($(DISP)_disp_doc)
355disp_bin = $($(DISP)_disp_bin)
356# CFLAGS-dir == $(CFLAGS-$(notdir $(@D)))
357# CFLAGS-dir-file.o == $(CFLAGS-$(notdir $(@D))-$(notdir $(@F)))
358# CFLAGS-dir-file.c == $(CFLAGS-$(notdir $(<D))-$(notdir $(<F)))
359# all prerequesites == $(foreach fil,$^,$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(fil))))-$(notdir $(fil))))
360cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I$(srcdir) -c -o $@ $< \
361 $(foreach f,$^,$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \
362 $(CFLAGS-$(notdir $(@D))-$(notdir $(@F))) \
363 $(CFLAGS-$(notdir $(@D)))
364cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
Mike Frysingerb38673f2006-02-02 01:41:53 +0000365cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
366cmd_strip = $(STRIPCMD) $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000367cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I$(srcdir) $(LDFLAGS)
368cmd_link.h = $(HOSTCC) $(HOSTCFLAGS) $(HOST_LDFLAGS) $^ -o $@
Mike Frysingerb38673f2006-02-02 01:41:53 +0000369cmd_ar = $(AR) $(ARFLAGS) $@ $^
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000370compile.c = $(disp_compile.c) $(cmd_compile.c)
371compile.m = $(disp_compile.c) $(cmd_compile.m)
372compile.h = $(disp_compile.h) $(cmd_compile.h)
373do_strip = $(disp_strip) $(cmd_strip)
374do_link = $(disp_link) $(cmd_link)
375do_link.h = $(disp_link.h) $(cmd_link.h)
376do_ar = $(disp_ar) $(cmd_ar)
377
378ifdef rules-mak-rules
379.SUFFIXES: .c .S .o .os .om .osm .oS .so .a .s .i .E
380
381# generic rules
382%.o: %.c ; $(compile.c)
383%.os: %.c ; $(compile.c) $(CFLAGS_PIC)
384%.o: ; $(compile.c)
385%.os: ; $(compile.c) $(CFLAGS_PIC)
386%.om: ; $(compile.m)
387%.osm: ; $(compile.m) $(CFLAGS_PIC)
388
389endif # rules-mak-rules
Mike Frysingerb38673f2006-02-02 01:41:53 +0000390
Eric Andersen85208e22002-04-12 12:05:57 +0000391.PHONY: dummy
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000392