• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4#
5#    Copyright 2016-2018 Nest Labs Inc. All Rights Reserved.
6#
7#    Licensed under the Apache License, Version 2.0 (the "License");
8#    you may not use this file except in compliance with the License.
9#    You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#    Unless required by applicable law or agreed to in writing, software
14#    distributed under the License is distributed on an "AS IS" BASIS,
15#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16#    See the License for the specific language governing permissions and
17#    limitations under the License.
18#
19
20#
21#    Description:
22#      This file is the GNU autoconf input source file for
23#      @PACKAGE_DESCRIPTION@.
24#
25
26#
27# Declare autoconf version requirements
28#
29AC_PREREQ([2.68])
30
31#
32# Initialize autoconf for the package
33#
34AC_INIT([@PACKAGE_SHORT_LOWER@],
35        m4_esyscmd([@NLBUILD_AUTOTOOLS_STEM@/scripts/mkversion -b `cat .default-version` .]),
36        [@PACKAGE_EMAIL@],
37        [@PACKAGE_SHORT_LOWER@],
38        [@PACKAGE_URL@])
39
40# Tell the rest of the build system the absolute path where the
41# nlbuild-autotools repository is rooted at.
42
43AC_SUBST(nlbuild_autotools_stem,[@NLBUILD_AUTOTOOLS_STEM@])
44AC_SUBST(abs_top_nlbuild_autotools_dir,[\${abs_top_srcdir}/\${nlbuild_autotools_stem}])
45
46#
47# @PACKAGE_SHORT_UPPER@ interface current, revision, and age versions.
48#
49# Maintainters: Please manage these fields as follows:
50#
51#   Interfaces removed:    CURRENT++, AGE = 0, REVISION = 0
52#   Interfaces added:      CURRENT++, AGE++,   REVISION = 0
53#   No interfaces changed:                     REVISION++
54#
55#
56AC_SUBST(LIB@PACKAGE_SHORT_UPPER@_VERSION_CURRENT,  [1])
57AC_SUBST(LIB@PACKAGE_SHORT_UPPER@_VERSION_AGE,      [0])
58AC_SUBST(LIB@PACKAGE_SHORT_UPPER@_VERSION_REVISION, [0])
59AC_SUBST(LIB@PACKAGE_SHORT_UPPER@_VERSION_INFO,     [${LIB@PACKAGE_SHORT_UPPER@_VERSION_CURRENT}:${LIB@PACKAGE_SHORT_UPPER@_VERSION_REVISION}:${LIB@PACKAGE_SHORT_UPPER@_VERSION_AGE}])
60
61#
62# Check the sanity of the source directory by checking for the
63# presence of a key watch file
64#
65AC_CONFIG_SRCDIR([include/@PACKAGE_SHORT_LOWER@.h])
66
67#
68# Tell autoconf where to find auxilliary build tools (e.g. config.guess,
69# install-sh, missing, etc.)
70#
71AC_CONFIG_AUX_DIR([@NLBUILD_AUTOTOOLS_STEM@/third_party/autoconf])
72
73#
74# Tell autoconf where to find auxilliary M4 macros
75#
76AC_CONFIG_MACRO_DIRS([@NLBUILD_AUTOTOOLS_STEM@/third_party/autoconf/m4 @NLBUILD_AUTOTOOLS_STEM@/autoconf/m4])
77
78#
79# Tell autoconf what file the package is using to aggregate C preprocessor
80# defines.
81#
82AC_CONFIG_HEADERS([include/@PACKAGE_SHORT_LOWER@-config.h])
83
84#
85# Figure out what the canonical build, host and target tuples are.
86#
87AC_CANONICAL_BUILD
88AC_CANONICAL_HOST
89AC_CANONICAL_TARGET
90
91#
92# Mac OS X / Darwin ends up putting some versioning cruft on the end of its
93# tuple that we don't care about in this script. Create "clean" variables
94# devoid of it.
95#
96
97NL_FILTERED_CANONICAL_BUILD
98NL_FILTERED_CANONICAL_HOST
99NL_FILTERED_CANONICAL_TARGET
100
101#
102# Configure automake with the desired options, indicating that this is not
103# a native GNU package, that we want "silent" build rules, and that we want
104# objects built in the same subdirectory as their source rather than collapsed
105# together at the top-level directory.
106#
107# Disable silent build rules by either passing --disable-silent-rules to
108# configure or passing V=1 to make
109#
110AM_INIT_AUTOMAKE([1.14 foreign silent-rules subdir-objects tar-pax])
111
112#
113# Silent build rules requires at least automake-1.11. Employ
114# techniques for not breaking earlier versions of automake.
115#
116m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
117AM_SILENT_RULES([yes])
118
119#
120# Enable maintainer mode to prevent the package from constantly trying
121# to rebuild configure, Makefile.in, etc. Rebuilding such files rarely,
122# if ever, needs to be done "in the field".
123#
124# Use the included 'bootstrap' script instead when necessary.
125#
126AM_MAINTAINER_MODE
127
128#
129# Checks for build host programs
130#
131
132# If we are cross-compiling and we are on an embedded target that
133# doesn't support independent, standalone executables, then all
134# compiler tests that attempt to create an executable will fail. In
135# such circumstances, set AC_NO_EXECUTABLES (see http://sourceware.org/
136# ml/newlib/2006/msg00353.html).
137
138AC_MSG_CHECKING([whether to disable executable checking])
139if test "$cross_compiling" = yes; then
140    AC_NO_EXECUTABLES
141    AC_MSG_RESULT([yes])
142else
143    AC_MSG_RESULT([no])
144fi
145
146# Passing -Werror to GCC-based or -compatible compilers breaks some
147# autoconf tests (see
148# http://lists.gnu.org/archive/html/autoconf-patches/2008-09/msg00014.html).
149#
150# If -Werror has been passed transform it into -Wno-error. We'll
151# transform it back later with NL_RESTORE_WERROR.
152
153NL_SAVE_WERROR
154
155# Check for compilers.
156#
157# These should be checked BEFORE we check for and, implicitly,
158# initialize libtool such that libtool knows what languages it has to
159# work with.
160
161AC_PROG_CPP
162AC_PROG_CPP_WERROR
163
164AC_PROG_CC
165AC_PROG_CC_C_O
166
167AC_PROG_CXXCPP
168
169AC_PROG_CXX
170AC_PROG_CXX_C_O
171
172# Check for other compiler toolchain tools.
173
174AC_CHECK_TOOL(AR, ar)
175AC_CHECK_TOOL(RANLIB, ranlib)
176AC_CHECK_TOOL(OBJCOPY, objcopy)
177AC_CHECK_TOOL(STRIP, strip)
178
179# Check for other host tools.
180
181AC_PROG_INSTALL
182AC_PROG_LN_S
183
184AC_PATH_PROG(CMP, cmp)
185AC_PATH_PROG(PERL, perl)
186
187#
188# Checks for specific compiler characteristics
189#
190
191#
192# Common compiler flags we would like to have.
193#
194#   -Wall                        CC, CXX
195#
196
197PROSPECTIVE_CFLAGS="-Wall"
198PROSPECTIVE_CXXFLAGS=""
199
200AX_CHECK_COMPILER_OPTIONS([C],   ${PROSPECTIVE_CFLAGS})
201AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CFLAGS} ${PROSPECTIVE_CXXFLAGS})
202
203# Check for and initialize libtool
204
205LT_INIT
206
207#
208# Debug instances
209#
210AC_MSG_NOTICE([checking whether to build debug instances])
211
212# Debug
213
214NL_ENABLE_DEBUG([no])
215
216AM_CONDITIONAL([@PACKAGE_SHORT_UPPER@_BUILD_DEBUG], [test "${nl_cv_build_debug}" = "yes"])
217
218#
219# Code coverage and compiler optimization
220#
221
222# Coverage
223
224NL_ENABLE_COVERAGE([no])
225
226AM_CONDITIONAL([@PACKAGE_SHORT_UPPER@_BUILD_COVERAGE], [test "${nl_cv_build_coverage}" = "yes"])
227
228NL_ENABLE_COVERAGE_REPORTS([auto])
229
230AM_CONDITIONAL([@PACKAGE_SHORT_UPPER@_BUILD_COVERAGE_REPORTS], [test "${nl_cv_build_coverage_reports}" = "yes"])
231
232# Optimization
233
234NL_ENABLE_OPTIMIZATION([yes])
235
236AM_CONDITIONAL([@PACKAGE_SHORT_UPPER@_BUILD_OPTIMIZED], [test "${nl_cv_build_optimized}" = "yes"])
237
238#
239# Tests
240#
241AC_MSG_NOTICE([checking whether to build tests])
242
243# Tests
244
245NL_ENABLE_TESTS([yes])
246
247AM_CONDITIONAL([@PACKAGE_SHORT_UPPER@_BUILD_TESTS], [test "${nl_cv_build_tests}" = "yes"])
248
249#
250# Documentation
251#
252
253# Determine whether or not documentation (via Doxygen) should be built
254# or not, with 'auto' as the default and establish a default support
255# value for GraphViz 'dot' support.
256
257NL_ENABLE_DOCS([auto],[NO])
258
259AM_CONDITIONAL(@PACKAGE_SHORT_UPPER@_BUILD_DOCS, [test "${nl_cv_build_docs}" = "yes"])
260
261#
262# Checks for libraries and packages.
263#
264# At minimum, the following packages are optional, depending on
265# configuration:
266#
267#   * TBD
268#
269AC_MSG_NOTICE([checking required package dependencies])
270
271# Check if the build host has pkg-config
272
273AC_PATH_PROG([PKG_CONFIG],[pkg-config])
274
275# Here is a package example with nlunit-test. Uncomment and adapt or delete
276# this, as needed. If you choose to use this, please also take a look at
277# Makefile.am and third_party/Makefile.am and uncomment the appropriate
278# sections there.
279
280# #
281# # Nlunit-test
282# #
283#
284# if test "${nl_cv_build_tests}" = "yes"; then
285#     NL_WITH_PACKAGE(
286#         [Nlunit-test],
287#         [NLUNIT_TEST],
288#         [nlunit_test],
289#         [-lnlunit-test],
290#         [
291# 	    # At this point, the internal Nlunit-test package will be neither
292# 	    # configured nor built, so the normal checks we undertake for an
293# 	    # external package cannot be run here. Simply set the appropriate
294# 	    # variables and trust all will be well.
295#
296#             NLUNIT_TEST_CPPFLAGS="-I\${abs_top_srcdir}/third_party/nlunit-test/repo/src"
297#             NLUNIT_TEST_LDFLAGS="-L${ac_pwd}/third_party/nlunit-test/repo/src"
298#             NLUNIT_TEST_LIBS="-lnlunit-test"
299#         ],
300#         [
301#             # Check for required nlunit-test headers.
302#
303#             AC_CHECK_HEADERS([nlunit-test.h],
304#             [],
305#             [
306#                 AC_MSG_ERROR(The nlunit-test header "$ac_header" is required but cannot be found.)
307#             ])
308#         ])
309# fi
310#
311# # Depending on whether nlunit-test has been configured for an internal
312# # location, its directory stem within this package needs to be set
313# # accordingly. In addition, if the location is internal, then we need
314# # to attempt to pull it down using the bootstrap makefile.
315#
316# if test "${nl_with_nlunit_test}" = "internal"; then
317#     maybe_nlunit_test_dirstem="nlunit-test/repo"
318#     nlunit_test_dirstem="third_party/${maybe_nlunit_test_dirstem}"
319#
320#     AC_MSG_NOTICE([attempting to create internal ${nlunit_test_dirstem}])
321#
322#     ${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${nlunit_test_dirstem}
323#
324#     if test $? -ne 0; then
325#         AC_MSG_ERROR([failed to create ${nlunit_test_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
326#     fi
327# else
328#     maybe_nlunit_test_dirstem=""
329# fi
330#
331# AC_SUBST(NLUNIT_TEST_SUBDIRS, [${maybe_nlunit_test_dirstem}])
332# AM_CONDITIONAL([@PACKAGE_SHORT_UPPER@_WITH_NLUNIT_TEST_INTERNAL], [test "${nl_with_nlunit_test}" = "internal"])
333
334#
335# Check for headers
336#
337AC_HEADER_STDBOOL
338AC_HEADER_STDC
339
340AC_CHECK_HEADERS([stdint.h])
341AC_CHECK_HEADERS([string.h])
342
343#
344# Check for types and structures
345#
346AC_TYPE_INT8_T
347AC_TYPE_INT16_T
348AC_TYPE_INT32_T
349AC_TYPE_INT64_T
350AC_TYPE_UINT8_T
351AC_TYPE_UINT16_T
352AC_TYPE_UINT32_T
353AC_TYPE_UINT64_T
354
355#
356# Checks for library functions
357#
358
359if test "${ac_no_link}" != "yes"; then
360    AC_CHECK_FUNCS([memcpy])
361fi
362
363# Here is an example with nlunit-test. Uncomment and adapt or delete
364# this, as needed.
365
366# # Add any nlunit-test CPPFLAGS, LDFLAGS, and LIBS
367#
368# CPPFLAGS="${CPPFLAGS} ${NLUNIT_TEST_CPPFLAGS}"
369# LDFLAGS="${LDFLAGS} ${NLUNIT_TEST_LDFLAGS}"
370# LIBS="${LIBS} ${NLUNIT_TEST_LIBS}"
371
372# Add any code coverage CPPFLAGS and LIBS
373
374CPPFLAGS="${CPPFLAGS} ${NL_COVERAGE_CPPFLAGS}"
375LIBS="${LIBS} ${NL_COVERAGE_LIBS}"
376LDFLAGS="${LDFLAGS} ${NL_COVERAGE_LDFLAGS}"
377
378# At this point, we can restore the compiler flags to whatever the
379# user passed in, now that we're clear of any -Werror issues by
380# transforming -Wno-error back to -Werror.
381
382NL_RESTORE_WERROR
383
384# Here is an example with nlunit-test. Uncomment and adapt or delete
385# this, as needed.
386
387# # Configure any autotools-based subdirectories
388#
389# if test "${nl_with_nlunit_test}" = "internal"; then
390#     AC_CONFIG_SUBDIRS([third_party/nlunit-test/repo])
391# fi
392
393#
394# Identify the various makefiles and auto-generated files for the package
395#
396AC_CONFIG_FILES([
397Makefile
398third_party/Makefile
399src/Makefile
400tests/Makefile
401doc/Makefile
402])
403
404#
405# Generate the auto-generated files for the package
406#
407AC_OUTPUT
408
409#
410# Summarize the package configuration
411#
412
413AC_MSG_NOTICE([
414
415  Configuration Summary
416  ---------------------
417  Package                                   : ${PACKAGE_NAME}
418  Version                                   : ${PACKAGE_VERSION}
419  Interface                                 : ${LIB@PACKAGE_SHORT_UPPER@_VERSION_INFO//:/.}
420  Build system                              : ${build}
421  Host system                               : ${host}
422  Target system                             : ${target}
423  Target architecture                       : ${target_cpu}
424  Target OS                                 : ${target_os}
425  Cross compiling                           : ${cross_compiling}
426  Build shared libraries                    : ${enable_shared}
427  Build static libraries                    : ${enable_static}
428  Build debug libraries                     : ${nl_cv_build_debug}
429  Build optimized libraries                 : ${nl_cv_build_optimized}
430  Build coverage libraries                  : ${nl_cv_build_coverage}
431  Build coverage reports                    : ${nl_cv_build_coverage_reports}
432  Lcov                                      : ${LCOV:--}
433  Genhtml                                   : ${GENHTML:--}
434  Build tests                               : ${nl_cv_build_tests}
435  Prefix                                    : ${prefix}
436  Shadow directory program                  : ${LNDIR}
437  Documentation support                     : ${nl_cv_build_docs}
438  Doxygen                                   : ${DOXYGEN:--}
439  GraphViz dot                              : ${DOT:--}
440  PERL                                      : ${PERL:--}
441  Nlunit-test source                        : ${nl_with_nlunit_test:--}
442  Nlunit-test compile flags                 : ${NLUNIT_TEST_CPPFLAGS:--}
443  Nlunit-test link flags                    : ${NLUNIT_TEST_LDFLAGS:--}
444  Nlunit-test link libraries                : ${NLUNIT_TEST_LIBS:--}
445  C Preprocessor                            : ${CPP}
446  C Compiler                                : ${CC}
447  C++ Preprocessor                          : ${CXXCPP}
448  C++ Compiler                              : ${CXX}
449  Archiver                                  : ${AR}
450  Archive Indexer                           : ${RANLIB}
451  Symbol Stripper                           : ${STRIP}
452  Object Copier                             : ${OBJCOPY}
453  C Preprocessor flags                      : ${CPPFLAGS:--}
454  C Compile flags                           : ${CFLAGS:--}
455  C++ Compile flags                         : ${CXXFLAGS:--}
456  Link flags                                : ${LDFLAGS:--}
457  Link libraries                            : ${LIBS}
458
459])
460