Commit graph

50 commits

Author SHA1 Message Date
Thomas Haller 923c52ffbb build: test for support of -flto compiler flag
... and prepend the $ld_gc_flags instead of appending to the $CFLAGS.
2017-02-10 12:53:32 +01:00
Thomas Haller a981c6c355 build: add m4 macros for --enable-lto and --enable-ld-gc 2017-02-10 12:11:21 +01:00
Thomas Haller 4a72c121ed build: reorder flags in "m4/compiler_options.m4"
Mostly sort alphabetically, but
  - keep -Wextra first
  - move "-Wno-*" flags to the end
2017-02-06 19:27:21 +01:00
Thomas Haller 5120205f98 build: enable -Wextra warning 2017-02-06 19:27:21 +01:00
Thomas Haller 705e63a292 build: disable -Wformat-truncation warning
The warning seems questionable and overly strict.
For now, just disable it to allow building with gcc7.

    src/systemd/src/basic/time-util.c: In function ‘format_timespan’:
    src/systemd/src/basic/time-util.c:509:46: error: ‘%0*lu’ directive output between 1 and 2147483648 bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-truncation=]
                                                  "%s"USEC_FMT".%0*"PRI_USEC"%s",
                                                  ^~~~
    src/systemd/src/basic/time-util.c:509:60: note: format string is defined here
                                                  "%s"USEC_FMT".%0*"PRI_USEC"%s",
    src/systemd/src/basic/time-util.c:509:46: note: directive argument in the range [0, 18446744073709551614]
                                                  "%s"USEC_FMT".%0*"PRI_USEC"%s",
                                                  ^~~~

https://mail.gnome.org/archives/networkmanager-list/2017-February/msg00001.html
2017-02-06 16:53:37 +01:00
Thomas Haller 4b9cebd8ad build: enable -Wimplicit-fallthrough warning from gcc7 2017-02-06 16:45:20 +01:00
Thomas Haller 6bd9f5361f m4/compiler_options.m4: add line breaks for compiler options to check
No change in behavior.
2017-02-06 14:24:28 +01:00
Lubomir Rintel fd47a9a762 build: move the --enable-more-warning option from m4/ to configure.ac
It will make it easier to policy the default.

(cherry picked from commit 8647be3717)
2017-01-19 16:15:30 +01:00
Thomas Haller ba2b2de3ad build: allow using GCC C99 dialect instead of C89
We already use several GCC extenions, like typeof() and
__attribute__((cleanup)). They are too convinient to miss
and every supported compiler must support these.
Currently, gcc and clang does. Maybe other compilers would
support that too, but who knows, nobody seems to test that.

We also already use stdbool.h (C99) and the imported systemd
code is mostly gnu99 too (it's not clear to me, because I don't
find it precisely documented. Certainly it makes use of C99 features
too).

C99/gnu99 has some nice improvements that we no longer should miss
out. For example "flexible array members" or "variable declaration
in init-part of for loop".

It doesn't mean we have to use every obscure (badly supported?)
feature, it means we don't have to forgo features that are well
supported. C99 is 17 years old, I mean, really...

If somebody comes along and ports NM to non-gcc/clang, we can address
bugs about unsupported language features as they surface.
But let's not restrict us to some hypothetical compiler (or language
specification).

Also, NetworkManager is not ported on environment beside Linux.
We don't have to be so considerate about the required build environment.
Gcc is probably the most portable compiler out there. I doubt porting
NetworkManager to *BSD fails due to missing gnu99 features. And if that
causes issues, we should fix them after they happen in practice.
2016-11-10 09:34:39 +01:00
Thomas Haller b33aacbc91 build: move detection of NM_GIT_SHA to separate "m4/git-sha-record.m4"
We want to embed the current commit-id in the ./configure script.
That way the generated ./configure file in the source tarball
references the commit-id from which the tarball was created.

Then, in a second step, a script can check ./configure to find
the parent commit. This is for example done by the 'makerepo.sh'
script.

This is generally useful, and also done by network-manager-applet
and libnl3 projects. Move the function to a separate m4 macro
to reuse it. It should also be re-used in NetworkManager's VPN plugins.
2016-09-14 14:11:07 +02:00
Thomas Haller b8b68e212d build: disable warning "-Wformat-y2k"
https://bugzilla.gnome.org/show_bug.cgi?id=767207
2016-06-06 14:07:23 +02:00
Beniamino Galvani b5daaf43bc build: configure.ac: always set -fno-strict-aliasing
We break the aliasing rules in the code, and thus the flag should
always be enabled to prevent wrong optimizations, even without
--enable-more-warnings.
2016-06-03 22:19:37 +02:00
Beniamino Galvani 54b873a475 build: import attributes.m4 from systemd
It contains useful macros for determining compiler support for
flags/attributes. We already similar macros in compiler_options.m4,
but the plan is to replace them.
2016-06-03 22:19:37 +02:00
Dan Williams 6725962f83 build: add -Wformat-nonliteral to --enable-more-warnings flags
New with gcc 6.0.
2016-06-03 11:05:05 -05:00
Lubomir Rintel 6d91c14b00 build: add macro to check the compiler flag support
Also, fold duplicate chunks together.
2016-05-18 20:53:51 +02:00
Lubomir Rintel 3b0dd0a55c trivial: rename compiler_warnings.m4 to compiler_options.m4
We'll use that for more compiler feature-checking macros.
2016-05-18 20:53:05 +02:00
Lubomir Rintel 85c92ff372 build: use the glib cflags when checking the compiler flags
Some of the checks include glib headers.
2016-05-18 20:52:36 +02:00
Thomas Haller f7941ceba3 build: compile with -Wno-duplicate-decl-specifier
Duplicated const specifiers are allowed by C99 and can easily
happen in macros. Also, systemd's interal code will use them.

