[821] | 1 | # Rules.make for busybox
|
---|
| 2 | #
|
---|
| 3 | # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
---|
| 4 | #
|
---|
| 5 | # Licensed under GPLv2, see the file LICENSE in this tarball for details.
|
---|
| 6 | #
|
---|
| 7 |
|
---|
| 8 | # Pull in the user's busybox configuration
|
---|
| 9 | ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
|
---|
| 10 | -include $(top_builddir)/.config
|
---|
| 11 | endif
|
---|
| 12 |
|
---|
| 13 | #--------------------------------------------------------
|
---|
| 14 | PROG := busybox
|
---|
| 15 | MAJOR_VERSION :=1
|
---|
| 16 | MINOR_VERSION :=2
|
---|
[902] | 17 | SUBLEVEL_VERSION:=2
|
---|
[821] | 18 | EXTRAVERSION :=
|
---|
| 19 | VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
|
---|
| 20 | BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | #--------------------------------------------------------
|
---|
| 24 | # With a modern GNU make(1) (highly recommended, that's what all the
|
---|
| 25 | # developers use), all of the following configuration values can be
|
---|
| 26 | # overridden at the command line. For example:
|
---|
| 27 | # make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
|
---|
| 28 | #--------------------------------------------------------
|
---|
| 29 |
|
---|
| 30 | # If you are running a cross compiler, you will want to set 'CROSS'
|
---|
| 31 | # to something more interesting... Target architecture is determined
|
---|
| 32 | # by asking the CC compiler what arch it compiles things for, so unless
|
---|
| 33 | # your compiler is broken, you should not need to specify TARGET_ARCH
|
---|
| 34 | CROSS =$(strip $(subst ",, $(strip $(CROSS_COMPILER_PREFIX))))
|
---|
| 35 | # be gentle to vi coloring.. "))
|
---|
| 36 | CC = $(CROSS)gcc
|
---|
| 37 | AR = $(CROSS)ar
|
---|
| 38 | AS = $(CROSS)as
|
---|
| 39 | LD = $(CROSS)ld
|
---|
| 40 | NM = $(CROSS)nm
|
---|
| 41 | STRIP = $(CROSS)strip
|
---|
| 42 | ELF2FLT = $(CROSS)elf2flt
|
---|
| 43 | CPP = $(CC) -E
|
---|
| 44 | SED ?= sed
|
---|
| 45 | BZIP2 ?= bzip2
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | # What OS are you compiling busybox for? This allows you to include
|
---|
| 49 | # OS specific things, syscall overrides, etc.
|
---|
| 50 | TARGET_OS=linux
|
---|
| 51 |
|
---|
| 52 | # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
|
---|
| 53 | LC_ALL:= C
|
---|
| 54 |
|
---|
| 55 | # This must bind late because srcdir is reset for every source subdirectory.
|
---|
| 56 | INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include
|
---|
| 57 | CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE
|
---|
| 58 | CFLAGS+=$(CHECKED_CFLAGS)
|
---|
| 59 | ARFLAGS=cru
|
---|
| 60 |
|
---|
| 61 | # gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
|
---|
| 62 | # get the CC MAJOR/MINOR version
|
---|
| 63 | CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
|
---|
| 64 | CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
|
---|
| 65 |
|
---|
| 66 | #--------------------------------------------------------
|
---|
| 67 | export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
|
---|
| 68 | ifeq ($(strip $(TARGET_ARCH)),)
|
---|
| 69 | TARGET_ARCH:=$(shell $(CC) -dumpmachine | $(SED) -e s'/-.*//' \
|
---|
| 70 | -e 's/i.86/i386/' \
|
---|
| 71 | -e 's/sparc.*/sparc/' \
|
---|
| 72 | -e 's/arm.*/arm/g' \
|
---|
| 73 | -e 's/m68k.*/m68k/' \
|
---|
| 74 | -e 's/ppc/powerpc/g' \
|
---|
| 75 | -e 's/v850.*/v850/g' \
|
---|
| 76 | -e 's/sh[234]/sh/' \
|
---|
| 77 | -e 's/mips-.*/mips/' \
|
---|
| 78 | -e 's/mipsel-.*/mipsel/' \
|
---|
| 79 | -e 's/cris.*/cris/' \
|
---|
| 80 | )
|
---|
| 81 | endif
|
---|
| 82 |
|
---|
| 83 | # A nifty macro to make testing gcc features easier, but note that everything
|
---|
| 84 | # that uses this _must_ use := or it will be re-evaluated everytime it is
|
---|
| 85 | # referenced.
|
---|
| 86 | ifeq ($(strip $(BUILD_VERBOSE)),2)
|
---|
| 87 | VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2;
|
---|
| 88 | endif
|
---|
| 89 | check_cc=$(shell \
|
---|
| 90 | $(VERBOSE_CHECK_CC) \
|
---|
| 91 | if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
|
---|
| 92 | echo "int i;" > ./conftest.c; \
|
---|
| 93 | if $(1) $(2) -c -o conftest.o conftest.c > /dev/null 2>&1; \
|
---|
| 94 | then echo "$(2)"; else echo "$(3)"; fi ; \
|
---|
| 95 | rm -f conftest.c conftest.o; \
|
---|
| 96 | fi)
|
---|
| 97 |
|
---|
| 98 | ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
|
---|
| 99 | check_cc:=
|
---|
| 100 | endif
|
---|
| 101 |
|
---|
| 102 | # A not very robust macro to check for available ld flags
|
---|
| 103 | ifeq ($(strip $(BUILD_VERBOSE)),2)
|
---|
| 104 | VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2;
|
---|
| 105 | endif
|
---|
| 106 | check_ld=$(shell \
|
---|
| 107 | $(VERBOSE_CHECK_LD) \
|
---|
| 108 | if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
|
---|
| 109 | $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && \
|
---|
| 110 | echo "-Wl,$(2)" ; \
|
---|
| 111 | fi)
|
---|
| 112 |
|
---|
| 113 | ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
|
---|
| 114 | check_ld:=
|
---|
| 115 | endif
|
---|
| 116 |
|
---|
| 117 | # A not very robust macro to check for available strip flags
|
---|
| 118 | ifeq ($(strip $(BUILD_VERBOSE)),2)
|
---|
| 119 | VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2;
|
---|
| 120 | endif
|
---|
| 121 | check_strip=$(shell \
|
---|
| 122 | $(VERBOSE_CHECK_STRIP) \
|
---|
| 123 | if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
|
---|
| 124 | echo "int i;" > ./conftest.c ; \
|
---|
| 125 | $(CC) -c -o conftest.o conftest.c > /dev/null 2>&1 ; \
|
---|
| 126 | $(1) $(2) conftest.o > /dev/null 2>&1 && \
|
---|
| 127 | echo "$(1) $(2)" || echo "$(3)"; \
|
---|
| 128 | rm -f conftest.c conftest.o > /dev/null 2>&1 ; \
|
---|
| 129 | fi)
|
---|
| 130 |
|
---|
| 131 | ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
|
---|
| 132 | check_strip:=
|
---|
| 133 | endif
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 | # Select the compiler needed to build binaries for your development system
|
---|
| 137 | HOSTCC = gcc
|
---|
| 138 | HOSTCFLAGS:=$(call check_cc,$(HOSTCC),-Wall,)
|
---|
| 139 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-Wstrict-prototypes,)
|
---|
| 140 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-O2,)
|
---|
| 141 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-fomit-frame-pointer,)
|
---|
| 142 |
|
---|
| 143 | LD_WHOLE_ARCHIVE:=$(shell echo "int i;" > conftest.c ; \
|
---|
| 144 | $(CC) -c -o conftest.o conftest.c ; \
|
---|
| 145 | echo "int main(void){return 0;}" > conftest_main.c ; \
|
---|
| 146 | $(CC) -c -o conftest_main.o conftest_main.c ; \
|
---|
| 147 | $(AR) $(ARFLAGS) conftest.a conftest.o ; \
|
---|
| 148 | $(CC) -Wl,--whole-archive conftest.a -Wl,--no-whole-archive \
|
---|
| 149 | conftest_main.o -o conftest > /dev/null 2>&1 \
|
---|
| 150 | && echo "-Wl,--whole-archive" ; \
|
---|
| 151 | rm conftest_main.o conftest_main.c conftest.o conftest.c \
|
---|
| 152 | conftest.a conftest > /dev/null 2>&1 ; )
|
---|
| 153 | ifneq ($(findstring whole-archive,$(LD_WHOLE_ARCHIVE)),)
|
---|
| 154 | LD_NO_WHOLE_ARCHIVE:= -Wl,--no-whole-archive
|
---|
| 155 | endif
|
---|
| 156 |
|
---|
| 157 | LD_START_GROUP:=$(shell echo "int bar(void){return 0;}" > conftest.c ; \
|
---|
| 158 | $(CC) -c -o conftest.o conftest.c ; \
|
---|
| 159 | echo "int main(void){return bar();}" > conftest_main.c ; \
|
---|
| 160 | $(CC) -c -o conftest_main.o conftest_main.c ; \
|
---|
| 161 | $(AR) $(ARFLAGS) conftest.a conftest.o ; \
|
---|
| 162 | $(CC) -Wl,--start-group conftest.a conftest_main.o -Wl,--end-group \
|
---|
| 163 | -o conftest > /dev/null 2>&1 && echo "-Wl,--start-group" ; \
|
---|
| 164 | rm conftest_main.o conftest_main.c conftest.o conftest.c \
|
---|
| 165 | conftest.a conftest > /dev/null 2>&1 ; )
|
---|
| 166 | ifneq ($(findstring start-group,$(LD_START_GROUP)),)
|
---|
| 167 | LD_END_GROUP:= -Wl,--end-group
|
---|
| 168 | endif
|
---|
| 169 |
|
---|
| 170 | CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,)
|
---|
| 171 |
|
---|
| 172 | # Pin CHECKED_CFLAGS with := so it's only evaluated once.
|
---|
| 173 | CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,)
|
---|
| 174 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
|
---|
| 175 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
|
---|
| 176 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,)
|
---|
| 177 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,)
|
---|
| 178 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen)
|
---|
| 179 |
|
---|
| 180 | # Preemptively pin this too.
|
---|
| 181 | PROG_CFLAGS:=
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 | #--------------------------------------------------------
|
---|
| 185 | # Arch specific compiler optimization stuff should go here.
|
---|
| 186 | # Unless you want to override the defaults, do not set anything
|
---|
| 187 | # for OPTIMIZATION...
|
---|
| 188 |
|
---|
| 189 | # use '-Os' optimization if available, else use -O2
|
---|
| 190 | OPTIMIZATION:=$(call check_cc,$(CC),-Os,-O2)
|
---|
| 191 |
|
---|
| 192 | ifeq ($(CONFIG_BUILD_AT_ONCE),y)
|
---|
| 193 | # gcc 2.95 exits with 0 for "unrecognized option"
|
---|
| 194 | ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
|
---|
| 195 | CFLAGS_COMBINE:=$(call check_cc,$(CC),--combine,)
|
---|
| 196 | endif
|
---|
| 197 | OPTIMIZATION+=$(call check_cc,$(CC),-funit-at-a-time,)
|
---|
| 198 | OPTIMIZATION+=$(call check_cc,$(CC),-fgcse-after-reload,)
|
---|
| 199 | ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y)
|
---|
| 200 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
|
---|
| 201 | # This prevents us from using -fwhole-program when we build the lib
|
---|
| 202 | PROG_CFLAGS+=$(call check_cc,$(CC),-fwhole-program,)
|
---|
| 203 | endif # CONFIG_BUILD_LIBBUSYBOX
|
---|
| 204 | endif # CONFIG_BUILD_AT_ONCE
|
---|
| 205 |
|
---|
| 206 | LIB_LDFLAGS:=$(call check_ld,$(LD),--enable-new-dtags,)
|
---|
| 207 | #LIB_LDFLAGS+=$(call check_ld,$(LD),--reduce-memory-overheads,)
|
---|
| 208 | #LIB_LDFLAGS+=$(call check_ld,$(LD),--as-needed,)
|
---|
| 209 | #LIB_LDFLAGS+=$(call check_ld,$(LD),--warn-shared-textrel,)
|
---|
| 210 |
|
---|
| 211 |
|
---|
| 212 | # Some nice architecture specific optimizations
|
---|
| 213 | ifeq ($(strip $(TARGET_ARCH)),arm)
|
---|
| 214 | OPTIMIZATION+=-fstrict-aliasing
|
---|
| 215 | endif
|
---|
| 216 | ifeq ($(strip $(TARGET_ARCH)),i386)
|
---|
| 217 | OPTIMIZATION+=$(call check_cc,$(CC),-march=i386,)
|
---|
| 218 | # gcc-4.0 and older seem to benefit from these
|
---|
| 219 | #ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
|
---|
| 220 | OPTIMIZATION+=$(call check_cc,$(CC),-mpreferred-stack-boundary=2,)
|
---|
| 221 | OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
|
---|
| 222 | -malign-functions=0 -malign-jumps=0 -malign-loops=0)
|
---|
| 223 | #endif # gcc-4.0 and older
|
---|
| 224 |
|
---|
| 225 | # gcc-4.1 and beyond seem to benefit from these
|
---|
| 226 | ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
|
---|
| 227 | # turn off flags which hurt -Os
|
---|
| 228 | OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-loop-optimize,)
|
---|
| 229 | OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-dominator-opts,)
|
---|
| 230 | OPTIMIZATION+=$(call check_cc,$(CC),-fno-strength-reduce,)
|
---|
| 231 |
|
---|
| 232 | OPTIMIZATION+=$(call check_cc,$(CC),-fno-branch-count-reg,)
|
---|
| 233 | endif # gcc-4.1 and beyond
|
---|
| 234 | endif
|
---|
| 235 | OPTIMIZATION+=$(call check_cc,$(CC),-fomit-frame-pointer,)
|
---|
| 236 | OPTIMIZATION+=$(call check_cc,$(CC),-ffunction-sections -fdata-sections,)
|
---|
| 237 |
|
---|
| 238 | #
|
---|
| 239 | #--------------------------------------------------------
|
---|
| 240 | # If you're going to do a lot of builds with a non-vanilla configuration,
|
---|
| 241 | # it makes sense to adjust parameters above, so you can type "make"
|
---|
| 242 | # by itself, instead of following it by the same half-dozen overrides
|
---|
| 243 | # every time. The stuff below, on the other hand, is probably less
|
---|
| 244 | # prone to casual user adjustment.
|
---|
| 245 | #
|
---|
| 246 |
|
---|
| 247 | ifeq ($(strip $(CONFIG_LFS)),y)
|
---|
| 248 | # For large file summit support
|
---|
| 249 | CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
|
---|
| 250 | endif
|
---|
| 251 | ifeq ($(strip $(CONFIG_DMALLOC)),y)
|
---|
| 252 | # For testing mem leaks with dmalloc
|
---|
| 253 | CFLAGS+=-DDMALLOC
|
---|
| 254 | LIBRARIES:=-ldmalloc
|
---|
| 255 | else
|
---|
| 256 | ifeq ($(strip $(CONFIG_EFENCE)),y)
|
---|
| 257 | LIBRARIES:=-lefence
|
---|
| 258 | endif
|
---|
| 259 | endif
|
---|
| 260 |
|
---|
| 261 | # Debugging info
|
---|
| 262 |
|
---|
| 263 | ifeq ($(strip $(CONFIG_DEBUG)),y)
|
---|
| 264 | CFLAGS +=-g
|
---|
| 265 | else
|
---|
| 266 | CFLAGS +=-DNDEBUG
|
---|
| 267 | CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,)
|
---|
[1004] | 268 | ifneq ($(strip $(CONFIG_STATIC)),y)
|
---|
[902] | 269 | CHECKED_LDFLAGS += $(call check_ld,$(LD),--gc-sections,)
|
---|
[821] | 270 | endif
|
---|
[1004] | 271 | endif
|
---|
[821] | 272 |
|
---|
| 273 | ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y)
|
---|
| 274 | CFLAGS += $(OPTIMIZATION)
|
---|
| 275 | endif
|
---|
| 276 |
|
---|
| 277 | # warn a bit more verbosely for non-release versions
|
---|
| 278 | ifneq ($(EXTRAVERSION),)
|
---|
| 279 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
|
---|
| 280 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-prototypes,)
|
---|
| 281 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-declarations,)
|
---|
| 282 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wunused,)
|
---|
| 283 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Winit-self,)
|
---|
| 284 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
|
---|
| 285 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wcast-align,)
|
---|
| 286 | endif
|
---|
| 287 | STRIPCMD:=$(call check_strip,$(STRIP),-s --remove-section=.note --remove-section=.comment,$(STRIP))
|
---|
| 288 | ifeq ($(strip $(CONFIG_STATIC)),y)
|
---|
| 289 | PROG_CFLAGS += $(call check_cc,$(CC),-static,)
|
---|
| 290 | endif
|
---|
| 291 | CFLAGS_SHARED := $(call check_cc,$(CC),-shared,)
|
---|
| 292 | LIB_CFLAGS+=$(CFLAGS_SHARED)
|
---|
| 293 |
|
---|
| 294 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
|
---|
| 295 | CFLAGS_PIC:= $(call check_cc,$(CC),-fPIC,)
|
---|
| 296 | LIB_CFLAGS+=$(CFLAGS_PIC)
|
---|
| 297 | endif
|
---|
| 298 |
|
---|
| 299 | ifeq ($(strip $(CONFIG_SELINUX)),y)
|
---|
[902] | 300 | LIBRARIES += -lselinux -lsepol
|
---|
[821] | 301 | endif
|
---|
| 302 |
|
---|
| 303 | ifeq ($(strip $(PREFIX)),)
|
---|
| 304 | PREFIX:=`pwd`/_install
|
---|
| 305 | endif
|
---|
| 306 |
|
---|
| 307 | ifneq ($(strip $(CONFIG_GETOPT_LONG)),y)
|
---|
| 308 | CFLAGS += -D__need_getopt
|
---|
| 309 | endif
|
---|
| 310 |
|
---|
| 311 | # Additional complications due to support for pristine source dir.
|
---|
| 312 | # Include files in the build directory should take precedence over
|
---|
| 313 | # the copy in top_srcdir, both during the compilation phase and the
|
---|
| 314 | # shell script that finds the list of object files.
|
---|
| 315 | # Work in progress by <ldoolitt@recycle.lbl.gov>.
|
---|
| 316 |
|
---|
| 317 |
|
---|
| 318 | OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
|
---|
| 319 | CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS)
|
---|
| 320 | LDFLAGS += $(CHECKED_LDFLAGS)
|
---|
| 321 |
|
---|
| 322 | ifdef BB_INIT_SCRIPT
|
---|
| 323 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
---|
| 324 | endif
|
---|
| 325 |
|
---|
| 326 | # Put user-supplied flags at the end, where they
|
---|
| 327 | # have a chance of winning.
|
---|
| 328 | -include $(top_builddir)/.config.mak
|
---|
| 329 |
|
---|
| 330 | #------------------------------------------------------------
|
---|
| 331 | # Installation options
|
---|
| 332 | ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y)
|
---|
| 333 | INSTALL_OPTS=--hardlinks
|
---|
| 334 | endif
|
---|
| 335 | ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y)
|
---|
| 336 | INSTALL_OPTS=--symlinks
|
---|
| 337 | endif
|
---|
| 338 | ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
|
---|
| 339 | INSTALL_OPTS=
|
---|
| 340 | endif
|
---|
| 341 |
|
---|
| 342 | #------------------------------------------------------------
|
---|
| 343 | # Make the output nice and tight
|
---|
| 344 | MAKEFLAGS += --no-print-directory
|
---|
| 345 | export MAKE_IS_SILENT=n
|
---|
| 346 | ifneq ($(findstring s,$(MAKEFLAGS)),)
|
---|
| 347 | export MAKE_IS_SILENT=y
|
---|
| 348 | SECHO := @-false
|
---|
| 349 | DISP := sil
|
---|
| 350 | Q := @
|
---|
| 351 | else
|
---|
| 352 | ifneq ($(BUILD_VERBOSE),)
|
---|
| 353 | SECHO := @-false
|
---|
| 354 | DISP := ver
|
---|
| 355 | Q :=
|
---|
| 356 | else
|
---|
| 357 | SECHO := @echo
|
---|
| 358 | DISP := pur
|
---|
| 359 | Q := @
|
---|
| 360 | endif
|
---|
| 361 | endif
|
---|
| 362 |
|
---|
| 363 | show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@))
|
---|
| 364 | pur_disp_compile.c = echo " "CC $(show_objs)
|
---|
| 365 | pur_disp_compile.h = echo " "HOSTCC $(show_objs)
|
---|
| 366 | pur_disp_strip = echo " "STRIP $(show_objs)
|
---|
| 367 | pur_disp_link = echo " "LINK $(show_objs)
|
---|
| 368 | pur_disp_link.h = echo " "HOSTLINK $(show_objs)
|
---|
| 369 | pur_disp_ar = echo " "AR $(ARFLAGS) $(show_objs)
|
---|
| 370 | pur_disp_elf2flt = echo " "ELF2FLT $(ELF2FLTFLAGS) $(show_objs)
|
---|
| 371 | sil_disp_compile.c = true
|
---|
| 372 | sil_disp_compile.h = true
|
---|
| 373 | sil_disp_strip = true
|
---|
| 374 | sil_disp_link = true
|
---|
| 375 | sil_disp_link.h = true
|
---|
| 376 | sil_disp_ar = true
|
---|
| 377 | sil_disp_elf2flt = true
|
---|
| 378 | ver_disp_compile.c = echo $(cmd_compile.c)
|
---|
| 379 | ver_disp_compile.h = echo $(cmd_compile.h)
|
---|
| 380 | ver_disp_strip = echo $(cmd_strip)
|
---|
| 381 | ver_disp_link = echo $(cmd_link)
|
---|
| 382 | ver_disp_link.h = echo $(cmd_link.h)
|
---|
| 383 | ver_disp_ar = echo $(cmd_ar)
|
---|
| 384 | ver_disp_elf2flt = echo $(cmd_elf2flt)
|
---|
| 385 | disp_compile.c = $($(DISP)_disp_compile.c)
|
---|
| 386 | disp_compile.h = $($(DISP)_disp_compile.h)
|
---|
| 387 | disp_strip = $($(DISP)_disp_strip)
|
---|
| 388 | disp_link = $($(DISP)_disp_link)
|
---|
| 389 | disp_link.h = $($(DISP)_disp_link.h)
|
---|
| 390 | disp_ar = $($(DISP)_disp_ar)
|
---|
| 391 | disp_gen = $(SECHO) " "GEN $@ ; true
|
---|
| 392 | disp_doc = $(SECHO) " "DOC $(subst docs/,,$@) ; true
|
---|
| 393 | disp_elf2flt = $($(DISP)_disp_elf2flt)
|
---|
| 394 | cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
---|
| 395 | cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) -c -o $@ $<
|
---|
| 396 | cmd_strip = $(STRIPCMD) $@
|
---|
| 397 | cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
|
---|
| 398 | $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
|
---|
| 399 | -o $@ $(LD_START_GROUP) \
|
---|
| 400 | $(APPLETS_DEFINE) $(APPLET_SRC) \
|
---|
| 401 | $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
|
---|
| 402 | $(LDBUSYBOX) $(LIBRARIES) \
|
---|
| 403 | $(LD_END_GROUP)
|
---|
| 404 | cmd_link.so = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
|
---|
| 405 | $(LIB_CFLAGS) $(CFLAGS_COMBINE) $(LIB_LDFLAGS) \
|
---|
| 406 | -o $(@) $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \
|
---|
| 407 | $(LIBRARY_DEFINE) $(^) \
|
---|
| 408 | $(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP)
|
---|
| 409 | cmd_link.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) $< -o $@
|
---|
| 410 | cmd_ar = $(AR) $(ARFLAGS) $@ $^
|
---|
| 411 | cmd_elf2flt = $(ELF2FLT) $(ELF2FLTFLAGS) $< -o $@
|
---|
| 412 | compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
|
---|
| 413 | compile.h = @$(disp_compile.h) ; $(cmd_compile.h)
|
---|
| 414 | do_strip = @$(disp_strip) ; $(cmd_strip)
|
---|
| 415 | do_link = @$(disp_link) ; $(cmd_link)
|
---|
| 416 | do_link.so = @$(disp_link) ; $(cmd_link.so)
|
---|
| 417 | do_link.h = @$(disp_link.h) ; $(cmd_link.h)
|
---|
| 418 | do_ar = @$(disp_ar) ; $(cmd_ar)
|
---|
| 419 | do_elf2flt = @$(disp_elf2flt) ; $(cmd_elf2flt)
|
---|
| 420 |
|
---|
| 421 | uppercase = $(shell echo $1 | $(SED) -e "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/")
|
---|
| 422 | %.a:
|
---|
| 423 | @if test -z "$($(call uppercase,$*)_DIR)" ; then \
|
---|
| 424 | echo "Invalid target $@" ; \
|
---|
| 425 | exit 1 ; \
|
---|
| 426 | fi
|
---|
| 427 | $(Q)$(MAKE) $($(call uppercase,$*)_DIR)$@
|
---|
| 428 |
|
---|
| 429 | .PHONY: dummy
|
---|