Skip to content

Commit 261b18a

Browse files
authored
Merge pull request #3489 from dougnazar/misc_aix
Fix minor issues to compile on AIX
2 parents 7853e76 + 65fef1a commit 261b18a

12 files changed

Lines changed: 66 additions & 28 deletions

File tree

Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ install-fanout-cleanup: install-recursive @dotMAKE@
137137
touch-include-all-nut_version-generated.timestamp:
138138
@[ -s include/nut_version.h ]
139139
@touch -r include/nut_version.h -d '-10 seconds' include/.all.nut_version-generated.timestamp 2>/dev/null && exit ; \
140-
touch -d '1970-01-01T00:00:00' include/.all.nut_version-generated.timestamp && exit ; \
140+
touch -t '197001010000.00' include/.all.nut_version-generated.timestamp && exit ; \
141141
touch include/.all.nut_version-generated.timestamp
142142

143143
touch-clients-all-libupsclient_version-generated.timestamp:
144144
@[ -s clients/libupsclient-version.h ]
145145
@touch -r clients/libupsclient-version.h -d '-10 seconds' clients/.all.libupsclient_version-generated.timestamp 2>/dev/null && exit ; \
146-
touch -d '1970-01-01T00:00:00' clients/.all.libupsclient_version-generated.timestamp && exit ; \
146+
touch -t '197001010000.00' clients/.all.libupsclient_version-generated.timestamp && exit ; \
147147
touch clients/.all.libupsclient_version-generated.timestamp
148148

149149
touch-docs-man-all-linkman-generated.timestamp:
@@ -153,7 +153,7 @@ touch-docs-man-all-linkman-generated.timestamp:
153153
else \
154154
touch -r docs/man/linkman-driver-names.txt -d '-10 seconds' docs/man/.all.nut_linkman-generated.timestamp 2>/dev/null && exit ; \
155155
fi ; \
156-
touch -d '1970-01-01T00:00:00' docs/man/.all.nut_linkman-generated.timestamp && exit ; \
156+
touch -t '197001010000.00' docs/man/.all.nut_linkman-generated.timestamp && exit ; \
157157
touch docs/man/.all.nut_linkman-generated.timestamp
158158

159159
# Verbosity for fanout rule tracing; 0/1 (or "default" that may auto-set

clients/upsc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ int main(int argc, char **argv)
549549
/* Formal do_upsconf_args implementation to satisfy linker on AIX */
550550
#if (defined NUT_PLATFORM_AIX)
551551
void do_upsconf_args(char *upsname, char *var, char *val) {
552+
NUT_UNUSED_VARIABLE(upsname);
553+
NUT_UNUSED_VARIABLE(var);
554+
NUT_UNUSED_VARIABLE(val);
552555
fatalx(EXIT_FAILURE, "INTERNAL ERROR: formal do_upsconf_args called");
553556
}
554557
#endif /* end of #if (defined NUT_PLATFORM_AIX) */

clients/upscmd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ int main(int argc, char **argv)
559559
/* Formal do_upsconf_args implementation to satisfy linker on AIX */
560560
#if (defined NUT_PLATFORM_AIX)
561561
void do_upsconf_args(char *upsname, char *var, char *val) {
562+
NUT_UNUSED_VARIABLE(upsname);
563+
NUT_UNUSED_VARIABLE(var);
564+
NUT_UNUSED_VARIABLE(val);
562565
fatalx(EXIT_FAILURE, "INTERNAL ERROR: formal do_upsconf_args called");
563566
}
564567
#endif /* end of #if (defined NUT_PLATFORM_AIX) */

clients/upslog.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,9 @@ int main(int argc, char **argv)
10951095
/* Formal do_upsconf_args implementation to satisfy linker on AIX */
10961096
#if (defined NUT_PLATFORM_AIX)
10971097
void do_upsconf_args(char *upsname, char *var, char *val) {
1098+
NUT_UNUSED_VARIABLE(upsname);
1099+
NUT_UNUSED_VARIABLE(var);
1100+
NUT_UNUSED_VARIABLE(val);
10981101
fatalx(EXIT_FAILURE, "INTERNAL ERROR: formal do_upsconf_args called");
10991102
}
11001103
#endif /* end of #if (defined NUT_PLATFORM_AIX) */

clients/upsrw.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,9 @@ int main(int argc, char **argv)
817817
/* Formal do_upsconf_args implementation to satisfy linker on AIX */
818818
#if (defined NUT_PLATFORM_AIX)
819819
void do_upsconf_args(char *upsname, char *var, char *val) {
820+
NUT_UNUSED_VARIABLE(upsname);
821+
NUT_UNUSED_VARIABLE(var);
822+
NUT_UNUSED_VARIABLE(val);
820823
fatalx(EXIT_FAILURE, "INTERNAL ERROR: formal do_upsconf_args called");
821824
}
822825
#endif /* end of #if (defined NUT_PLATFORM_AIX) */