Disable this warning, it doesn't seem useful.
2016-03-09 11:45:03 +01:00
Thomas Haller 7e091a230a m4: update introspection.m4 with original file from gobject-introspection
Originally m4/introspection.m4 was copied from gobject-introspection
repository. We however modified it in commit f6272144e9.

Reimport the file with latest changes, but still preserving our
workaround.
2016-03-04 09:25:23 +01:00
Thomas Haller f6272144e9 build: hack around compiler warning in g-ir-scanner
The autoconf macro for GIR passes $CFLAGS to g-ir-scanner.
g-ir-scanner extends those flags with the system-default which
includes -D_FORTIFY_SOURCE=2. Probably it should not do that,
but if you disable optimization, this results in a compler warning
in "/usr/include/features.h" [1]

    export CFLAGS='-O0'
    # Happens both with clang or gcc.
    #export CC=clang
    git clean -fdx
    ./autogen.sh
    make

Work around that by injecting -Wno-error to $CFLAGS when invoking
g-ir-scanner.

[1] Related: https://sourceware.org/bugzilla/show_bug.cgi?id=13979
2015-11-10 18:12:12 +01:00
Lubomir Rintel b38bc15747 build: set -Werror when checking whether a -W<warning> option works
Otherwise the check is effectively a no-op and unknown options still get
turned on. This results in unknown warnings when build without
--with-extra-warnings=error:

  warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]
2015-09-29 14:08:14 +02:00
Lubomir Rintel 84021454eb build: don't default to -Werror
It seems like a poor default for various downstream toolchains. We can't
anticipate the compiler warnings for future compiler versions and older
ones are prone to false positives. Also, older gdbus-codegen is known
to generate code that triggers compiler warnings.

