From fbb87ffed3ba15378954253accb69f7905809c97 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Fri, 31 Aug 2018 08:31:39 -0400 Subject: [PATCH] 2018-08-31 Fred Gleason * Added support for cross-compiling 'rivwebcapi' for Windows with the MingW64 environment. --- ChangeLog | 3 + INSTALL-WINDOWS | 30 +++++ Makefile.am | 1 + apis/rivwebcapi/Makefile.am | 6 + apis/rivwebcapi/acinclude.m4 | 61 ++++++++++ apis/rivwebcapi/autogen.sh | 46 ++++++++ apis/rivwebcapi/configure.ac | 98 ++++++++++++++++ apis/rivwebcapi/get_distro.pl | 148 +++++++++++++++++++++++++ apis/rivwebcapi/get_target.sh | 42 +++++++ apis/rivwebcapi/rivwebcapi/Makefile.am | 2 +- apis/rivwebcapi/rivwebcapi/rd_common.h | 2 +- apis/rivwebcapi/tests/Makefile.am | 4 +- 12 files changed, 439 insertions(+), 4 deletions(-) create mode 100644 INSTALL-WINDOWS create mode 100644 apis/rivwebcapi/acinclude.m4 create mode 100755 apis/rivwebcapi/autogen.sh create mode 100644 apis/rivwebcapi/configure.ac create mode 100755 apis/rivwebcapi/get_distro.pl create mode 100755 apis/rivwebcapi/get_target.sh diff --git a/ChangeLog b/ChangeLog index cec646e4..d33e6f61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17549,3 +17549,6 @@ [from https://github.com/RadioFreeAsia/rivendell-c-api] in 'apis/rivwebcapi/'. * Added a 'rivendell-webapi' RPM subpackage. +2018-08-31 Fred Gleason + * Added support for cross-compiling 'rivwebcapi' for Windows with + the MingW64 environment. diff --git a/INSTALL-WINDOWS b/INSTALL-WINDOWS new file mode 100644 index 00000000..24865c26 --- /dev/null +++ b/INSTALL-WINDOWS @@ -0,0 +1,30 @@ +BUILDING RIVWEBCAPI FOR WINDOWS USING MINGW64 +--------------------------------------------- + +To build the Rivendell Web C API client library for Windows using +the MingW64 cross-compiler environment, proceed as follows: + +1) Ensure that the necessary MingW64 packages are installed. On RHEL-7, +this can be accomplished with the following command (as 'root'): + +*** snip snip *** +yum install mingw32-pkg-config mingw32-headers mingw-binutils-generic mingw32-libtiff mingw32-qt mingw32-sqlite-static mingw32-qt-static mingw32-pixman mingw32-gettext mingw32-libogg mingw32-openssl mingw32-libmad mingw-filesystem-base mingw32-crt mingw32-zlib mingw32-libjpeg-turbo mingw32-expat mingw32-qt-qmake mingw32-binutils mingw32-gcc-c++ mingw32-dbus mingw32-sqlite mingw32-zlib-static mingw32-libtiff-static mingw32-libpng-static mingw32-libjpeg-turbo-static mingw32-bzip2 mingw32-fontconfig mingw32-win-iconv mingw32-termcap mingw32-glib2 mingw32-cairo-static mingw32-libsamplerate mingw32-libvorbis mingw32-libltdl mingw32-libssh2 mingw32-curl mingw32-filesystem mingw32-winpthreads mingw32-cpp mingw32-gcc mingw32-libpng mingw32-dbus-static mingw32-winpthreads-static mingw32-freetype mingw32-libffi mingw32-cairo mingw32-libsndfile mingw32-opus mingw32-libidn mingw32-nsis +*** snip snip *** + + +2) Define the following variables in your build environment: + +export MINGW32_SYS_ROOT=/usr/i686-w64-mingw32/sys-root/mingw +export PKG_CONFIG_PATH=$MINGW32_SYS_ROOT/lib/pkgconfig +export CC=i686-w64-mingw32-gcc +export CXX=i686-w64-mingw32-g++ +export WINDRES=i686-w64-mingw32-windres +export RANLIB=i686-w64-mingw32-gcc-ranlib + + +3) cd to 'apis/rivwebcapi/' in the Rivendell sources and do: + + ./autogen.sh + ./configure --prefix=$MINGW32_SYS_ROOT --i686-w64-mingw32 + make + make install (as root) diff --git a/Makefile.am b/Makefile.am index d3c64e3c..3df7e6d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -110,6 +110,7 @@ EXTRA_DIST = autogen.sh\ CODINGSTYLE\ get_distro.pl\ get_target.sh\ + INSTALL-WINDOWS\ make_slack.in\ PACKAGE_VERSION\ rdrepld-suse.in\ diff --git a/apis/rivwebcapi/Makefile.am b/apis/rivwebcapi/Makefile.am index 8587d365..daea1823 100644 --- a/apis/rivwebcapi/Makefile.am +++ b/apis/rivwebcapi/Makefile.am @@ -39,6 +39,12 @@ DISTCLEANFILES = rivwebcapi.pc MAINTAINERCLEANFILES = *~\ *.tar.gz\ aclocal.m4\ + config.guess\ + config.sub\ configure\ + depcomp\ + install-sh\ + ltmain.sh\ Makefile.in\ + missing\ moc_* diff --git a/apis/rivwebcapi/acinclude.m4 b/apis/rivwebcapi/acinclude.m4 new file mode 100644 index 00000000..1787290c --- /dev/null +++ b/apis/rivwebcapi/acinclude.m4 @@ -0,0 +1,61 @@ +dnl acinclude.m4 +dnl +dnl Local Autoconf macro definitions for LibRHpi +dnl +dnl (C) Copyright 2006,2016 Fred Gleason +dnl +dnl BNV_HAVE_QT Macro Copyright (C) 2001, 2002, 2003, 2005, 2006 +dnl Bastiaan Veelo +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License version 2 as +dnl published by the Free Software Foundation. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public +dnl License along with this program; if not, write to the Free Software +dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +dnl + +dnl AR_GCC_TARGET() +dnl +dnl Get gcc(1)'s idea of the target architecture, distribution and os. +dnl The following variables are set: +dnl $ar_gcc_arch = Target Architecture (i586, XF86_64, etc) +dnl $ar_gcc_distro = Target Distribution (suse, slackware, etc) +dnl $ar_gcc_os = Target Operating System (linux, solaris, etc) +dnl +AC_DEFUN([AR_GCC_TARGET],[AC_REQUIRE([AC_PROG_CC])] + [ + AC_MSG_CHECKING(target architecture) + ar_gcc_arch=$(./get_target.sh $CC $AWK arch) + ar_gcc_distro=$(./get_target.sh $CC $AWK distro) + ar_gcc_os=$(./get_target.sh $CC $AWK os) + AC_MSG_RESULT([$ar_gcc_arch-$ar_gcc_distro-$ar_gcc_os]) + ] +) + +dnl AR_GET_DISTRO() +dnl +dnl Try to determine the name and version of the distribution running +dnl on the host machine, based on entries in '/etc/'. +dnl The following variables are set: +dnl $ar_distro_name = Distribution Name (SuSE, Debian, etc) +dnl $ar_distro_version = Distribution Version (10.3, 3.1, etc) +dnl $ar_distro_major = Distribution Version Major Number (10, 3, etc) +dnl $ar_distro_minor = Distribution Version Minor Number (3, 1, etc) +dnl +AC_DEFUN([AR_GET_DISTRO],[] + [ + AC_MSG_CHECKING(distribution) + ar_distro_name=$(./get_distro.pl NAME) + ar_distro_version=$(./get_distro.pl VERSION) + ar_distro_major=$(./get_distro.pl MAJOR) + ar_distro_minor=$(./get_distro.pl MINOR) + AC_MSG_RESULT([$ar_distro_name $ar_distro_version]) + ] +) diff --git a/apis/rivwebcapi/autogen.sh b/apis/rivwebcapi/autogen.sh new file mode 100755 index 00000000..aa9c127d --- /dev/null +++ b/apis/rivwebcapi/autogen.sh @@ -0,0 +1,46 @@ +#!/bin/sh +## +## (C) Copyright 2002-2003 Fred Gleason +## +## Adapted from './autogen.sh' in the Jack Audio Connection Kit. +## Copyright (C) 2001-2003 Paul Davis, et al. +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of version 2 of the GNU General Public License as +## published by the Free Software Foundation; +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, +## Boston, MA 02111-1307 USA +## + +libtoolize=libtoolize +if which glibtoolize > /dev/null 2>&1; then + libtoolize=glibtoolize +fi + +$libtoolize --force 2>&1 | sed '/^You should/d' || { + echo "libtool failed, exiting..." + exit 1 +} + +aclocal $ACLOCAL_FLAGS || { + echo "aclocal \$ACLOCAL_FLAGS where \$ACLOCAL_FLAGS= failed, exiting..." + exit 1 +} + +automake --foreign --add-missing -Wno-portability || { + echo "automake --add-missing failed, exiting..." + exit 1 +} + +autoconf || { + echo "autoconf failed, exiting..." + exit 1 +} diff --git a/apis/rivwebcapi/configure.ac b/apis/rivwebcapi/configure.ac new file mode 100644 index 00000000..1cbcbc6d --- /dev/null +++ b/apis/rivwebcapi/configure.ac @@ -0,0 +1,98 @@ +dnl configure.ac +dnl +dnl Autoconf configuration for the MingW32 build of rivwebcapi. +dnl +dnl (C) Copyright 2015-2018 Fred Gleason +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License version 2 as +dnl published by the Free Software Foundation. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public +dnl License along with this program; if not, write to the Free Software +dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +dnl +dnl Use autoconf to process this into a configure script + +AC_INIT([rivwebcapi],m4_esyscmd_s(cat ../../PACKAGE_VERSION)) +AM_INIT_AUTOMAKE +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) + +# +# Basic Compiler Checks +# +AC_PROG_CC +AC_PROG_LIBTOOL + +# +# Determine Library API Versioning +# +# From http://www.gnu.org/software/libtool/manual.html#Updating-version-info +# +# 1. Start with version information of 0:0:0 for each libtool library. +# 2. Update the version information only immediately before a public +# release of your software. More frequent updates are unnecessary, +# and only guarantee that the current interface number gets larger +# faster. +# 3. If the library source code has changed at all since the last update, +# then increment 'REVISION' (c:r:a becomes c:r+1:a). +# 4. If any interfaces have been added, removed, or changed since the last +# update, increment 'CURRENT', and set 'REVISION' to 0. +# 5. If any interfaces have been added since the last public release, then +# increment 'AGE'. +# 6. If any interfaces have been removed since the last public release, +# then set 'AGE' to 0. +RIVWEBCAPI_CURRENT=1 +RIVWEBCAPI_REVISION=0 +RIVWEBCAPI_AGE=1 +RIVWEBCAPI_POINT=$(($RIVWEBCAPI_CURRENT - $RIVWEBCAPI_AGE)) + +AC_SUBST(INTERFACE_RIVWEBCAPI_CURRENT,$RIVWEBCAPI_CURRENT) +AC_SUBST(INTERFACE_RIVWEBCAPI_REVISION,$RIVWEBCAPI_REVISION) +AC_SUBST(INTERFACE_RIVWEBCAPI_AGE,$RIVWEBCAPI_AGE) +AC_SUBST(INTERFACE_RIVWEBCAPI_MAJOR,$RIVWEBCAPI_POINT) +AC_SUBST(INTERFACE_RIVWEBCAPI_MINOR,$RIVWEBCAPI_AGE) +AC_SUBST(INTERFACE_RIVWEBCAPI_POINT,$RIVWEBCAPI_REVISION) + +# +# Determine the target architecture +# +AR_GCC_TARGET() +AC_SUBST(VENDOR,$ar_gcc_distro) +AC_SUBST(ARCH,$ar_gcc_arch) +if test $ar_gcc_os = mingw32 ; then + AC_DEFINE(MINGW32,"yes") +fi + +# +# Determine Distro +# +AR_GET_DISTRO() +AC_SUBST(DISTRO,$ar_gcc_distro) + +# +# Check for LibCurl +# +AC_CHECK_HEADER(curl/curl.h,[],[AC_MSG_ERROR([*** LibCurl not found ***])]) + +# +# Check for Expat +# +AC_CHECK_HEADER(expat.h,[],[AC_MSG_ERROR([*** Expat not found ***])]) + +AC_CONFIG_FILES([ \ + rivwebcapi/Makefile \ + tests/Makefile \ + rivwebcapi.pc \ + Makefile \ + ]) +AC_OUTPUT() + +AC_MSG_NOTICE() +AC_MSG_NOTICE(Now enter 'make' to build the software.) +AC_MSG_NOTICE() diff --git a/apis/rivwebcapi/get_distro.pl b/apis/rivwebcapi/get_distro.pl new file mode 100755 index 00000000..7c03a220 --- /dev/null +++ b/apis/rivwebcapi/get_distro.pl @@ -0,0 +1,148 @@ +#!/usr/bin/perl -W + +# get_distro.pl +# +# Try to determine the distribution name and version of the host machine. +# Used as part of the AR_GET_DISTRO() macro. +# +# (C) Copyright 2012,2016 Fred Gleason +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +#USAGE: get_distro.pl NAME|VERSION|MAJOR|MINOR|POINT + +if($ARGV[0] eq "NAME") { + if(!system("test","-f","/etc/SuSE-release")) { + print "SuSE"; + exit 0; + } + if(!system("test","-f","/etc/debian_version")) { + print "Debian"; + exit 0; + } + if(!system("test","-f","/etc/redhat-release")) { + print "RedHat"; + exit 0; + } +} + +if($ARGV[0] eq "VERSION") { + if(!system("test","-f","/etc/SuSE-release")) { + print &GetVersion("/etc/SuSE-release"); + exit 0; + } + if(!system("test","-f","/etc/debian_version")) { + print &GetVersion("/etc/debian_version"); + exit 0; + } + if(!system("test","-f","/etc/redhat-release")) { + print &GetVersion("/etc/redhat-release"); + exit 0; + } +} + +if($ARGV[0] eq "MAJOR") { + if(!system("test","-f","/etc/SuSE-release")) { + print &GetMajor("/etc/SuSE-release"); + exit 0; + } + if(!system("test","-f","/etc/debian_version")) { + print &GetMajor("/etc/debian_version"); + exit 0; + } + if(!system("test","-f","/etc/redhat-release")) { + print &GetMajor("/etc/redhat-release"); + exit 0; + } +} + +if($ARGV[0] eq "MINOR") { + if(!system("test","-f","/etc/SuSE-release")) { + print &GetMinor("/etc/SuSE-release"); + exit 0; + } + if(!system("test","-f","/etc/debian_version")) { + print &GetMinor("/etc/debian_version"); + exit 0; + } + if(!system("test","-f","/etc/redhat-release")) { + print &GetMinor("/etc/redhat-release"); + exit 0; + } +} + +if($ARGV[0] eq "POINT") { + if(!system("test","-f","/etc/SuSE-release")) { + print &GetPoint("/etc/SuSE-release"); + exit 0; + } + if(!system("test","-f","/etc/debian_version")) { + print &GetPoint("/etc/debian_version"); + exit 0; + } + if(!system("test","-f","/etc/redhat-release")) { + print &GetPoint("/etc/redhat-release"); + exit 0; + } +} + +exit 256; + + +sub GetVersion +{ + if(open VERSION,"<",$_[0]) { + my $version=; + my @f0=split " ",$version; + for(my $i=0;$i<@f0;$i++) { + my @f1=split "[.]",$f0[$i]; + if(@f1>1) { + return $f0[$i]; + } + } + } + return ""; +} + + +sub GetMajor +{ + my @f0=split "[.]",&GetVersion($_[0]); + + return $f0[0]; +} + + +sub GetMinor +{ + my @f0=split "[.]",&GetVersion($_[0]); + + if(@f0 ge 2) { + return $f0[1]; + } + return ""; +} + + +sub GetPoint +{ + my @f0=split "[.]",&GetVersion($_[0]); + + if(@f0 ge 3) { + return $f0[2]; + } + return ""; +} diff --git a/apis/rivwebcapi/get_target.sh b/apis/rivwebcapi/get_target.sh new file mode 100755 index 00000000..ad071a06 --- /dev/null +++ b/apis/rivwebcapi/get_target.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# get_target.sh +# +# Return machine target information from gcc(1) +# Used as part of the AR_GCC_TARGET() macro. +# +# (C) Copyright 2012,2016 Fred Gleason +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +$1 -dumpmachine > ./gcc_arch + +case "$3" in + arch) + $2 -F- "// {print \$1}" ./gcc_arch + ;; + distro) + $2 -F- "// {print \$2}" ./gcc_arch + ;; + os) + $2 -F- "// {print \$3}" ./gcc_arch + ;; +esac + +rm -f ./gcc_arch + + +# End of get_target.sh diff --git a/apis/rivwebcapi/rivwebcapi/Makefile.am b/apis/rivwebcapi/rivwebcapi/Makefile.am index 35235932..d7357477 100644 --- a/apis/rivwebcapi/rivwebcapi/Makefile.am +++ b/apis/rivwebcapi/rivwebcapi/Makefile.am @@ -18,7 +18,7 @@ ## ## Use automake to process this into a Makefile.in -AM_CFLAGS = -I$(top_srcdir)/apis/rivwebcapi +AM_CFLAGS = -I .. lib_LTLIBRARIES = librivwebcapi.la dist_librivwebcapi_la_SOURCES = rd_addcart.c rd_addcart.h \ rd_addcut.c rd_addcut.h \ diff --git a/apis/rivwebcapi/rivwebcapi/rd_common.h b/apis/rivwebcapi/rivwebcapi/rd_common.h index 4376f804..63661e11 100644 --- a/apis/rivwebcapi/rivwebcapi/rd_common.h +++ b/apis/rivwebcapi/rivwebcapi/rd_common.h @@ -33,8 +33,8 @@ #define snprintf _snprintf #define strcasecmp _stricmp #define sscanf_s sscanf -#endif // MINGW32 #define VERSION "0.0.6" +#endif // MINGW32 #endif /* #define RIVC_DEBUG_OUT Uncomment for stderr output */ diff --git a/apis/rivwebcapi/tests/Makefile.am b/apis/rivwebcapi/tests/Makefile.am index d6ef9ce5..a9f8dd10 100644 --- a/apis/rivwebcapi/tests/Makefile.am +++ b/apis/rivwebcapi/tests/Makefile.am @@ -18,8 +18,8 @@ ## ## Use automake to process this into a Makefile.in -AM_CFLAGS = -Wall -I$(top_srcdir)/apis/rivwebcapi -LIBS = -L$(top_srcdir)/apis/rivwebcapi/rivwebcapi +AM_CFLAGS = -Wall -I$ .. +LIBS = -L$ ../rivwebcapi noinst_PROGRAMS = listgroups_test \ listgroup_test \ listcarts_test \