xref: /freebsd/contrib/ntp/sntp/m4/os_cflags.m4 (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1dnl ######################################################################
2dnl Specify additional compile options based on the OS and the compiler
3AC_DEFUN([NTP_OS_CFLAGS], [
4    AC_MSG_CHECKING([additional compiler flags])
5    # allow ntp_os_cflags to be preset to skip this stuff
6    case "${ntp_os_cflags+set}" in
7     set)
8	;;
9     *)
10	ntp_os_cflags=
11	case "$host_os" in
12	 aix[[1-3]]*)
13	    ;;
14	 aix4.[[0-2]]*)
15	    # turn on additional headers
16	    ntp_os_cflags="-D_XOPEN_EXTENDED_SOURCE"
17	    ;;
18	 aix5.3*)
19	    # avoid circular dependencies in yp headers, and more
20	    ntp_os_cflags="-DHAVE_BAD_HEADERS -D_XOPEN_EXTENDED_SOURCE"
21	    ntp_os_cflags="${ntp_os_cflags} -D_USE_IRS -D_MSGQSUPPORT"
22	    ;;
23	 aix*)
24	    # XXX Only verified thru AIX6.
25	    # aix7 seems to need a different XOPEN_SOURCE_EXTENDED thing.
26	    # avoid circular dependencies in yp headers
27	    # _XOPEN_SOURCE=500 = X/Open 5: POSIX 1995
28	    # _XOPEN_SOURCE=600 = X/Open 6: POSIX 2004
29	    # _XOPEN_SOURCE=700 = X/Open 7: POSIX 2008
30	    ntp_os_cflags="-DHAVE_BAD_HEADERS -D_XOPEN_SOURCE=600"
31	    ntp_os_cflags="${ntp_os_cflags} -D_USE_IRS"
32	    ;;
33	 amigaos)
34	    ntp_os_cflags="-DSYS_AMIGA"
35	    ;;
36	 darwin*|macosx*|rhapsody*)
37	    ntp_os_cflags="-D_P1003_1B_VISIBLE"
38	    ;;
39	 hpux10.*)		# at least for hppa2.0-hp-hpux10.20
40	    case "$GCC" in
41	     yes)
42		;;
43	     *)
44		# use Ansi compiler on HPUX, and some -Wp magic
45		ntp_os_cflags="-Ae -Wp,-H18816"
46		;;
47	    esac
48	    ntp_os_cflags="${ntp_os_cflags} -D_HPUX_SOURCE -D__STDC_VERSION__=199901L"
49	    ;;
50	 hpux*)
51	    case "$GCC" in
52	     yes)
53		;;
54	     *)
55		# use Ansi compiler on HPUX
56		ntp_os_cflags="-Ae"
57	    esac
58	    ntp_os_cflags="${ntp_os_cflags} -D_HPUX_SOURCE -D__STDC_VERSION__=199901L"
59	    ;;
60	 irix6*)
61	    case "$CC" in
62	     cc)
63		# do not use 64-bit compiler
64		ntp_os_cflags="-n32 -mips3 -Wl,-woff,84"
65	    esac
66	    ;;
67	 nextstep3)
68	    ntp_os_cflags="-posix"
69	    ;;
70	 solaris1*|solaris2.[[0-5]]|solaris2.5.*)
71	    ;;
72	 sunos[[34]]*|sunos5.[[0-5]]|sunos5.5.*)
73	    ;;
74	 solaris2*|sunos5*)
75	    # turn on 64-bit file offset interface
76	    ntp_os_cflags="-D_LARGEFILE64_SOURCE"
77	    ;;
78	 vxworks*)
79	    case "$build" in
80	     $host)
81		;;
82	     *)
83		# Quick and dirty sanity check
84		case "$VX_KERNEL" in
85		 '')
86		    AC_MSG_ERROR([See html/build/hints/vxworks.html])
87		esac
88		ntp_os_cflags="-DSYS_VXWORKS"
89	    esac
90	    ;;
91	esac
92    esac
93    case "$ntp_os_cflags" in
94     '')
95	ntp_os_cflags_msg="none needed"
96	;;
97     *)
98	ntp_os_cflags_msg="$ntp_os_cflags"
99    esac
100    CFLAGS_NTP="$CFLAGS_NTP $ntp_os_cflags"
101    AC_MSG_RESULT([$ntp_os_cflags_msg])
102    AS_UNSET([ntp_os_cflags_msg])
103    ###
104    AC_MSG_CHECKING([additional linker flags])
105    # HMS: The following might still need tweaking
106    # allow ntp_os_ldflags to be preset to skip this stuff
107    case "${ntp_os_ldflags+set}" in
108     set)
109	;;
110     *)
111	ntp_os_ldflags=
112	case "$host_os" in
113	 hpux*)
114	    case "$GCC" in
115	     yes)
116		ntp_os_ldflags="-Wl,+allowdups"
117		;;
118	    esac
119	    ;;
120	esac
121	;;
122    esac
123    case "$ntp_os_ldflags" in
124     '')
125	ntp_os_ldflags_msg="none needed"
126	;;
127     *)
128	ntp_os_ldflags_msg="$ntp_os_ldflags"
129    esac
130    LDFLAGS_NTP="$LDFLAGS_NTP $ntp_os_ldflags"
131    AC_MSG_RESULT([$ntp_os_ldflags_msg])
132    AS_UNSET([ntp_os_ldflags_msg])
133])
134dnl ======================================================================
135