# ***********************< BEGIN COPYRIGHT >************************
#
# Copyright 2009, Freescale Semiconductor, Inc. All Rights Reserved.
#
# NOTICE: The information contained in this file is proprietary
# to Freescale Semiconductor and is being made available to
# Freescale's customers under a specific license agreement.
# Use or disclosure of this information is permissible only
# under the terms of the license agreement.
#
#
# ***********************< END COPYRIGHT >**************************
# ---- USER MUST EDIT DIRS TO ADD THE DIR TO COMPILE IN -----
DIRS := common controlInterface loaderAgent applications
# ---- DO NOT EDIT BELOW THIS LINE --------------------------
#
# ----=[NOTE]=----
# SYS_PATH must point to the location of libregex.a, libpmll.a and lib must be
# on the same level as pme_tools because rules and libstatefulrules.a.
# Currently it is hardcoded in this makefile to be ../pme_tools/lib_<arch>. In
# an rpm spec SYS_PATH must be specified at make time to override this setting.
#
# Build flow:
# -make must be called at the top level
# -export all vars needed by the build here.
# -sub makefiles will include Makefile.rules
# -generated files are all dumped at top level in objs_/lib_/bin_ARCH
# -add directories to make in to DIRS
#
# Tool chain paths:
# paths to gcc are set in the rules/Makefile.$(ARCH) files. Do not use abs
# paths for gcc here.
ifneq (distclean,$(MAKECMDGOALS))
ifndef ARCH
$(error "ARCH not defined.")
endif
#
# arch specific rules, e.g. toolchain, defines etc
include rules/Makefile.$(ARCH)
endif
# ----[ TOOLS ]----
# Tools apart from gcc, that are arch agnostic are placed in
include rules/Makefile.tools
# Export all required envs, e.g. tools required.
export TOP_LEVEL:= $(PWD)
export SYS_PATH := $(dir $(TOP_LEVEL))pme_priv
export CC := $(CROSS_COMPILE)gcc
export LD := $(CROSS_COMPILE)ld
export AR := $(CROSS_COMPILE)ar
export OBJ_DIR := objs_$(ARCH)
export BIN_DIR := $(TOP_LEVEL)/bin_$(ARCH)
export LIB_DIR := $(TOP_LEVEL)/lib_$(ARCH)
export APP_DIR := $(TOP_LEVEL)/bin_$(ARCH)
export RULE_PATH:=$(TOP_LEVEL)/rules
# ----=[exclude defines]=----
ifndef OS_TYPE
export OS_TYPE := NO_OS_TYPE_SET
endif
ifndef PLATFORM
export PLATFORM := NO_PLATFORM_SET
endif
ifndef CMODE
export CMODE := NO_CMODE_SET
endif
#
# local vars
# add -D<defname>
# DEFINES, LIB_PATH, INC_PATH are set in the rules/Makefile.<arch> files.
DEFINES :=$($(ARCH)_DEFINES)
LIB_PATH := $(addprefix -L,$(LIB_DIR)) $(addprefix -L,$($(ARCH)_LIB_PATH))
LIB_PATH += -L$(SYS_PATH)/lib_$(ARCH)
INC_PATH := -I$(TOP_LEVEL)/include -I. $(addprefix -I,$($(ARCH)_INC_PATH))
WARN := -W -Wall -Wshadow -g3
#
# aggregate exported vars
export CFLAGS := $(LIB_PATH) $(INC_PATH) $(WARN) $(DEFINES) $(EXTRA_CFLAGS) $(ARCH_SPEC_CFLAGS)
export LDFLAGS := $(LIB_PATH) $(EXTRA_LDFLAGS) $(ARCH_SPEC_LDFLAGS)
export ARFLAGS := rcs
#
# used for the help
H_ARCHS :=powerpc i686
H_RULES :=all(default) clean distclean
H_FLAGS :=V=1 (verbose)
H_FLAGS +=EXTRA_DEFINES=\"<def> <def2>\" (no -D)
ifndef V
export Q := @
MAKE_FLAGS += --no-print-directory
export MAKE_FLAGS
endif
.PHONY: $(DIRS) mkdirs help install
all: mkdirs $(DIRS)
ifeq (,$(MAKECMDGOALS))
ACTION := (compiling)
else
ACTION := ($(MAKECMDGOALS))
endif
export ACTION
$(DIRS):
$(Q)echo "----- Processing: $@ $(ACTION) -----"
$(Q)$(MAKE) $(MAKE_FLAGS) -C $@ $(MAKECMDGOALS)
clean:$(DIRS)
distclean:
$(Q)$(MAKE) ARCH=powerpc clean
$(Q)$(MAKE) ARCH=i686 clean
mkdirs:
$(Q)test -e $(BIN_DIR) || mkdir -p $(BIN_DIR)
$(Q)test -e $(LIB_DIR) || mkdir -p $(LIB_DIR)
help:
$(Q)echo "Usage:"
$(Q)echo " make ARCH=<arch> <flags> <rule>"
$(Q)echo " [arch : $(H_ARCHS)]"
$(Q)echo " [flags: $(H_FLAGS)]"
$(Q)echo " [rules: $(H_RULES)]"
$(Q)echo "e.g."
$(Q)echo " make ARCH=powerpc"
#
# ----=[ install for LTIB ]=----
# This rule should be called by ltib only but could be used by other
# applications. The flow is:
# -INSTALL_DIR is passed in. There will be a bin and lib under this.
# -ARCH is passed in
# -INSTALL_APPS is defined in the Makefile.ARCH file, controlling what apps are
# installed.
# -INSTALL_LIBS is defined in the Makefile.ARCH file, controlling what libs are
# installed (if any)
install:
ifdef INSTALL_DIR
$(Q)test -e $(INSTALL_DIR)/bin|| (echo "Error: dir does not exist: $(INSTALL_DIR)/bin" && exit 1)
$(Q)echo " [INSTALL] $(INSTALL_APPS) $(INSTALL_LIBS) --> $(INSTALL_DIR)"
$(Q)$(foreach a,$(INSTALL_APPS),$(shell cp bin_$(ARCH)/$(a) $(INSTALL_DIR)/bin))
$(Q)$(foreach l,$(INSTALL_LIBS),$(shell cp lib_$(ARCH)/$(l) $(INSTALL_DIR)/lib))
else
$(Q)$(error "Error: INSTALL_DIR was not defined.")
endif
|