blob: 607eef81d0dce0fdecb25359314a4a13382b19cd [file] [log] [blame]
Brian Waters13d96012017-12-08 16:53:31 -06001#Copyright (c) 2017 Sprint
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#!/bin/sh
16
17usage ()
18{
19 echo "Used to configure cmake files to turn on/off building a specific dictionary "
20 echo "Usage: $0 <dictionary name> <ON|OFF> <make file>"
21}
22
23if [ "$#" -ne 3 ]; then
24 usage
25 exit 0
26fi
27
28if [ "$2" != "ON" ] && [ "$2" != "OFF" ]; then
29 usage
30 exit
31fi
32
33DCTDIR=$1
34STATE=$2
35CFGFILE=$3
36
37if [ -e $3 ]; then
38 if [ -d "${DCTDIR}" ]; then
39 INDIR=`grep -c FD_EXTENSION_SUBDIR\(${DCTDIR} $3`
40 if [ "$INDIR" -eq 0 ]; then
41 echo "Adding ${DCTDIR} to file"
42 echo "FD_EXTENSION_SUBDIR(${DCTDIR} \"${DCTDIR} extension library\" $2)" >> ${CFGFILE}
43 elif [ "${STATE}" = "ON" ]; then
44 echo "Turning On"
45 sed -i.bak -e "s/FD_EXTENSION_SUBDIR(${DCTDIR}\\(.*\\)\"\\(.*\\)\"\\(.*\\)*OFF)/FD_EXTENSION_SUBDIR(${DCTDIR}\\1\"\\2\"\\3ON)/" ${CFGFILE}
46 else
47 echo "Turning Off"
48 sed -i.bak -e "s/FD_EXTENSION_SUBDIR(${DCTDIR}\\(.*\\)\"\\(.*\\)\"\\(.*\\)*ON)/FD_EXTENSION_SUBDIR(${DCTDIR}\\1\"\\2\"\\3OFF)/" ${CFGFILE}
49 fi
50 else
51 echo "Directory ${DCTDIR} doesn't exist\n"
52 fi
53else
54 echo "File $3 doesn't exist. Please provide valid make file\n"
55fi