[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Static .v. shared - how to choose?



Hi!

The applications are compiled with debug information. They are then 
stripped while copied to the target directory. Add an install rule 
that looks something like this in your Makefile:

install: ntpclient
	$(INSTALL) -d $(prefix)/bin
      $(INSTALL) -m 0755 ntpclient $(prefix)/bin

After "make install" the binary in target/cris-axis-linux-gnu/bin is
~19 KB.

You can remove the AXIS_STATIC stuff from the Makefile.

/Mikae

-----Original Message-----
From: owner-dev-etrax@xxxxxxx.com">mailto:owner-dev-etrax@xxxxxxx.com] On
Behalf Of Mark Richards
Sent: Tuesday, July 13, 2004 10:32 PM
To: dev-etrax
Subject: Static .v. shared - how to choose?


A requirement of my application is that the AXIS 82 have the correct
date
and time in its RTC.  Therefore I located a good solution, ntpclient
(http://doolittle.faludi.com/ntpclient/)

When ntpclient is generated without the AXIS Rules, that is - it's build
for
the RedHat system I am using for development - the size of the
executable
file is around 18KB.  However when I build this same utility for the
AXIS 82
using the AXIS development kit, the size baloons to 123KB.

I'm assuming there's a static switch somewhere that I'm missing (in
other
words, the application should be linked using shared libraries for the
AXIS
and CRIS), but I cannot determine where this is set.

The Makefile I am using was copied, as the documentation recommends,
from
the apps/init directory, and modified so that it has the correct
filenames
in place.  Otherwise I have changed nothing.

Here's the Makefile, the environment, and Rules.axis

I notice AXIS_STATIC = in the Rules.axis.  I put AXIS_STATIC = nostatic
in
my Makefile for ntpclient and it doesn't change the behaviour.

Any clues here?


MAKEFILE:
------------------------------------------------------
AXIS_USABLE_LIBS = UCLIBC GLIBC
include $(AXIS_TOP_DIR)/tools/build/Rules.axis

AXIS_STATIC = nostatic

DEST	      = $(prefix)/sbin

CONF_FILE     = inittab
CONF_DEST     = $(prefix)/etc

PROGS     = ntpclient

SRCS	      = ntpclient.c phaselock.c

OBJS = ntpclient.o phaselock.o


all:	$(PROGS)

$(PROGS): $(OBJS)
	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@

install:	$(PROGS)
	@echo Installing $(PROGS) in $(DEST)
	$(INSTALL) -d $(DEST)
	$(INSTALL) -m 0755 $(PROGS) $(DEST)
	$(INSTALL) -d $(CONF_DEST)
	if [ ! -f $(CONF_DEST)/$(CONF_FILE) ]; then \
		$(INSTALL) -m 0644 $(CONF_FILE) $(CONF_DEST); fi

ifeq ($(strip $(AXIS_TARGET_OS)),host)
	$(INSTALL) -m 700 hrun $(prefix)
endif

clean:
	rm -f $(PROGS) *.o core

test: ntpclient
	./ntpclient -d -r <test.dat


clobber:	clean
	rm -f tags

echo:
	@echo $(HDRS) $(SRCS)

index:
	@ctags -wx $(HDRS) $(SRCS)

tags:	$(HDRS) $(SRCS)
	@ctags $(HDRS) $(SRCS)


ENVIRONMENT:
------------------------------------------------------


[root@localhost ntpclient]# set

APPS=/usr/src/axis/devboard_82/apps
AXIS_KERNEL_DIR=/usr/src/axis/devboard_82/os/linux
AXIS_TOP_DIR=/usr/src/axis/devboard_82
BASH=/bin/bash
BASH_VERSINFO=([0]="2" [1]="05b" [2]="0" [3]="1" [4]="release"
[5]="i386-redhat-
linux-gnu")
BASH_VERSION='2.05b.0(1)-release'
COLORS=/etc/DIR_COLORS.xterm
COLUMNS=80
DIRSTACK=()
EUID=0
GROUPS=()
G_BROKEN_FILENAMES=1
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/root
HOSTNAME=localhost
HOSTTYPE=i386
IFS=$' \t\n'
INPUTRC=/etc/inputrc
KDEDIR=/usr
LANG=en_US.UTF-8
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=30
LOGNAME=admin
LS_COLORS='no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:c
d=40
;33;
01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=
00;3
2:*.
btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.a
rj=0
0;31
:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz
2=00
;31:
*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*
.bmp
=00;
35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:'
MACHTYPE=i386-redhat-linux-gnu
MAIL=/var/spool/mail/admin
MAILCHECK=60
OLDPWD=/usr/src/axis/devboard_82/apps
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/src/axis/devboard_82/tools/build/bin:/usr/src/axis/devboard_82
/too
ls/b
uild/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/b
in:/
usr/
X11R6/bin:/home/admin/bin:/usr/local/cris:/usr/local/cris
PIPESTATUS=([0]="0")
PPID=19525
PROMPT_COMMAND='echo -ne
"\033]0;${USER}@xxxxxxx.*}:${PWD/#$HOME/~}\007"'
PS1='[\u@\h \W]\$ '
PS2='> '
PS4='+ '
PWD=/usr/src/axis/devboard_82/apps/ntpclient
QTDIR=/usr/lib/qt-3.3
REMOTEHOST=192.168.1.113
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comme
nts:
moni
tor
SHLVL=2
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SUPPORTED=en_US.UTF-8:en_US:en
TERM=xterm
UID=0
USER=admin
_=-l
[root@localhost ntpclient]#


RULES.AXIS:
------------------------------------------------------

# Hey Emacs, this Makefile is in -*- makefile -*- mode!
## $Id: Rules.axis,v 1.102 2004/03/03 14:58:24 pkj Exp $

# Try 'make axishelp' to display the possible targets

makefrag_name = .target-makefrag

# Set VERBOSE_FRAG to nothing to print that stuff if you want it,
# it clutters up the screen so it's @xxxxxxx.
VERBOSE_FRAG = @

# By default we do not build statically except for one target (clinux),
# but it can be enabled/disabled with the targets static and nostatic.
AXIS_STATIC =

AXIS_WARNING_PREFIX = ---------- WARNING:
AXIS_ERROR_PREFIX   = ---------- ERROR:
AXIS_LIB_MISMATCH = The code in $(shell pwd) cannot be linked with\
 $(AXIS_WILL_USE_LIB)

# A nifty macro to make testing gcc features easier
check_opt=$(shell if $(1) $(2) -S -o /dev/null -xc /dev/null >/dev/null
2>&1; \
        then echo "$(2)"; else echo "$(3)"; fi)

# Help "function" to add slashes before spaces
slashify = $(shell echo "$(1)" | sed 's/ /\\ /g')

########################################################################
###
# Start by deciding what we are building for

ifndef AXIS_BUILDTYPE
# Build for host if the build type is not defined.
AXIS_BUILDTYPE = host

# If we have a .target-makefrag, read stuff from it.
-include $(makefrag_name)
endif # !AXIS_BUILDTYPE

# Should we build with debug information or not?
ifeq ($(AXIS_DEBUG),debug)
AXIS_USE_DEBUG = yes
else
AXIS_USE_DEBUG = no
endif

#-----------------------------------------------------------------------
---

# Deduce other build variables from AXIS_BUILDTYPE.

AXIS_BUILDTYPE_KNOWN = no

ifeq ($(AXIS_BUILDTYPE),cris-axis-linux-gnu)
AXIS_TARGET_ARCH = cris
AXIS_TARGET_CPU = crisv10
AXIS_TARGET_OS = linux
AXIS_WILL_USE_LIB = GLIBC
AXIS_SHARE_LIBS = yes
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == cris-axis-linux-gnu

ifeq ($(AXIS_BUILDTYPE),crisv32-axis-linux-gnu)
AXIS_TARGET_ARCH = cris
AXIS_TARGET_CPU = crisv32
AXIS_TARGET_OS = linux
AXIS_WILL_USE_LIB = GLIBC
AXIS_SHARE_LIBS = yes
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == crisv32-axis-linux-gnu

ifeq ($(AXIS_BUILDTYPE),arm-axis-linux-gnu)
AXIS_TARGET_ARCH = arm
AXIS_TARGET_CPU = argus
AXIS_TARGET_OS = linux
AXIS_WILL_USE_LIB = GLIBC
AXIS_SHARE_LIBS = no
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == arm-axis-linux-gnu

ifeq ($(AXIS_BUILDTYPE),cris-axis-linux-gnuuclibc)
AXIS_TARGET_ARCH = cris
AXIS_TARGET_CPU = crisv10
AXIS_TARGET_OS = linux
AXIS_WILL_USE_LIB = UCLIBC
AXIS_SHARE_LIBS = yes
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == cris-axis-linux-gnuuclibc

ifeq ($(AXIS_BUILDTYPE),crisv32-axis-linux-gnuuclibc)
AXIS_TARGET_ARCH = cris
AXIS_TARGET_CPU = crisv32
AXIS_TARGET_OS = linux
AXIS_WILL_USE_LIB = UCLIBC
AXIS_SHARE_LIBS = yes
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == crisv32-axis-linux-gnuuclibc

ifeq ($(AXIS_BUILDTYPE),arm-axis-linux-gnuuclibc)
AXIS_TARGET_ARCH = arm
AXIS_TARGET_CPU = argus
AXIS_TARGET_OS = linux
AXIS_WILL_USE_LIB = UCLIBC
AXIS_SHARE_LIBS = yes
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == arm-axis-linux-gnuuclibc

ifeq ($(AXIS_BUILDTYPE),clinux)
AXIS_TARGET_ARCH = cris
AXIS_TARGET_CPU = crisv10
AXIS_TARGET_OS = linux
AXIS_WILL_USE_LIB = UCLIBC
# Default static
AXIS_STATIC = static
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == clinux

ifeq ($(AXIS_BUILDTYPE),elinux)
AXIS_TARGET_ARCH = cris
AXIS_TARGET_CPU = crisv10
AXIS_TARGET_OS = elinux
AXIS_WILL_USE_LIB = UCLIBC
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == elinux

ifeq ($(AXIS_BUILDTYPE),host)
AXIS_TARGET_ARCH = host
AXIS_TARGET_CPU = host
AXIS_TARGET_OS = host
AXIS_SHARE_LIBS = no
# We want to be able to use gdb with full debug info for host compiled
# programs.
ifneq ($(AXIS_DEBUG),no)
AXIS_USE_DEBUG = yes
endif
AXIS_BUILDTYPE_KNOWN = yes
endif # AXIS_BUILDTYPE == host

ifeq ($(AXIS_STATIC),static)
AXIS_SHARE_LIBS = no
endif

########################################################################
###

ifeq ($(AXIS_TARGET_OS),elinux)
# This is for gcc-cris & Co. of R25 or higher.  Get it; don't
# use older versions or R25 without glibc installed.

# Without "-melinux", the compiler will not get the right
# include-files and have the right defines etc. so it should be
# seen as part of CC rather than CFLAGS.
CC_FLAGS    = -melinux

# This is for compatibility with cris-dist-1.7, where a.out was the
# default, but which does not understand -mcrisaout.  We'll only do the
# costly assignment if we don't inherit the value, which is a " " or
# -mcrisaout.
ifndef AXIS_LD_OUTPUT_FORMAT_OPTION
AXIS_LD_OUTPUT_FORMAT_OPTION := $(shell `gcc-cris -print-prog-name=ld`
-V |
sed -n -e 's/.* crisaout/-mcrisaout/p') #
endif

# eLinux always uses uClibc.  Though a check that the app can use uClibc
# is in order.
ifdef AXIS_USABLE_LIBS
ifneq ($(filter $(AXIS_USABLE_LIBS),UCLIBC),UCLIBC)
$(error $(AXIS_ERROR_PREFIX) $(AXIS_LIB_MISMATCH))
endif # UCLIBC not in AXIS_USABLE_LIBS
endif # AXIS_USABLE_LIBS

# OBSOLETE: Remove whenever possible
ELINUX    = 1

endif # AXIS_TARGET_OS == elinux

#-----------------------------------------------------------------------
---

ifeq ($(AXIS_TARGET_OS),linux)

# Here we will check AXIS_WILL_USE_LIB against AXIS_USABLE_LIBS which
# represents what the thing we want to compile can be linked with.  If
# library and compile variable settings (like CC) aren't supposed to be
# set or are not applicable, then AXIS_USABLE_LIBS should not be set.

ifdef AXIS_USABLE_LIBS
ifneq ($(filter
$(AXIS_USABLE_LIBS),$(AXIS_WILL_USE_LIB)),$(AXIS_WILL_USE_LIB))
$(error $(AXIS_ERROR_PREFIX) $(AXIS_LIB_MISMATCH))
endif
endif # AXIS_USABLE_LIBS

# Now that we've checked that AXIS_WILL_USE_LIB matches
AXIS_USABLE_LIBS,
# we set the other build vars.

CC_FLAGS  =

ifneq ($(AXIS_WILL_USE_LIB),UCLIBC)
ifeq ($(AXIS_WILL_USE_LIB),GLIBC)
# Using glibc, linking dynamically like on the host.

# We prefer getting <asm/...> and <linux/...> from the kernel we
compile,
# rather than what was installed with the compiler, so put it first in
the
# system include path.  Though we have to go through a separate
directory
# with just the linux and asm dirs, rather than use
$(AXIS_KERNEL_DIR)/include,
# lest we also drag in the other subdirs, which collide with the normal
# gcc-cris -mlinux system-includes, for example <net/...>.

CC_FLAGS += -isystem $(prefix)/include
else
$(error $(AXIS_ERROR_PREFIX) Unexpected library $(AXIS_WILL_USE_LIB).)
endif # AXIS_WILL_USE_LIB == GLIBC
endif # AXIS_WILL_USE_LIB != UCLIBC

AXIS_LD_OUTPUT_FORMAT_OPTION =

endif # AXIS_TARGET_OS == linux

#-----------------------------------------------------------------------
---

ifeq ($(AXIS_TARGET_CPU)-$(AXIS_TARGET_OS),crisv10-linux)

CC_FLAGS += -mlinux

AXIS_LD_OUTPUT_FORMAT_OPTION = -mcrislinux

endif # AXIS_TARGET_CPU == crisv10 && AXIS_TARGET_OS == linux

#-----------------------------------------------------------------------
---
ifeq ($(AXIS_TARGET_CPU)-$(AXIS_TARGET_OS),crisv32-linux)

CC_FLAGS += -mlinux -march=v32

AXIS_LD_OUTPUT_FORMAT_OPTION = -mcrislinux

endif # AXIS_TARGET_CPU == crisv32 && AXIS_TARGET_OS == linux

#-----------------------------------------------------------------------
---

ifeq ($(AXIS_TARGET_ARCH),cris)

# Check if the compiler supports -mno-mul-bug-workaround, in which case
# it shall be used.
NO_MUL_WORKAROUND := $(call check_opt,gcc-cris,-mno-mul-bug-workaround,)
CC_FLAGS += $(NO_MUL_WORKAROUND)

# This is for building for the CRIS architecture.

ifeq ($(AXIS_WILL_USE_LIB),UCLIBC)
# We use a wrapper (gcc_cris) when compiling with uC-libc
CC        = $(AT_PRETTY) $(CCACHE) gcc_cris $(CC_FLAGS)
-muclibc=$(prefix)
CXX       = $(AT_PRETTY) $(CCACHE) g++_cris $(CC_FLAGS)
-muclibc=$(prefix)
else
CC        = $(AT_PRETTY) $(CCACHE) gcc-cris $(CC_FLAGS)
CXX       = $(AT_PRETTY) $(CCACHE) g++-cris $(CC_FLAGS)
endif

OBJCOPY   = objcopy-cris
LD        = $(AT_PRETTY) ld-cris $(AXIS_LD_OUTPUT_FORMAT_OPTION)
AR        = $(AT_PRETTY) ar-cris
RANLIB    = ranlib-cris
STRIP     = $(AT_PRETTY) strip-cris

# Page size is 8KB for CRIS
AXIS_PAGE_SIZE = 8192

run_prefix =

# OBSOLETE: Remove whenever possible
CRIS      = 1

endif # AXIS_TARGET_ARCH == cris

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

ifeq ($(AXIS_TARGET_ARCH),arm)

# This is for building for the ARM architecture.

CC_FLAGS  += -march=armv4 -mtune=arm9tdmi

ifeq ($(AXIS_WILL_USE_LIB),UCLIBC)
# We use a wrapper (arm_linux_gcc) when compiling with uC-libc
CC        = $(AT_PRETTY) $(CCACHE) arm_linux_gcc $(CC_FLAGS)
-muclibc=$(prefix)
CXX       = $(AT_PRETTY) $(CCACHE) arm_linux_g++ $(CC_FLAGS)
-muclibc=$(prefix)
else
CC        = $(AT_PRETTY) $(CCACHE) arm-linux-gcc $(CC_FLAGS)
CXX       = $(AT_PRETTY) $(CCACHE) arm-linux-g++ $(CC_FLAGS)
endif

OBJCOPY   = arm-linux-objcopy
LD        = $(AT_PRETTY) arm-linux-ld $(AXIS_LD_OUTPUT_FORMAT_OPTION)
AR        = $(AT_PRETTY) arm-linux-ar
RANLIB    = arm-linux-ranlib
STRIP     = $(AT_PRETTY) arm-linux-strip

# Page size is 4KB for arm
AXIS_PAGE_SIZE = 4096

run_prefix =

endif # AXIS_TARGET_ARCH == arm

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

ifeq ($(AXIS_TARGET_ARCH),host)

# This is for building for the local host.

CC        = $(AT_PRETTY) $(CCACHE) gcc
CXX       = $(AT_PRETTY) $(CCACHE) g++
LD        = $(AT_PRETTY) ld
AR        = $(AT_PRETTY) ar
RANLIB    = ranlib
STRIP     = $(AT_PRETTY) strip

AXIS_PAGE_SIZE = 4096

run_prefix = $(prefix)

endif # AXIS_TARGET_ARCH == host

#-----------------------------------------------------------------------
---

# Now that $(CC) is initialized for the intended target architecture, we
# can find out the version of the compiler.
ifndef AXIS_GCC_VERSION
AXIS_GCC_VERSION := $(shell $(CC) -dumpversion 2> /dev/null)
endif

export AXIS_GCC_VERSION

#-----------------------------------------------------------------------
---

ifndef prefix
ifdef AXIS_TOP_DIR
prefix    = $(AXIS_TOP_DIR)/target/$(AXIS_BUILDTYPE)
endif # AXIS_TOP_DIR
endif # !prefix

export prefix

#-----------------------------------------------------------------------
---

# Define CFLAGS to something sensible.
CFLAGS    = -Wall -Wshadow

ifeq ($(AXIS_BUILDTYPE),host)
# cris-axis-linux-gnu has this in -isystem option.
# gcc_cris adds it when using -muclibc with elinux and clinux
CFLAGS   += -I$(prefix)/include
endif

ifeq ($(AXIS_USE_DEBUG),yes)
# Add suitable compiler flags for debugging.
CFLAGS   += -O0 -g -fno-omit-frame-pointer
else
CFLAGS   += -O2
ifneq ($(AXIS_TARGET_OS),elinux)
CFLAGS   += -g
endif
endif

# OBSOLETE: Add ELINUX define.
ifeq ($(AXIS_TARGET_OS),elinux)
CFLAGS   += -DELINUX
endif

# Can't use -pedantic due to use of long long in standard includes. :(
CXXFLAGS  = $(CFLAGS) -Wno-ctor-dtor-privacy -ansi -pipe

# Define LDFLAGS to something sensible.
LDFLAGS   =

LDFLAGS  += -L$(prefix)/lib

# Strip the binaries when building for elinux unless debug or static.
ifeq ($(AXIS_TARGET_OS),elinux)
ifneq ($(AXIS_USE_DEBUG),yes)
ifneq ($(AXIS_STATIC),static)
LDFLAGS  += -s
endif
endif
endif

ifeq ($(AXIS_STATIC),static)
LDFLAGS  += -static
else
ifeq ($(AXIS_TARGET_OS),elinux)
LDFLAGS  += -shlib
endif
endif # AXIS_STATIC == static

ifneq ($(AXIS_BUILDTYPE),host)
INSTALL   = $(AT_PRETTY) install_elinux -p
else
ifneq ($(shell which install_elinux 2>/dev/null),)
INSTALL   = $(AT_PRETTY) install_elinux -p
else
INSTALL   = $(AT_PRETTY) install -p
endif
endif

# -f must be there or some implicit rules will fail:
RM        = $(AT_PRETTY) rm -f
LN        = $(AT_PRETTY) ln
MKNOD     = $(AT_PRETTY) mknod_elinux

########################################################################
###

PRETTY    =
AT_PRETTY =

ifeq ($(AXIS_PRETTIFY),yes)
ifneq ($(shell which ccdv 2>/dev/null),)
PRETTY    = ccdv
AT_PRETTY = @$(PRETTY)
endif
endif

########################################################################
###

CCACHE    =

ifeq ($(AXIS_USE_CCACHE),yes)
ifneq ($(shell which ccache 2>/dev/null),)
CCACHE    = ccache
endif
endif

########################################################################
###
# The following is a set of standard rules to try to make sure we build
# and install the correct files.

# Make verify_builddir a dependency of all build and install rules to
make
# sure the build directory is set correctly before trying to actually
build
# anything.

all:			all-recurse
all-recurse:		pre-all-recurse
pre-all-recurse:	verify_builddir

depend:			depend-recurse
depend-recurse:		pre-depend-recurse
pre-depend-recurse:	verify_builddir

install:		install-recurse
install-recurse:	pre-install-recurse
pre-install-recurse:	verify_builddir

uninstall:		uninstall-recurse
uninstall-recurse:	pre-uninstall-recurse
pre-uninstall-recurse:	verify_builddir

clean:			clean-recurse
clean-recurse:		pre-clean-recurse

ifndef ROOT_MAKEFRAG
ROOT_MAKEFRAG := $(shell echo `pwd`/$(makefrag_name))
endif # !ROOT_MAKEFRAG

##
## The following special targets exists:

## axishelp                   - This help
axishelp:
	@xxxxxxx.axis

##
## The following build types exist:
## cris-axis-linux-gnu           - CRIS/Linux 2.4 with shared glibc
## cris-axis-linux-gnuuclibc     - CRIS/Linux 2.4 with shared uClibc
## crisv32-axis-linux-gnu        - CRISv32/Linux 2.6 with shared glibc
## crisv32-axis-linux-gnuuclibc  - CRISv32/Linux 2.6 with shared uClibc
## arm-axis-linux-gnu            - ARM/Linux 2.4 with shared glibc
## arm-axis-linux-gnuuclibc      - ARM/Linux 2.4 with shared uClibc
## clinux                        - CRIS/Linux 2.4 with static uClibc
## elinux                        - CRIS/Linux 2.0 NO_MMU with uC-libc
## host                          - Host build with debug
cris-axis-linux-gnu cris-axis-linux-gnuuclibc crisv32-axis-linux-gnu
crisv32-axis-linux-gnuuclibc arm-axis-linux-gnu arm-axis-linux-gnuuclibc
clinux elinux host:
	$(VERBOSE_FRAG)echo AXIS_BUILDTYPE=$@xxxxxxx.tmp$(makefrag_name)
ifeq ($(AXIS_DEBUG),debug)
	$(VERBOSE_FRAG)echo AXIS_DEBUG=$(AXIS_DEBUG) >>
.tmp$(makefrag_name)
endif
	@$(MAKE) configsubs AXIS_BUILDTYPE=$@ ROOT_MAKEFRAG="$(shell
echo
`pwd`/.tmp$(makefrag_name))" || ( rm -f .tmp$(makefrag_name); exit 1 )
	@xxxxxxx.tmp$(makefrag_name)

##
## The following build options exist:
## debug                      - Enable debug
## nodebug                    - Do not enable debug
## static                     - Enable static linking
## nostatic                   - Do not enable static linking
debug nodebug static nostatic:
	@option=`echo $@ | sed 's/^no//'`;\
	target=`echo AXIS_$$option | tr a-z A-Z`;\
	grep -v "$$target" $(makefrag_name) > .tmp$(makefrag_name) 2>
/dev/null; \
	if test "$$option" = "$@"; then \
	  echo $$target=$@xxxxxxx.tmp$(makefrag_name); \
	  neg_check='!'; \
	fi; \
	$(MAKE) configsubs AXIS_CHECK_STRING="$$target=$$option"
AXIS_NEG_CHECK=$$neg_check ROOT_MAKEFRAG="$(shell echo
`pwd`/.tmp$(makefrag_name))" || ( rm -f .tmp$(makefrag_name); exit 1 )
	@xxxxxxx.tmp$(makefrag_name)

