Initial snapshot

This commit is contained in:
Mercier Pierre-Olivier 2013-02-11 22:04:30 +01:00
commit fee4dd4e6d
373 changed files with 62144 additions and 0 deletions

View file

@ -0,0 +1 @@
.

View file

@ -0,0 +1 @@
../linux.conf

View file

@ -0,0 +1 @@
../linux.desc

View file

@ -0,0 +1 @@
../linux.mk

View file

@ -0,0 +1 @@
../linux.py

View file

@ -0,0 +1 @@
.

View file

@ -0,0 +1,137 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ofile/host/linux/ia32.mips64/mips64.conf
#
# created julien quintard [thu jun 28 21:15:33 2007]
# updated julien quintard [fri may 1 23:54:21 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains definitions specific to the mips64 target microprocessor
# architecture.
#
#
# include the linux generic definitions
#
_INCLUDES_ = -I${_INCLUDE_DIR_}
#
# ---------- flags ------------------------------------------------------------
#
_CC_FLAGS_ = -D___kaneton \
${_INCLUDES_} \
${_KANETON_FLAGS_} \
-fno-builtin \
-Wimplicit \
-Wparentheses \
-Wreturn-type \
-Wswitch -Wswitch-enum \
-Wunused-function \
-Wunused-variable \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wall -W -std=c99 \
-mabi=64 \
-G 0 \
-march=mips64 \
-EL \
-mgp64 \
-mfp64 \
-mlong64 \
-DMIPS64_DEPENDENT \
-DMIPS64_DEV
_LD_FLAGS_ = --warn-unresolved-symbols \
--oformat=elf64-littlemips
_ASM_FLAGS_ = -mabi=64 \
-G 0 \
-march=mips64 \
-EL \
-mgp64 \
-mfp64
_CPP_FLAGS_ =
_SHELL_FLAGS_ =
_PYTHON_FLAGS_ =
_PERL_FLAGS_ =
_MAKE_FLAGS_ =
#
# ---------- binaries ---------------------------------------------------------
#
_BINARIES_ = ${_SHELL_}, ${_CC_}, ${_MAKE_}, \
${_RM_}, ${_AR_}, ${_RANLIB_}, \
${_LD_}, ${_AS_}, ${_BIBTEX_},\
${_LN_}, ${_TOUCH_}, ${_WC_}, \
${_DATE_}, ${_TAIL_}, ${_TAR_}, \
${_PDFLATEX_}, ${_CP_}, \
${_CAT_}, ${_SED_}, ${_CPP_}, \
${_MTOOLS_}, ${_MCOPY_}, \
${_XPDF_}, ${_MKTEMP_}, ${_MV_},\
${_LEX_}, ${_SCRIPT_}, \
${_PERL_}, ${_PYTHON_}, \
${_DIRNAME_}, ${_BASENAME_}, \
${_WHICH_}
_SHELL_ = bash
_CC_ = mips64-gcc
_AS_ = mips64-as
_OBJCOPY_ = mips64-objcopy
_MAKE_ = gmake
_RM_ = rm -f
_PURGE_ = ${_RM_} *.pyc *~ .*~ \#* .\#*
_AR_ = mips64-ar cq
_RANLIB_ = mips64-ranlib
_CD_ = cd
_LD_ = mips64-ld
_LN_ = ln -s -f
_TOUCH_ = touch
_WC_ = wc
_DATE_ = date -u
_TAIL_ = tail
_TAR_ = tar
_PDFLATEX_ = pdflatex
_BIBTEX_ = bibtex
_CP_ = cp
_CAT_ = cat
_SED_ = sed -r
_ECHO_ = echo
_CPP_ = mips64-cpp
_MTOOLS_ = mtools
_MCOPY_ = mcopy
_XPDF_ = xpdf
_MKTEMP_ = mktemp
_MV_ = mv
_PWD_ = pwd
_LEX_ = lex -t
_SCRIPT_ = script
_PERL_ = perl
_PYTHON_ = python
_DIRNAME_ = dirname
_BASENAME_ = basename
_WHICH_ = which
_EXIT_ = exit
#
# microprocessor specific definitions
#
_CC_FLAGS_ += -D___kaneton$$\endian=1 \
-D___kaneton$$\wordsz=64 \
-D___kaneton$$\pagesz=4096

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...nvironment/profile/host/linux/linux.desc
#
# created julien quintard [tue may 8 13:20:04 2007]
# updated julien quintard [tue may 29 16:37:31 2007]
#
#
# ---------- information ------------------------------------------------------
#
# this file describes the linux environment variables.
#
- variable: _SHELL_
string: Shell
type: any
description: The shell binary path
- variable: _CC_
string: C Compiler
type: any
description: The C compiler binary path
- variable: _MAKE_
string: Make
type: any
description: The make binary path

