~ubuntu-branches/debian/sid/link-monitor-applet/sid

« back to all changes in this revision

Viewing changes to jbsrc/jb.c

  • Committer: Bazaar Package Importer
  • Author(s): Adriaan Peeters
  • Date: 2008-03-30 22:26:13 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080330222613-5aubcuo9mgg2n7st
Tags: upstream-3.0
ImportĀ upstreamĀ versionĀ 3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Link Monitor Applet
 
3
 * Copyright (C) 2004-2008 Jean-Yves Lefort <jylefort@brutele.be>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 3 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
17
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
18
 */
 
19
 
 
20
#include <string.h>
 
21
#include "jb.h"
 
22
 
 
23
#jb_include "lm-gdk-pixbuf-loader"
 
24
#jb_include "lm-geoip"
 
25
#jb_include "lm-glibc"
 
26
 
 
27
#define LM_WARNING_CFLAGS \
 
28
  "-Wall "                              \
 
29
  "-Wformat-y2k "                       \
 
30
  "-Wformat-security "                  \
 
31
  "-Wno-unused-parameter "              \
 
32
  "-Wdeclaration-after-statement "      \
 
33
  "-Wendif-labels "                     \
 
34
  "-Wpointer-arith "                    \
 
35
  "-Wcast-align "                       \
 
36
  "-Waggregate-return "                 \
 
37
  "-Wmissing-noreturn "                 \
 
38
  "-Wmissing-format-attribute "         \
 
39
  "-Wpacked "                           \
 
40
  "-Wredundant-decls "                  \
 
41
  "-Wnested-externs "                   \
 
42
  "-Winline "                           \
 
43
  "-Wno-pointer-sign "                  \
 
44
  "-Wshadow "
 
45
 
 
46
static const JBFeature *jb_features[] = {
 
47
  &jb_pkg_config_feature,
 
48
  &jb_gettext_feature,
 
49
  &jb_intltool_feature,
 
50
  &jb_gconf_feature,
 
51
  &jb_gnome_help_feature,
 
52
  &jb_gob2_feature
 
53
};
 
54
 
 
55
void
 
56
jb_package_init (void)
 
57
{
 
58
  JBVariableGroup *lm_features_group;
 
59
 
 
60
  /* by default, use the GNOME prefix */
 
61
  jb_set_prefix_from_program("gnome-open");
 
62
 
 
63
  /*
 
64
   * At the time of this writing, gob2 2.0.16 is not yet
 
65
   * released. What is required is gob2 2.0.15 + my patches (see the
 
66
   * gob mailing list), which should eventually become gob2 2.0.16.
 
67
   */
 
68
  jb_variable_set_string("gob2-minversion", "2.0.16");
 
69
 
 
70
  lm_features_group = jb_variable_add_group("Link Monitor Applet features");
 
71
 
 
72
  jb_variable_add_bool("ipv6",
 
73
                       "enable IPv6 support",
 
74
                       lm_features_group,
 
75
                       JB_VARIABLE_C_DEFINE,
 
76
                       TRUE);
 
77
  jb_variable_add_bool("geoip",
 
78
                       "enable GeoIP support",
 
79
                       lm_features_group,
 
80
                       JB_VARIABLE_C_DEFINE,
 
81
                       TRUE);
 
82
 
 
83
  jb_variable_add_bool("compile-warnings", NULL, NULL, 0, FALSE);
 
84
  jb_variable_add_bool("debug", NULL, NULL, 0, TRUE);
 
85
  jb_variable_add_bool("suid-root", NULL, NULL, 0, TRUE);
 
86
}
 
87
 
 
88
static void
 
89
report_invalid_prefix (void)
 
90
{
 
91
  const char *gnome_prefix;
 
92
 
 
93
  jb_check_gnome_prefix();
 
94
 
 
95
  gnome_prefix = jb_variable_get_string("gnome-prefix");
 
96
  if (*gnome_prefix == '\0')
 
97
    jb_warning_expand("$human-package must be installed in the same prefix as GNOME, but the GNOME prefix could not be found. $human-package might be inoperable.", NULL);
 
98
  else
 
99
    {
 
100
      char *prefix;
 
101
 
 
102
      prefix = jb_variable_expand("$prefix", NULL);
 
103
      if (strcmp(prefix, gnome_prefix))
 
104
        jb_warning_expand("the $human-package prefix ($prefix) is different from the GNOME prefix ($gnome-prefix). $human-package will be inoperable. Unless you know what you are doing, please run \"./jb configure prefix=$gnome-prefix\".", NULL);
 
105
      g_free(prefix);
 
106
    }
 
107
}
 