ifndef AXIS_CHECK_STRING
#Trailing $$ so we get an exact match or changing from ..-gnuuclibc to
..-gnu
#won't make clean
AXIS_CHECK_STRING = "AXIS_BUILDTYPE=$(AXIS_BUILDTYPE)"
AXIS_NEG_CHECK = !
endif

checkclean:
	@if ! test "$(AXIS_CLEAN_WHEN_NEW_BUILD_TYPE)" = "no" && \
	    ! test -f .target_$(AXIS_BUILDTYPE) \
	    && ( ! test -f $(makefrag_name) \
	         || $(AXIS_NEG_CHECK) grep $(AXIS_CHECK_STRING)$$
$(makefrag_name) > /dev/null ); then \
	  NO_SUBDIR_RECURSION=1 $(MAKE) --no-print-directory clean
ROOT_MAKEFRAG="$(ROOT_MAKEFRAG)"; \
	fi

configsubs: 		configsubs-recurse
configsubs-recurse:	pre-configsubs-recurse
pre-configsubs-recurse:	$(call slashify,$(ROOT_MAKEFRAG))

configsubs: checkclean
	-@if ! cmp -s "$(ROOT_MAKEFRAG)" $(makefrag_name); then \
	  rm -f .target*; \
	  echo "cp \"$(ROOT_MAKEFRAG)\" $(makefrag_name)"; \
	  cp "$(ROOT_MAKEFRAG)" $(makefrag_name); \
	fi

