Magellan Linux

Annotation of /trunk/include/mozilla.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33316 - (hide annotations) (download)
Wed Sep 16 10:26:25 2020 UTC (3 years, 7 months ago) by niro
File size: 3262 byte(s)
-respect NULL values
1 niro 1933 # $Id$
2 niro 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 niro 1933 # this removes extraneous CFLAGS from the Makefiles to reduce RAM
23 niro 2 # 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 niro 1933 # mozilla use .mk includes
39 niro 2 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 niro 1933 makemake()
51     {
52 niro 2 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 niro 1933 makemake2()
61     {
62 niro 2 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 niro 2860
70     msetpref()
71     {
72 niro 2867 : ${MOZILLA_PREF_CONFIG="01-magellan.js"}
73 niro 20077 case ${PNAME} in
74 niro 20234 *firefox*) : ${MOZILLA_PREF_PATH="/usr/$(mlibdir)/${PNAME}/browser/defaults/preferences"} ;;
75     *thunderbird*) : ${MOZILLA_PREF_PATH="/usr/$(mlibdir)/${PNAME}/defaults/preferences"} ;;
76 niro 20077 esac
77 niro 2866 local pref="$1"
78     local value="$2"
79 niro 2860
80     [[ -z ${pref} ]] && die "msetpref(): no \$pref given"
81    
82     if [[ ${pref} = --init ]]
83     then
84     # only create an empty config
85 niro 15843 if [[ ! -d ${BINDIR}/${MOZILLA_PREF_PATH} ]]
86     then
87     install -d ${BINDIR}/${MOZILLA_PREF_PATH} || die
88     fi
89 niro 2860 :> ${BINDIR}/${MOZILLA_PREF_PATH}/${MOZILLA_PREF_CONFIG} || die
90     else
91     # write a pref value
92     [[ -z ${value} ]] && die "msetpref(): no \$value given"
93 niro 33316 # respect NULL values
94     [[ ${value} = NULL ]] && value=""
95 niro 2861
96     # handle escaped strings:
97 niro 2862
98 niro 2861 # check if value is an integer -> no escaping
99 niro 2862 #if printf "%d" ${value} > /dev/null 2>&1
100     # the better way (only use one! bracket!!)
101     if [ "${value}" -eq "${value}" ] > /dev/null 2>&1
102 niro 2861 then
103     value="${value}"
104    
105     # check for "false" or "true" -> no escaping
106     elif [[ ${value} = false ]] || [[ ${value} = true ]]
107 niro 2863 then
108 niro 2861 value="${value}"
109    
110     # all other values needs escaping
111     else
112     value="\"${value}\""
113     fi
114 niro 2860
115     # eg:
116     # pref("general.useragent.vendor","Magellan-Linux");
117 niro 2870 echo "pref(\"${pref}\", ${value});" >> ${BINDIR}/${MOZILLA_PREF_PATH}/${MOZILLA_PREF_CONFIG} || die
118 niro 2860 fi
119     }