Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 255 lines (193 sloc) 6.143 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
# Copyright (c) 2009 Openmoko Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


FATFS_MODE ?= read-only
CROSS_COMPILER ?= YES

# +++START_COPY: this section into the start of each Makefile
#REMARK: Notes:
#REMARK: 1. The "+++TAG:" and "---TAG:" are matched exactly
#REMARK: 2. The prefix "#INC: " will be stripped. There must be one space
#REMARK: after the ':' and it is stripped. Any more spaces are retained.
#REMARK: 3. Lines starting "#REMARK" are not copied.
#REMARK:
# The text between the +++ and --- tags is copied by the
# UpdateMakefiles script. Do not remove or change these tags.
# ---
# Autodetect root directory
define FIND_ROOT_DIR
while : ; do \
  d=$$(pwd) ; \
  [ -d "$${d}/samo-lib" ] && echo $${d} && exit 0 ; \
  [ X"/" = X"$${d}" ] && echo ROOT_DIRECTORY_NOT_FOUND && exit 1 ; \
  cd .. ; \
done
endef
ROOT_DIR := $(shell ${FIND_ROOT_DIR})
# Directory of Makefile includes
MK_DIR := ${ROOT_DIR}/samo-lib/Mk
# Include the initial Makefile setup
#INC: include ${MK_DIR}/definitions.mk
# ---END_COPY: of section to copy to individual makefiles


# Standard definitions for _ALL_ Makefiles
# ----------------------------------------

OS := $(strip $(shell uname -s))

export SHELL = /bin/sh
RM = rm -f
MKDIR = mkdir -p
COPY = cp -p
TOUCH = touch
STRIP_HASH_OR_BLANK_LINES = grep -v '^[[:space:]]*\(\#.*\)\?[[:space:]]*$$'


ifeq (Linux,${OS})

LOCKF = flock
AWK = gawk

# path must exist
REALPATH = readlink -es

# path may not exist
RESOLVEPATH = readlink -m

else ifeq (FreeBSD,${OS})

LOCKF = lockf
AWK = gawk

# path must exist
REALPATH = realpath

# path may not exist
RESOLVEPATH = /usr/local/bin/readlink -f

else ifeq (Darwin,${OS})

LOCKF = postlock
AWK = gawk

# path must exist
REALPATH = /opt/local/bin/greadlink -es

# path may not exist
RESOLVEPATH = /opt/local/bin/greadlink -m

else
$(error Unsupported OS: ${OS})
endif


# this is to get a single blank line
define BLANK_LINE


endef

# some special characters
EMPTY :=
COMMA := ,
SPACE := ${EMPTY} ${EMPTY}

# this allows detection of installed program
# and gives apt-get command to install the missing program
# $1 binary
# $2 list of install names
define REQUIRED_BINARY_1
ifeq (,$$(strip $$(shell which ${1})))
$$(error Error: Could not find program: ${1} \
$${BLANK_LINE}install using:\
$${BLANK_LINE} sudo apt-get install ${2}\
$${BLANK_LINE}then restart $${MAKE})
endif
endef
REQUIRED_BINARY = $(eval $(call REQUIRED_BINARY_1,$(strip ${1}),$(strip ${2})))


# this allows detection of installed PHP module
# and gives apt-get command to install the missing program
# $1 PHP module name
# $2 list of install names
define REQUIRED_PHP_1
ifneq (YES,$$(strip $$(shell php -r 'echo array_search("$$(strip ${1})", get_loaded_extensions()) ? "YES\n" : "NO\n";')))
$$(error Error: Could not find PHP module: ${1} \
$${BLANK_LINE}install using:\
$${BLANK_LINE} sudo apt-get install ${2}\
$${BLANK_LINE}then restart $${MAKE})
endif
endef
REQUIRED_PHP = $(eval $(call REQUIRED_PHP_1,$(strip ${1}),$(strip ${2})))


# in the root directory
# =====================

LICENSES := ${ROOT_DIR}/Licenses

WIKI_APP = ${ROOT_DIR}/wiki-app/
WIKI_APP_INCLUDE = ${WIKI_APP}
WIKI_APP_SRC = ${WIKI_APP}

