aboutsummaryrefslogtreecommitdiff
path: root/src/makesource.sh
blob: 8b634bba0e8801ac3ac9665de51101c577ed6f9c (plain)
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
#!/bin/sh

IEMMATRIX_H=iemmatrix_sources.h
IEMMATRIX_C=iemmatrix_sources.c

EGREP=egrep
SED=sed
LS=ls

#################################
## functions

function head_h() {
 echo "/* iemmatrix-setup autogenerated header-file"
 echo " * generated by \"$0\""
 echo " * !! DO NOT MANUALLY EDIT  !!"
 echo " */"
 echo
 echo "#ifndef IEMMATRIX_SOURCES_H__"
 echo "#define IEMMATRIX_SOURCES_H__"
}

function foot_h() {
 echo "#endif /* IEMMATRIX_SOURCES_H__ */"
 echo ""
}

function head_c() {
 echo "/* iemmatrix-setup autogenerated setup-file"
 echo " * generated by \"$0\""
 echo " * !! DO NOT MANUALLY EDIT  !!"
 echo " */"
 echo 
 echo "#include \"$IEMMATRIX_H\""
 echo
 echo "void iemmatrix_sources_setup(void)"
 echo "{"
}

function foot_c() {
 echo "}"
 echo
}


##################################
## body

head_h > $IEMMATRIX_H
head_c > $IEMMATRIX_C

for i in $(${LS} *.c | ${EGREP} -v "iemmatrix.*\.c")
do
## each c-file in iemmatrix needs to have an ie<file>_setup()-function
## that calls all needed setup-functions
## any non-alpha-numeric-character is replaced by "_"
## e.g. "multiplex~.c" -> "z_multiplex__setup()"
  SETUPNAME=ie$(echo ${i%.c} | ${SED} -e 's/[^[:alnum:]]/_/g')_setup
  echo "void ${SETUPNAME}(void); /* $i */" >> $IEMMATRIX_H
  echo "	${SETUPNAME}(); /* $i */" >> $IEMMATRIX_C
done

foot_h >> $IEMMATRIX_H
foot_c >> $IEMMATRIX_C