Source

LIME / lib / LIME.mk

Full commit
##################################################################
# This mk file defines all commands and configuration (no rules) of
# the LIME compilation process
#
#Copyright (C) 2008 NXP Semiconductors B.V.
#
#This file is part of LIME.
#
#LIME is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License version 2
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#LIME 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 LIME.  If not, see <http://www.gnu.org/licenses/>.
##################################################################
STRICT_DOMAINS=yes

ifneq ($(VERBOSE),)
e?=
E?=
else
e?=@
E?=@
redir=2>/dev/null
quiet=1>/dev/null
endif

fail=( $(rm) $@; exit 1 )

ifneq ($(VERBOSE_TRACE),)
inform=$eecho "$(notdir $^) -> $(notdir $@)" >/dev/stderr
minform=$eecho "$(notdir $$^) -> $(notdir $$@)" >/dev/stderr
endif

NOWARN=-Wno-unknown-pragmas -Wno-main

___DEFINES=-D__LIME__ 		# defined for all LIME compilations
FE_DEFINES=-DLIME_FRONTEND	# defined for FE compilers only
BE_DEFINES=-DLIME_BACKEND	# defined for BE compilers only

COMMON_CFLAGS+=-std=c99 $(___DEFINES) -Wall $(NOWARN) -g -O1 -I. -I$(inc) -I$(rinc)
LIME_CFLAGS+=$(COMMON_CFLAGS) $(FE_DEFINES) -D_ISOC99_SOURCE
CFLAGS+=$(COMMON_CFLAGS) $(BE_DEFINES) -D__inout__=

SHELL=/bin/bash

gcc=gcc
GCC=$(gcc)
CC=$(gcc)
objdump=objdump
objcopy=objcopy
cat=cat
echo=echo
touch=touch
mv=mv
cp=cp
rm=rm
ln=ln
mkdir=mkdir
sed=sed
sort=sort

export awk=gawk
export iawk=$(rbin)/igawk
export AWKPATH=$(rlib)

unmarkup=/usr/lib/noweb/unmarkup
markup=/usr/lib/noweb/markup -t4
finduses=/usr/lib/noweb/finduses
noidx=/usr/lib/noweb/noidx
l2h=/usr/lib/noweb/l2h
tohtml=/usr/lib/noweb/tohtml
totex=/usr/lib/noweb/totex
autodef=/usr/lib/noweb/autodefs.c
htmltoc=htmltoc
emptydefn=/usr/lib/noweb/emptydefn
disambiguate=/usr/lib/noweb/disambiguate

filters=-filter "emptydefn | disambiguate"

notangle=notangle
noweave=noweave
nodefs=nodefs
nod=$(nodefs) -auto c
#not=$(notangle) -t4
not=$(notangle) -t4 $(filters)
#not=$(notangle) -t4 -L'\#line %L "%F"%N' $(filters)
#not=$(notangle) -t4 -L'\#line %L "%F"%N'
indent=LINE_LENGTH=40 INDENT=astyle INDENT_OPTIONS="--style=linux -s4"
now=$(indent) $(noweave) -t4 $(filters) -autodefs c -filter nopp
#now=$(noweave) -filter findident -filter nopp
#now=$(indent) $(noweave) -filter nopp
#now=$(noweave) -autodefs c

cast=cast
nopp=nopp
fixmarkup=fixmarkup
fixall=fixall
fixhtml=fixhtml
gendeps=gendeps.noweb $(filters)
texlog=texlog

pdflatex=pdflatex -interaction batchmode 

dot=dot
expand=expand

ifneq ($(GCC),)
GCC_VERSION=$(shell $(GCC) -v 2>&1| awk '/^gcc version/ { split($$3,a,"."); print a[1]*100*100+a[2]*100+a[3] }')            
endif

DIVERSITY=$(shell ls {.,..,../..,../../..}/diversity 2>/dev/null)

cparse=$r/bin/cparse

uniq=$(awk) -f $(rlib)/uniq.awk
nvp2cpp=$(awk) -f $(rlib)/nvp2cpp.awk
fwdecl=$(awk) -f $(rlib)/fwdecl.awk

dtd_root?=http://bitbucket.org/pjotr/lime/raw/karma/doc

xml_opts+=-vdo_dtd=1 -vdo_xsl=1 -vuse_xi=1 -vuse_xlink=extended -vdtd_root="$(dtd_root)"

