mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-29 13:03:38 +01:00
Update configure and makefile
This commit is contained in:
parent
9c59763ad7
commit
ac36fce54d
2 changed files with 87 additions and 156 deletions
74
configure
vendored
74
configure
vendored
|
@ -17,12 +17,17 @@ cflags=
|
||||||
makefile='Makefile.default'
|
makefile='Makefile.default'
|
||||||
|
|
||||||
# configuration
|
# configuration
|
||||||
declare -A config
|
debug=false
|
||||||
config[__DEBUG]=false
|
valgrind=false
|
||||||
config[__ENABLE_VALGRIND]=false
|
|
||||||
config[__SUPPORT_VHEX_KERNEL]=false
|
# ABI support
|
||||||
config[__SUPPORT_CASIO_FX9860]=false
|
support_vhex_kernel=false
|
||||||
config[__SUPPORT_CASIO_FXCG50]=false
|
support_casio_abi_fx9860=false
|
||||||
|
support_casio_abi_fxcg50=false
|
||||||
|
|
||||||
|
# format
|
||||||
|
format_static=false
|
||||||
|
format_dynamic=false
|
||||||
|
|
||||||
#---
|
#---
|
||||||
# Help screen
|
# Help screen
|
||||||
|
@ -63,7 +68,8 @@ The 'ABI support' is used to allow some part of the code, in particular the 'uni
|
||||||
part, I/O management and additionals feature. (like process, fs, ...).
|
part, I/O management and additionals feature. (like process, fs, ...).
|
||||||
|
|
||||||
Format:
|
Format:
|
||||||
--dyn-lib Generate dynamic librairies (Vhex kernel dependant)
|
--static Generate static libraries (default)
|
||||||
|
--dynamic Generate dynamic libraries (Vhex kernel dependant)
|
||||||
|
|
||||||
Little note for the generation of dynamic libraries. The superH toolchain currently
|
Little note for the generation of dynamic libraries. The superH toolchain currently
|
||||||
used (GCC) does not support the '--shared' flags when the archive is build. So we
|
used (GCC) does not support the '--shared' flags when the archive is build. So we
|
||||||
|
@ -84,12 +90,12 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#---
|
||||||
# Check mandatory build location
|
# Check mandatory build location
|
||||||
# @note:
|
# @note:
|
||||||
# * You should build out-of-tree by creating a build directory and configuring
|
# * You should build out-of-tree by creating a build directory and configuring
|
||||||
# from there.
|
# from there.
|
||||||
#
|
#---
|
||||||
if [ -f 'make/Makefile.default' ]; then
|
if [ -f 'make/Makefile.default' ]; then
|
||||||
echo 'error: you should configure from a build directory, like this:' >&2
|
echo 'error: you should configure from a build directory, like this:' >&2
|
||||||
echo ' mkdir build && cd build && ../configure [options..]' >&2
|
echo ' mkdir build && cd build && ../configure [options..]' >&2
|
||||||
|
@ -97,16 +103,16 @@ if [ -f 'make/Makefile.default' ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#---
|
||||||
# Parsing arguments
|
# Parsing arguments
|
||||||
#
|
#---
|
||||||
for arg; do case "$arg" in
|
for arg; do case "$arg" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
help;;
|
help;;
|
||||||
|
|
||||||
# debug options
|
# debug options
|
||||||
--debug)
|
--debug)
|
||||||
config[__DEBUG]=true;;
|
debug=true;;
|
||||||
--unit-test)
|
--unit-test)
|
||||||
makefile='Malefile.unitest';;
|
makefile='Malefile.unitest';;
|
||||||
|
|
||||||
|
@ -120,15 +126,17 @@ for arg; do case "$arg" in
|
||||||
|
|
||||||
# ABI support
|
# ABI support
|
||||||
--support-vhex)
|
--support-vhex)
|
||||||
config[__SUPPORT_VHEX_KERNEL]=true;;
|
support_vhex_kernel=true;;
|
||||||
--support-casio-abi-fx9860)
|
--support-casio-abi-fx9860)
|
||||||
config[__SUPPORT_CASIO_ABI_FX9860]=true;;
|
support_casio_abi_fx9860=true;;
|
||||||
--support-casio-abi-fxcg50)
|
--support-casio-abi-fxcg50)
|
||||||
config[__SUPPORT_CASIO_ABI_FXCG50]=true;;
|
support_casio_abi_fxcg50=true;;
|
||||||
|
|
||||||
# format options
|
# format options
|
||||||
--dyn-lib)
|
--static)
|
||||||
makefile='Makefile.dynlib';;
|
format_static=true;;
|
||||||
|
--dynamic)
|
||||||
|
format_dynamic=true;;
|
||||||
|
|
||||||
# error part
|
# error part
|
||||||
*)
|
*)
|
||||||
|
@ -140,14 +148,6 @@ esac; done
|
||||||
#---
|
#---
|
||||||
# Check error
|
# Check error
|
||||||
#---
|
#---
|
||||||
# Check ABI support error
|
|
||||||
if [ ${config[__SUPPORT_CASIO_ABI_FX9860]} = true ] && [ ${config[__SUPPORT_CASIO_ABI_FXCG50]} = true ] ||
|
|
||||||
[ ${config[__SUPPORT_VHEX_KERNEL]} = true ] && [ ${config[__SUPPORT_CASIO_ABI_FXCG50]} = true ] ||
|
|
||||||
[ ${config[__SUPPORT_VHEX_KERNEL]} = true ] && [ ${config[__SUPPORT_CASIO_ABI_FX9860]} = true ]; then
|
|
||||||
echo "error: too many ABI target" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If no prefix is specified, install to the GCC's build folder
|
# If no prefix is specified, install to the GCC's build folder
|
||||||
if [[ -z "$prefix" ]]
|
if [[ -z "$prefix" ]]
|
||||||
then
|
then
|
||||||
|
@ -169,9 +169,9 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
# TODO
|
||||||
# TODO: check if the wanted lib exist (check lib verion too)!
|
# TODO: check if the wanted lib exist (check lib verion too)!
|
||||||
#
|
# TODO
|
||||||
|
|
||||||
#---
|
#---
|
||||||
# Dump appropriate Makefile
|
# Dump appropriate Makefile
|
||||||
|
@ -193,16 +193,24 @@ ln -s $src $dst
|
||||||
#---
|
#---
|
||||||
generate_config()
|
generate_config()
|
||||||
{
|
{
|
||||||
echo "CONFIG.CFLAGS := "
|
echo 'CONFIG.CFLAGS := '
|
||||||
echo "CONFIG.TARGET := "
|
echo 'CONFIG.TARGET := '
|
||||||
|
echo 'CONFIG.FORMAT := '
|
||||||
echo "CONFIG.TOOLCHAIN := $toolchain"
|
echo "CONFIG.TOOLCHAIN := $toolchain"
|
||||||
[ "$prefix" ] && echo "CONFIG.PREFIX := $prefix"
|
[ "$prefix" ] && echo "CONFIG.PREFIX := $prefix"
|
||||||
[ "$cflags" ] && echo "CONFIG.CFLAGS += $cflags"
|
[ "$cflags" ] && echo "CONFIG.CFLAGS += $cflags"
|
||||||
|
|
||||||
#[ ${config[__DEBUG]} = true ] && echo "CONFIG.CFLAGS += -g3"
|
# debug / unit tests
|
||||||
[ ${config[__SUPPORT_VHEX_KERNEL]} = true ] && echo "CONFIG.TARGET += fxlibc-vhex"
|
[ $debug = true ] && echo 'CONFIG.CFLAGS += -g3'
|
||||||
[ ${config[__SUPPORT_CASIO_ABI_FX9860]} = true ] && echo "CONFIG.TARGET += fxlibc-fx9860"
|
|
||||||
[ ${config[__SUPPORT_CASIO_ABI_FXCG50]} = true ] && echo "CONFIG.TARGET += fxlibc-fxcg50"
|
# ABI support
|
||||||
|
[ $support_vhex_kernel = true ] && echo 'CONFIG.TARGET += fxlibc-vhex'
|
||||||
|
[ $support_casio_abi_fx9860 = true ] && echo 'CONFIG.TARGET += fxlibc-fx9860'
|
||||||
|
[ $support_casio_abi_fxcg50 = true ] && echo 'CONFIG.TARGET += fxlibc-fxcg50'
|
||||||
|
|
||||||
|
# formats
|
||||||
|
[ $format_static = true ] && echo 'CONFIG.FORMAT += static'
|
||||||
|
[ $format_dynamic = true ] && echo 'CONFIG.FORMAT += dynamic'
|
||||||
}
|
}
|
||||||
generate_config > $confile
|
generate_config > $confile
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,24 @@
|
||||||
# | `-- otherinfo.txt
|
# | `-- otherinfo.txt
|
||||||
# |-- Makefile
|
# |-- Makefile
|
||||||
# |-- fxlibc.cfg
|
# |-- fxlibc.cfg
|
||||||
# `-- bin/
|
# `-- ouptut/
|
||||||
# |-- fxlibc_stubs.a (workaround for the shared librairie, see documentation note)
|
# |-- static/
|
||||||
# |-- fxlibc.so (shared librairy)
|
# | |--- libfxlibc.a
|
||||||
# `-- fxlibc.a (static librairy)
|
# | |--- libfxlibc-casio-abi-fx9860.a
|
||||||
|
# | `--- libfxlibc-casio-abi-fxcg50.a
|
||||||
|
# `--- dynamic/
|
||||||
|
# |--- libfxlibc.so
|
||||||
|
# |--- libfxlibc-casio-abi-fx9860.so
|
||||||
|
# `--- libfxlibc-casio-abi-fxcg50.so
|
||||||
#
|
#
|
||||||
# TODO:
|
# TODO:
|
||||||
# * generate all libraries for all ABI by default ?
|
|
||||||
# * handle versionning
|
# * handle versionning
|
||||||
#---
|
#---
|
||||||
|
MAJOR := 0
|
||||||
|
MINOR := 1
|
||||||
|
PATCH := 1
|
||||||
|
EXTRAVERSION := -alpha
|
||||||
|
|
||||||
|
|
||||||
#---
|
#---
|
||||||
# Build configuration
|
# Build configuration
|
||||||
|
@ -61,11 +70,9 @@ endef
|
||||||
# Define all directory used to stored informations
|
# Define all directory used to stored informations
|
||||||
dir_object := object
|
dir_object := object
|
||||||
dir_output := output
|
dir_output := output
|
||||||
dir_bin := bin
|
|
||||||
|
|
||||||
# Output configurations
|
# Output configurations
|
||||||
name := fxlibc
|
name := fxlibc
|
||||||
target := $(dir_bin)/$(name).a
|
|
||||||
|
|
||||||
# automated variable
|
# automated variable
|
||||||
directory := $(shell find ../src -not -path "*/\.*" -type d)
|
directory := $(shell find ../src -not -path "*/\.*" -type d)
|
||||||
|
@ -77,7 +84,6 @@ src := $(foreach path,$(directory), \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---
|
#---
|
||||||
# Toolchain
|
# Toolchain
|
||||||
#---
|
#---
|
||||||
|
@ -90,14 +96,6 @@ objcopy = $(CONFIG.TOOLCHAIN)-objcopy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---
|
|
||||||
# Version management
|
|
||||||
#---
|
|
||||||
# TODO
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---
|
#---
|
||||||
# Build rules
|
# Build rules
|
||||||
#---
|
#---
|
||||||
|
@ -114,6 +112,7 @@ first: all
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---
|
#---
|
||||||
# Automated rules
|
# Automated rules
|
||||||
#---
|
#---
|
||||||
|
@ -125,10 +124,9 @@ first: all
|
||||||
# * handle custom cflags (format, abi management)
|
# * handle custom cflags (format, abi management)
|
||||||
# * handle verbose option
|
# * handle verbose option
|
||||||
define compile-src
|
define compile-src
|
||||||
$(patsubst .._src_%,$2/%.o,$(subst /,_,$(basename $1))): $1 | $2/
|
$(patsubst .._src_%,$2%.o,$(subst /,_,$(basename $1))): $1 | $2/
|
||||||
@ printf "compiling $(white)$$@$(nocolor)..."
|
@ printf "$(green)>$(nocolor) $(white)$$@$(nocolor)\n"
|
||||||
@ $(gcc) $(cflags) -o $$@ -c $$< -lgcc
|
@ $(gcc) $(cflags) -o $$@ -c $$< -lgcc
|
||||||
@ printf "$(green)[ok]$(nocolor)\n"
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# common part used by all library geneation
|
# common part used by all library geneation
|
||||||
|
@ -141,28 +139,37 @@ define generate-target
|
||||||
lib-output-dir := $(dir_output)/$2/
|
lib-output-dir := $(dir_output)/$2/
|
||||||
lib-build-dir := $(dir_object)/$2/$1/
|
lib-build-dir := $(dir_object)/$2/$1/
|
||||||
ifeq ($2,dynamic)
|
ifeq ($2,dynamic)
|
||||||
lib-name := $$(lib-output-dir)/lib$1.so
|
lib-name := $$(lib-output-dir)lib$1.so.$$(lib-version)
|
||||||
lib-cflags := -pic $(cflags)
|
lib-cflags := -fPIC $(cflags)
|
||||||
else
|
else
|
||||||
lib-name := $$(lib-output-dir)/lib$1.a
|
lib-name := $$(lib-output-dir)lib$1.a
|
||||||
lib-cflags := $(cflags)
|
lib-cflags := $(cflags)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# indicate the new lib that will be ouputed
|
# indicate the new lib that will be ouputed
|
||||||
generated-libs += $$(lib-name)
|
generated-libs += $$(lib-name)
|
||||||
|
|
||||||
|
# add custom flags based on the target ABI
|
||||||
|
ifeq ($1,fxlibc-vhex)
|
||||||
|
lib-cflags += -D __SUPPORT_VHEX_KERNEL
|
||||||
|
else ifeq ($1,fxlibc-casio-abi-fx9860)
|
||||||
|
lib-cflags += -D __SUPPORT_CASIO_ABI_FX9860G
|
||||||
|
else ifeq ($1,fxlibc-casio-abi-fxcf50)
|
||||||
|
lib-cflags += -D __SUPPORT_CASIO_ABI_FXCG50
|
||||||
|
endif
|
||||||
|
|
||||||
# generate all file object name
|
# generate all file object name
|
||||||
$$(foreach source,$3,$$(eval \
|
$$(foreach source,$3,$$(eval \
|
||||||
$$(call compile-src,$$(source),$$(lib-build-dir)) \
|
$$(call compile-src,$$(source),$$(lib-build-dir)) \
|
||||||
))
|
))
|
||||||
|
|
||||||
# link the library
|
# link the library
|
||||||
# @note: based on the wanted format
|
# @note: we need to generate the library verion information manually
|
||||||
ifeq ($2,shared)
|
# TODO: find a better way to generate the version symbols
|
||||||
$$(lib-name): $$(patsubst .._src_%,$$(lib-build-dir)/%.o,$$(subst /,_,$$(basename $3))) | $$(lib-output-dir)
|
$$(lib-name): $$(patsubst .._src_%,$$(lib-build-dir)%.o,$$(subst /,_,$$(basename $3))) | $$(lib-output-dir)
|
||||||
$(gcc) -shared -o $$@ $$^ -nostdlib -lgcc
|
ifeq ($2,dynamic)
|
||||||
|
$(gcc) -shared -Wl,-soname=$$@ -o $$@ $$^ -nostdlib -lgcc
|
||||||
else
|
else
|
||||||
$$(lib-name): $$(patsubst .._src_%,$$(lib-build-dir)/%.o,$$(subst /,_,$$(basename $3))) | $$(lib-output-dir)
|
|
||||||
$(ar) crs $$@ $$^
|
$(ar) crs $$@ $$^
|
||||||
endif
|
endif
|
||||||
endef
|
endef
|
||||||
|
@ -178,6 +185,9 @@ target-libs := $(if $(CONFIG.TARGET),$(CONFIG.TARGET),fxlibc)
|
||||||
# the dynamic make code generation (generated by the "foreach")
|
# the dynamic make code generation (generated by the "foreach")
|
||||||
generated-libs :=
|
generated-libs :=
|
||||||
|
|
||||||
|
# generate the library version
|
||||||
|
lib-version := $(MAJOR).$(MINOR).$(PATCH)$(EXTRAVERSION)
|
||||||
|
|
||||||
# Generate all targets
|
# Generate all targets
|
||||||
$(foreach format,$(target-formats), \
|
$(foreach format,$(target-formats), \
|
||||||
$(foreach lib,$(target-libs),$(eval \
|
$(foreach lib,$(target-libs),$(eval \
|
||||||
|
@ -187,11 +197,15 @@ $(foreach format,$(target-formats), \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---
|
#---
|
||||||
# Build rule
|
# Build rule
|
||||||
#---
|
#---
|
||||||
all: $(generated-libs)
|
all: $(generated-libs)
|
||||||
|
|
||||||
|
version:
|
||||||
|
@ echo "$(lib-version)"
|
||||||
|
|
||||||
DEBUG=$(call generate-target,fxlibc,static,$(dir_objects),$(src))
|
DEBUG=$(call generate-target,fxlibc,static,$(dir_objects),$(src))
|
||||||
export DEBUG
|
export DEBUG
|
||||||
debug:
|
debug:
|
||||||
|
@ -205,99 +219,8 @@ debug:
|
||||||
# clean rules
|
# clean rules
|
||||||
#---
|
#---
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(dir_objects)
|
rm -rf $(dir_object)
|
||||||
fclean: clean
|
fclean: clean
|
||||||
rm -rf $(dir_bin)
|
rm -rf $(dir_output)
|
||||||
re: fclean clean
|
re: fclean clean
|
||||||
.PHONY: clean fclean re
|
.PHONY: clean fclean re
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---
|
|
||||||
# Build rules
|
|
||||||
#---
|
|
||||||
#all: $(target)
|
|
||||||
#
|
|
||||||
## linker part
|
|
||||||
#$(target): $(obj) | $(dir_bin)
|
|
||||||
# $(ar) crs $@ $^
|
|
||||||
#
|
|
||||||
## installation part
|
|
||||||
#install: $(target)
|
|
||||||
# install -d $(CONFIG.PREFIX)
|
|
||||||
# install $(target) -m 644 $(CONFIG.PREFIX)
|
|
||||||
# cp -r $(header) $(CONFIG.PREFIX)/include/fxlibc
|
|
||||||
#uninstall:
|
|
||||||
# rm -f $(CONFIG.PREFIX)/$(target)
|
|
||||||
# rm -rf $(CONFIG.PREFIX)/include/fxlibc
|
|
||||||
#
|
|
||||||
## Directory management
|
|
||||||
#$(dir_bin) $(dir_objects):
|
|
||||||
# @ printf "Create $(blue)$@$(nocolor) directory\n"
|
|
||||||
# @ mkdir -p $@
|
|
||||||
#
|
|
||||||
#.PHONY: all install uninstall
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
##define rule-src
|
|
||||||
##$(patsubst .._src_%,$(dir_objects)/%.o,$(subst /,_,$(basename $1))): $1 | $(dir_objects)
|
|
||||||
## @ printf "compiling $(white)$$<$(nocolor)..."
|
|
||||||
## @ $(gcc) $(cflags) -o $$@ -c $$< -lgcc
|
|
||||||
## @ printf "$(green)[ok]$(nocolor)\n"
|
|
||||||
##endef
|
|
||||||
##
|
|
||||||
##$(foreach source,$(src),$(eval \
|
|
||||||
## $(call rule-src,$(source))) \
|
|
||||||
##)
|
|
||||||
#
|
|
||||||
#
|
|
||||||
##---
|
|
||||||
## Debugging rules
|
|
||||||
##---
|
|
||||||
#help:
|
|
||||||
# @ echo 'make [options]...'
|
|
||||||
# @ echo ''
|
|
||||||
# @ echo 'Options:'
|
|
||||||
# @ echo ' * install install the library and headers to the PREFIX'
|
|
||||||
# @ echo ' * uninstall uninstall the library and headers of the PREFIX'
|
|
||||||
# @ echo ' * disasm use objdump to display the content of the archive'
|
|
||||||
# @ echo ' * debug display source files name and objects name'
|
|
||||||
# @ echo ' * elf_sec display ELF section of the archive'
|
|
||||||
#__debug:
|
|
||||||
# @ echo 'src: $(src)'
|
|
||||||
# @ echo ''
|
|
||||||
# @ echo 'obj: $(obj)'
|
|
||||||
# @ echo ''
|
|
||||||
# @ echo 'directory: $(dir_bin) $(dir_output) $(dir_objects)'
|
|
||||||
#
|
|
||||||
#disasm:
|
|
||||||
# @ $(objdump) -D $(target) | less
|
|
||||||
#
|
|
||||||
#elf_sec:
|
|
||||||
# @ $(objdump) -h $(target) | less
|
|
||||||
#
|
|
||||||
#.PHONY: help __debug disasm elf_sec
|
|
||||||
#
|
|
||||||
#
|
|
||||||
##---
|
|
||||||
## clean rules
|
|
||||||
##---
|
|
||||||
#clean:
|
|
||||||
# rm -rf $(dir_objects)
|
|
||||||
#
|
|
||||||
#fclean: clean
|
|
||||||
# rm -rf $(dir_bin)
|
|
||||||
#
|
|
||||||
#re: fclean clean
|
|
||||||
#
|
|
||||||
#.PHONY: clean fclean re
|
|
||||||
|
|
Loading…
Reference in a new issue