# These are hooks that can be used to have rules executed before the
# recursive rules are checked.
pre-all-recurse pre-depend-recurse pre-install-recurse
pre-uninstall-recurse
pre-clean-recurse pre-configsubs-recurse:

# Recursive rules to make all, depend, install, uninstall, clean and
configsubs
all-recurse depend-recurse install-recurse uninstall-recurse
clean-recurse
configsubs-recurse:
ifneq ($(NO_SUBDIR_RECURSION),1)
	@subdirs="$(SUBDIRS)"; \
	for subdir in $$subdirs; do \
	  if test -d "$$subdir"; then \
	    target=`echo $@ | sed 's/-recurse//'`; \
	    echo "Making $$target in $$subdir for $(AXIS_BUILDTYPE)"; \
	    $(MAKE) -C "$$subdir" $$target
ROOT_MAKEFRAG="$(ROOT_MAKEFRAG)"
|| exit 1; \
	  else \
	    echo "The directory '$$subdir' does not exist or is not a
directory!"; \
	    exit 1; \
	  fi; \
	done
endif

verify_builddir:	verify_buildtype
ifndef prefix
	@echo "You must define either the environment variable
\$$AXIS_TOP_DIR to where your"
	@echo "source tree is located, or \$$prefix to where anything
(independent of target"
	@echo "type) should be installed!"
	@exit 1
endif

verify_buildtype:
ifneq ($(AXIS_BUILDTYPE_KNOWN),yes)
	@echo "Unknown build type '$(AXIS_BUILDTYPE)'!"
	@xxxxxxx."
	@exit 1
endif

########################################################################
###

# Automatically generate dependencies if AXIS_AUTO_DEPEND is yes.
# If the compiler is based on gcc 3.x or later then -MP is used to
prevent
# problems when header files are removed, and -MF is used to put the
# dependency files in a .depend directory instead of in the main
directory.

ifeq ($(AXIS_AUTO_DEPEND),yes)
ifneq ($(patsubst 2.%,2.x,$(AXIS_GCC_VERSION)),2.x)
# The patsubst and subst prevent a leading period and any slashes from
# messing up the name of the dependency file
DEPEND_FLAGS += -MD -MP -MF .depend/$(patsubst .%,_.%,$(subst
/,_,$(@xxxxxxx.d)))

pre-all-recurse:	.depend

.depend:
	$(INSTALL) -d .depend

-include .depend/*.d
else
# Use -MMD instead of -MD as the absolute dependencies generated by -MD
# causes problems if a new compiler is used or the sources are moved.
This
# problem is avoided above with -MP, which cannot be used here.
DEPEND_FLAGS += -MMD

-include *.d
endif
CFLAGS   += $(DEPEND_FLAGS)

clean:	remove_depend_files

remove_depend_files:
	$(RM) -rf .depend *.d
endif

########################################################################
###

# Convenient to have if you want to check out the asm:
%.s: %.c
	$(CC) $(CFLAGS) -S -o $@ $<

# Convenient to have if you want to check out what the preprocessor
does:
%.i: %.c
	$(CC) $(CFLAGS) -E -o $@ $<

########################################################################
###