#_:=$(shell echo $(firstword $(subst :, ,$(dtd_root))) >/dev/stderr)

ifeq ($(firstword $(subst :, ,$(dtd_root))),http)
get=wget -nv $1 -O $2
else
get=$(cp) $1 $2
endif

#TODO figure out if we have internet
#xmllint=xmllint --xinclude --valid -
ifneq ($(NO_INET),)
xmllint=xmllint --dropdtd - | xmllint --xinclude --dtdvalid $r/doc/$1.dtd -
else
xmllint=xmllint --xinclude --dtdvalid $r/doc/$1.dtd -
endif
#xmllint=xmllint --xinclude --nonet --dtdvalid $r/doc/$1.dtd -

#xmllint=xmllint --xinclude --valid
#xmllint=xmllint --xinclude --dtdvalid $r/doc/$1.dtd

typeq=$(iawk) -f $(rlib)/typeq.awk -vrelax=1
xmlnorm=$(iawk) -f $(rlib)/xmlnorm.awk

composer=$(iawk) -f $(rlib)/composer.awk -vrelax=1
incarnator=$(rbin)/incarnator
replicator=$(rbin)/replicator

gxf2dot=$(iawk) -f $(rlib)/gxfdump.awk -vOP=dot -vrelax=1
en2xml=$(iawk) -f $(rlib)/en2xml.awk

nvp2cpp.awk=$(nvp2cpp) $(1)

tex=$r/tex
before.tex=$(tex)/before.tex
middle.tex=$(tex)/middle.tex
after1.tex=$(tex)/after1.tex
after2.tex=$(tex)/after2.tex
afterall.tex=$(tex)/afterall.tex

ifneq ($(DO_HIDECODE),)
hidecode='\let\HideCode=\empty'
endif

htmlit.sed=$(sed) -e 's,YYY,$1,g;s,XXX,$(notdir $1),g'
texit.sed=$(sed) -e 's,YYY,$1,g;s,XXX,$(notdir $1),g'

ifeq ($(STRICT_DOMAINS),yes)
dom2hdr=`$(sed) -e '/LIME/bL;/$(DOMAIN)/bL;d;:L s,.*,-D&="$1",g' $2`
else
dom2hdr=`$(sed) -e 's,.*,-D&="$1",g' $2`
endif

# calculate absolute path to $(inc) & $(rinc)
Inc=$(shell cd $(inc); pwd)
RInc=$(shell cd $(rinc); pwd)

dom2imp=$(cat) $1 | while read m; do for d in $(Inc) $(RInc); do [ -r $$d/$$m.h ] && echo $$d/$$m; done; done
#$(sed) -e "s,.*,$(Inc)/&,g" $1
imp2type=`$(sed) -e 's,$$,.types,g' $1`
imps2imp=$(awk) -f $(rlib)/imp2hdr.awk -vpostorder=1 $1
imp2hdr=$(sed) -e 's,.*,\#include <&.h>,g' $1
imp2hdrp=$(sed) -e 's,.*,\#if !defined($2)\n\#include <&.h>\n\#endif,g' $1
c2dom=$(sed) -n 's,\#include[[:space:]]\([^"< ]\+\).*,\1,p' $1

unbundle=$(awk) -f $(rlib)/unbundle.awk

ifneq ($(LIME_DEBUG),)
.PRECIOUS: %.depx.h %.dep.h
.PRECIOUS: %.E %.E0
.PRECIOUS: %.tu

.PRECIOUS: %.0.gxf
.PRECIOUS: %.01.gxf
.PRECIOUS: %.1.gxf
.PRECIOUS: %.2.gxf
.PRECIOUS: %.3.gxf
.PRECIOUS: %.mod

.PRECIOUS: %.tex
.PRECIOUS: %.nw
.PRECIOUS: %-log.tex
.PRECIOUS: %-gen.nw
.PRECIOUS: %-gen.tex
.PRECIOUS: %-gen.noweb
.PRECIOUS: %-gen-log.tex
endif

#.PRECIOUS: %.domains

#.PRECIOUS: %.div %.ren %.mv
#.INTERMEDIATE: %.div
#.PRECIOUS: %.imports %.imps
#.PRECIOUS: %.forwards

#.PRECIOUS: %.syms 

#.PRECIOUS: %.png
#.PRECIOUS: %-gen.nw.tex
#.PRECIOUS: %-acros.tex
#.PRECIOUS: %.defs
.PRECIOUS: %.tex