xref: /freebsd/contrib/ntp/sntp/m4/os_cflags.m4 (revision b626f5a73a48f44a31a200291b141e1da408a2ff)
12b15cb3dSCy Schubertdnl ######################################################################
22b15cb3dSCy Schubertdnl Specify additional compile options based on the OS and the compiler
32b15cb3dSCy SchubertAC_DEFUN([NTP_OS_CFLAGS], [
42b15cb3dSCy Schubert    AC_MSG_CHECKING([additional compiler flags])
5*9034852cSGleb Smirnoff    # allow ntp_os_cflags to be preset to skip this stuff
62b15cb3dSCy Schubert    case "${ntp_os_cflags+set}" in
72b15cb3dSCy Schubert     set)
82b15cb3dSCy Schubert	;;
92b15cb3dSCy Schubert     *)
102b15cb3dSCy Schubert	ntp_os_cflags=
112b15cb3dSCy Schubert	case "$host_os" in
122b15cb3dSCy Schubert	 aix[[1-3]]*)
132b15cb3dSCy Schubert	    ;;
142b15cb3dSCy Schubert	 aix4.[[0-2]]*)
152b15cb3dSCy Schubert	    # turn on additional headers
162b15cb3dSCy Schubert	    ntp_os_cflags="-D_XOPEN_EXTENDED_SOURCE"
172b15cb3dSCy Schubert	    ;;
182b15cb3dSCy Schubert	 aix5.3*)
192b15cb3dSCy Schubert	    # avoid circular dependencies in yp headers, and more
202b15cb3dSCy Schubert	    ntp_os_cflags="-DHAVE_BAD_HEADERS -D_XOPEN_EXTENDED_SOURCE"
212b15cb3dSCy Schubert	    ntp_os_cflags="${ntp_os_cflags} -D_USE_IRS -D_MSGQSUPPORT"
222b15cb3dSCy Schubert	    ;;
232b15cb3dSCy Schubert	 aix*)
242b15cb3dSCy Schubert	    # XXX Only verified thru AIX6.
252b15cb3dSCy Schubert	    # aix7 seems to need a different XOPEN_SOURCE_EXTENDED thing.
262b15cb3dSCy Schubert	    # avoid circular dependencies in yp headers
272b15cb3dSCy Schubert	    # _XOPEN_SOURCE=500 = X/Open 5: POSIX 1995
282b15cb3dSCy Schubert	    # _XOPEN_SOURCE=600 = X/Open 6: POSIX 2004
292b15cb3dSCy Schubert	    # _XOPEN_SOURCE=700 = X/Open 7: POSIX 2008
302b15cb3dSCy Schubert	    ntp_os_cflags="-DHAVE_BAD_HEADERS -D_XOPEN_SOURCE=600"
312b15cb3dSCy Schubert	    ntp_os_cflags="${ntp_os_cflags} -D_USE_IRS"
322b15cb3dSCy Schubert	    ;;
332b15cb3dSCy Schubert	 amigaos)
342b15cb3dSCy Schubert	    ntp_os_cflags="-DSYS_AMIGA"
352b15cb3dSCy Schubert	    ;;
362b15cb3dSCy Schubert	 darwin*|macosx*|rhapsody*)
372b15cb3dSCy Schubert	    ntp_os_cflags="-D_P1003_1B_VISIBLE"
382b15cb3dSCy Schubert	    ;;
392b15cb3dSCy Schubert	 hpux10.*)		# at least for hppa2.0-hp-hpux10.20
402b15cb3dSCy Schubert	    case "$GCC" in
412b15cb3dSCy Schubert	     yes)
422b15cb3dSCy Schubert		;;
432b15cb3dSCy Schubert	     *)
442b15cb3dSCy Schubert		# use Ansi compiler on HPUX, and some -Wp magic
452b15cb3dSCy Schubert		ntp_os_cflags="-Ae -Wp,-H18816"
462b15cb3dSCy Schubert		;;
472b15cb3dSCy Schubert	    esac
48276da39aSCy Schubert	    ntp_os_cflags="${ntp_os_cflags} -D_HPUX_SOURCE -D__STDC_VERSION__=199901L"
492b15cb3dSCy Schubert	    ;;
502b15cb3dSCy Schubert	 hpux*)
512b15cb3dSCy Schubert	    case "$GCC" in
522b15cb3dSCy Schubert	     yes)
532b15cb3dSCy Schubert		;;
542b15cb3dSCy Schubert	     *)
552b15cb3dSCy Schubert		# use Ansi compiler on HPUX
562b15cb3dSCy Schubert		ntp_os_cflags="-Ae"
572b15cb3dSCy Schubert	    esac
58276da39aSCy Schubert	    ntp_os_cflags="${ntp_os_cflags} -D_HPUX_SOURCE -D__STDC_VERSION__=199901L"
592b15cb3dSCy Schubert	    ;;
602b15cb3dSCy Schubert	 irix6*)
612b15cb3dSCy Schubert	    case "$CC" in
622b15cb3dSCy Schubert	     cc)
632b15cb3dSCy Schubert		# do not use 64-bit compiler
642b15cb3dSCy Schubert		ntp_os_cflags="-n32 -mips3 -Wl,-woff,84"
652b15cb3dSCy Schubert	    esac
662b15cb3dSCy Schubert	    ;;
672b15cb3dSCy Schubert	 nextstep3)
682b15cb3dSCy Schubert	    ntp_os_cflags="-posix"
692b15cb3dSCy Schubert	    ;;
702b15cb3dSCy Schubert	 solaris1*|solaris2.[[0-5]]|solaris2.5.*)
712b15cb3dSCy Schubert	    ;;
722b15cb3dSCy Schubert	 sunos[[34]]*|sunos5.[[0-5]]|sunos5.5.*)
732b15cb3dSCy Schubert	    ;;
742b15cb3dSCy Schubert	 solaris2*|sunos5*)
752b15cb3dSCy Schubert	    # turn on 64-bit file offset interface
762b15cb3dSCy Schubert	    ntp_os_cflags="-D_LARGEFILE64_SOURCE"
772b15cb3dSCy Schubert	    ;;
782b15cb3dSCy Schubert	 vxworks*)
792b15cb3dSCy Schubert	    case "$build" in
802b15cb3dSCy Schubert	     $host)
812b15cb3dSCy Schubert		;;
822b15cb3dSCy Schubert	     *)
832b15cb3dSCy Schubert		# Quick and dirty sanity check
842b15cb3dSCy Schubert		case "$VX_KERNEL" in
852b15cb3dSCy Schubert		 '')
862b15cb3dSCy Schubert		    AC_MSG_ERROR([See html/build/hints/vxworks.html])
872b15cb3dSCy Schubert		esac
882b15cb3dSCy Schubert		ntp_os_cflags="-DSYS_VXWORKS"
892b15cb3dSCy Schubert	    esac
902b15cb3dSCy Schubert	    ;;
912b15cb3dSCy Schubert	esac
922b15cb3dSCy Schubert    esac
93*9034852cSGleb Smirnoff    case "$ntp_os_cflags" in
942b15cb3dSCy Schubert     '')
952b15cb3dSCy Schubert	ntp_os_cflags_msg="none needed"
962b15cb3dSCy Schubert	;;
972b15cb3dSCy Schubert     *)
982b15cb3dSCy Schubert	ntp_os_cflags_msg="$ntp_os_cflags"
992b15cb3dSCy Schubert    esac
1002b15cb3dSCy Schubert    CFLAGS_NTP="$CFLAGS_NTP $ntp_os_cflags"
1012b15cb3dSCy Schubert    AC_MSG_RESULT([$ntp_os_cflags_msg])
1022b15cb3dSCy Schubert    AS_UNSET([ntp_os_cflags_msg])
103*9034852cSGleb Smirnoff    ###
104*9034852cSGleb Smirnoff    AC_MSG_CHECKING([additional linker flags])
105*9034852cSGleb Smirnoff    # HMS: The following might still need tweaking
106*9034852cSGleb Smirnoff    # allow ntp_os_ldflags to be preset to skip this stuff
107*9034852cSGleb Smirnoff    case "${ntp_os_ldflags+set}" in
108*9034852cSGleb Smirnoff     set)
109*9034852cSGleb Smirnoff	;;
110*9034852cSGleb Smirnoff     *)
111*9034852cSGleb Smirnoff	ntp_os_ldflags=
112*9034852cSGleb Smirnoff	case "$host_os" in
113*9034852cSGleb Smirnoff	 hpux*)
114*9034852cSGleb Smirnoff	    case "$GCC" in
115*9034852cSGleb Smirnoff	     yes)
116*9034852cSGleb Smirnoff		ntp_os_ldflags="-Wl,+allowdups"
117*9034852cSGleb Smirnoff		;;
118*9034852cSGleb Smirnoff	    esac
119*9034852cSGleb Smirnoff	    ;;
120*9034852cSGleb Smirnoff	esac
121*9034852cSGleb Smirnoff	;;
122*9034852cSGleb Smirnoff    esac
123*9034852cSGleb Smirnoff    case "$ntp_os_ldflags" in
124*9034852cSGleb Smirnoff     '')
125*9034852cSGleb Smirnoff	ntp_os_ldflags_msg="none needed"
126*9034852cSGleb Smirnoff	;;
127*9034852cSGleb Smirnoff     *)
128*9034852cSGleb Smirnoff	ntp_os_ldflags_msg="$ntp_os_ldflags"
129*9034852cSGleb Smirnoff    esac
130*9034852cSGleb Smirnoff    LDFLAGS_NTP="$LDFLAGS_NTP $ntp_os_ldflags"
131*9034852cSGleb Smirnoff    AC_MSG_RESULT([$ntp_os_ldflags_msg])
132*9034852cSGleb Smirnoff    AS_UNSET([ntp_os_ldflags_msg])
1332b15cb3dSCy Schubert])
1342b15cb3dSCy Schubertdnl ======================================================================
135