View file

@ -0,0 +1,23 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/enguerrand/...profile/host/linux/ia32.mips64/mips64.mk
#
# created julien quintard [tue may 8 13:03:34 2007]
# updated enguerrand raymond [sun may 17 09:36:48 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton make interface.
#
# indeed the major generic part of the interface is already provided by the
# host profile.
#
include ../linux.mk

View file

@ -0,0 +1,219 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/enguerrand/...profile/host/linux/ia32.mips64/mips64.py
#
# created julien quintard [tue may 8 13:20:21 2007]
# updated enguerrand raymond [fri apr 17 20:59:36 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton python interface.
#
# note that the host profile already provides many functions. these
# functions can be overriden but you will probably just use them.
#
# in addition, the host profile already imports some packages.
#
#
# ---------- python path ------------------------------------------------------
#
pythonpath = os.getenv("PYTHONPATH")
if not pythonpath:
pythonpath = ""
os.putenv("PYTHONPATH", pythonpath + ":" + _PYTHON_INCLUDE_DIR_)
#
# ---------- functions --------------------------------------------------------
#
#
# colorize()
#
# this function returns a colorized text if the environment is configured
# to or simply the original text.
#
# note that this function implementation is based on UNIX escape sequences.
#
def colorize(text, color, options):
if _DISPLAY_ == _DISPLAY_UNCOLORED_:
return text
if options & OPTION_FLICKERING:
text = "" + text + ""
if color == COLOR_BLACK:
text = "" + text + ""
elif color == COLOR_RED:
text = "" + text + ""
elif color == COLOR_GREEN:
text = "" + text + ""
elif color == COLOR_YELLOW:
text = "" + text + ""
elif color == COLOR_BLUE:
text = "" + text + ""
elif color == COLOR_MAGENTA:
text = "" + text + ""
elif color == COLOR_CYAN:
text = "" + text + ""
elif color == COLOR_WHITE:
text = "" + text + ""
return text
#
# launch()
#
# this function launch a new program/script/make etc.
#
def launch(file, arguments, options):
directory = None
info = None
status = 0
wd = None
info = os.path.split(file)
directory = info[0]
file = info[1]
if directory:
wd = cwd(OPTION_NONE)
cd(directory, OPTION_NONE)
if re.match("^.*\.sh$", file):
status = os.system(_SHELL_ + " " + file + " " + arguments)
elif re.match("^.*\.py$", file):
status = os.system(_PYTHON_ + " " + file + " " + arguments)
elif re.match("^.*\.pl$", file):
status = os.system(_PERL_ + " " + file + " " + arguments)
elif re.match("^Makefile$", file):
status = os.system(_MAKE_ + " -f " + file + " " + arguments)
else:
status = os.system(file + " " + arguments)
if directory:
cd(wd, OPTION_NONE)
return status
#
# pack()
#
# this function creates an archive of the given directory.
#
def pack(directory, file, options):
launch(_TAR_, "-cjf " + file + " " + directory, OPTION_NONE)
#
# unpack()
#
# this function unpackages an archive into the given (optional) directory.
#
def unpack(file, directory, options):
if directory:
launch(_TAR_, "-xjf " + file + " -C " + directory, OPTION_NONE)
else:
launch(_TAR_, "-xjf " + file, OPTION_NONE)
#
# load()
#
# this function copies a file on a device, this device can be virtual:
# an image.
#
def load(file, device, path, options):
if options == OPTION_DEVICE:
launch(_MCOPY_, "-o -n " + file + " " + device + path, OPTION_NONE)
if options == OPTION_IMAGE:
launch(_MCOPY_, "-o -n " + "-i" + device + " " +
file + " ::" + path, OPTION_NONE)
#
# record()
#
# this function runs the program recording a session.
#
def record(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
directory = tmp + "/" + "transcript"
log = directory + "/" + "log"
time = directory + "/" + "time"
mkdir(directory, OPTION_NONE)
launch(_SCRIPT_, "-q -t " + log + " -c " +
_TRANSCRIPT_CMD_ + " 2> " + time, OPTION_NONE)
wd = cwd(OPTION_NONE)
cd(tmp, OPTION_NONE)
pack("transcript", wd + "/" + transcript, OPTION_NONE)
cd(wd, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# play()
#
# this function runs the program replaying a session.
#
def play(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
log = tmp + "/" + "transcript/log"
time = tmp + "/" + "transcript/time"
unpack(transcript, tmp, OPTION_NONE)
launch(_SCRIPTREPLAY_TOOL_, time + " " + log, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# locate()
#
# this function tries to locate a program on the system.
#
def locate(file, options):
return launch(_WHICH_, file + " 1>/dev/null 2>/dev/null", OPTION_NONE)

View file

@ -0,0 +1,48 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/enguerrand/...t/profile/host/linux/ia32.mips64/util.py
#
# created enguerrand raymond [fri apr 17 20:59:04 2009]
# updated enguerrand raymond [fri apr 17 21:00:47 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements some useful functions used for mips compilation, build
# and installation.
#
#
# binary_extract()
#
# this function extracts given sections (section names separate by space)
# from elf to put in binary
#
def binary_extract(elf, sections, binary):
section_list = sections.split()
cmd_option = "-S"
for section in section_list:
cmd_option += " -j " + section
cmd_option += " --output-target binary " + elf + " " + binary
launch(_OBJCOPY_, cmd_option, "")
#
# concat_file()
#
# this function concatenates file a the result file end
#
def concat_file(file, result):
os.system(_CAT_ + " " + file + " >> " + result)

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...t/profile/host/linux/ia32.null/null.conf
#
# created julien quintard [thu jun 28 21:15:33 2007]
# updated julien quintard [wed mar 26 23:37:31 2008]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains definitions specific to the null target microprocessor
# architecture.
#
#
# include the linux generic definitions
#
include ../linux.conf
#
# microprocessor specific definitions
#
_CC_FLAGS_ += -D___kaneton$$\endian=0 \
-D___kaneton$$\wordsz=32 \
-D___kaneton$$\pagesz=1

View file

@ -0,0 +1 @@
../linux.desc

View file

@ -0,0 +1 @@
../linux.mk

View file

@ -0,0 +1 @@
../linux.py

View file

@ -0,0 +1,113 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...nvironment/profile/host/linux/linux.conf
#
# created julien quintard [tue may 8 13:19:52 2007]
# updated julien quintard [mon feb 7 10:36:01 2011]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains the libraries, binaries, script and tools related to
# the generic linux host sub-profile.
#
#
# ---------- includes ---------------------------------------------------------
#
_INCLUDES_ = -I${_INCLUDE_DIR_}
#
# ---------- flags ------------------------------------------------------------
#
_CC_FLAGS_ = ${_INCLUDES_} \
${_KANETON_FLAGS_} \
-fno-builtin \
-fno-stack-protector \
-Wimplicit \
-Wparentheses \
-Wreturn-type \
-Wswitch -Wswitch-enum \
-Wunused-function \
-Wunused-variable \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wall
_LD_FLAGS_ = ${_INCLUDES_}
_ASM_FLAGS_ =
_CPP_FLAGS_ =
_SHELL_FLAGS_ =
_PYTHON_FLAGS_ =
_PERL_FLAGS_ =
_MAKE_FLAGS_ =
#
# ---------- binaries ---------------------------------------------------------
#
_BINARIES_ = ${_SHELL_}, ${_CC_}, ${_MAKE_}, \
${_RM_}, ${_AR_}, ${_RANLIB_}, \
${_LD_}, ${_AS_}, ${_BIBTEX_},\
${_LN_}, ${_TOUCH_}, ${_WC_}, \
${_DATE_}, ${_TAIL_}, ${_TAR_}, \
${_PDFLATEX_}, ${_CP_}, \
${_CAT_}, ${_SED_}, ${_CPP_}, \
${_MTOOLS_}, ${_MCOPY_}, \
${_XPDF_}, ${_MKTEMP_}, ${_MV_},\
${_LEX_}, ${_SCRIPT_}, \
${_PERL_}, ${_PYTHON_}, \
${_DIRNAME_}, ${_BASENAME_}, \
${_WHICH_}
_SHELL_ = bash
_CC_ = gcc
_AS_ = as
_MAKE_ = make
_RM_ = rm -f
_PURGE_ = ${_RM_} ${_GARBAGE_}
_AR_ = ar cq
_RANLIB_ = ranlib
_CD_ = cd
_LD_ = ld
_LN_ = ln -s -f
_TOUCH_ = touch
_WC_ = wc
_DATE_ = date -u
_TAIL_ = tail
_TAR_ = tar
_PDFLATEX_ = pdflatex
_BIBTEX_ = bibtex
_CP_ = cp
_CAT_ = cat
_SED_ = sed -r
_ECHO_ = echo
_CPP_ = cpp
_MTOOLS_ = mtools
_MCOPY_ = mcopy
_XPDF_ = xpdf
_MKTEMP_ = mktemp
_MV_ = mv
_PWD_ = pwd
_LEX_ = lex -t
_SCRIPT_ = script
_PERL_ = perl
_PYTHON_ = python
_DIRNAME_ = dirname
_BASENAME_ = basename
_WHICH_ = which
_EXIT_ = exit

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...nvironment/profile/host/linux/linux.desc
#
# created julien quintard [tue may 8 13:20:04 2007]
# updated julien quintard [tue may 29 16:37:31 2007]
#
#
# ---------- information ------------------------------------------------------
#
# this file describes the linux environment variables.
#
- variable: _SHELL_
string: Shell
type: any
description: The shell binary path
- variable: _CC_
string: C Compiler
type: any
description: The C compiler binary path
- variable: _MAKE_
string: Make
type: any
description: The make binary path

View file

@ -0,0 +1,507 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane.../environment/profile/host/linux/linux.mk
#
# created julien quintard [tue may 8 13:03:34 2007]
# updated julien quintard [sun dec 5 00:02:41 2010]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton make interface.
#
# indeed the major generic part of the interface is already provided by the
# host profile.
#
#
# ---------- lang -------------------------------------------------------------
#
# incorrect locales may prevent the system from compiling properly.
#
# the following forces the LANG environment variable to US.
#
export LANG=US
#
# ---------- python path ------------------------------------------------------
#
export PYTHONPATH=$(shell $(_ECHO_) $${PYTHONPATH}):$(_PYTHON_INCLUDE_DIR_)
#
# ---------- functions --------------------------------------------------------
#
#
# colorize functions
#
# 1: text
# 2: options
#
define env_colorize-black
"$(1)"
endef
define env_colorize-red
"$(1)"
endef
define env_colorize-green
"$(1)"
endef
define env_colorize-yellow
"$(1)"
endef
define env_colorize-blue
"$(1)"
endef
define env_colorize-magenta
"$(1)"
endef
define env_colorize-cyan
"$(1)"
endef
define env_colorize-white
"$(1)"
endef
define env_colorize-
"$(1)"
endef
#
# perform function
#
# 1: command
#
ifeq ($(_OUTPUT_),$(_OUTPUT_VERBOSE_)) # if the user wants to display
# additional debug information
define env_perform
$(_ECHO_) " $(1)" && \
$(1)
endef
else
define env_perform
$(1)
endef
endif
#
# print functions wrapper
#
# 1: text
# 2: color
# 3: options
#
ifeq ($(_DISPLAY_),$(_DISPLAY_COLORED_)) # if the user wants to display
# the text with color
define env_print
print_options="" && \
if [ -n "$(3)" ] ; then \
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
print_options="$${print_options} -n" ; \
fi ; \
fi && \
$(_ECHO_) $${print_options} $(call env_colorize-$(2),$(1),)
endef
else # if not ...
define env_print
print_options="" && \
if [ -n "$(3)" ] ; then \
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
print_options="$${print_options} -n" ; \
fi ; \
fi && \
$(_ECHO_) $${print_options} "$(1)"
endef
endif
#
# change the current working directory
#
# $(1): directory
# $(2): options
#
define env_cd
cd_options="" && \
$(call env_perform, \
$(_CD_) $${cd_options} $(1))
endef
#
# returns a file contents
#
# $(1): the file
# $(2): options
#
define env_pull
$(_CAT_) $(2) $(1)
endef
#
# launch a new program/script/make etc.
#
# $(1): file
# $(2): arguments
# $(3): options
#
define env_launch
launch_options="" && \
cwd=$$($(_PWD_)) && \
directory=$$($(_DIRNAME_) $(1)) && \
file=$$($(_BASENAME_) $(1)) && \
if [ "$${directory}" != "." ] ; then \
$(call env_perform, \
$(_CD_) $${directory}) ; \
fi && \
case "$${file}" in \
*.sh) \
$(call env_perform, \
$(_SHELL_) $${launch_options} $${file} $(_SHELL_FLAGS_) $(2)) ; \
;; \
*.py) \
$(call env_perform, \
$(_PYTHON_) $${launch_options} $${file} $(_PYTHON_FLAGS_) $(2)) ; \
;; \
*.pl) \
$(call env_perform, \
$(_PERL_) $${launch_options} $${file} $(_PERL_FLAGS_) $(2)) ; \
;; \
Makefile) \
$(call env_perform, \
$(_MAKE_) $${launch_options} -f $${file} $(_MAKE_FLAGS_) ${2}) ; \
;; \
esac ; \
return=$${?} && \
if [ "$${directory}" != "." ] ; then \
$(call env_perform, \
$(_CD_) $${cwd}) ; \
fi && \
if [ $${return} -ne 0 ] ; then \
$(_EXIT_) 42 ; \
fi
endef
#
# from c file to preprocessed c file
#
# $(1): preprocessed file
# $(2): c file
# $(3): options
#
define env_preprocess
preprocess_options="" && \
$(call env_display,green,PREPROCESS,$(2), ,) && \
$(call env_perform, \
$(_CPP_) -P $(_CPP_FLAGS_) $${preprocess_options} $(2) -o $(1))
endef
#
# from c file to object file
#
# $(1): object file
# $(2): c file
# $(3): options
#
define env_compile-c
compile_c_options="" && \
$(call env_display,green,COMPILE-C,$(2), ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) $${compile_c_options} -c $(2) -o $(1))
endef
#
# from lex file to c file
#
# $(1): c file
# $(2): lex file
# $(3): options
#
define env_lex-l
lex_l_options="" && \
$(call env_display,green,LEX-L,$(2), ,) && \
$(call env_perform, \
$(_LEX_) $${lex_l_options} $(2) > $(1))
endef
#
# from S file to object file
#
# $(1): object file
# $(2): S file
# $(3): options
#
define env_assemble-S
assemble_S_options="" && \
$(call env_display,green,ASSEMBLE-S,$(2), ,) && \
$(call env_perform, \
$(_CPP_) $(2) | $(_AS_) $(_ASM_FLAGS_) $${assemble_S_options} -o $(1))
endef
#
# create a static library from object files
#
# $(1): static library file name
# $(2): object files
# $(3): options
#
define env_static-library
static_library_options="" && \
$(call env_display,magenta,STATIC-LIBRARY,$(1), ,) && \
$(call env_perform, \
$(_AR_) $${static_library_options} $(1) $(2)) && \
$(call env_perform, \
$(_RANLIB_) $${static_library_options} $(1))
endef
#
# create a dynamic library from object files, static libraries
# and/or dynamic libraries
#
# $(1): dynamic library file name
# $(2): objects files and/or libraries
# $(3): options
#
define env_dynamic-library
dynamic_library_options="" && \
$(call env_display,magenta,DYNAMIC-LIBRARY,$(1), ,) && \
$(call env_perform, \
$(_LD_) --shared $(_LD_FLAGS_) $${dynamic_library_options} \
-o $(1) $(2))
endef
#
# create an executable file from object file and/or library files
#
# $(1): executable file name
# $(2): objects files and/or libraries
# $(3): layout file
# $(4): options
#
define env_executable
executable_options="" && \
if [ -n "$(3)" ] ; then \
executable_options="$${executable_options} -T $(3)" ; \
fi && \
if [ -n "$(4)" ] ; then \
if [ $$(( $(4) & $(ENV_OPTION_NO_STANDARD) )) -ne 0 ] ; then \
executable_options="$${executable_options} -nostdinc -nostdlib" ; \
fi ; \
fi && \
$(call env_display,magenta,EXECUTABLE,$(1), ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) $(_LD_FLAGS_) $${executable_options} -o $(1) \
$(2) "`$(_CC_) -print-libgcc-file-name`")
endef
#
# create an archive file from multiple object files
#
# note that the archive file is also an object file
#
# $(1): archive file name
# $(2): objects files and/or libraries
# $(3): options
#
define env_archive
archive_options="" && \
$(call env_display,magenta,ARCHIVE,$(1), ,) && \
$(call env_perform, \
$(_LD_) -r $(_LD_FLAGS_) $${archive_options} -o $(1) $(2))
endef
#
# remove the files
#
# $(1): files
# $(2): options
#
define env_remove
remove_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,red,REMOVE,$${f}, ,) ; \
fi && \
$(call env_perform, \
$(_RM_) $${remove_options} $${f}) ; \
done
endef
#
# purge i.e clean the directory from unwanted files
#
define env_purge
$(call env_display,red,PURGE,,,) && \
$(call env_perform, \
$(_PURGE_))
endef
#
# generate prototypes from a source file
#
# $(1): file list
# $(2): options
#
define env_prototypes
prototypes_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,yellow,PROTOTYPES,$${f}, ,) && \
$(call env_launch,$(_MKP_TOOL_), \
$${prototypes_options} $${f},) ; \
fi ; \
done
endef
#
# genereate header dependencies
#
# $(1): the files for which the dependencies are generated
# $(2): options
#
define env_headers
headers_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,yellow,HEADERS,$$f, ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) -M -MG $${headers_options} \
$${f} >> $(_DEPENDENCY_MK_)) ; \
fi ; \
done
endef
#
# generate a version file
#
# $(1): the version file to generate
#
define env_version
$(call env_display,yellow,VERSION,$(1), ,) && \
$(_ECHO_) -n "" > $(1) && \
$(_ECHO_) -n "const char version[] = \"$(_TITLE_)-$(_VERSION_)" >> $(1) && \
$(_ECHO_) " "$(shell $(_DATE_))" $(USER)@$(HOSTNAME)\";" >> $(1)
endef
#
# create a link between two files
#
# $(1): link created
# $(2): destination
# $(3): options
#
define env_link
link_options="" && \
$(call env_display,cyan,LINK,$(1), ,) && \
$(call env_perform, \
$(_LN_) $${link_options} $(2) $(1))
endef
#
# compile a tex document
#
# $(1): the file name without extension
# $(2): options
#
define env_compile-tex
compile_tex_options="" && \
$(call env_display,green,COMPILE-TEX,$(1), ,) && \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1)) && \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1)) && \
$(call env_perform, \
$(_BIBTEX_) $(1)) && \
$(call env_perform, \
$(_BIBTEX_) $(1)) && \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1)) ; \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1))
endef
#
# build a document
#
# $(1): the file name without extension
# $(2): options
#
define env_document
$(call env_remove,$(_DEPENDENCY_TEX_),) && \
if [ -n "$(2)" ] ; then \
if [ $$(( $(2) & $(ENV_OPTION_PRIVATE) )) -ne 0 ] ; then \
$(_ECHO_) '\def\mode{private}' > $(_DEPENDENCY_TEX_) ; \
fi ; \
fi && \
if [ ! -f $(_DEPENDENCY_TEX_) ] ; then \
$(_ECHO_) '\def\mode{public}' > $(_DEPENDENCY_TEX_) ; \
fi && \
$(call env_compile-tex,$(1),$(2))
endef
#
# launch a document viewer
#
# $(1): the file name without extension
# $(2): options
#
define env_view
$(call env_display,yellow,VIEW,$(1), ,) && \
$(call env_perform, \
$(_XPDF_) $(1).pdf)
endef
#
# ---------- component-based behaviour ----------------------------------------
#
#
# kaneton
#
ifneq ($(call findstring,kaneton,$(components)),)
_CC_FLAGS_ += -D___kaneton$$\kernel
endif

