Modernize configure script.

Add Github Actions CI builds and Coverity scanning.

Add clang and cppcheck scanning.

Add test target.
This commit is contained in:
Michael R Sweet 2021-10-26 08:25:41 -04:00
parent c44aa254cc
commit 0b1aa069c9
No known key found for this signature in database
GPG Key ID: 999559A027815955
6 changed files with 2887 additions and 1989 deletions

20
.cppcheck Normal file
View File

@ -0,0 +1,20 @@
// Bad CERT recommendation: C memory layout not determined by variable locations
cert-API01-C
// Cppcheck doesn't know enough about variables to know whether they are
// uninitialized...
uninitvar
// Don't report non-const casts. Inline suppression comments are not working,
// otherwise we'd be more selective...
cert-EXP05-C
// Not handling "(unsigned)~CONSTANT" properly...
cert-INT31-c
// fopen_s is NOT supported on POSIX platforms and DOES NOT APPLY for reading
// of files!
cert-MSC24-C
// Not sure why this is a thing...
preprocessorErrorDirective

59
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,59 @@
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: update build environment
run: sudo apt-get update --fix-missing -y
- name: install prerequisites
run: sudo apt-get install -y cppcheck
- name: configure
env:
CC: /usr/bin/gcc
run: ./configure --enable-debug --enable-maintainer
- name: make
run: make
- name: test
env:
ASAN_OPTIONS: leak_check_at_exit=false
run: make test
- name: clang static analyzer
run: make CC=clang "GHA_ERROR=::error::" clang
- name: cppcheck
run: make "GHA_ERROR=::error::" cppcheck
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: configure
run: ./configure --enable-debug --enable-maintainer
- name: make
run: make
- name: test
run: make test
- name: clang static analyzer
run: make CC=clang "GHA_ERROR=::error::" clang
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: setup-msbuild
uses: microsoft/setup-msbuild@v1.0.2
- name: msbuild
run: msbuild vcnet\mxml.sln

39
.github/workflows/coverity.yml vendored Normal file
View File

@ -0,0 +1,39 @@
name: Coverity Scan
on: workflow_dispatch
jobs:
coverity-scan:
runs-on: ubuntu-latest
environment: Coverity
steps:
- uses: actions/checkout@v2
- name: update build environment
run: sudo apt-get update --fix-missing -y
- name: Download Coverity Build Tool
run: |
wget -q https://scan.coverity.com/download/linux64 --post-data token="$TOKEN&project=$GITHUB_REPOSITORY" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
- name: configure
run: ./configure --enable-debug --enable-maintainer
- name: Build with cov-build
run: |
export PATH=`pwd`/cov-analysis-linux64/bin:$PATH
cov-build --dir cov-int make
- name: Submit the result to Coverity Scan
run: |
tar czvf cov.tgz cov-int
curl \
--form token=$TOKEN \
--form email=michael.r.sweet@gmail.com \
--form file=@cov.tgz \
--form version="$GITHUB_REF" \
--form description="$GITHUB_SHA" \
"https://scan.coverity.com/builds?project=$GITHUB_REPOSITORY"
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}

View File