configure.ac

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ AS_IF([test ! -d "${PIDPATH}" -o -h "${PIDPATH}" && test -d "/run" -a ! -h "/run
525525

526526
AC_CHECK_PROGS([GETENT], [getent], [])
527527
AC_CHECK_PROGS([ID], [id], [])
528+
AC_CHECK_PROGS([LSGROUP], [lsgroup], [])
528529

529530
PROBE_OS_USER="false"
530531
PROBE_OS_GROUP="false"
@@ -534,20 +535,24 @@ AS_IF([test x"${GETENT}" != x], [
534535
],[
535536
AS_IF([test x"${ID}" != x], [
536537
PROBE_OS_USER="${ID} -u "
537-
AS_IF([test -r "/etc/groups"], [
538-
dnl FIXME: For command prefix usage like used in this
539-
dnl script, we might be better off defining a shell
540-
dnl function and referring to it. Grep would catch
541-
dnl also user names that have a group as secondary!
542-
PROBE_OS_GROUP="cat /etc/groups | ${GREP} -w "
538+
AS_IF([test x"${LSGROUP}" != x], [
539+
PROBE_OS_GROUP="${LSGROUP} "
543540
], [
544-
dnl This shows groups of a USER with specified name!
545-
dnl But to probe for cases where string names are
546-
dnl same (e.g. "nut" or "ups") this might be good
547-
dnl enough.
548-
PROBE_OS_GROUP="${ID} -g "
541+
AS_IF([test -r "/etc/groups"], [
542+
dnl FIXME: For command prefix usage like used in this
543+
dnl script, we might be better off defining a shell
544+
dnl function and referring to it. Grep would catch
545+
dnl also user names that have a group as secondary!
546+
PROBE_OS_GROUP="cat /etc/groups | ${GREP} -w "
547+
], [
548+
dnl This shows groups of a USER with specified name!
549+
dnl But to probe for cases where string names are
550+
dnl same (e.g. "nut" or "ups") this might be good
551+
dnl enough.
552+
PROBE_OS_GROUP="${ID} -g "
553+
])
554+
AC_MSG_WARN([Can not PROPERLY check existence of group accounts on this system, but can try best-effort])
549555
])
550-
AC_MSG_WARN([Can not PROPERLY check existence of group accounts on this system, but can try best-effort])
551556
],[
552557
AC_MSG_WARN([Can not check existence of user and group accounts on this system])
553558
])
@@ -1698,12 +1703,13 @@ AC_CACHE_CHECK([for %zu as PRIuSIZE],
16981703
[ac_cv_printfmt_zu],
16991704
[AX_RUN_OR_LINK_IFELSE(
17001705
[AC_LANG_PROGRAM([$CODE_STRINGINCL
1706+
#include <stdio.h>
17011707
#include <stdlib.h>
17021708
],
17031709
[[size_t n = 123;
17041710
char buf[64];
17051711
snprintf(buf, sizeof(buf), "%zu", n);
1706-
return !strcmp(buf, "123");
1712+
return strcmp(buf, "123");
17071713
]])],
17081714
[ac_cv_printfmt_zu=yes], [ac_cv_printfmt_zu=no]
17091715
)])

drivers/powervar_cx_ser.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,20 @@ void upsdrv_initups(void)
142142
ser_set_speed(upsfd, device_path, B38400);
143143
upsdebugx (4, "Serial baud set to 38400.");
144144
}
145+
#if defined(B57600)
145146
else if (ulBaud == 57600)
146147
{
147148
ser_set_speed(upsfd, device_path, B57600);
148149
upsdebugx (4, "Serial baud set to 57600.");
149150
}
151+
#endif
152+
#if defined(B115200)
150153
else if (ulBaud == 115200) /* The only other baud known to be available. */
151154
{
152155
ser_set_speed(upsfd, device_path, B115200);
153156
upsdebugx (4, "Serial baud set to 115200.");
154157
}
158+
#endif
155159
else
156160
{
157161
upsdebugx (4, "Serial baud not set!! (%" PRIu32 ").", ulBaud);

include/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#endif /* WIN32 */
3939

4040
/* Need this on AIX when using xlc to get alloca */
41-
#ifdef _AIX
41+
#if defined(_AIX) && defined(__IBMC__)
4242
#pragma alloca
4343
#endif /* _AIX */
4444

include/timehead.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static inline struct tm *gmtime_r( const time_t *timer, struct tm *buf ) {
8181
# define timegm(tm) _mkgmtime(tm)
8282
# else
8383
# ifdef WANT_TIMEGM_FALLBACK
84+
time_t timegm_fallback(struct tm const* t);
8485
/* use an implementation from fallbacks in NUT codebase */
8586
# define timegm(tm) timegm_fallback(tm)
8687
# else

m4/nut_compiler_family.m4

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ dnl NOTE: this option should not be passed via the fourth argument of the macro,
111111
dnl or it ends up in the flags too, possibly during the "pop"; have to use the
112112
dnl GOOD_FLAG instead :\
113113
COMPILERFLAG="$1"
114+
dnl GCC will silently accept warning disable options, but then if there is an issue, warn about the option, i.e.
115+
dnl "cc1: note: unrecognized command-line option '-Wno-unknown-warning-option' may have been intended to silence earlier diagnostics"
116+
dnl Instead try the enable option to check if it is valid
117+
COMPILERTESTFLAG="`echo $1 | sed 's/^-Wno-/-W/'`"
114118
115119
dnl We also try to run an actual build since tools called from that might
116120
dnl complain if they are forwarded unknown flags accepted by the front-end.
@@ -119,14 +123,22 @@ dnl complain if they are forwarded unknown flags accepted by the front-end.
119123
AC_MSG_NOTICE([Starting check compile flag for '${COMPILERFLAG}'; now CFLAGS='${CFLAGS}' and CXXFLAGS='${CXXFLAGS}'])
120124
121125
AC_LANG_PUSH([C])
126+
dnl Use a simple program with out previous #defines so we don't cause errors on clang with -Wreserved-identifier
127+
m4_pushdef([AC_LANG_CONFTEST(C)], [m4_ifdef([AC_LANG_DEFINES_PROVIDED], [AC_LANG_DEFINES_PROVIDED])
128+
cat << _ACEOF > conftest.$ac_ext
129+
int main(void) { return 0; }
130+
_ACEOF
131+
])
122132
GOOD_FLAG=no
123-
AX_CHECK_COMPILE_FLAG([${COMPILERFLAG}],
133+
# CFLAGS="-Werror $CFLAGS"
134+
AX_CHECK_COMPILE_FLAG([${COMPILERTESTFLAG}],
124135
[CFLAGS="-Werror $NUT_SAVED_CFLAGS ${COMPILERFLAG}"
125136
AC_MSG_CHECKING([whether the flag '${COMPILERFLAG}' is still supported in CC linker mode])
126137
AX_RUN_OR_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
127138
[GOOD_FLAG=yes],[])
128139
AC_MSG_RESULT([${GOOD_FLAG}])
129140
], [], [])
141+
m4_popdef([AC_LANG_CONFTEST(C)])
130142
AC_LANG_POP([C])
131143
AS_IF([test x"${GOOD_FLAG}" = xyes],
132144
[CFLAGS="$NUT_SAVED_CFLAGS ${COMPILERFLAG}"],
@@ -135,14 +147,22 @@ dnl complain if they are forwarded unknown flags accepted by the front-end.
135147
AC_MSG_NOTICE([${GOOD_FLAG} for C '${COMPILERFLAG}'; now CFLAGS=${CFLAGS}])
136148
137149
AC_LANG_PUSH([C++])
150+
dnl Use a simple program with out previous #defines so we don't cause errors on clang with -Wreserved-identifier
151+
m4_pushdef([AC_LANG_CONFTEST(C++)], [m4_ifdef([AC_LANG_DEFINES_PROVIDED], [AC_LANG_DEFINES_PROVIDED])
152+
cat << _ACEOF > conftest.$ac_ext
153+
int main(void) { return 0; }
154+
_ACEOF
155+
])
138156
GOOD_FLAG=no
139-
AX_CHECK_COMPILE_FLAG([${COMPILERFLAG}],
157+
# CXXFLAGS="-Werror $CXXFLAGS"
158+
AX_CHECK_COMPILE_FLAG([${COMPILERTESTFLAG}],
140159
[CXXFLAGS="-Werror $NUT_SAVED_CXXFLAGS ${COMPILERFLAG}"
141160
AC_MSG_CHECKING([whether the flag '${COMPILERFLAG}' is still supported in CXX linker mode])
142161
AX_RUN_OR_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
143162
[GOOD_FLAG=yes],[])
144163
AC_MSG_RESULT([${GOOD_FLAG}])
145164
], [], [])
165+
m4_popdef([AC_LANG_CONFTEST(C++)])
146166
AC_LANG_POP([C++])
147167
AS_IF([test x"${GOOD_FLAG}" = xyes],
148168
[CXXFLAGS="$NUT_SAVED_CXXFLAGS ${COMPILERFLAG}"],

0 commit comments

Comments
 (0)