[r23]: LIME-core / lib / main.mk  Maximize  Restore  History

Download this file

166 lines (137 with data), 4.2 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
##################################################################
# This mk file contains rules (no configuration or command defines)
# that drive the LIME flow
#
#Copyright 2008 Pjotr Kourzanov
#
#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.
#
#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/>.
##################################################################
include $(rlib)/LIME.mk
include $(rlib)/literate.mk
include $(rlib)/gcc.mk
######### compilation stuff
%.domains: %.c
$(inform)
$e(\
$(call c2dom,$<);\
for x in $(syshdr); do\
echo $$x | sed -ne 's,$(rinc)/\(.*\).h,\1,p';\
done;\
) | $(uniq) >$@
# in case a component does not specify diversity,
# just create an empty one
%.diversity:
$(inform)
$e$(touch) $@
%.div: $(DIVERSITY) %.diversity
$(inform)
$e(\
if test -s "$(filter %.diversity,$^)"; then\
$(echo) "# Locally-set parameters take precedence";\
$(cat) $(filter %.diversity,$^);\
fi;\
if test -n "$(filter-out %.diversity,$^)"; then\
$(echo) "# Globally-set parameters as a default";\
$(awk) -vMODULE=$* -vFS="=" '/^#/ { next }\
{ split($$1,path,"[.]");\
if (!path[1]) next;\
if (MODULE !~ path[1]) next;\
print path[2] "=" $$2\
}' $(filter-out %.diversity,$^);\
fi;\
) > $@
%.E: %.c %.dep.h %.domains
$(inform)
$e$(CC) $(LIME_CFLAGS) $(call dom2hdr,$*.dep.h,$*.domains) -c $*.c -E -o $@
# break cyclical dependency of .E by first processing incomplete module
%.E0: %.c %.domains
$(inform)
$e$(CC) $(LIME_CFLAGS) $(call dom2hdr,ctype.h,$*.domains) -c $*.c -E -o $@
%.forwards: %.E0
$(inform)
$e$(fwdecl) $^ > $@
%.imps: %.forwards %.domains
$(inform)
$e(\
$(call dom2imp,$*.domains);\
if test -s $*.forwards -a -n "$(types)"; then\
$(typeq) -vFILE=$*.forwards $(types) $(redir);\
fi;\
) | $(uniq) > $@
%.imports: %.imps
$(inform)
$e$(call imps2imp,$<) > $@
%.pdepx.h: %.div %.ren %.imports
$(inform)
$e(\
$(call imp2hdrp,$*.imports,TARGET);\
$(call nvp2cpp.awk,$(filter-out %.imports,$^));\
) > $@
%.depx.h: %.div %.ren %.imports
$(inform)
$e(\
$(call imp2hdr,$*.imports);\
$(call nvp2cpp.awk,$(filter-out %.imports,$^));\
) > $@
%.dep.h: %.div %.imports
$(inform)
$e(\
$(call imp2hdr,$*.imports);\
$(call nvp2cpp.awk,$(filter-out %.imports,$^));\
) > $@
%.ren: %.syms
$(inform)
$e( $(echo) "# Rename standard local names";\
$(awk) -vMODULE=$* '/^[a-z$$A-Z_][a-z$$A-Z_0-9]*$$/ { print $$0 "=" MODULE "_" $$0 }' $(filter %.syms,$^);\
) > $@
%.mv: %.syms
$(inform)
$e$(awk) -vMODULE=$* '/^[a-z$$A-Z_][a-z$$A-Z_0-9]*$$/ { print $$0, MODULE "_" $$0 }' $< > $@
# generate preprocessed source
%.mod.c: %.c %.depx.h %.domains
$(inform)
$E$(CC) $(CFLAGS) $(call dom2hdr,$*.depx.h,$*.domains) $(FLAGS) -E $*.c -o $@
# simply compile now
%.mod.o: %.mod.c
$(inform)
$E$(CC) $(CFLAGS) -o $@ -c $<
# header handling
%.c: %.h
$(inform)
$e(\
$(echo) '#include LIME';\
$(echo) '#include <ctype.h>';\
$(echo) '#include "$(filter %.h,$^)"';\
) > $@
%.types: %.tu %.E
$(inform)
$e$(cparse) -vDIR=$(dir $*) -vSRC=$(filter %.E,$^) -vOP="types,typedefs" -vFNAME=$(notdir $(basename $*.c).h) $(filter %.tu,$^) | $(xmlnorm) -vroot="types" > $@ || $(fail)
$e$(rm) -f $*.c
#GXF
%.module: %.mod %.imports
$(inform)
$e$(composer) -vroot="@" $(filter-out %.imports,$^) $(call imp2type,$*.imports) > $@ || $(fail)
%.graph.xml: %.graph
$(inform)
$e$(en2xml) $< >$@ || $(fail)
%.xml: %
$(inform)
$e$(en2xml) -vroot=$(subst .,,$(suffix $<)) -vuse_xlink=extended -vdo_dtd=1 $< >$@ || $(fail)
%.gxf: $(modules) %.graph.xml
$(inform)
$e$(xmlnorm) -vroot=$(subst .,,$(suffix $@)) -vuse_xlink=extended -vdo_dtd=1 $^ > $@ || $(fail)
%.dot: %.gxf
$(inform)
$e$(gxf2dot) $^ > $@ || $(fail)