@ -3,7 +3,7 @@
# #
# https://www.msweet.org/mxml # https://www.msweet.org/mxml
# #
# Copyright © 2003-2019 by Michael R Sweet. # Copyright © 2003-2021 by Michael R Sweet.
# #
# Licensed under Apache License v2.0. See the file "LICENSE" for more # Licensed under Apache License v2.0. See the file "LICENSE" for more
# information. # information.
@ -17,20 +17,22 @@ AR = @AR@
ARFLAGS = @ARFLAGS@ ARFLAGS = @ARFLAGS@
ARCHFLAGS = @ARCHFLAGS@ ARCHFLAGS = @ARCHFLAGS@
CC = @CC@ CC = @CC@
CFLAGS = $(OPTIM) $(ARCHFLAGS) @CFLAGS@ @CPPFLAGS@ @PTHREAD_FLAGS@ CFLAGS = $(OPTIM) $(ARCHFLAGS) @CFLAGS@ $(CPPFLAGS) $(WARNINGS)
CP = @CP@ CP = @CP@
CPPFLAGS = @CPPFLAGS@
DSO = @DSO@ DSO = @DSO@
DSOFLAGS = @DSOFLAGS@ DSOFLAGS = @DSOFLAGS@
LDFLAGS = $(OPTIM) $(ARCHFLAGS) @LDFLAGS@ LDFLAGS = $(OPTIM) $(ARCHFLAGS) @LDFLAGS@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
LIBMXML = @LIBMXML@ LIBMXML = @LIBMXML@
LIBS = @LIBS@ @PTHREAD_LIBS@ LIBS = @LIBS@
LN = @LN@ -s LN = @LN@ -s
MKDIR = @MKDIR@ MKDIR = @MKDIR@
OPTIM = @OPTIM@ OPTIM = @OPTIM@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
RM = @RM@ -f RM = @RM@ -f
SHELL = /bin/sh SHELL = /bin/sh
WARNINGS = @WARNINGS@
# #
@ -201,6 +203,34 @@ uninstall-libmxml.1.dylib:
$(RM) $(BUILDROOT)$(libdir)/libmxml.1.dylib $(RM) $(BUILDROOT)$(libdir)/libmxml.1.dylib
#
# Test everything...
#
test: testmxml
@echo Testing library...
./testmxml test.xml temp1s.xml >temp1.xml
./testmxml temp1.xml temp2s.xml >temp2.xml
@if cmp temp1.xml temp2.xml; then \
echo Stdio file test passed!; \
$(RM) temp2.xml temp2s.xml; \
else \
echo Stdio file test failed!; \
fi
@if cmp temp1.xml temp1s.xml; then \
echo String test passed!; \
$(RM) temp1.xml temp1s.xml; \
else \
echo String test failed!; \
fi
@if cmp test.xml test.xmlfd; then \
echo File descriptor test passed!; \
$(RM) test.xmlfd temp1.xmlfd; \
else \
echo File descriptor test failed!; \
fi
# #
# Figure out lines-of-code... # Figure out lines-of-code...
# #
@ -270,27 +300,6 @@ libmxml.1.dylib: $(LIBOBJS)
testmxml: libmxml.a testmxml.o testmxml: libmxml.a testmxml.o
echo Linking $@... echo Linking $@...
$(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a $(LIBS) $(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a $(LIBS)
@echo Testing library...
./testmxml test.xml temp1s.xml >temp1.xml
./testmxml temp1.xml temp2s.xml >temp2.xml
@if cmp temp1.xml temp2.xml; then \
echo Stdio file test passed!; \
$(RM) temp2.xml temp2s.xml; \
else \
echo Stdio file test failed!; \
fi
@if cmp temp1.xml temp1s.xml; then \
echo String test passed!; \
$(RM) temp1.xml temp1s.xml; \
else \
echo String test failed!; \
fi
@if cmp test.xml test.xmlfd; then \
echo File descriptor test passed!; \
$(RM) test.xmlfd temp1.xmlfd; \
else \
echo File descriptor test failed!; \
fi
testmxml-vg: $(LIBOBJS) testmxml.o testmxml-vg: $(LIBOBJS) testmxml.o
echo Linking $@... echo Linking $@...
@ -299,6 +308,27 @@ testmxml-vg: $(LIBOBJS) testmxml.o
testmxml.o: mxml.h testmxml.o: mxml.h
#
# Analyze code with the Clang static analyzer <https://clang-analyzer.llvm.org>
#
.PHONY: clang
clang:
clang $(CPPFLAGS) --analyze $(OBJS:.o=.c) 2>clang.log
rm -rf $(OBJS:.o=.plist)
test -s clang.log && (echo "$(GHA_ERROR)Clang detected issues."; echo ""; cat clang.log; exit 1) || exit 0
#
# Analyze code using Cppcheck <http://cppcheck.sourceforge.net>
#
.PHONY: cppcheck
cppcheck:
cppcheck $(CPPFLAGS) --template=gcc --addon=cert.py --suppressions-list=.cppcheck $(OBJS:.o=.c) 2>cppcheck.log
test -s cppcheck.log && (echo "$(GHA_ERROR)Cppcheck detected issues."; echo ""; cat cppcheck.log; exit 1) || exit 0
# #
# Documentation (depends on separate codedoc utility) # Documentation (depends on separate codedoc utility)
# #

4037
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -3,20 +3,26 @@ dnl Configuration script for Mini-XML, a small XML-like file parsing library.
dnl dnl
dnl https://www.msweet.org/mxml dnl https://www.msweet.org/mxml
dnl dnl
dnl Copyright © 2003-2020 by Michael R Sweet. dnl Copyright © 2003-2021 by Michael R Sweet.
dnl dnl
dnl Licensed under Apache License v2.0. See the file "LICENSE" for more dnl Licensed under Apache License v2.0. See the file "LICENSE" for more
dnl information. dnl information.
dnl dnl
dnl We need at least autoconf 2.70 for --runstatedir...
AC_PREREQ([2.70])
dnl Package name and version... dnl Package name and version...
AC_INIT([Mini-XML], [3.2], [https://github.com/michaelrsweet/mxml/issues], [mxml], [https://michaelrsweet.github.io/mxml]) AC_INIT([Mini-XML], [3.2.1], [https://github.com/michaelrsweet/mxml/issues], [mxml], [https://www.msweet.org/mxml])
dnl This line is provided to ensure that you don't run the autoheader program dnl This line is provided to ensure that you don't run the autoheader program
dnl against this project. Doing so is completely unsupported and WILL cause dnl against this project. Doing so is completely unsupported and WILL cause
dnl problems! dnl problems!
AH_TOP([#error "Somebody ran autoheader on this project which is unsupported and WILL cause problems."]) AH_TOP([#error "Somebody ran autoheader on this project which is unsupported and WILL cause problems."])
dnl Get the build and host platforms and split the host_os value dnl Get the build and host platforms and split the host_os value
AC_CANONICAL_BUILD AC_CANONICAL_BUILD
AC_CANONICAL_HOST AC_CANONICAL_HOST
@ -24,58 +30,73 @@ AC_CANONICAL_HOST
[host_os_name=`echo $host_os | sed -e '1,$s/[0-9.]*$//g'`] [host_os_name=`echo $host_os | sed -e '1,$s/[0-9.]*$//g'`]
[host_os_version=`echo $host_os | sed -e '1,$s/^[^0-9.]*//g'`] [host_os_version=`echo $host_os | sed -e '1,$s/^[^0-9.]*//g'`]
dnl Set the name of the config header file... dnl Set the name of the config header file...
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADERS([config.h])
dnl Version number... dnl Version number...
VERSION="AC_PACKAGE_VERSION" VERSION="AC_PACKAGE_VERSION"
AC_SUBST(VERSION) AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION") AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")
dnl Clear default debugging options and set normal optimization by dnl Clear default debugging options and set normal optimization by
dnl default unless the user asks for debugging specifically. dnl default unless the user asks for debugging specifically.
CFLAGS="${CFLAGS:=}" CFLAGS="${CFLAGS:=}"
CXXFLAGS="${CXXFLAGS:=}" CPPFLAGS="${CPPFLAGS:=}"
LDFLAGS="${LDFLAGS:=}" LDFLAGS="${LDFLAGS:=}"
AC_SUBST(LDFLAGS) AC_SUBST([LDFLAGS])
LIBS="${LIBS:=}"
AC_ARG_WITH(ansi, [ --with-ansi set full ANSI C mode, default=no],
use_ansi="$withval",
use_ansi="no")
AC_ARG_WITH(archflags, [ --with-archflags set additional architecture flags, default=none], dnl Options...
ARCHFLAGS="$withval", AC_ARG_WITH([ansi], AS_HELP_STRING([--with-ansi], [set full ANSI C mode, default=no]), [
ARCHFLAGS="") use_ansi="$withval"
AC_SUBST(ARCHFLAGS) ], [
use_ansi="no"
])
AC_ARG_WITH(optim, [ --with-optim set additional optimization flags, default=none], AC_ARG_WITH([archflags], AS_HELP_STRING([--with-archflags], [set additional architecture flags, default=none]), [
OPTIM="$withval", ARCHFLAGS="$withval"
OPTIM="") ], [
AC_SUBST(OPTIM) ARCHFLAGS=""
])
AC_SUBST([ARCHFLAGS])
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no], AC_ARG_WITH([optim], AS_HELP_STRING([--with-optim], [set additional optimization flags, default=none]), [
if eval "test x$enable_debug = xyes"; then OPTIM="$withval"
OPTIM="$OPTIM -g" ], [
fi) OPTIM=""
])
AC_SUBST([OPTIM])
AC_ARG_WITH(docdir, [ --with-docdir set directory for documentation, default=${prefix}/share/doc/mxml], AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [turn on debugging, default=no]))
docdir="$withval", AC_ARG_ENABLE([maintainer], AS_HELP_STRING([--enable-maintainer], [turn on maintainer mode, default=no]))
docdir="NONE") AC_ARG_ENABLE([sanitizer], AS_HELP_STRING([--enable-sanitizer], [build with AddressSanitizer, default=no]))
AC_ARG_WITH([docdir], AS_HELP_STRING([--with-docdir], [set directory for documentation, default=${prefix}/share/doc/mxml]), [
docdir="$withval"
], [
docdir="NONE"
])
AC_SUBST(docdir) AC_SUBST(docdir)
AC_ARG_WITH(vsnprintf, [ --with-vsnprintf use vsnprintf emulation functions, default=auto], AC_ARG_WITH([vsnprintf], AS_HELP_STRING([--with-vsnprintf], [use vsnprintf emulation functions, default=auto]), [
use_vsnprintf="$withval", use_vsnprintf="$withval"
use_vsnprintf="no") ], [
use_vsnprintf="no"
])
dnl Checks for programs... dnl Checks for programs...
AC_PROG_CC AC_PROG_CC
AC_PROG_CXX AC_PROG_CXX
AC_PROG_INSTALL AC_PROG_INSTALL
if test "$INSTALL" = "$ac_install_sh"; then AS_IF([test "$INSTALL" = "$ac_install_sh"], [
# Use full path to install-sh script... # Use full path to install-sh script...
INSTALL="`pwd`/install-sh -c" INSTALL="`pwd`/install-sh -c"
fi ])
AC_PROG_RANLIB AC_PROG_RANLIB
AC_CHECK_TOOL(AR,ar) AC_CHECK_TOOL(AR,ar)
AC_PATH_PROG(CP,cp) AC_PATH_PROG(CP,cp)
@ -84,264 +105,270 @@ AC_PATH_PROG(LN,ln)
AC_PATH_PROG(MKDIR,mkdir) AC_PATH_PROG(MKDIR,mkdir)
AC_PATH_PROG(RM,rm) AC_PATH_PROG(RM,rm)
dnl Flags for "ar" command...
case "$host_os_name" in
darwin* | *bsd)
ARFLAGS="-rcv"
;;
*)
ARFLAGS="crvs"
;;
esac
dnl Flags for "ar" command...
AS_CASE(["$host_os_name"], [darwin* | *bsd], [
ARFLAGS="-rcv"
], [*], [
ARFLAGS="crvs"
])
AC_SUBST(ARFLAGS) AC_SUBST(ARFLAGS)
dnl Inline functions... dnl Inline functions...
AC_C_INLINE AC_C_INLINE
dnl Checks for string functions.
if test "x$use_ansi" != xyes; then
AC_CHECK_FUNCS(strdup strlcat strlcpy)
fi
if test "x$use_vsnprintf" != xyes; then dnl Checks for string functions.
AC_CHECK_FUNCS(snprintf vasprintf vsnprintf) AS_IF([test "x$use_ansi" != xyes], [
fi AC_CHECK_FUNCS([strdup strlcat strlcpy])
])
AS_IF([test "x$use_vsnprintf" != xyes], [
AC_CHECK_FUNCS([snprintf vasprintf vsnprintf])
])
dnl Check for "long long" support... dnl Check for "long long" support...
AC_CACHE_CHECK(for long long int, ac_cv_c_long_long, AC_CACHE_CHECK([for long long int], [ac_cv_c_long_long], [
[if test "$GCC" = yes; then AS_IF([test "$GCC" = yes], [
ac_cv_c_long_long=yes ac_cv_c_long_long=yes
else ], [
AC_TRY_COMPILE(,[long long int i;], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
ac_cv_c_long_long=yes, long long int i;]])
ac_cv_c_long_long=no) ], [
fi]) ac_cv_c_long_long=yes
], [
ac_cv_c_long_long=no
])
])
])
AS_IF([test $ac_cv_c_long_long = yes], [
AC_DEFINE([HAVE_LONG_LONG], [Have the long long type?])
])
if test $ac_cv_c_long_long = yes; then
AC_DEFINE(HAVE_LONG_LONG)
fi
dnl Threading support dnl Threading support
AC_ARG_ENABLE(threads, [ --enable-threads enable multi-threading support]) AC_ARG_ENABLE([threads], AS_HELP_STRING([--disable-threads], [disable multi-threading support, default=no]))
have_pthread=no have_pthread=no
PTHREAD_FLAGS="" AS_IF([test "x$enable_threads" != xno], [
PTHREAD_LIBS="" AC_CHECK_HEADER([pthread.h], [
AC_DEFINE([HAVE_PTHREAD_H], [Have <pthread.h>?])
])
if test "x$enable_threads" != xno; then AS_IF([test x$ac_cv_header_pthread_h = xyes], [
AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
if test x$ac_cv_header_pthread_h = xyes; then
dnl Check various threading options for the platforms we support dnl Check various threading options for the platforms we support
for flag in -lpthreads -lpthread -pthread; do for flag in -lpthreads -lpthread -pthread; do
AC_MSG_CHECKING([for pthread_create using $flag]) AC_MSG_CHECKING([for pthread_create using $flag])
SAVELIBS="$LIBS" SAVELIBS="$LIBS"
LIBS="$flag $LIBS" LIBS="$flag $LIBS"
AC_TRY_LINK([#include <pthread.h>], AC_LANG([C])
[pthread_create(0, 0, 0, 0);], AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],[pthread_create(0, 0, 0, 0);])], [
have_pthread=yes) have_pthread=yes
AC_MSG_RESULT([$have_pthread]) ], [
LIBS="$SAVELIBS" LIBS="$SAVELIBS"
])
if test $have_pthread = yes; then AS_IF([test x$have_pthread = xyes], [
PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT" AC_MSG_RESULT([yes])
PTHREAD_LIBS="$flag" CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -D_REENTRANT"
# Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
# be POSIX-compliant... :(
case "$host_os_name" in
sunos)
PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
;;
esac
break break
fi ], [
AC_MSG_RESULT([no])
])
done done
fi ])
fi ])
AC_SUBST(PTHREAD_FLAGS)
AC_SUBST(PTHREAD_LIBS)
dnl Shared library support... dnl Shared library support...
DSO="${DSO:=:}" DSO="${DSO:=:}"
DSOFLAGS="${DSOFLAGS:=}" DSOFLAGS="${DSOFLAGS:=}"
AC_ARG_ENABLE(shared, [ --enable-shared turn on shared libraries, default=no]) AC_ARG_ENABLE([shared], AS_HELP_STRING([--disable-shared], [turn off shared libraries, default=no]))
if test x$enable_shared != xno; then AS_IF([test x$enable_shared != xno], [
AC_MSG_CHECKING(for shared library support) AC_MSG_CHECKING([for shared library support])
PICFLAG=1 PICFLAG=1
case "$host_os_name" in AS_CASE(["$host_os_name"], [sunos | unix_s], [
sunos | unix_s) AC_MSG_RESULT([yes])
AC_MSG_RESULT(yes)
LIBMXML="libmxml.so.1.6" LIBMXML="libmxml.so.1.6"
DSO="\$(CC)" DSO="\$(CC)"
DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)" DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)"
LDFLAGS="$LDFLAGS -R\$(libdir)" LDFLAGS="$LDFLAGS -R\$(libdir)"
;; ], [linux*], [
AC_MSG_RESULT([yes])
linux*)
AC_MSG_RESULT(yes)
LIBMXML="libmxml.so.1.6" LIBMXML="libmxml.so.1.6"
DSO="\$(CC)" DSO="\$(CC)"
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1 -shared \$(OPTIM)" DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1 -shared \$(OPTIM)"
;; ], [osf | gnu], [
AC_MSG_RESULT([yes])
osf | gnu)
AC_MSG_RESULT(yes)
LIBMXML="libmxml.so.1.6" LIBMXML="libmxml.so.1.6"
DSO="\$(CC)" DSO="\$(CC)"
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)" DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)"
LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)" LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)"
;; ], [*bsd | haiku*], [
AC_MSG_RESULT([yes])
*bsd | haiku*)
AC_MSG_RESULT(yes)
LIBMXML="libmxml.so.1.6" LIBMXML="libmxml.so.1.6"
DSO="\$(CC)" DSO="\$(CC)"
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)" DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)"
LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)" LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)"
;; ], [darwin], [
AC_MSG_RESULT([yes])
darwin)
AC_MSG_RESULT(yes)
LIBMXML="libmxml.1.dylib" LIBMXML="libmxml.1.dylib"
DSO="\$(CC)" DSO="\$(CC)"
DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -lc" DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -lc"
;; ], [mingw], [
AC_MSG_RESULT([yes])
mingw)
AC_MSG_RESULT(yes)
LIBMXML="mxml1.dll" LIBMXML="mxml1.dll"
DSO="\$(CC)" DSO="\$(CC)"
DSOFLAGS="$DSOFLAGS -shared -Wl,--out-implib,libmxml1.a,--no-undefined,--enable-runtime-pseudo-reloc" DSOFLAGS="$DSOFLAGS -shared -Wl,--out-implib,libmxml1.a,--no-undefined,--enable-runtime-pseudo-reloc"
;; ], [*], [
AC_MSG_RESULT([no])
*) AC_MSG_WARN([shared libraries not supported on this platform.])
AC_MSG_RESULT(no)
AC_MSG_WARN(shared libraries not supported on this platform.)
PICFLAG=0 PICFLAG=0
LIBMXML="libmxml.a" LIBMXML="libmxml.a"
;; ])
esac ], [
else
PICFLAG=0 PICFLAG=0
LIBMXML="libmxml.a" LIBMXML="libmxml.a"
fi ])
AC_SUBST(DSO) AC_SUBST([DSO])
AC_SUBST(DSOFLAGS) AC_SUBST([DSOFLAGS])
AC_SUBST(LIBMXML) AC_SUBST([LIBMXML])
AC_SUBST(PICFLAG) AC_SUBST([PICFLAG])
dnl Add -Wall for GCC...
if test -n "$GCC"; then
CFLAGS="-Wall -D_GNU_SOURCE $CFLAGS"
if test "x$OPTIM" = x; then dnl Compiler options...
OPTIM="-Os -g" WARNINGS=""
fi AC_SUBST([WARNINGS])
if test "x$use_ansi" = xyes; then AS_IF([test -n "$GCC"], [
CFLAGS="-D_GNU_SOURCE $CFLAGS"
AS_IF([test "x$OPTIM" = x], [
AS_IF([test x$enable_debug = xyes], [
OPTIM="-g"
], [
OPTIM="-g -Os"
])
], [test x$enable_debug = xyes], [
OPTIM="$OPTIM -g"
])
AS_IF([test x$enable_sanitizer = xyes], [
# Use -fsanitize=address with debugging...
OPTIM="$OPTIM -fsanitize=address"
], [
# Otherwise use the Fortify enhancements to catch any unbounded
# string operations...
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
])
AS_IF([test "x$use_ansi" = xyes], [
CFLAGS="-ansi -pedantic $CFLAGS" CFLAGS="-ansi -pedantic $CFLAGS"
fi ])
if test $PICFLAG = 1 -a "$host_os_name" != aix; then dnl Show all standard warnings + unused variables when compiling...
WARNINGS="-Wall -Wunused"
dnl Drop some not-useful/unreliable warnings...
for warning in char-subscripts format-truncation format-y2k switch unused-result; do
AC_MSG_CHECKING([whether compiler supports -Wno-$warning])
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wno-$warning -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
AC_MSG_RESULT(yes)
WARNINGS="$WARNINGS -Wno-$warning"
], [
AC_MSG_RESULT(no)
])
CFLAGS="$OLDCFLAGS"
done
dnl Maintainer mode enables -Werror...
AS_IF([test x$enable_maintainer = xyes], [
WARNINGS="$WARNINGS -Werror"
])
AS_IF([test $PICFLAG = 1 -a "$host_os_name" != aix], [
OPTIM="-fPIC $OPTIM" OPTIM="-fPIC $OPTIM"
fi ])
else ], [
case "$host_os_name" in AS_IF([test "x$OPTIM" = x], [
hp-ux) AS_IF([test x$enable_debug = xyes], [
CFLAGS="-Ae $CFLAGS" OPTIM="-g"
], [
if test "x$OPTIM" = x; then
OPTIM="-O" OPTIM="-O"
fi ])
])
AS_CASE(["$host_os_name"], [hp-ux], [
CFLAGS="-Ae $CFLAGS"
OPTIM="+DAportable $OPTIM" OPTIM="+DAportable $OPTIM"
if test $PICFLAG = 1; then AS_IF([test $PICFLAG = 1], [
OPTIM="+z $OPTIM" OPTIM="+z $OPTIM"
fi ])
;; ], [unix_svr | sunos], [
AS_IF([test $PICFLAG = 1], [
unix_svr | sunos)
if test "x$OPTIM" = x; then
OPTIM="-O"
fi
if test $PICFLAG = 1; then
OPTIM="-KPIC $OPTIM" OPTIM="-KPIC $OPTIM"
fi ])
;; ])
])
*)
if test "x$OPTIM" = x; then
OPTIM="-O"
fi
;;
esac
fi
dnl Determine whether we are cross-compiling... dnl Determine whether we are cross-compiling...
if test "$build" = "$host"; then AS_IF([test "$build" = "$host"], [
TARGETS="ALLTARGETS" TARGETS="ALLTARGETS"
else ], [
TARGETS="CROSSTARGETS" TARGETS="CROSSTARGETS"
fi ])
AC_SUBST(TARGETS) AC_SUBST([TARGETS])
dnl Fix "prefix" variable if it hasn't been specified...
if test "$prefix" = "NONE"; then dnl Fix installation directories...
AS_IF([test "$prefix" = "NONE"], [
prefix="/usr/local" prefix="/usr/local"
fi ])
dnl Fix "exec_prefix" variable if it hasn't been specified... AS_IF([test "$exec_prefix" = "NONE"], [
if test "$exec_prefix" = "NONE"; then
exec_prefix="$prefix" exec_prefix="$prefix"
fi ])
dnl Fix "docdir" variable if it hasn't been specified... AS_IF([test "$docdir" = "NONE"], [
if test "$docdir" = "NONE"; then
docdir="$datadir/doc/mxml" docdir="$datadir/doc/mxml"
fi ])
dnl Fix "mandir" variable if it hasn't been specified... AS_IF([test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"], [
if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"; then
case "$host_os_name" in
*bsd | darwin | linux*)
# *BSD, Darwin (macOS), and Linux
mandir="/usr/share/man" mandir="/usr/share/man"
;; ])
irix)
# SGI IRIX
mandir="/usr/share/catman/u_man"
;;
*)
# All others
mandir="/usr/man"
;;
esac
fi
dnl pkg-config stuff... dnl pkg-config stuff...
if test "$includedir" != /usr/include; then AS_IF([test "$includedir" != /usr/include], [
PC_CFLAGS="-I$includedir" PC_CFLAGS="-I$includedir"
else ], [
PC_CFLAGS="" PC_CFLAGS=""
fi ])
AC_SUBST([PC_CFLAGS])
if test "$libdir" != /usr/lib; then AS_IF([test "$libdir" != /usr/lib], [
PC_LIBS="-L$libdir -lmxml" PC_LIBS="-L$libdir -lmxml"
else ], [
PC_LIBS="-lmxml" PC_LIBS="-lmxml"
fi ])
AC_SUBST([PC_LIBS])
AC_SUBST(PC_CFLAGS)
AC_SUBST(PC_LIBS)
dnl Output the makefile, etc... dnl Output the makefile, etc...
AC_OUTPUT(Makefile mxml.pc) AC_CONFIG_FILES([Makefile mxml.pc])
AC_OUTPUT