mirror of
https://github.com/michaelrsweet/mxml.git
synced 2024-11-24 03:15:30 +00:00
Modernize configure script.
Add Github Actions CI builds and Coverity scanning. Add clang and cppcheck scanning. Add test target.
This commit is contained in:
parent
c44aa254cc
commit
0b1aa069c9
20
.cppcheck
Normal file
20
.cppcheck
Normal 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
59
.github/workflows/build.yml
vendored
Normal 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
39
.github/workflows/coverity.yml
vendored
Normal 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 }}
|
78
Makefile.in
78
Makefile.in
@ -3,7 +3,7 @@
|
||||
#
|
||||
# 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
|
||||
# information.
|
||||
@ -17,20 +17,22 @@ AR = @AR@
|
||||
ARFLAGS = @ARFLAGS@
|
||||
ARCHFLAGS = @ARCHFLAGS@
|
||||
CC = @CC@
|
||||
CFLAGS = $(OPTIM) $(ARCHFLAGS) @CFLAGS@ @CPPFLAGS@ @PTHREAD_FLAGS@
|
||||
CFLAGS = $(OPTIM) $(ARCHFLAGS) @CFLAGS@ $(CPPFLAGS) $(WARNINGS)
|
||||
CP = @CP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
DSO = @DSO@
|
||||
DSOFLAGS = @DSOFLAGS@
|
||||
LDFLAGS = $(OPTIM) $(ARCHFLAGS) @LDFLAGS@
|
||||
INSTALL = @INSTALL@
|
||||
LIBMXML = @LIBMXML@
|
||||
LIBS = @LIBS@ @PTHREAD_LIBS@
|
||||
LIBS = @LIBS@
|
||||
LN = @LN@ -s
|
||||
MKDIR = @MKDIR@
|
||||
OPTIM = @OPTIM@
|
||||
RANLIB = @RANLIB@
|
||||
RM = @RM@ -f
|
||||
SHELL = /bin/sh
|
||||
WARNINGS = @WARNINGS@
|
||||
|
||||
|
||||
#
|
||||
@ -201,6 +203,34 @@ uninstall-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...
|
||||
#
|
||||
@ -270,27 +300,6 @@ libmxml.1.dylib: $(LIBOBJS)
|
||||
testmxml: libmxml.a testmxml.o
|
||||
echo Linking $@...
|
||||
$(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
|
||||
echo Linking $@...
|
||||
@ -299,6 +308,27 @@ testmxml-vg: $(LIBOBJS) testmxml.o
|
||||
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)
|
||||
#
|
||||
|
415
configure.ac
415
configure.ac
@ -3,20 +3,26 @@ dnl Configuration script for Mini-XML, a small XML-like file parsing library.
|
||||
dnl
|
||||
dnl https://www.msweet.org/mxml
|
||||
dnl
|
||||
dnl Copyright © 2003-2020 by Michael R Sweet.
|
||||
dnl Copyright © 2003-2021 by Michael R Sweet.
|
||||
dnl
|
||||
dnl Licensed under Apache License v2.0. See the file "LICENSE" for more
|
||||
dnl information.
|
||||
dnl
|
||||
|
||||
dnl We need at least autoconf 2.70 for --runstatedir...
|
||||
AC_PREREQ([2.70])
|
||||
|
||||
|
||||
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 against this project. Doing so is completely unsupported and WILL cause
|
||||
dnl 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
|
||||
AC_CANONICAL_BUILD
|
||||
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_version=`echo $host_os | sed -e '1,$s/^[^0-9.]*//g'`]
|
||||
|
||||
|
||||
dnl Set the name of the config header file...
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
|
||||
dnl Version number...
|
||||
VERSION="AC_PACKAGE_VERSION"
|
||||
AC_SUBST(VERSION)
|
||||
AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")
|
||||
|
||||
|
||||
dnl Clear default debugging options and set normal optimization by
|
||||
dnl default unless the user asks for debugging specifically.
|
||||
CFLAGS="${CFLAGS:=}"
|
||||
CXXFLAGS="${CXXFLAGS:=}"
|
||||
CPPFLAGS="${CPPFLAGS:=}"
|
||||
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],
|
||||
ARCHFLAGS="$withval",
|
||||
ARCHFLAGS="")
|
||||
AC_SUBST(ARCHFLAGS)
|
||||
dnl Options...
|
||||
AC_ARG_WITH([ansi], AS_HELP_STRING([--with-ansi], [set full ANSI C mode, default=no]), [
|
||||
use_ansi="$withval"
|
||||
], [
|
||||
use_ansi="no"
|
||||
])
|
||||
|
||||
AC_ARG_WITH(optim, [ --with-optim set additional optimization flags, default=none],
|
||||
OPTIM="$withval",
|
||||
OPTIM="")
|
||||
AC_SUBST(OPTIM)
|
||||
AC_ARG_WITH([archflags], AS_HELP_STRING([--with-archflags], [set additional architecture flags, default=none]), [
|
||||
ARCHFLAGS="$withval"
|
||||
], [
|
||||
ARCHFLAGS=""
|
||||
])
|
||||
AC_SUBST([ARCHFLAGS])
|
||||
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
|
||||
if eval "test x$enable_debug = xyes"; then
|
||||
OPTIM="$OPTIM -g"
|
||||
fi)
|
||||
AC_ARG_WITH([optim], AS_HELP_STRING([--with-optim], [set additional optimization flags, default=none]), [
|
||||
OPTIM="$withval"
|
||||
], [
|
||||
OPTIM=""
|
||||
])
|
||||
AC_SUBST([OPTIM])
|
||||
|
||||
AC_ARG_WITH(docdir, [ --with-docdir set directory for documentation, default=${prefix}/share/doc/mxml],
|
||||
docdir="$withval",
|
||||
docdir="NONE")
|
||||
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [turn on debugging, default=no]))
|
||||
AC_ARG_ENABLE([maintainer], AS_HELP_STRING([--enable-maintainer], [turn on maintainer mode, default=no]))
|
||||
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_ARG_WITH(vsnprintf, [ --with-vsnprintf use vsnprintf emulation functions, default=auto],
|
||||
use_vsnprintf="$withval",
|
||||
use_vsnprintf="no")
|
||||
AC_ARG_WITH([vsnprintf], AS_HELP_STRING([--with-vsnprintf], [use vsnprintf emulation functions, default=auto]), [
|
||||
use_vsnprintf="$withval"
|
||||
], [
|
||||
use_vsnprintf="no"
|
||||
])
|
||||
|
||||
|
||||
dnl Checks for programs...
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_INSTALL
|
||||
if test "$INSTALL" = "$ac_install_sh"; then
|
||||
AS_IF([test "$INSTALL" = "$ac_install_sh"], [
|
||||
# Use full path to install-sh script...
|
||||
INSTALL="`pwd`/install-sh -c"
|
||||
fi
|
||||
])
|
||||
AC_PROG_RANLIB
|
||||
AC_CHECK_TOOL(AR,ar)
|
||||
AC_PATH_PROG(CP,cp)
|
||||
@ -84,264 +105,270 @@ AC_PATH_PROG(LN,ln)
|
||||
AC_PATH_PROG(MKDIR,mkdir)
|
||||
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)
|
||||
|
||||
|
||||
dnl Inline functions...
|
||||
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
|
||||
AC_CHECK_FUNCS(snprintf vasprintf vsnprintf)
|
||||
fi
|
||||
dnl Checks for string functions.
|
||||
AS_IF([test "x$use_ansi" != xyes], [
|
||||
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...
|
||||
AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
|
||||
[if test "$GCC" = yes; then
|
||||
AC_CACHE_CHECK([for long long int], [ac_cv_c_long_long], [
|
||||
AS_IF([test "$GCC" = yes], [
|
||||
ac_cv_c_long_long=yes
|
||||
else
|
||||
AC_TRY_COMPILE(,[long long int i;],
|
||||
ac_cv_c_long_long=yes,
|
||||
ac_cv_c_long_long=no)
|
||||
fi])
|
||||
], [
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
|
||||
long long int i;]])
|
||||
], [
|
||||
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
|
||||
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
|
||||
PTHREAD_FLAGS=""
|
||||
PTHREAD_LIBS=""
|
||||
AS_IF([test "x$enable_threads" != xno], [
|
||||
AC_CHECK_HEADER([pthread.h], [
|
||||
AC_DEFINE([HAVE_PTHREAD_H], [Have <pthread.h>?])
|
||||
])
|
||||
|
||||
if test "x$enable_threads" != xno; then
|
||||
AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
|
||||
|
||||
if test x$ac_cv_header_pthread_h = xyes; then
|
||||
AS_IF([test x$ac_cv_header_pthread_h = xyes], [
|
||||
dnl Check various threading options for the platforms we support
|
||||
for flag in -lpthreads -lpthread -pthread; do
|
||||
AC_MSG_CHECKING([for pthread_create using $flag])
|
||||
SAVELIBS="$LIBS"
|
||||
LIBS="$flag $LIBS"
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_create(0, 0, 0, 0);],
|
||||
have_pthread=yes)
|
||||
AC_MSG_RESULT([$have_pthread])
|
||||
AC_LANG([C])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],[pthread_create(0, 0, 0, 0);])], [
|
||||
have_pthread=yes
|
||||
], [
|
||||
LIBS="$SAVELIBS"
|
||||
])
|
||||
|
||||
if test $have_pthread = yes; then
|
||||
PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
|
||||
PTHREAD_LIBS="$flag"
|
||||
|
||||
# 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
|
||||
AS_IF([test x$have_pthread = xyes], [
|
||||
AC_MSG_RESULT([yes])
|
||||
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -D_REENTRANT"
|
||||
break
|
||||
fi
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
done
|
||||
fi
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
AC_SUBST(PTHREAD_FLAGS)
|
||||
AC_SUBST(PTHREAD_LIBS)
|
||||
|
||||
dnl Shared library support...
|
||||
DSO="${DSO:=:}"
|
||||
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
|
||||
AC_MSG_CHECKING(for shared library support)
|
||||
AS_IF([test x$enable_shared != xno], [
|
||||
AC_MSG_CHECKING([for shared library support])
|
||||
PICFLAG=1
|
||||
|
||||
case "$host_os_name" in
|
||||
sunos | unix_s)
|
||||
AC_MSG_RESULT(yes)
|
||||
AS_CASE(["$host_os_name"], [sunos | unix_s], [
|
||||
AC_MSG_RESULT([yes])
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -R\$(libdir)"
|
||||
;;
|
||||
|
||||
linux*)
|
||||
AC_MSG_RESULT(yes)
|
||||
], [linux*], [
|
||||
AC_MSG_RESULT([yes])
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
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"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)"
|
||||
;;
|
||||
|
||||
*bsd | haiku*)
|
||||
AC_MSG_RESULT(yes)
|
||||
], [*bsd | haiku*], [
|
||||
AC_MSG_RESULT([yes])
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)"
|
||||
;;
|
||||
|
||||
darwin)
|
||||
AC_MSG_RESULT(yes)
|
||||
], [darwin], [
|
||||
AC_MSG_RESULT([yes])
|
||||
LIBMXML="libmxml.1.dylib"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -lc"
|
||||
;;
|
||||
|
||||
mingw)
|
||||
AC_MSG_RESULT(yes)
|
||||
], [mingw], [
|
||||
AC_MSG_RESULT([yes])
|
||||
LIBMXML="mxml1.dll"
|
||||
DSO="\$(CC)"
|
||||
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
|
||||
LIBMXML="libmxml.a"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
])
|
||||
], [
|
||||
PICFLAG=0
|
||||
LIBMXML="libmxml.a"
|
||||
fi
|
||||
])
|
||||
|
||||
AC_SUBST(DSO)
|
||||
AC_SUBST(DSOFLAGS)
|
||||
AC_SUBST(LIBMXML)
|
||||
AC_SUBST(PICFLAG)
|
||||
AC_SUBST([DSO])
|
||||
AC_SUBST([DSOFLAGS])
|
||||
AC_SUBST([LIBMXML])
|
||||
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
|
||||
OPTIM="-Os -g"
|
||||
fi
|
||||
dnl Compiler options...
|
||||
WARNINGS=""
|
||||
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"
|
||||
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"
|
||||
fi
|
||||
else
|
||||
case "$host_os_name" in
|
||||
hp-ux)
|
||||
CFLAGS="-Ae $CFLAGS"
|
||||
|
||||
if test "x$OPTIM" = x; then
|
||||
])
|
||||
], [
|
||||
AS_IF([test "x$OPTIM" = x], [
|
||||
AS_IF([test x$enable_debug = xyes], [
|
||||
OPTIM="-g"
|
||||
], [
|
||||
OPTIM="-O"
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
AS_CASE(["$host_os_name"], [hp-ux], [
|
||||
CFLAGS="-Ae $CFLAGS"
|
||||
|
||||
OPTIM="+DAportable $OPTIM"
|
||||
|
||||
if test $PICFLAG = 1; then
|
||||
AS_IF([test $PICFLAG = 1], [
|
||||
OPTIM="+z $OPTIM"
|
||||
fi
|
||||
;;
|
||||
|
||||
unix_svr | sunos)
|
||||
if test "x$OPTIM" = x; then
|
||||
OPTIM="-O"
|
||||
fi
|
||||
|
||||
if test $PICFLAG = 1; then
|
||||
])
|
||||
], [unix_svr | sunos], [
|
||||
AS_IF([test $PICFLAG = 1], [
|
||||
OPTIM="-KPIC $OPTIM"
|
||||
fi
|
||||
;;
|
||||
])
|
||||
])
|
||||
])
|
||||
|
||||
*)
|
||||
if test "x$OPTIM" = x; then
|
||||
OPTIM="-O"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
dnl Determine whether we are cross-compiling...
|
||||
if test "$build" = "$host"; then
|
||||
AS_IF([test "$build" = "$host"], [
|
||||
TARGETS="ALLTARGETS"
|
||||
else
|
||||
], [
|
||||
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"
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Fix "exec_prefix" variable if it hasn't been specified...
|
||||
if test "$exec_prefix" = "NONE"; then
|
||||
AS_IF([test "$exec_prefix" = "NONE"], [
|
||||
exec_prefix="$prefix"
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Fix "docdir" variable if it hasn't been specified...
|
||||
if test "$docdir" = "NONE"; then
|
||||
AS_IF([test "$docdir" = "NONE"], [
|
||||
docdir="$datadir/doc/mxml"
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Fix "mandir" variable if it hasn't been specified...
|
||||
if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"; then
|
||||
case "$host_os_name" in
|
||||
*bsd | darwin | linux*)
|
||||
# *BSD, Darwin (macOS), and Linux
|
||||
AS_IF([test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"], [
|
||||
mandir="/usr/share/man"
|
||||
;;
|
||||
irix)
|
||||
# SGI IRIX
|
||||
mandir="/usr/share/catman/u_man"
|
||||
;;
|
||||
*)
|
||||
# All others
|
||||
mandir="/usr/man"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl pkg-config stuff...
|
||||
if test "$includedir" != /usr/include; then
|
||||
AS_IF([test "$includedir" != /usr/include], [
|
||||
PC_CFLAGS="-I$includedir"
|
||||
else
|
||||
], [
|
||||
PC_CFLAGS=""
|
||||
fi
|
||||
])
|
||||
AC_SUBST([PC_CFLAGS])
|
||||
|
||||
if test "$libdir" != /usr/lib; then
|
||||
AS_IF([test "$libdir" != /usr/lib], [
|
||||
PC_LIBS="-L$libdir -lmxml"
|
||||
else
|
||||
], [
|
||||
PC_LIBS="-lmxml"
|
||||
fi
|
||||
])
|
||||
AC_SUBST([PC_LIBS])
|
||||
|
||||
AC_SUBST(PC_CFLAGS)
|
||||
AC_SUBST(PC_LIBS)
|
||||
|
||||
dnl Output the makefile, etc...
|
||||
AC_OUTPUT(Makefile mxml.pc)
|
||||
AC_CONFIG_FILES([Makefile mxml.pc])
|
||||
AC_OUTPUT
|
||||
|
Loading…
Reference in New Issue
Block a user