Web lists-archives.com

Re: Monit Compilation Errors




Hello again,

Well,your are right, I modified the sources to port monit to cygwin, as I
did correctly in version 5.10.

Below you will find a quick how-to (and at the end the required diff files).

##############################################################
CYGWIN PACKGAGING
##############################################################

0- Install Cygwin via setup-x86_64 or setup-x86 from https://www.cygwin.com

1- The following packages are required from the Cygwin:

Devel Tree:
make, autoconf,automake,gcc-core,bison,libtool,flex, cygwin32-zlib,
zlib-devel

Libs Tree:
libcrypt-devel


    Select also all the required dependecies when installing

##############################################################
MONIT DOWNLOAD
##############################################################

2- For better success, start cygwin.bat or cygwin Terminal with
Administration Elevation Privileges "Run as Administrator":

3- Download monit source from https://mmonit.com/monit/ and copy it to your
"cywin forlder"/tmp:

$ cd /tmp
$ tar xvfz monit-5.25.1.tar.gz
$ cd monit-5.25.1


##############################################################
CREATE SYSTEM DEPENDENCIES FILES
##############################################################

Copy the Minimal System Dependencies from sysdep_UNKNOWN to the cygwin
architecture:

cp file /src/device/sysdep_UNKNOWN.c /src/device/sysdep_CYGWIN.c
cp file /src/process/sysdep_UNKNOWN.c /src/process/sysdep_CYGWIN.c


##############################################################
ADAPT CONIFUGRE.AC TO CYGWIN in # Architecture/OS part of code
##############################################################

For configure.ac:
###### CYGWIN ADDED LINES START #####
elif test "${architecture:0:6}" = "CYGWIN"  # CYGWIN_NT-6.1 -> CYGWIN
(Array slice)
then
    ARCH="CYGWIN"
    CFLAGS="$CFLAGS -D _REENTRANT"
### LDFLAGS="$LDFLAGS -lcrypt"
###    CFLAGS="-E $CFLAGS -D _REENTRANT"
###### CYGWIN ADDED LINES END ######

For libmonit configure.ac:
###### CYGWIN ADDED LINES START #####
elif test "${architecture:0:6}" = "CYGWIN"  # CYGWIN_NT-6.1 -> CYGWIN
(Array slice)
then
    CFLAGS="$CFLAGS -D _REENTRANT"
###    CFLAGS="-E $CFLAGS -D _REENTRANT"
    AC_DEFINE([CYGWIN], 1, [Define to 1 if the system is CYGWIN])
###### CYGWIN ADDED LINES END ######

##############################################################
ADAPT MONIT.H
##############################################################
In monit.h add:

#ifdef CYGWIN

#ifndef ICMP_ECHO
#define ICMP_ECHO 8
#endif

#ifndef ICMP_ECHOREPLY
#define ICMP_ECHOREPLY 20
#endif

#endif

##############################################################
ADAPT NET.C
##############################################################
In net.c modify icmp_echo function:

#ifdef CYGWIN
double icmp_echo(const char *hostname, Socket_Family family, Outgoing_T
*outgoing, int size, int timeout, int maxretries) {
    return -1;
}
#else
double icmp_echo(const char *hostname, Socket_Family family, Outgoing_T
*outgoing, int size, int timeout, int maxretries) {
        ASSERT(hostname);

....


##############################################################
COMPILATION
##############################################################

$ ./bootstrap && autoreconf -i -f && automake -acf && ./configure
--without-pam --without-ssl --without-ipv6 --without-largefiles
--without-zlib
   Success bootstrapping libmonit
   Success bootstrapping Monit ...

+------------------------------------------------------------+
| License:                                                   |
| This is Open Source Software and use is subject to the GNU |
| AFFERO GENERAL PUBLIC LICENSE version 3, available in this |
| distribution in the file COPYING.                          |
|                                                            |
| By continuing this installation process, you are bound by  |
| the terms of this license agreement. If you do not agree   |
| with the terms of this license, you must abort the         |
| installation process at this point.                        |
+------------------------------------------------------------+
| Libmonit is configured as follows:                         |
|                                                            |
|   Optimized:                                    DISABLED   |
|   Profiling:                                    DISABLED   |
|   Compression:                                  DISABLED   |
+------------------------------------------------------------+

Monit Build Information:

                Architecture: CYGWIN
              Compiler flags: -Wno-address -Wno-pointer-sign -g -O2 -Wall
-Wunused -Wno-unused-label -funsigned-char -D_GNU_SOURCE -std=c99 -D
_REENTRANT
                Linker flags: -lpthread -lcrypt -lresolv
           pid file location: /var/run
           Install directory: /usr/local

+------------------------------------------------------------+
| License:                                                   |
| This is Open Source Software and use is subject to the GNU |
| AFFERO GENERAL PUBLIC LICENSE version 3, available in this |
| distribution in the file COPYING.                          |
|                                                            |
| By continuing this installation process, you are bound by  |
| the terms of this license agreement. If you do not agree   |
| with the terms of this license, you must abort the         |
| installation process at this point.                        |
+------------------------------------------------------------+
| Monit has been configured with the following options:      |
|                                                            |
|   Compression:                                  ENABLED    |
|   PAM support:                                  DISABLED   |
|   SSL support:                                  DISABLED   |
|   Large files support:                          DISABLED   |
|   IPv6 support:                                 DISABLED   |
|   Optimized:                                    DISABLED   |
|   Profiling:                                    DISABLED   |




##############################################################################
MAKE MONIT
##############################################################################
NOTE: disable your Antivirus Software to successfully run the program !!!
NOTE: make clean can help if some compilation has tried and failed

$ make clean
& make

gcc -DHAVE_CONFIG_H -I. -I./src    -DCYGWIN
-DSYSCONFDIR="\"/usr/local/etc\"" -I./src -I./src/device -I./src/http
-I./src/notification -I./src/process -I./src/protocols -I./src/ssl
-I./src/terminal -I./libmonit/src   -Wno-address -Wno-pointer-sign -g -O2
-Wall -Wunused -Wno-unused-label -funsigned-char -D_GNU_SOURCE -std=c99 -D
_REENTRANT -c -o src/y.tab.o src/y.tab.c
<command-line>:0:6: error: expected identifier or ‘(’ before numeric
constant
src/monit.h:647:19: note: in expansion of macro ‘unix’
                 } unix;
                   ^~~~
<command-line>:0:6: error: expected identifier or ‘(’ before numeric
constant
src/monit.h:1291:27: note: in expansion of macro ‘unix’
                         } unix;
                           ^~~~
In file included from src/net.h:30:0,
                 from src/p.y:120:
src/monit.h:1292:17: warning: no semicolon at end of struct or union
                 } socket;
                 ^
src/p.y: In function ‘yyparse’:
<command-line>:0:6: error: expected identifier before numeric constant
src/p.y:1059:42: note: in expansion of macro ‘unix’
                         Run.httpd.socket.unix.path = $2;
                                          ^~~~
<command-line>:0:6: error: expected identifier before numeric constant
src/p.y:1069:42: note: in expansion of macro ‘unix’
                         Run.httpd.socket.unix.uid = get_uid($2, 0);
                                          ^~~~
<command-line>:0:6: error: expected identifier before numeric constant
src/p.y:1074:42: note: in expansion of macro ‘unix’
                         Run.httpd.socket.unix.gid = get_gid($2, 0);
                                          ^~~~
<command-line>:0:6: error: expected identifier before numeric constant
src/p.y:1079:42: note: in expansion of macro ‘unix’
                         Run.httpd.socket.unix.uid = get_uid(NULL, $2);
                                          ^~~~
<command-line>:0:6: error: expected identifier before numeric constant
src/p.y:1083:42: note: in expansion of macro ‘unix’
                         Run.httpd.socket.unix.gid = get_gid(NULL, $2);
                                          ^~~~
<command-line>:0:6: error: expected identifier before numeric constant
src/p.y:1087:42: note: in expansion of macro ‘unix’
                         Run.httpd.socket.unix.permission = check_perm($2);
                                          ^~~~
<command-line>:0:6: error: expected identifier before numeric constant
src/p.y:1477:40: note: in expansion of macro ‘unix’
                         portset.target.unix.pathname = $2;
                                        ^~~~
src/p.y: In function ‘addport’:
<command-line>:0:6: error: expected identifier before numeric constant
src/p.y:3380:27: note: in expansion of macro ‘unix’
                 p->target.unix.pathname = port->target.unix.pathname;
                           ^~~~
make[2]: *** [Makefile:752: src/y.tab.o] Error 1
make[2]: Leaving directory '/tmp/monit-5.25.1'
make[1]: *** [Makefile:819: all-recursive] Error 1
make[1]: Leaving directory '/tmp/monit-5.25.1'
make: *** [Makefile:531: all] Error 2


##############################################################################
DIFF FILES (sources are configure.ac.bck)
##############################################################################

diff configure.ac configure.ac.bck
622,634d621
<
<
<
< ###### CYGWIN ADDED LINES START #####
< elif test "${architecture:0:6}" = "CYGWIN"  # CYGWIN_NT-6.1 -> CYGWIN
(Array slice)
< then
<       ARCH="CYGWIN"
<       CFLAGS="$CFLAGS -D _REENTRANT"
< ### LDFLAGS="$LDFLAGS -lcrypt"
< ###   CFLAGS="-E $CFLAGS -D _REENTRANT"
< ###### CYGWIN ADDED LINES END ######