108
 
 
109
void
 
110
jb_package_configure (void)
 
111
{
 
112
  if (lm_glibc_check())
 
113
    {
 
114
      /*
 
115
       * We need -std=c99 for lround(), ...
 
116
       * We need _BSD_SOURCE (which requires -lbsd-compat) for struct icmp, ...
 
117
       * We need _POSIX_C_SOURCE for struct addrinfo, clock_gettime(), ...
 
118
       */
 
119
      jb_variable_set_string("glibc-cflags", "-std=c99 -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L");
 
120
      jb_variable_set_string("glibc-cppflags", "");
 
121
      jb_variable_set_string("glibc-ldflags", "-lbsd-compat");
 
122
    }
 
123
  else
 
124
    {
 
125
      jb_variable_set_string("glibc-cflags", "");
 
126
      jb_variable_set_string("glibc-cppflags", "");
 
127
      jb_variable_set_string("glibc-ldflags", "");
 
128
    }
 
129
 
 
130
  if (jb_check_functions("clock_gettime", "rt"))
 
131
    jb_variable_set_string("clock-gettime-ldflags", "-lrt");
 
132
  else if (jb_check_functions("clock_gettime", NULL))
 
133
    jb_variable_set_string("clock-gettime-ldflags", "");
 
134
  else
 
135
    jb_error("clock_gettime() found neither in librt nor in libc");
 
136
 
 
137
  jb_check_reentrant_dns_resolver();
 
138
 
 
139
  jb_require_packages("GNOME", "gnome", "gthread-2.0 gtk+-2.0 >= 2.12 libgnomeui-2.0 libpanelapplet-2.0 libglade-2.0");
 
140
 
 
141
  if (jb_variable_get_bool("geoip"))
 
142
    {
 
143
      if (lm_geoip_check())
 
144
        {
 
145
          if (! lm_gdk_pixbuf_loader_check("art/flags/fr.svg", "image/svg+xml"))
 
146
            jb_warning("GTK+ cannot load image/svg+xml images, country flags will not be displayed");
 
147
        }
 
148
      else
 
149
        {
 
150
          jb_warning("disabling option \"geoip\" since GeoIP was not found");
 
151
          jb_variable_set_bool("geoip", FALSE);
 
152
        }
 
153
    }
 
154
 
 
155
  report_invalid_prefix();
 
156
}
 
157
 
 
158
void
 
159
jb_package_add_resources (void)
 