Let's keep it enabled for maintainer builds and distcheck so that we're
sure a tool chain that builds releases without warnings exists.
2015-06-02 12:30:03 +02:00
Dan Williams 21fef6a357 build: correct help message about missing readline + termcap libraries 2015-05-11 10:33:21 -05:00
Lubomir Rintel 5206a9b28d build: fix clang + glib 2.43 build
Known glib issue. Fixes Fedora 22 build.
2015-03-19 16:29:33 +01:00
Lubomir Rintel f0740aff88 build: disable warnings that trigger known clang problems
Fixes build with clang 3.5 on Fedora 21.
2015-03-19 11:48:49 +01:00
Lubomir Rintel 3ccc6f290d build: disable warnings where macros expand to tautological comparisons 2015-03-19 11:48:49 +01:00
Thomas Haller 0462104317 build: fix detecting support for -Wno-* compiler flags
Since GCC 4.4, gcc does not warn about unknown -Wno-* flags. At
least, it does not warning unless another warning is raised as well
(https://gcc.gnu.org/wiki/FAQ#wnowarning).

We didn't notice up to now, because we only tested flags that GCC
actually supports.

Hack around this, by checking for the -W* counterpart instead.
2015-02-24 18:43:44 +01:00
Thomas Haller 94274c6fcd build: fix wrongly linking against libreadline in all applications
Every Makefile in the subtrees would include -lreadline
as part of LIBS, hence every application would link against
the library.

This was broken since we added 'm4/ax_lib_readline.m4'.

Fixes: 29297f8531
2014-11-26 11:43:23 +01:00
Dan Williams d2dd3b2c90 dhcp: add systemd-based "internal" DHCP client
We must also remove -Waggregate-return from m4/compiler-warnings.m4 because systemd
uses aggregate return (correctly) in a couple cases, and we cannot keep single-level
makefiles and override aggregate-return only for the systemd sub-library.

This client currently only supports DHCPv4 because the base systemd code
does not yet fully support DHCPv6.
2014-11-06 22:42:43 -06:00
Thomas Haller f1a0b4afd2 build: renable -Wstrict-prototypes compiler warning
The warning -Wstrict-prototypes was disabled by commit
db9b1df0e4 .

Enable it again, but avoid warnings for WiMax SDK by explicitly disabling the
compiler warning where needed.

Apparently clang does not produce a warning for -Wstrict-prototypes,
hence we don't need a clang specific #pragma.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-29 14:09:52 +01:00
Thomas Haller dd243ceefe build: refactor compiler_warnings.m4 macro
NM_COMPILER_WARNINGS still works the same, but
rename variables to have a CFLAGS_* prefix.

Also cleanup the construction of CFLAGS by appending
to CFLAGS_MORE_WARNINGS variable instead of appending
to CFLAGS, and resetting to SAVE_CFLAGS.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-29 12:40:03 +01:00
Dan Williams b69143b508 build: ensure rl_echo_signal_char() exists in the readline library 2014-10-14 14:30:44 -05:00
Thomas Haller 5009f2c7a3 build/clang: fix detection of valid warning compiler flags
clang does not exit with error when it is called with an
unrecognized (warning) option. Instead it just prints
a warning that makes the configure script believe the
warning is supported. Later, during build we might pass
-Werror, which causes clang to fail due to unrecognized
arguments.

Fix the script to detect compiler warnings by passing
'-Werror=unknown-warning-option', which lets clang fail too.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:16:33 +02:00
Dan Williams 29297f8531 build: check harder for readline
Not all distros build their readline linked with a termcap library,
since apps are (apparently) supposed to choose one for themselves
and explicitly link to it when using readline.  So add some checks
to figure out whether readline is already linked, and if not, prefer
ncurses since we use that for nmtui already.

ax_lib_readline based off:

http://www.gnu.org/software/autoconf-archive/ax_lib_readline.html
2014-06-27 13:10:50 -05:00
Dan Winship ece92fe67a build: add -Wformat-security to the default warning flags 2014-04-02 09:24:56 -04:00
Dan Winship 9008730f89 build: update gnome-code-coverage.m4
Update gnome-code-coverage.m4 from gnome-common to fix some (harmless)
error messages when coverage is disabled (bug 699943), and to add
support for lcov 1.10.
2013-05-09 09:19:08 -04:00
Pavel Šimerda a3d6a825df coverage: delete *.gcno on make clean 2013-04-24 14:50:04 +02:00
Pavel Šimerda 663859c180 build: drop libnl 1.x and 2.x support, require libnl >= 3.2.7 2013-01-24 19:47:53 +01:00
Pavel Šimerda 998f4ccc88 build: add code coverage support
Use the following in Makefile.am to enable code coverage for individual modules:

@GNOME_CODE_COVERAGE_RULES@
my_program_LIBS = … $(CODE_COVERAGE_LDFLAGS) …
my_program_CFLAGS = … $(CODE_COVERAGE_CFLAGS) …
2013-01-08 13:30:56 +01:00
Dan Williams bb363997ed build: add some more build-time warnings 2012-07-30 10:58:47 -05:00
Alberto Ruiz b1e1ee79bd vala: add vala bindings for libnm-util and libnm-glib
This patch adds the autotools facilities to generate vapi files so that
libnm-util and libnm-glib can be consumed from Vala.

It depends on vapigen and it is a soft dependency.
2012-06-12 16:31:20 -05:00
Colin Walters e4f51d1968 build: allow --set-more-warnings=no|yes|error
For the GNOME autobuilders, we want compiler warnings, but don't want
-Werror.  For developer compatibility, the default value is "error".

https://bugzilla.gnome.org/show_bug.cgi?id=668974
2012-02-09 16:54:04 -06:00
Krzesimir Nowak c2fffd76d2 build: put test source code into AC_LANG_PROGRAM (bgo #655225)
This change silences autotools warnings about source code not
being inside AC_LANG_SOURCE in AC_LANG_CONFTEST.
2011-07-28 13:53:36 -05:00
Dan Williams db9b1df0e4 build: don't use -Wstrict-prototypes (bgo #584947)
First, -Wstrict-prototypes wasn't actually getting used because
-Werror was already in CFLAGS and AC_TRY_COMPILE doesn't produce
main() functions with valid strict prototypes.  Suck.  But even
fixing that, the WiMAX SDK won't build with the flag, so just rip
it out.
2011-04-26 13:55:52 -05:00
Dan Williams df511f74f7 build: use -Wundef and fix up cases where stuff wasn't defined (bgo #647157) 2011-04-14 13:19:12 -05:00
Dan Williams b7259fd2a8 Merge remote branch 'origin/master' into rm-userset 2011-01-25 15:41:03 -06:00
Dan Williams 398993e2f4 build: turn off set-but-not-used variable warnings in new GCC 2011-01-24 15:57:33 -06:00
Giovanni Campagna 3ebecd2a29 introspection: add GObject introspection support (bgo #637032)
Add the necessary annotations (the mininum required, that is those
on return values. NULL parameters or container types may require
more), and the Autotools stuff to get a NetworkManager GIR for
libnm-util and a NMClient for libnm-glib.
2011-01-21 14:46:09 -06:00
Dan Winship 67a5f31fc8 Work around libnl address caching bug
rtnl_addr requires that all addresses have the "peer" attribute set in
order to be compared for equality, but this attribute is not normally
set. As a result, most addresses will not compare as equal even to
themselves, busting caching. We fix this for now by poking into the
guts of libnl if it is broken...
2009-08-26 14:37:17 -04:00
Michael Biebl dbd85915f1 Split compiler warnings into separate m4 macro file
The m4 macro is called NM_COMPILER_WARNINGS. Being in a separate file
makes it easier reusable for the other NM projects.
2009-05-02 18:01:13 -04:00