Blame view

configure.ac 8.83 KB
7b880f0a9   Silvan Calarco   Rough fix for new...
1
  dnl A tool for maintaining an RPM based distribution
45aed8c11   Silvan Calarco   Initial commit
2
3
  dnl
  dnl Copyright 2006 (C) Davide Madrisan <davide.madrisan@gmail.com>
7b880f0a9   Silvan Calarco   Rough fix for new...
4
  dnl Copyright 2007-2014 (C) Silvan Calarco <silvan.calarco@mambasoft.it>
45aed8c11   Silvan Calarco   Initial commit
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  dnl
  dnl This program is free software; you can redistribute it and/or modify it under
  dnl the terms of version 2 of the GNU General Public License as published by the
  dnl Free Software Foundation.
  dnl
  dnl This program is distributed in the hope that it will be useful, but WITHOUT
  dnl ANY WARRANTY, to the extent permitted by law; without even the implied
  dnl warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  dnl See the GNU General Public License for more details.
  dnl
  dnl You should have received a copy of the GNU General Public License along with
  dnl this program; if not, write to the Free Software Foundation, Inc.,
  dnl 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
  
  dnl Process this file with autoconf to produce a configure script.
  
  
  dnl Initialization
  dnl ------------------------------------------------------------
  m4_define(PROG_NAME, [distromatic])
  m4_define(PROG_BUGREPORT, [silvan.calarco@mambasoft.it])
  m4_define(PROG_VERSION,dnl
  regexp(m4_include(VERSION),[.*=[ \t]*\([.0-9A-Za-z]+\)],[\1]))
  
  AC_PREREQ(2.59)
  AC_INIT([PROG_NAME],[PROG_VERSION],[PROG_BUGREPORT],[PROG_NAME])
  
  AC_CONFIG_SRCDIR(src/distromatic.c)
  AC_CONFIG_HEADERS(src/include/config.h:src/include/config.h.in)
  AC_COPYRIGHT(dnl
  [Copyright 2006 by Davide Madrisan <davide.madrisan@gmail.com>
  ])
  
  dnl set `ac_aux_dir' = 'config'
  dnl ------------------------------------------------------------
  AC_CONFIG_AUX_DIR(config)
  AC_SUBST(ac_aux_dir)
  
  dnl Just to display the version number of this program
  dnl ------------------------------------------------------------
  AC_MSG_CHECKING([for PROG_NAME version])
  AC_MSG_RESULT([PROG_VERSION])
  
  dnl Set and display default target architecture
  dnl ------------------------------------------------------------
  AC_MSG_CHECKING([for the default target architecture])
  DEFAULT_ARCH="i586"
  AC_SUBST(DEFAULT_ARCH)
  AC_MSG_RESULT([$DEFAULT_ARCH])
  
  dnl Compute the canonical build-system type variable, `build' and
  dnl its three individual parts `build_cpu', `build_vendor', `build_os'
  dnl ------------------------------------------------------------
  AC_CANONICAL_TARGET
  
  AM_INIT_AUTOMAKE([1.7 foreign dist-bzip2 nostdinc])
18e522572   Silvan Calarco   Autotools gettext...
61
  AM_GNU_GETTEXT([external])
