draw.h: Remove ClearPin prototype missed in last commit
[geda-pcb/gde.git] / lib / CreateLibraryContents.sh.in
blobccba4a3ef78b52cec779923ac57f6a2b048b62c6
1 #!/bin/sh
3 # COPYRIGHT
4 #
5 # PCB, interactive printed circuit board design
6 # Copyright (C) 1994,1995,1996 Thomas Nau
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 # Contact addresses for paper mail and Email:
23 # Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
24 # Thomas.Nau@rz.uni-ulm.de
26 # RCS: $Id$
28 # create all objects as defined in passed list_files
30 # usage: CreateLibraryContents.sh common_macro_file file...
32 M4=@GNUM4@
35 # Check for input flags
38 while test -n "$1" ; do
39 case "$1"
41 -I|--include)
42 m4_flags="$m4_flags -I $2"
43 srcdir=$2
44 shift 2
47 -*)
48 echo "error: unknown flag $1 to $0"
49 exit 1
53 break
55 esac
56 done
58 # a TAB plus one blank for some stupid old sed implementations
60 SPACE="[ ]"
63 # Make sure we've been given a common file plus at least 1 list file
64 # as arguments
67 if [ $# -lt 2 ]; then
68 echo "usage: $0 common_macro_file file..." >&2; exit 1
70 CommonFile=$1
71 shift
74 # Make sure the common file exists
77 if [ ! -r $CommonFile ]; then
78 echo "$0: file '$CommonFile' isn't readable or doesn't exit" >&2; exit 1
82 # Process the list files
85 while [ $# -ne 0 ]; do
86 # strip the extension '.list'
90 # Turn something like foo.list in to
91 # /path/to/foo.m4
93 if [ -f $srcdir/$1 ]; then
94 ListFile="$srcdir/$1"
95 else
96 ListFile="$1"
98 PlainFile=`dirname $ListFile`/`basename $ListFile .list`
99 M4File=$PlainFile.m4
101 if [ ! -r $ListFile ]; then
102 echo "$0: file '$ListFile' isn't readable or doesn't exit" >&2; exit 1
104 if [ ! -r $M4File ]; then
105 echo "$0: file '$M4File' isn't readable or doesn't exit" >&2; exit 1
109 # for foo.list spit out "TYPE=~foo". This defines the library
110 # in the PCB library window
112 echo "TYPE=~`basename $PlainFile | sed -e 's/_/ /g'`"
114 sed -e 's/'"$SPACE"'*#.*$//' \
115 -e 's/'"$SPACE"'*:'"$SPACE"'*/:/g' \
116 -e '/^'"$SPACE"'*$/d' $ListFile |
118 IFS=:
119 export IFS
120 while read mask package values; do
121 set -- $values
122 while [ $# -ne 0 ]; do
123 echo "\`$mask:$package:$1:'Description_$mask\` [$package'ifdef(\`Param1_$mask', \` Param1_$mask')\`'ifdef(\`Param2_$mask', \` Param2_$mask')]"
124 shift
125 done
126 done
127 } | $M4 $m4_flags $CommonFile $M4File - | sed -e '/^'"$SPACE"'*$/d'
128 shift
129 done