使用AUTOCONF和AUTOMAKE编写Makefile实现GTK编程
时间:2007-05-24 来源:gxmacc
1)autoscan 生成文件configure.scan
2)mv configure.scan configure.ac
3)编辑 configure.ac,在其中的 # Checks for library functions. 处添加:
AM_PATH_GTK_2_0(2.2.0,,AC_MSG_ERROR(mypkgname 0.1 needs GTK+ 2.2.0))
4)编写 Makefile.am文件,在其中添加:
AM_CPPFLAGS = @GTK_CFLAGS@
LDADD = @GTK_LIBS@
5)执行: autoreconf --install
./configure
make
例子:
configure.ac:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_SRCDIR([src/test.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AM_PATH_GTK_2_0(2.2.0,,AC_MSG_ERROR(mypkgname 0.1 needs GTK+ 2.2.0))
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
Makefile.am:
bin_PROGRAMS = test
test_SOURCES = test.c
AM_CPPFLAGS = @GTK_CFLAGS@
LDADD = @GTK_LIBS@
2)mv configure.scan configure.ac
3)编辑 configure.ac,在其中的 # Checks for library functions. 处添加:
AM_PATH_GTK_2_0(2.2.0,,AC_MSG_ERROR(mypkgname 0.1 needs GTK+ 2.2.0))
4)编写 Makefile.am文件,在其中添加:
AM_CPPFLAGS = @GTK_CFLAGS@
LDADD = @GTK_LIBS@
5)执行: autoreconf --install
./configure
make
例子:
configure.ac:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_SRCDIR([src/test.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AM_PATH_GTK_2_0(2.2.0,,AC_MSG_ERROR(mypkgname 0.1 needs GTK+ 2.2.0))
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
Makefile.am:
bin_PROGRAMS = test
test_SOURCES = test.c
AM_CPPFLAGS = @GTK_CFLAGS@
LDADD = @GTK_LIBS@
相关阅读 更多 +
排行榜 更多 +