160
{
 
161
  JBGroup *group;
 
162
  JBObject *object;
 
163
 
 
164
  if (jb_variable_get_bool("compile-warnings"))
 
165
    jb_compile_options_add_cflags(&jb_compile_options, LM_WARNING_CFLAGS " -Werror");
 
166
 
 
167
  if (! jb_variable_get_bool("debug"))
 
168
    jb_compile_options_add_cflags(&jb_compile_options, "-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS");
 
169
 
 
170
  jb_compile_options_add_gob2flags(&jb_compile_options, "--exit-on-warn");
 
171
 
 
172
  /*** art *******************************************************************/
 
173
 
 
174
  group = jb_group_new("art");
 
175
 
 
176
  jb_group_add_data_file(group, "link-monitor-applet.png", "$datadir/pixmaps");
 
177
 
 
178
  if (jb_variable_get_bool("geoip"))
 
179
    jb_group_add_data_files_pattern(group, "flags/*.svg", "$pkgdatadir/flags");
 
180
 
 
181
  jb_group_add(group);
 
182
 
 
183
  /*** data ******************************************************************/
 
184
 
 
185
  group = jb_group_new("data");
 
186
 
 
187
  jb_group_add_resource(group, JB_GROUP_RESOURCE(jb_template_new("GNOME_LinkMonitorApplet.server.in.in")));
 
188
  jb_group_add_bonobo_server(group, "GNOME_LinkMonitorApplet.server.in");
 
189
 
 
190
  jb_group_add_gconf_schemas(group, "link-monitor-applet.schemas.in");
 
191
 
 
192
  jb_group_add(group);
 
193
 
 
194
  /*** help ******************************************************************/
 
195
 
 
196
  group = jb_group_new("help");
 
197
 
 
198
  jb_group_add_resource(group, JB_GROUP_RESOURCE(jb_gnome_help_new("C", "documentation-license.xml software-license.xml")));
 
199
 
 
200
  jb_group_add(group);
 
201
 
 
202
  /*** jbsrc *****************************************************************/
 
203
 
 
204
  group = jb_group_new("jbsrc");
 
205
 
 
206
  jb_group_add_dist_files(group,
 
207
                          "lm-gdk-pixbuf-loader-test.c",
 
208
                          "lm-glibc-test.c",
 
209
                          NULL);
 
210
 
 
211
  jb_group_add(group);
 
212
 
 
213
  /*** po ********************************************************************/
 
214
 
 
215
  group = jb_group_new("po");
 
216
 
 
217
  jb_group_add_translations(group, "bg fr it");
 
218
 
 
219
  jb_group_add(group);
 
220
 
 
221
  /*** src *******************************************************************/
 
222
 
 
223
  group = jb_group_new("src");
 
224
 
 
225
  object = JB_OBJECT(jb_program_new("link-monitor-applet"));
 
226
 
 
227
  jb_install_options_set_installdir(&object->install_options, "$libexecdir");
 
228
 
 
229
  if (jb_variable_get_bool("suid-root"))
 
230
    {
 
231
      jb_install_options_set_owner(&object->install_options, "root");
 
232
      jb_install_options_set_extra_mode(&object->install_options, S_ISUID);
 
233
    }
 
234
 
 
235
  jb_compile_options_add_string_defines(&object->compile_options,
 
236
                                        "PACKAGE", "$package", 
 
237
                                        "VERSION", "$version",
 
238
                                        "GETTEXT_PACKAGE", "$package",
 
239
                                        "PREFIX", "$prefix",
 
240
                                        "SYSCONFDIR", "$sysconfdir",
 
241
                                        "DATADIR", "$datadir",
 
242
                                        "PKGDATADIR", "$pkgdatadir",
 
243
                                        "LIBDIR", "$libdir",
 
244
                                        "GNOMELOCALEDIR", "$datadir/locale",
 
245
                                        "GNOMEPIXMAPSDIR", "$datadir/pixmaps",
 
246
                                        NULL);
 
247
 
 
248
  /*
 
249
   * We need --export-dynamic because because libglade needs to
 
250
   * resolve symbols from our own binary in order to autoconnect
 
251
   * signal handlers.
 
252
   */
 
253
  jb_compile_options_add_ldflags(&object->compile_options, "-Wl,--export-dynamic");
 
254
    
 
255
  jb_compile_options_add_ldflags(&object->compile_options, "-lm");
 
256
 
 
257
  jb_compile_options_add_package(&object->compile_options, "glibc");
 
258
  jb_compile_options_add_ldflags(&object->compile_options, "$clock-gettime-ldflags");
 
259
  jb_compile_options_add_package(&object->compile_options, "gettext");
 
260
  jb_compile_options_add_package(&object->compile_options, "gnome");
 
261
 
 
262
  if (jb_variable_get_bool("geoip"))
 
263
    jb_compile_options_add_package(&object->compile_options, "geoip");
 
264
 
 
265
  jb_object_add_sources(object,
 
266
                        "LM:About:Dialog",
 
267
                        "LM:Applet",
 
268
                        "LM:Bar:Graph",
 
269
                        "LM:Cell:Renderer:Color",
 
270
                        "LM:Data:Set",
 
271
                        "LM:Dialog",
 
272
                        "LM:Framed:Image",
 
273
                        "LM:Host",
 
274
                        "LM:Host:Frontend",
 
275
                        "LM:Host:View",
 
276
                        "LM:Line:Graph",
 
277
                        "LM:Line:Graph:Icon",
 
278
                        "LM:Preferences:Dialog",
 
279
                        "LM:Shell",
 
280
                        "LM:Tooltips",
 
281
                        "lm-color-generator",
 
282
                        "lm-decls.h",
 
283
                        "lm-icmp",
 
284
                        "lm-main.c",
 
285
                        "lm-non-linear-range",
 
286
                        "lm-util",
 
287
                        NULL);
 
288
 
 
289
  jb_group_add_resource(group, JB_GROUP_RESOURCE(object));
 
290
 
 
291
  jb_group_add(group);
 
292
 
 
293
  /*** ui ********************************************************************/
 
294
 
 
295
  group = jb_group_new("ui");
 
296
 
 
297
  jb_group_add_data_files(group,
 
298
                          "preferences-dialog.glade", "$pkgdatadir",
 
299
                          "GNOME_LinkMonitorApplet.xml", "$datadir/gnome-2.0/ui",
 
300
                          NULL);
 
301
 
 
302
  jb_group_add(group);
 
303
}
 
304
 
 
305
JB_MAIN("link-monitor-applet", "3.0", "Link Monitor Applet")