Magellan Linux

Contents of /branches/magellan-next/include/mozilla.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2861 - (show annotations) (download)
Sun Jul 12 16:33:09 2009 UTC (15 years, 3 months ago) by niro
Original Path: trunk/core/include/mozilla.sminc
File size: 2833 byte(s)
-msetpref(): handle escaping proberly
1 # $Id$
2 # mozilla global smage2 functions
3
4 mozconf_add()
5 {
6 echo "ac_add_options $@" >> .mozconfig || die
7 }
8
9 rebuild_extension_list()
10 {
11 # do not use die here, if no extension are selected this will break
12
13 # resolve multiple --enable-extensions down to one
14 declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
15 ${SRCDIR}/.mozconfig | xargs)
16 sed -i '/^ac_add_options --enable-extensions/d' ${SRCDIR}/.mozconfig
17 echo "ac_add_options --enable-extensions=${exts// /,}" >> ${SRCDIR}/.mozconfig
18 }
19
20 mozilla_remove_cflags()
21 {
22 # this removes extraneous CFLAGS from the Makefiles to reduce RAM
23 # requirements while compiling (gentoo)
24 export CFLAGS="${CFLAGS} -Wno-return-type -w"
25 export CXXFLAGS="${CXXFLAGS} -Wno-return-type -w"
26
27 echo "Parsing Makefiles ..."
28 find . -iname makefile | while read MAKEFILE
29 do
30 cp ${MAKEFILE} ${MAKEFILE}.old
31 # We already add "-Wno-return-type -w" to compiler flags, so
32 # no need to replace "-Wall" and "-Wreturn-type" with them.
33 sed -e 's:-Wall::g' \
34 -e 's:-Wreturn-type::g' \
35 -e 's:-pedantic::g' ${MAKEFILE}.old > ${MAKEFILE}
36 rm -f ${MAKEFILE}.old
37 done
38 # mozilla use .mk includes
39 find . -name '*.mk' | while read MAKEFILE
40 do
41 cp ${MAKEFILE} ${MAKEFILE}.old
42 sed -e 's:-Wall::g' \
43 -e 's:-Wreturn-type::g' \
44 -e 's:-pedantic::g' ${MAKEFILE}.old > ${MAKEFILE}
45 rm -f ${MAKEFILE}.old
46 done
47 }
48
49 # simulate the csh makemake script (gentoo)
50 makemake()
51 {
52 typeset m topdir
53 for m in $(find . -name Makefile.in); do
54 topdir=$(echo "$m" | sed -r 's:[^/]+:..:g')
55 sed -e "s:@srcdir@:.:g" -e "s:@top_srcdir@:${topdir}:g" \
56 < ${m} > ${m%.in} || die "sed ${m} failed"
57 done
58 }
59
60 makemake2()
61 {
62 typeset m topdir
63 for m in $(find ../ -name Makefile.in); do
64 topdir=$(echo "$m" | sed -r 's:[^/]+:..:g')
65 sed -e "s:@srcdir@:.:g" -e "s:@top_srcdir@:${topdir}:g" \
66 < ${m} > ${m%.in} || die "sed ${m} failed"
67 done
68 }
69
70 msetpref()
71 {
72 : ${MOZILLA_PREF_CONFIG="magellan.js"}
73 : ${MOZILLA_PREF_PATH="/usr/$(mlibdir)/mozilla-firefox/defaults/pref"}
74 local pref
75 local value
76
77 [[ -z ${pref} ]] && die "msetpref(): no \$pref given"
78
79 if [[ ${pref} = --init ]]
80 then
81 # only create an empty config
82 :> ${BINDIR}/${MOZILLA_PREF_PATH}/${MOZILLA_PREF_CONFIG} || die
83 else
84 # write a pref value
85 [[ -z ${value} ]] && die "msetpref(): no \$value given"
86
87 # handle escaped strings:
88 # check if value is an integer -> no escaping
89 if printf "%d" ${value} > /dev/null 2>&1
90 then
91 value="${value}"
92
93 # check for "false" or "true" -> no escaping
94 elif [[ ${value} = false ]] || [[ ${value} = true ]]
95 value="${value}"
96
97 # all other values needs escaping
98 else
99 value="\"${value}\""
100 fi
101
102 # eg:
103 # pref("general.useragent.vendor","Magellan-Linux");
104 echo "pref(\"${pref}\",${value});" >> ${BINDIR}/${MOZILLA_PREF_PATH}/${MOZILLA_PREF_CONFIG} || die
105 fi
106 }