# need to source (.) this script to use its definitions
WIKI_NAMES = ${ROOT_DIR}/scripts/wiki-names.sh


# In samo-lib
# ===========

SAMO_LIB = ${ROOT_DIR}/samo-lib
SAMO_LIB_INCLUDE = ${SAMO_LIB}/include

MINI_LIBC = ${SAMO_LIB}/mini-libc
MINI_LIBC_INCLUDE = ${MINI_LIBC}/include

MINI_LIBC_LIB = ${MINI_LIBC}/lib/libc.a

FATFS = ${SAMO_LIB}/fatfs
FATFS_CONFIG_INCLUDE = ${FATFS}/config/c33/${FATFS_MODE}
FATFS_INCLUDE = ${FATFS}/src
FATFS_SRC = ${FATFS}/src
FATFS_LIB = ${FATFS}/lib/${FATFS_MODE}/libtinyfat.a

DRIVERS = ${SAMO_LIB}/drivers
DRIVERS_INCLUDE = ${DRIVERS}/include
DRIVERS_SRC = ${DRIVERS}/src
DRIVERS_LIB = ${DRIVERS}/lib/libdrivers.a

GRIFO = ${SAMO_LIB}/grifo
GRIFO_SCRIPTS = ${GRIFO}/scripts
GRIFO_INCLUDE = ${GRIFO}/include
GRIFO_COMMON = ${GRIFO}/common
GRIFO_SIMULATOR = ${GRIFO}/simulator
GRIFO_APPLICATION_LDS = ${GRIFO}/lds/application.lds
GRIFO_APPLICATION_PRE = ${GRIFO}/Mk/application-pre.mk
GRIFO_APPLICATION_POST = ${GRIFO}/Mk/application-post.mk
GRIFO_LIB = ${GRIFO}/lib/libgrifo.a

LZMA = ${SAMO_LIB}/lzma
LZMA_INCLUDE = ${LZMA}
LZMA_SRC = ${LZMA}

MAHATMA = ${SAMO_LIB}/mahatma
MAHATMA_INCLUDE = ${MAHATMA}
MAHATMA_SRC = ${MAHATMA}

FORTH = ${SAMO_LIB}/forth
FORTH_INCLUDE = ${FORTH}
FORTH_SRC = ${FORTH}

MBBR = ${SAMO_LIB}/mbr
MBBR_INCLUDE = ${MBBR}
MBBR_SRC = ${MBBR}

MISC_FILES := ${SAMO_LIB}/misc-files
SCRIPTS := ${SAMO_LIB}/scripts


# In host-tools
# =============

HOST_TOOLS = ${ROOT_DIR}/host-tools

IMAGE2HEADER= ${HOST_TOOLS}/imagetool/image2header


# Cross compiler definitions
# ==========================

export PATH:=${HOST_TOOLS}/toolchain-install/bin:${PATH}

BUILD_PREFIX =

CROSS = c33-epson-elf-

# substitute cross compiler for mormal utilities
# only if enabled
ifeq (YES,$(strip ${CROSS_COMPILER}))
GCC = $(CROSS)gcc
AS = $(CROSS)as
AR = $(CROSS)ar
LD = $(CROSS)ld
CC = $(GCC)
OBJCOPY = $(CROSS)objcopy
OBJDUMP = $(CROSS)objdump
STRIP = $(CROSS)strip
endif

# for host compile
HOSTCC = gcc
HOSTLD = ld

# for cross
CROSS_GCC = ${CROSS}gcc
CROSS_AS = ${CROSS}as
CROSS_AR = ${CROSS}ar
CROSS_LD = ${CROSS}ld
CROSS_STRIP = ${CROSS}strip
CROSS_OBJDUMP = ${CROSS}objdump
CROSS_OBJCOPY = ${CROSS}objcopy


# Debugging
# =========

ifneq (,$(strip ${DEBUG}))
# special function to display debugging information on every shell
OLD_SHELL := ${SHELL}
SHELL = $(warning [$@ ($^) ($?)])${OLD_SHELL} -x
endif
Something went wrong with that request. Please try again.