45aed8c11   Silvan Calarco   Initial commit
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  AC_REVISION($Revision: 1.4 $)
  
  dnl Determine a C compiler to use. Define `CFLAGS', `EXEEXT', `OBJEXT'
  dnl Define `CFLAGS' to `-g -O2' for the GNU C compiler, or `-g' for
  dnl other compilers.
  dnl If the C compiler is not in ANSI C mode by default, try to add an
  dnl option to output variable `CC' to make it so.
  dnl ------------------------------------------------------------
  AC_PROG_CC
  if test "x$ac_cv_prog_cc_stdc" = xno; then
     AC_MSG_ERROR([$CC is not an ANSI C compiler.])
  fi
  AM_PROG_CC_C_O
  AC_ISC_POSIX
  #AC_PROG_GCC_TRADITIONAL
  
  #CFLAGS+=-O1
  SUPPORTED_CFLAGS=
  
  dnl cc_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
  dnl ------------------------------------------------------------
  dnl Checks if $CC supports a given set of CFLAGS.
  dnl If supported, the current CFLAGS is appended to SUPPORTED_CFLAGS
  AC_DEFUN([cc_TRY_CFLAGS],
     [AC_MSG_CHECKING([whether compiler accepts $1])
     ac_save_CFLAGS="$CFLAGS"
     CFLAGS="$CFLAGS $1"
28b142041   Silvan Calarco   configure.ac: fix...
89
     AC_COMPILE_IFELSE([AC_LANG_SOURCE([
45aed8c11   Silvan Calarco   Initial commit
90
91
92
        [[int x;]],
        [ac_cv_try_cflags_ok=yes
         SUPPORTED_CFLAGS="$SUPPORTED_CFLAGS $1"],
28b142041   Silvan Calarco   configure.ac: fix...
93
        [ac_cv_try_cflags_ok=no]])])
45aed8c11   Silvan Calarco   Initial commit
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
     CFLAGS="$ac_save_CFLAGS"
     AC_MSG_RESULT([$ac_cv_try_cflags_ok])
     if test x"$ac_cv_try_cflags_ok" = x"yes"; then
        ifelse([$2],[],[:],[$2])
     else
        ifelse([$3],[],[:],[$3])
     fi
  ])[]dnl @end [cc_TRY_CFLAGS]
  
  cc_TRY_CFLAGS([-Wall])
  cc_TRY_CFLAGS([-W])
  cc_TRY_CFLAGS([-Wmissing-prototypes])
  cc_TRY_CFLAGS([-Wstrict-prototypes])
  cc_TRY_CFLAGS([-Wshadow])
  #cc_TRY_CFLAGS([-Wunreachable-code])
  
  AC_SUBST([CFLAGS], ["$CFLAGS $SUPPORTED_CFLAGS"])
45aed8c11   Silvan Calarco   Initial commit
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
  dnl Check if C the compiler does not fully support the ANSI C qualifier
  dnl `const'.
  dnl ------------------------------------------------------------
  AC_C_CONST
  
  AC_LANG([C])
  
  dnl Define `WORDS_BIGENDIAN' if a big-endian architecture is found
  dnl AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN])
  dnl The default for ACTION-IF-TRUE is to define `WORDS_BIGENDIAN'.
  dnl The default for ACTION-IF-FALSE is to do nothing.
  dnl And finally, the default for ACTION-IF-UNKNOWN is to abort configure and tell
  dnl the installer which variable he should preset to bypass this test.
  dnl ------------------------------------------------------------
  AC_C_BIGENDIAN
  
  dnl Check for standard header files
  dnl ------------------------------------------------------------
  AC_HEADER_STDC
  AC_HEADER_TIME
  
  dnl Check for library functions for portability issues
  dnl ------------------------------------------------------------
  AC_CHECK_DECLS([getopt])
  dnl If the `malloc' works correctly (`malloc (0)' returns a valid pointer),
  dnl define `HAVE_MALLOC'
  AC_CHECK_FUNCS([memcpy strchr])
  AC_FUNC_MALLOC
  
  dnl Check for needed header files, libraries and tools
  dnl ------------------------------------------------------------
  AC_CHECK_HEADERS(dirent.h ndir.h sys/ndir.h, break)
  AC_CHECK_HEADERS(errno.h)
  
  dnl Check for zlib library and header files
  AC_CHECK_HEADER([zlib.h],
     AC_DEFINE(HAVE_ZLIB_H,1,
        [Define to 1 if you have the <zlib.h> header file.]),
     [AC_MSG_ERROR([Can't find zlib.h in your system])])
  AC_CHECK_LIB(z,gzopen, [ZLIB="-lz"],
     [AC_MSG_ERROR([Can't find libz library in your system])])
  LIBS="$LIBS $ZLIB"
  
  dnl Check for rpm tool and needed libraries
  AC_PATH_PROG(RPM_PATH,rpm,none)
  if test "$RPM_PATH" = "none"; then
     AC_MSG_ERROR([RPM executable was not found in your system])
  else
     AC_DEFINE_UNQUOTED([HAVE_RPM],1,[Define if RPM backend is available])
  
     dnl Check for RPM version
     AC_MSG_CHECKING(for RPM version)
     RPM_VERSION_RAW=`LANG= LC_ALL= $RPM_PATH --version | sed 's/^.* //'`
     RPM_VERSION_MAJOR=`echo $RPM_VERSION_RAW | cut -d. -f1`
     RPM_VERSION_MINOR=`echo $RPM_VERSION_RAW | cut -d. -f2`
     RPM_VERSION_MICRO=`echo $RPM_VERSION_RAW | cut -d. -f3`
     if test -z "$RPM_VERSION_MAJOR" -o -z "$RPM_VERSION_MINOR"; then
        AC_MSG_ERROR([can't parse RPM version])
     fi
     if test -z "$RPM_VERSION_MICRO"; then
        RPM_VERSION_MICRO=0
     fi
     AC_DEFINE_UNQUOTED([RPM_VERSION_MAJOR],$RPM_VERSION_MAJOR,[RPM major version])
     AC_DEFINE_UNQUOTED([RPM_VERSION_MINOR],$RPM_VERSION_MINOR,[RPM minor version])
     AC_DEFINE_UNQUOTED([RPM_VERSION_MICRO],$RPM_VERSION_MICRO,[RPM micro version])
     AC_DEFINE_UNQUOTED([RPM_VERSION],
        [((RPM_VERSION_MAJOR<<16)|(RPM_VERSION_MINOR<<8)|RPM_VERSION_MICRO)],
        [Define to the RPM version])
     AC_DEFINE_UNQUOTED([RPM_VERSION_RAW],"$RPM_VERSION_RAW",[RPM raw version])
     AC_MSG_RESULT($RPM_VERSION_RAW)
  
     dnl Check for RPM libraries and headers
  
     AC_CHECK_LIB(bz2,BZ2_bzopen, [],
                  [AC_MSG_ERROR([Can't find libbz2 library in your system])])
     AC_CHECK_LIB(z,gzopen, [],
                  [AC_MSG_ERROR([Can't find libz library in your system])])
     AC_CHECK_HEADERS(db1/db.h)
  
     CPPFLAGS="$CPPFLAGS -I/usr/include/rpm"
     AC_CHECK_HEADER(rpm/rpmlib.h, [],
                     [AC_MSG_ERROR([Can't find rpmlib.h in your system])])
  
    if test $RPM_VERSION_MAJOR -lt 4; then
        RPMLIBS="-lrpm -lz -lbz2 -lpopt"
     else
        AC_CHECK_LIB(rpmdb,rpmdbOpen,
           [RPMDBLIBS="-lrpmdb"],
           [RPMDBLIBS="-ldb-3.1"],
           [-lrpm -lrpmio -lz -lbz2 -lpopt])
        RPMLIBS="-lrpm $RPMDBLIBS -lrpmio -lz -lbz2 -lpopt"
     fi
     AC_MSG_CHECKING(for RPM libraries)
     AC_MSG_RESULT($RPMLIBS)
     AC_SUBST(RPMLIBS)
  fi
  LIBS="$LIBS $RPMLIBS"
  
  dnl Check for libiberty' library and header files
7b880f0a9   Silvan Calarco   Rough fix for new...
210
  AC_CHECK_HEADERS([libiberty/libiberty.h], [],
45aed8c11   Silvan Calarco   Initial commit
211
212
213
     [AC_MSG_ERROR([Can't find libiberty.h in your system,]
     [check http://www.gnu.org/software/binutils/binutils.html for libiberty])])
  AC_CHECK_LIB(iberty, freeargv,
dd2ec3fdb   Silvan Calarco   configure.ac: rem...
214
     [LIBS="$LIBS -liberty"
45aed8c11   Silvan Calarco   Initial commit
215
216
217
218
      AC_DEFINE(HAVE_LIBIBERTY,1,
                [Define to 1 if you have the `libiberty' library (-liberty).])],
     [AC_MSG_ERROR([Can't find libiberty in your system,]
     [check http://www.gnu.org/software/binutils/binutils.html for libiberty])])
944c8673e   Silvan Calarco   Added new sqlite3...
219
220
  dnl Check for sqlite library and header files
  PKG_CHECK_MODULES([SQLITE], [sqlite3])
45aed8c11   Silvan Calarco   Initial commit
221
222
  dnl Set the default `prefix' variable to `/usr'
  dnl ------------------------------------------------------------
654c4fbf4   Silvan Calarco   distroquery: fina...
223
  dnl AC_PREFIX_DEFAULT([/usr])
45aed8c11   Silvan Calarco   Initial commit
224
225
226
  
  dnl Generate the output files
  dnl ------------------------------------------------------------
18e522572   Silvan Calarco   Autotools gettext...
227
  AC_CONFIG_FILES([Makefile po/Makefile.in]
45aed8c11   Silvan Calarco   Initial commit
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
                  [config/Makefile]
                  [html/Makefile]
                  [html/index.php]
                  [html/index.postnuke.php]
  		[html/index.html]
                  [src/Makefile]
                  [src/include/Makefile]
                  [src/include/globaldefs.h]
                  [src/missing/Makefile])
  
  AC_OUTPUT
  
  cat <<_EOF
  
  Good - your configure finished. Start make now.
  
  _EOF
  
  dnl configure.ac ends here