include config.h via Makefiles

Ensures that config.h is always ordered correctly (first) in the
includes. Also means that new source files get this for free without
having to remember to add it.

We opt for -imacros over -include as its more portable, and the
added constraint by -imacros doesn't bother us for config.h.

This also touches the HACKING file to remove the explicit mention of
config.h as part of the includes.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dave Reisner 2011-12-17 21:42:35 -05:00 committed by Dan McGee
parent 6c1426842a
commit d6ccd44390
47 changed files with 13 additions and 90 deletions

View File

@ -114,8 +114,6 @@ general pattern, including blank lines:
[source,C]
-------------------------------------------
#include "config.h"
#include <standardheader.h>
#include <another.h>
#include <...>
@ -144,6 +142,8 @@ For pacman:
#include "anythingelse.h"
-------------------------------------------
Never directly include config.h. This will always be added via Makefiles.
GDB and Valgrind Usage
~~~~~~~~~~~~~~~~~~~~~~

View File

@ -7,6 +7,9 @@ include_HEADERS = alpm_list.h alpm.h
DEFS = -DLOCALEDIR=\"@localedir@\" @DEFS@
AM_CPPFLAGS = \
-imacros $(top_builddir)/config.h
AM_CFLAGS = -pedantic -D_GNU_SOURCE
if ENABLE_VISIBILITY_CC

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <errno.h>
#include <string.h>

View File

@ -21,8 +21,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#endif

View File

@ -21,8 +21,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>

View File

@ -22,8 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -22,8 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <stdint.h> /* intmax_t */

View File

@ -20,8 +20,6 @@
#ifndef _ALPM_DELTA_H
#define _ALPM_DELTA_H
#include "config.h" /* ensure off_t is correct length */
#include <sys/types.h> /* off_t */
#include "alpm.h"

View File

@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
#if defined(HAVE_MNTENT_H)
#include <mntent.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#endif

View File

@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "graph.h"
#include "util.h"
#include "log.h"

View File

@ -19,8 +19,6 @@
#ifndef _ALPM_GRAPH_H
#define _ALPM_GRAPH_H
#include "config.h" /* ensure off_t is correct length */
#include <sys/types.h> /* off_t */
#include "alpm_list.h"

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>

View File

@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>

View File

@ -21,8 +21,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

View File

@ -24,8 +24,6 @@
#ifndef _ALPM_PACKAGE_H
#define _ALPM_PACKAGE_H
#include "config.h" /* ensure off_t is correct length */
#include <sys/types.h> /* off_t */
#include "alpm.h"

View File

@ -22,8 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <errno.h>
#include <string.h>

View File

@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -21,8 +21,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <sys/types.h> /* off_t */
#include <stdlib.h>
#include <stdio.h>

View File

@ -21,8 +21,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -22,8 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>

View File

@ -24,8 +24,6 @@
#ifndef _ALPM_UTIL_H
#define _ALPM_UTIL_H
#include "config.h"
#include "alpm_list.h"
#include "alpm.h"
#include "package.h" /* alpm_pkg_t */

View File

@ -15,8 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <ctype.h>

View File

@ -17,7 +17,10 @@ DEFS = -DLOCALEDIR=\"@localedir@\" \
-DCACHEDIR=\"$(cachedir)\" \
-DLOGFILE=\"$(logfile)\" \
@DEFS@
INCLUDES = -I$(top_srcdir)/lib/libalpm
AM_CPPFLAGS = \
-imacros $(top_builddir)/config.h \
-I$(top_srcdir)/lib/libalpm
AM_CFLAGS = -pedantic -D_GNU_SOURCE

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
#include <glob.h>
#include <limits.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <alpm.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <alpm.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
/* special handling of package version for GIT */
#if defined(GIT_VERSION)
#undef PACKAGE_VERSION

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <fnmatch.h>
#include <stdlib.h>
#include <stdio.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -18,8 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>

View File

@ -11,7 +11,10 @@ DEFS = -DLOCALEDIR=\"@localedir@\" \
-DDBPATH=\"$(dbpath)\" \
-DCACHEDIR=\"$(cachedir)\" \
@DEFS@
INCLUDES = -I$(top_srcdir)/lib/libalpm
AM_CPPFLAGS = \
-imacros $(top_builddir)/config.h \
-I$(top_srcdir)/lib/libalpm
AM_CFLAGS = -pedantic -D_GNU_SOURCE

View File

@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
#include <getopt.h>
#include <stdio.h>

View File

@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <ctype.h>
#include <getopt.h>
#include <stdio.h>

View File

@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>