2 # /*+------------------------------------------------------------------**
3 # ** OpenScop Library **
4 # **------------------------------------------------------------------**
6 # **------------------------------------------------------------------**
7 # ** First version: 28/05/2011 **
8 # **------------------------------------------------------------------**
11 # ***************************************************************************
12 # * OpenScop: Structures and formats for polyhedral tools to talk together *
13 # ***************************************************************************
14 # * ,___,,_,__,,__,,__,,__,,_,__,,_,__,,__,,___,_,__,,_,__, *
15 # * / / / // // // // / / / // // / / // / /|,_, *
16 # * / / / // // // // / / / // // / / // / / / /\ *
17 # * |~~~|~|~~~|~~~|~~~|~~~|~|~~~|~|~~~|~~~|~~~|~|~~~|~|~~~|/_/ \ *
18 # * | G |C| P | = | L | P |=| = |C| = | = | = |=| = |=| C |\ \ /\ *
19 # * | R |l| o | = | e | l |=| = |a| = | = | = |=| = |=| L | \# \ /\ *
20 # * | A |a| l | = | t | u |=| = |n| = | = | = |=| = |=| o | |\# \ \ *
21 # * | P |n| l | = | s | t |=| = |d| = | = | = | | |=| o | | \# \ \ *
22 # * | H | | y | | e | o | | = |l| | | = | | | | G | | \ \ \ *
23 # * | I | | | | e | | | | | | | | | | | | | \ \ \ *
24 # * | T | | | | | | | | | | | | | | | | | \ \ \ *
25 # * | E | | | | | | | | | | | | | | | | | \ \ \ *
26 # * | * |*| * | * | * | * |*| * |*| * | * | * |*| * |*| * | / \* \ \ *
27 # * | O |p| e | n | S | c |o| p |-| L | i | b |r| a |r| y |/ \ \ / *
28 # * '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---' '--' *
30 # * Copyright (C) 2008 University Paris-Sud 11 and INRIA *
32 # * (3-clause BSD license) *
33 # * Redistribution and use in source and binary forms, with or without *
34 # * modification, are permitted provided that the following conditions *
37 # * 1. Redistributions of source code must retain the above copyright *
38 # * notice, this list of conditions and the following disclaimer. *
39 # * 2. Redistributions in binary form must reproduce the above copyright *
40 # * notice, this list of conditions and the following disclaimer in the *
41 # * documentation and/or other materials provided with the distribution. *
42 # * 3. The name of the author may not be used to endorse or promote *
43 # * products derived from this software without specific prior written *
46 # * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
47 # * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
48 # * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
49 # * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, *
50 # * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
51 # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
52 # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
53 # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
54 # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING *
55 # * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
56 # * POSSIBILITY OF SUCH DAMAGE. *
58 # * OpenScop Library, a library to manipulate OpenScop formats and data *
59 # * structures. Written by: *
60 # * Cedric Bastoul <Cedric.Bastoul@u-psud.fr> and *
61 # * Louis-Noel Pouchet <Louis-Noel.pouchet@inria.fr> *
63 # ***************************************************************************/
65 EXTENSIONS_DIR
='./source/extensions'
66 EXTENSIONS_IN
='./source/extension.c.in'
67 EXTENSIONS_TMP
='./extension.tmp'
68 EXTENSIONS_OUT
='./source/extension.c'
70 # ***************************************************************************
73 TEMPLATE_SUBSTITUTION
[0]='@IDUMP1@'
75 case OPENSCOP_EXTENSION_TEMPLATE: {\
76 fprintf(file, "|\\ttype = OPENSCOP_EXTENSION_TEMPLATE\\n");\
80 # ***************************************************************************
83 TEMPLATE_SUBSTITUTION
[1]='@IDUMP2@'
85 case OPENSCOP_EXTENSION_TEMPLATE: {\
86 openscop_template_idump(\
88 (openscop_template_p)extension->extension,\
93 # ***************************************************************************
96 TEMPLATE_SUBSTITUTION
[2]='@SPRINT@'
98 case OPENSCOP_EXTENSION_TEMPLATE: {\
99 string = openscop_template_sprint(\
100 (openscop_template_p)extension->extension);\
104 # ***************************************************************************
107 TEMPLATE_SUBSTITUTION
[3]='@SREAD@'
109 x = (void *)openscop_template_sread(extension_string);\
110 openscop_extension_add(\&extension, OPENSCOP_EXTENSION_TEMPLATE, x);'
112 # ***************************************************************************
115 TEMPLATE_SUBSTITUTION
[4]='@FREE@'
117 case OPENSCOP_EXTENSION_TEMPLATE: {\
118 openscop_template_free(extension->extension);\
122 # ***************************************************************************
125 TEMPLATE_SUBSTITUTION
[5]='@COPY@'
127 case OPENSCOP_EXTENSION_TEMPLATE: {\
128 x = (void *)openscop_template_clone(extension->extension);\
132 # ***************************************************************************
135 TEMPLATE_SUBSTITUTION
[6]='@EQUAL@'
137 case OPENSCOP_EXTENSION_TEMPLATE: {\
138 equal = openscop_template_equal(x1->extension, x2->extension);\
142 # ***************************************************************************
144 # For each file in the extension directory.
145 for i
in ${EXTENSIONS_DIR}/*.c
;
147 # Get the extension name, lower case and upper case.
148 EXTENSION_LO
=`basename ${i%.c}`
149 EXTENSION_UP
=`echo ${EXTENSION_LO} | tr '[a-z]' '[A-Z]'`
151 # Replace the extension name in the templates.
152 for (( i
= 0 ; i
< ${#TEMPLATE[@]} ; i
++ ))
154 TEMP1
=`echo "${TEMPLATE[$i]}" | sed "s/TEMPLATE/${EXTENSION_UP}/g"`
155 TEMP2
=`echo "${TEMP1}" | sed "s/template/${EXTENSION_LO}/g"`
156 TEMPLATE_STRING
[$i]="${TEMPLATE_STRING[$i]}""${TEMP2}"
160 # Substitute the generated code parts in the source.
161 cp ${EXTENSIONS_IN} ${EXTENSIONS_TMP}
162 for (( i
= 0 ; i
< ${#TEMPLATE[@]} ; i
++ ))
164 sed "s/${TEMPLATE_SUBSTITUTION[$i]}/${TEMPLATE_STRING[$i]}/g" \
165 <${EXTENSIONS_TMP} >${EXTENSIONS_OUT}
166 mv ${EXTENSIONS_OUT} ${EXTENSIONS_TMP}
168 mv ${EXTENSIONS_TMP} ${EXTENSIONS_OUT}