View file

@ -0,0 +1,239 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/host/linux/linux.py
#
# created julien quintard [tue may 8 13:20:21 2007]
# updated julien quintard [sat mar 5 09:13:35 2011]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton python interface.
#
# note that the host profile already provides many functions. these
# functions can be overriden but you will probably just use them.
#
# in addition, the host profile already imports some packages.
#
#
# ---------- lang -------------------------------------------------------------
#
# incorrect locales may prevent the system from compiling properly.
#
# the following forces the LANG environment variable to US.
#
os.putenv("LANG", "US")
#
# ---------- python path ------------------------------------------------------
#
_pythonpath_ = os.getenv("PYTHONPATH")
if not _pythonpath_:
os.putenv("PYTHONPATH", _PYTHON_INCLUDE_DIR_)
else:
os.putenv("PYTHONPATH", _pythonpath_ + ":" + _PYTHON_INCLUDE_DIR_)
#
# ---------- functions --------------------------------------------------------
#
#
# colorize()
#
# this function returns a colorized text if the environment is configured
# to or simply the original text.
#
# note that this function implementation is based on UNIX escape sequences.
#
def colorize(text, color, options):
if _DISPLAY_ == _DISPLAY_UNCOLORED_:
return text
if options & OPTION_FLICKERING:
text = "" + text
if options & OPTION_BOLD:
text = "" + text
if color == COLOR_BLACK:
text = "" + text
elif color == COLOR_RED:
text = "" + text
elif color == COLOR_GREEN:
text = "" + text
elif color == COLOR_YELLOW:
text = "" + text
elif color == COLOR_BLUE:
text = "" + text
elif color == COLOR_MAGENTA:
text = "" + text
elif color == COLOR_CYAN:
text = "" + text
elif color == COLOR_WHITE:
text = "" + text
return text + ""
#
# launch()
#
# this function launch a new program/script/make etc.
#
def launch(file, arguments, options):
directory = None
info = None
status = 0
wd = None
if options & OPTION_QUIET:
output = " >/dev/null 2>&1"
else:
output = ""
info = os.path.split(file)
directory = info[0]
file = info[1]
if directory:
wd = cwd(OPTION_NONE)
cd(directory, OPTION_NONE)
if re.match("^.*\.sh$", file):
status = os.system(_SHELL_ + " " + file + " " + arguments + output)
elif re.match("^.*\.py$", file):
status = os.system(_PYTHON_ + " " + file + " " + arguments + output)
elif re.match("^.*\.pl$", file):
status = os.system(_PERL_ + " " + file + " " + arguments + output)
elif re.match("^Makefile$", file):
status = os.system(_MAKE_ + " -f " + file + " " + arguments + output)
else:
if directory:
file = "./" + file
status = os.system(file + " " + arguments + output)
if directory:
cd(wd, OPTION_NONE)
return status
#
# pack()
#
# this function creates an archive of the given directory.
#
def pack(directory, file, options):
launch(_TAR_, "-cjf " + file + " " + directory, OPTION_NONE)
#
# unpack()
#
# this function unpackages an archive into the given (optional) directory.
#
def unpack(file, directory, options):
if directory:
launch(_TAR_, "-xjf " + file + " -C " + directory, OPTION_NONE)
else:
launch(_TAR_, "-xjf " + file, OPTION_NONE)
#
# load()
#
# this function copies a file on a device, this device can be virtual:
# an image.
#
def load(file, device, path, options):
if options == OPTION_DEVICE:
return launch(_MCOPY_, "-o -n " + file + " " + device + path,
OPTION_NONE)
elif options == OPTION_IMAGE:
return launch(_MCOPY_, "-o -n " + "-i" + device + " " +
file + " ::" + path, OPTION_NONE)
#
# record()
#
# this function runs the program recording a session.
#
def record(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
directory = tmp + "/" + "transcript"
log = directory + "/" + "log"
time = directory + "/" + "time"
mkdir(directory, OPTION_NONE)
launch(_SCRIPT_, "-q -t " + log + " -c " +
_TRANSCRIPT_CMD_ + " 2> " + time, OPTION_NONE)
wd = cwd(OPTION_NONE)
cd(tmp, OPTION_NONE)
pack("transcript", wd + "/" + transcript, OPTION_NONE)
cd(wd, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# play()
#
# this function runs the program replaying a session.
#
def play(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
log = tmp + "/" + "transcript/log"
time = tmp + "/" + "transcript/time"
unpack(transcript, tmp, OPTION_NONE)
launch(_REPLAY_TOOL_, time + " " + log, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# locate()
#
# this function tries to locate a program on the system.
#
def locate(file, options):
return launch(_WHICH_, file + " 1>/dev/null 2>/dev/null", OPTION_NONE)