$ cd libmonit
$ diff configure.ac configure.ac.bck
249,260d248
<
<
< ###### CYGWIN ADDED LINES START #####
< elif test "${architecture:0:6}" = "CYGWIN"  # CYGWIN_NT-6.1 -> CYGWIN
(Array slice)
< then
<       CFLAGS="$CFLAGS -D _REENTRANT"
< ###   LDFLAGS="$LDFLAGS -lcrypt"
< ###   CFLAGS="-E $CFLAGS -D _REENTRANT"
<       AC_DEFINE([CYGWIN], 1, [Define to 1 if the system is CYGWIN])
< ###### CYGWIN ADDED LINES END ######
<
<
262c250
<       AC_MSG_ERROR([Architecture not supported: ${architecture}])
---
>    AC_MSG_ERROR([Architecture not supported: ${architecture}])

$cd ..
$ cd src

$ diff monit.h monit.h.bck
26,41d25
< /* CYGWIN */
< #ifdef CYGWIN
<
< #ifndef ICMP_ECHO
< #define ICMP_ECHO 8
< #endif
<
< #ifndef ICMP_ECHOREPLY
< #define ICMP_ECHOREPLY 20
< #endif
<
< #endif
< /* CYGWIN */
<
<
<
$ diff net.c net.c.bck
459,466d458
< /* CYGWIN */
<
< #ifdef CYGWIN
< double icmp_echo(const char *hostname, Socket_Family family, Outgoing_T
*outgoing, int size, int timeout, int maxretries) {
<       return -1;
< }
< #else
< /* CYGWIN */
548,550d539
<
<
< #endif



2018-01-15 15:27 GMT+01:00 Ken Brown <kbrown@xxxxxxxxxxx>:

> On 1/15/2018 7:22 AM, Kizito Porta Balanyà wrote:
>
>> Hello all,
>>
>> I'm trying to compile the last version of MONIT and I get some errors that
>> I can not solve.
>>
>> Basically I get errors like: expected identifier or ‘(’ before numeric
>> constant, but reviewing the code I don't see any wrong, beside that the
>> sources compile correctly with Linux, AIX, etc ...
>>
>> Can you help me? Do you have any clue?
>>
>> I show you the errors obtained:
>>
>> gcc -DHAVE_CONFIG_H -I. -I./src    -DCYGWIN
>> -DSYSCONFDIR="\"/usr/local/etc\"" -I./src -I./src/device -I./src/http
>> -I./src/process -I./src/protocols -I./src/ssl -I./libmonit/src
>> -Wno-address -Wno-pointer-sign -g -O2 -Wall -Wunused -Wno-unused-label
>> -funsigned-char -D_GNU_SOURCE -std=c99 -D _REENTRANT -c -o src/y.tab.o
>> src/y.tab.c
>> <command-line>:0:6: error: expected identifier or ‘(’ before numeric
>> constant
>> src/monit.h:581:19: note: in expansion of macro ‘unix’
>>                   } unix;
>>                     ^~~~
>> <command-line>:0:6: error: expected identifier or ‘(’ before numeric
>> constant
>> src/monit.h:1129:27: note: in expansion of macro ‘unix’
>>                           } unix;
>>                             ^~~~
>> In file included from src/net.h:30:0,
>>                   from src/p.y:116:
>> src/monit.h:1130:17: warning: no semicolon at end of struct or union
>>                   } socket;
>>                   ^
>> src/p.y: In function ‘yyparse’:
>> <command-line>:0:6: error: expected identifier before numeric constant
>> src/p.y:740:42: note: in expansion of macro ‘unix’
>>                           Run.httpd.socket.unix.path = $4;
>>                                            ^~~~
>> <command-line>:0:6: error: expected identifier before numeric constant
>> src/p.y:1154:40: note: in expansion of macro ‘unix’
>>                           portset.target.unix.pathname = $2;
>>                                          ^~~~
>> src/p.y: In function ‘addport’:
>> <command-line>:0:6: error: expected identifier before numeric constant
>> src/p.y:2765:27: note: in expansion of macro ‘unix’
>>                   p->target.unix.pathname = port->target.unix.pathname;
>>
>
> I tried to reproduce the problem, but I think you must be using different
> sources than what I found.  I downloaded monit-5.25.1.tar.gz from
> https://mmonit.com/monit/ and found that I couldn't configure it:
>
> $ ./bootstrap
> [...]
>
> $ ./configure --without-pam
> [...]
> configure: error: Architecture not supported: CYGWIN_NT-10.0-WOW
> configure: error: ./configure failed for libmonit
>
> Also, the line numbers in my sources differ from those in your error
> messages.  Could you say where you got your sources and how you tried to
> build?
>
> Ken
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple