forked from macports/macports-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aclocal.m4
1300 lines (1144 loc) · 35.7 KB
/
aclocal.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
builtin(include,m4/tcl.m4)
dnl Search for a variable in a list. Run ACTION-IF-FOUND if it is in the list,
dnl ACTION-IF-NOT-FOUND otherwise.
dnl
dnl Parameters:
dnl - The name of the list.
dnl - The name of the variable that should be searched in the list.
dnl - An optional action to be run if found
dnl - An optional action to be run if not found
dnl
dnl _MP_LIST_CONTAINS_QUOTED([listname], [varname], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
AC_DEFUN([_MP_LIST_CONTAINS], [dnl
mp_list_contains_present=
eval "mp_list_contains_list=\"$$1\""
for mp_list_contains_entry in $mp_list_contains_list; do
test -z "$mp_list_contains_entry" && continue
if test "x$$2" = "x$mp_list_contains_entry"; then
mp_list_contains_present=1
break
fi
done
if test "x$mp_list_contains_present" = "x"; then
m4_ifvaln([$3], [$3], [:])dnl
m4_ifvaln([$4], [else $4])dnl
fi
])
dnl Quote a variable and prepend it to a list.
dnl
dnl Parameters:
dnl - The name of the list.
dnl - The name of the variable that should be quoted and prepended to the
dnl list.
AC_DEFUN([_MP_LIST_PREPEND_QUOTED], [dnl
_MP_QUOTE([$2])
_MP_VAR_PREPEND([$1], ["$$2 "])
])
dnl Quote a variable and append it to a list.
dnl
dnl Parameters:
dnl - The name of the list.
dnl - The name of the variable that should be quoted and appended to the list.
AC_DEFUN([_MP_LIST_APPEND_QUOTED], [dnl
_MP_QUOTE([$2])
AS_VAR_APPEND([$1], [" $$2"])
])
dnl Prepend the shell expansion of a value to a variable.
dnl
dnl Parameters:
dnl - The name of the variable to which the second argument should be
dnl prepended.
dnl - The value that should be expanded using the shell expansion rules and
dnl prepended to the variable given in the first argument.
AC_DEFUN([_MP_VAR_PREPEND], [dnl
AC_REQUIRE([_MP_VAR_PREPEND_PREPARE])dnl
mp_fn_var_prepend $1 $2
])
dnl Define the function required for _MP_VAR_PREPEND
AC_DEFUN([_MP_VAR_PREPEND_PREPARE], [dnl
mp_fn_var_prepend() {
eval "$[]1=\"$[]2\$$[]1\""
}
])
dnl Quote a variable in single quotes (escaping any existing single quotes) and
dnl store it in itself.
dnl
dnl Parameters:
dnl - The name of the variable that should be quoted using single quotes.
AC_DEFUN([_MP_QUOTE], [dnl
case $$1 in
*\'*)
$1=$(AS_ECHO(["$$1"]) | sed "s/'/'\\\\\\\\''/g")
;;
esac
$1="'$$1'"dnl
])
dnl Extract the key part of a key-value pair given as string in the form
dnl --key=value or
dnl -key=value
dnl
dnl Parameters:
dnl - The variable name to assign to
dnl - The (quoted, if necessary) key-value pair
AC_DEFUN([_MP_EXTRACT_KEY], [dnl
$1=$(AS_ECHO([$2]) | sed -E 's/^--?([[^=]]+)=.*$/\1/')dnl
])
dnl Similar to AC_ARG_VAR, but implemented with --with-pkg=PATH for PKG.
dnl
dnl Parameters: Similar to AC_ARG_VAR ($2 gets some boiler plate around it)
AC_DEFUN([MP_TOOL_PATH], [dnl
AC_ARG_WITH([m4_tolower($1)], [AS_HELP_STRING([--with-m4_tolower($1)=PATH],
[path to alternate $2 command])], [$1=$withval],dnl
[])dnl
])
dnl Configure a project contained in a subdirectory. Different from
dnl AC_CONFIG_SUBDIRS (on which this macro is based), you can pass parameters
dnl to the sub-configure script.
dnl
dnl Parameters:
dnl - The relative path to the directory that contains the configure script
dnl to be run
dnl - Parameters to pass to the configure script
dnl
dnl MP_CONFIG_SUBDIR([path-to-directory], [configure-parameters])
AC_DEFUN([MP_CONFIG_SUBDIR], [
ac_dir="$1"
mp_popdir=$(pwd)
AS_MKDIR_P(["$ac_dir"])
_AC_SRCDIRS(["$ac_dir"])
cd "$ac_dir"
if test "$no_recursion" != yes || test ! -f "$ac_srcdir/config.status"; then
AC_MSG_NOTICE([=== configuring in $ac_dir ($mp_popdir/$ac_dir)])
if test -f "$ac_srcdir/configure"; then
mp_sub_configure_args=
mp_sub_configure_keys=
# Compile a list of keys that have been given to the MP_CONFIG_SUBDIR
# macro; we want to skip copying those parameters from the original
# configure invocation.
for mp_arg in $2; do
case $mp_arg in
--*=* | -*=*)
_MP_EXTRACT_KEY([mp_arg_key], ["$mp_arg"])
_MP_LIST_APPEND_QUOTED([mp_sub_configure_keys], [mp_arg_key])
;;
esac
_MP_LIST_APPEND_QUOTED([mp_sub_configure_args], [mp_arg])
done
# Walk the list of arguments given to the original configure script;
# filter out a few common ones we likely would not want to pass along,
# add --disable-option-checking and filter those already given as
# argument to MP_CONFIG_SUBDIR.
# Most of this code is adapted from _AC_OUTPUT_SUBDIRS in
# $prefix/share/autoconf/autoconf/status.m4.
mp_prev=
eval "set x $ac_configure_args"
shift
for mp_arg; do
if test -n "$mp_prev"; then
mp_prev=
continue
fi
case $mp_arg in
-cache-file \
| --cache-file \
| --cache-fil \
| --cache-fi \
| --cache-f \
| --cache- \
| --cache \
| --cach \
| --cac \
| --ca \
| --c)
mp_prev=cache_file
;;
-cache-file=* \
| --cache-file=* \
| --cache-fil=* \
| --cache-fi=* \
| --cache-f=* \
| --cache-=* \
| --cache=* \
| --cach=* \
| --cac=* \
| --ca=* \
| --c=*)
# ignore --cache-file
;;
--config-cache \
| -C)
# ignore -C
;;
-srcdir \
| --srcdir \
| -srcdi \
| -srcd \
| -src \
| -sr)
mp_prev=srcdir
;;
-srcdir=* \
| --srcdir=* \
| --srcdi=* \
| --srcd=* \
| --src=* \
| --sr=*)
# ignore --srcdir
;;
-prefix \
| --prefix \
| --prefi \
| --pref \
| --pre \
| --pr \
| --p)
mp_prev=prefix
;;
-prefix=* \
| --prefix=* \
| --prefi=* \
| --pref=* \
| --pre=* \
| --pr=* \
| --p=*)
# ignore --prefix
;;
--disable-option-checking)
# ignore --disable-option-checking
;;
--*=* | -*=*)
_MP_EXTRACT_KEY([mp_arg_key], ["$mp_arg"])
_MP_LIST_CONTAINS([mp_sub_configure_keys], [mp_arg_key], [], [
_MP_LIST_APPEND_QUOTED([mp_sub_configure_args], [mp_arg])
])
;;
*)
# always pass positional arguments
_MP_LIST_APPEND_QUOTED([mp_sub_configure_args], [mp_arg])
;;
esac
done
# Now prepend some arguments that should always be present unless
# overriden, such as --prefix, --silent, --disable-option-checking,
# --cache-file, --srcdir
# Pass --prefix unless already given
mp_arg_key=prefix
_MP_LIST_CONTAINS([mp_sub_configure_args], [mp_arg_key], [], [
mp_arg="--prefix=$prefix"
_MP_LIST_PREPEND_QUOTED([mp_sub_configure_args], [mp_arg])
])
# Pass --silent
if test "$silent" = yes; then
mp_arg="--silent"
_MP_LIST_PREPEND_QUOTED([mp_sub_configure_args], [mp_arg])
fi
# Always prepend --disable-option-checking to silence warnings, since
# different subdirs can have different --enable and --with options.
mp_arg="--disable-option-checking"
_MP_LIST_PREPEND_QUOTED([mp_sub_configure_args], [mp_arg])
# Make the cache file name correct relative to the subdirectory.
case $cache_file in
[[\\/]]* | ?:[[\\/]]* )
mp_sub_cache_file=$cache_file
;;
*) # Relative name.
mp_sub_cache_file=$ac_top_build_prefix$cache_file
;;
esac
mp_arg="--cache-file=$mp_sub_cache_file"
_MP_LIST_PREPEND_QUOTED([mp_sub_configure_args], [mp_arg])
mp_arg="--srcdir=$ac_srcdir"
_MP_LIST_APPEND_QUOTED([mp_sub_configure_args], [mp_arg])
mp_arg="CC=$CC"
_MP_LIST_APPEND_QUOTED([mp_sub_configure_args], [mp_arg])
AC_MSG_NOTICE([running $SHELL $ac_srcdir/configure $mp_sub_configure_args in $ac_dir])
eval "\$SHELL \$ac_srcdir/configure $mp_sub_configure_args" || AC_MSG_ERROR([configure failed for $ac_dir])
else
AC_MSG_ERROR([no configure script found in $ac_dir])
fi
AC_MSG_NOTICE([=== finished configuring in $ac_dir ($mp_popdir/$ac_dir)])
fi
cd "$mp_popdir"
])
#------------------------------------------------------------------------
# MP_CHECK_FRAMEWORK_COREFOUNDATION --
#
# Check if CoreFoundation framework is available, define HAVE_FRAMEWORK_COREFOUNDATION if so.
#
# Arguments:
# None.
#
# Requires:
# None.
#
# Depends:
# AC_LANG_PROGRAM
#
# Results:
# Result is cached.
#
# If CoreFoundation framework is available, defines the following variables:
# HAVE_FRAMEWORK_COREFOUNDATION
#
#------------------------------------------------------------------------
AC_DEFUN(MP_CHECK_FRAMEWORK_COREFOUNDATION, [
FRAMEWORK_LIBS="-framework CoreFoundation"
AC_MSG_CHECKING([for CoreFoundation framework])
AC_CACHE_VAL(mp_cv_have_framework_corefoundation, [
ac_save_LIBS="$LIBS"
LIBS="$FRAMEWORK_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <CoreFoundation/CoreFoundation.h>
], [
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, CFSTR("/testing"), kCFURLPOSIXPathStyle, 1);
CFArrayRef bundles = CFBundleCreateBundlesFromDirectory(NULL, url, CFSTR("pkg"));
])
], [
mp_cv_have_framework_corefoundation="yes"
], [
mp_cv_have_framework_corefoundation="no"
]
)
LIBS="$ac_save_LIBS"
])
AC_MSG_RESULT(${mp_cv_have_framework_corefoundation})
if test x"${mp_cv_have_framework_corefoundation}" = "xyes"; then
AC_DEFINE([HAVE_FRAMEWORK_COREFOUNDATION], [], [Define if CoreFoundation framework is available])
fi
AC_SUBST(HAVE_FRAMEWORK_COREFOUNDATION, [$mp_cv_have_framework_corefoundation])
])
#------------------------------------------------------------------------
# MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER --
#
# Check if if the routine CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
# is available in CoreFoundation.
#
# Arguments:
# None.
#
# Requires:
# None.
#
# Depends:
# AC_LANG_PROGRAM
#
# Results:
# Result is cached.
#
# If function CFNotificationCenterGetDarwinNotifyCenter is in the CoreFoundation framework, defines the following variables:
# HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
#
#------------------------------------------------------------------------
AC_DEFUN(MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER, [
FRAMEWORK_LIBS="-framework CoreFoundation"
AC_MSG_CHECKING([for CFNotificationCenterGetDarwinNotifyCenter])
AC_CACHE_VAL(mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter, [
ac_save_LIBS="$LIBS"
LIBS="$FRAMEWORK_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <CoreFoundation/CoreFoundation.h>
], [
CFNotificationCenterRef ref = CFNotificationCenterGetDarwinNotifyCenter();
])
], [
mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter="yes"
], [
mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter="no"
]
)
LIBS="$ac_save_LIBS"
])
AC_MSG_RESULT(${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter})
if test x"${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter}" = "xyes"; then
AC_DEFINE([HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER], [], [Define if function CFNotificationCenterGetDarwinNotifyCenter in CoreFoundation framework])
fi
AC_SUBST(HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER)
])
#------------------------------------------------------------------------
# MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION --
#
# Check if SystemConfiguration framework is available, define HAVE_FRAMEWORK_SYSTEMCONFIGURATION if so.
#
# Arguments:
# None.
#
# Requires:
# None.
#
# Depends:
# AC_LANG_PROGRAM
#
# Results:
# Result is cached.
#
# If SystemConfiguration framework is available, defines the following variables:
# HAVE_FRAMEWORK_SYSTEMCONFIGURATION
#
#------------------------------------------------------------------------
AC_DEFUN(MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION, [
FRAMEWORK_LIBS="-framework SystemConfiguration"
AC_MSG_CHECKING([for SystemConfiguration framework])
AC_CACHE_VAL(mp_cv_have_framework_systemconfiguration, [
ac_save_LIBS="$LIBS"
LIBS="$FRAMEWORK_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <SystemConfiguration/SystemConfiguration.h>
], [
int err = SCError();
SCDynamicStoreRef dsRef = SCDynamicStoreCreate(NULL, NULL, NULL, NULL);
])
], [
mp_cv_have_framework_systemconfiguration="yes"
], [
mp_cv_have_framework_systemconfiguration="no"
]
)
LIBS="$ac_save_LIBS"
])
AC_MSG_RESULT(${mp_cv_have_framework_systemconfiguration})
if test x"${mp_cv_have_framework_systemconfiguration}" = "xyes"; then
AC_DEFINE([HAVE_FRAMEWORK_SYSTEMCONFIGURATION], [], [Define if SystemConfiguration framework is available])
fi
AC_SUBST(HAVE_FRAMEWORK_SYSTEMCONFIGURATION, [$mp_cv_have_framework_systemconfiguration])
])
#------------------------------------------------------------------------
# MP_CHECK_FRAMEWORK_IOKIT --
#
# Check if IOKit framework is available, define HAVE_FRAMEWORK_IOKIT if so.
#
# Arguments:
# None.
#
# Requires:
# None.
#
# Depends:
# AC_LANG_PROGRAM
#
# Results:
# Result is cached.
#
# If IOKit framework is available, defines the following variables:
# HAVE_FRAMEWORK_IOKIT
#
#------------------------------------------------------------------------
AC_DEFUN(MP_CHECK_FRAMEWORK_IOKIT, [
FRAMEWORK_LIBS="-framework IOKit"
AC_MSG_CHECKING([for IOKit framework])
AC_CACHE_VAL(mp_cv_have_framework_iokit, [
ac_save_LIBS="$LIBS"
LIBS="$FRAMEWORK_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <IOKit/IOKitLib.h>
], [
IOCreateReceivePort(0, NULL);
IORegisterForSystemPower(0, NULL, NULL, NULL);
])
], [
mp_cv_have_framework_iokit="yes"
], [
mp_cv_have_framework_iokit="no"
]
)
LIBS="$ac_save_LIBS"
])
AC_MSG_RESULT(${mp_cv_have_framework_iokit})
if test x"${mp_cv_have_framework_iokit}" = "xyes"; then
AC_DEFINE([HAVE_FRAMEWORK_IOKIT], [], [Define if IOKit framework is available])
fi
AC_SUBST(HAVE_FRAMEWORK_IOKIT, [$mp_cv_have_framework_iokit])
])
# MP_PATH_MPCONFIGDIR
#---------------------------------------
AC_DEFUN([MP_PATH_MPCONFIGDIR],[
dnl if the user actually specified --prefix, shift
dnl mpconfigdir to $prefix/etc/macports
AC_MSG_CHECKING([for MacPorts config directory])
mpconfigdir='${sysconfdir}/macports'
AC_MSG_RESULT([$mpconfigdir])
MPCONFIGDIR="$mpconfigdir"
AC_SUBST(MPCONFIGDIR)
])
# MP_CHECK_OLDLAYOUT
#---------------------------------------
AC_DEFUN([MP_CHECK_OLDLAYOUT],[
dnl Bail if there is an existing install of DP/MP older than 1.5
AC_MSG_CHECKING([that any existing MacPorts install can be upgraded])
eval dpversionfile="${sysconfdir}/ports/dp_version"
if test -f "$dpversionfile"; then
AC_MSG_ERROR([Existing MacPorts or DarwinPorts install is too old to be upgraded. Install MacPorts 1.7.1 first.])
else
AC_MSG_RESULT([yes])
fi
])
# MP_CHECK_NOROOTPRIVILEGES
#-------------------------------------------------
AC_DEFUN([MP_CHECK_NOROOTPRIVILEGES],[
dnl if the user specifies --with-no-root-privileges,
dnl use current user and group.
dnl use ~/Library/Tcl as Tcl package directory
AC_REQUIRE([MP_PATH_MPCONFIGDIR])
AC_ARG_WITH(no-root-privileges, [AS_HELP_STRING([--with-no-root-privileges],[specify that MacPorts should be installed in your home directory])], [ROOTPRIVS=$withval] )
if test "${ROOTPRIVS+set}" = set; then
# Set install-user to current user
AC_MSG_CHECKING([for install user])
DSTUSR=`id -un`
AC_MSG_RESULT([$DSTUSR])
AC_SUBST(DSTUSR)
# Set install-group to current user
AC_MSG_CHECKING([for install group])
DSTGRP=`id -gn`
AC_MSG_RESULT([$DSTGRP])
AC_SUBST(DSTGRP)
# Set run-user to current user
AC_MSG_CHECKING([for macports user])
RUNUSR=`id -un`
AC_MSG_RESULT([$RUNUSR])
AC_SUBST(RUNUSR)
fi
])
# MP_CHECK_RUNUSER
#-------------------------------------------------
AC_DEFUN([MP_CHECK_RUNUSER],[
dnl if the user specifies --with-macports-user,
dnl use it, otherwise default to platform defaults
AC_REQUIRE([MP_PATH_MPCONFIGDIR])
AC_ARG_WITH(macports-user, [AS_HELP_STRING([--with-macports-user=USER],[specify user to drop privileges to, if possible, during compiles, etc.])], [ RUNUSR=$withval ] )
AC_MSG_CHECKING([for macports user])
if test "x$RUNUSR" = "x" ; then
RUNUSR=macports
fi
AC_MSG_RESULT([$RUNUSR])
AC_SUBST(RUNUSR)
])
# MP_SHARED_DIRECTORY
#-------------------------------------------------
AC_DEFUN([MP_SHARED_DIRECTORY],[
dnl if the user specifies --with-shared-directory,
dnl use 0775 permissions for ${prefix} directories
AC_REQUIRE([MP_PATH_MPCONFIGDIR])
AC_ARG_WITH(shared-directory, [AS_HELP_STRING([--with-shared-directory],[use 0775 permissions for installed directories])], [ SHAREDIR=$withval ] )
if test "${SHAREDIR+set}" = set; then
AC_MSG_CHECKING([whether to share the install directory with all members of the install group])
DSTMODE=0775
AC_MSG_RESULT([$DSTMODE])
AC_SUBST(DSTMODE)
fi
])
# MP_CHECK_INSTALLUSER
#-------------------------------------------------
AC_DEFUN([MP_CHECK_INSTALLUSER],[
dnl if the user specifies --with-install-user,
dnl use it, otherwise default to platform defaults
AC_REQUIRE([MP_PATH_MPCONFIGDIR])
AC_ARG_WITH(install-user, [AS_HELP_STRING([--with-install-user=USER],[specify user ownership of installed files])], [ DSTUSR=$withval ] )
AC_MSG_CHECKING([for install user])
if test "x$DSTUSR" = "x" ; then
DSTUSR=root
fi
AC_MSG_RESULT([$DSTUSR])
AC_SUBST(DSTUSR)
])
# MP_CHECK_INSTALLGROUP
#-------------------------------------------------
AC_DEFUN([MP_CHECK_INSTALLGROUP],[
dnl if the user specifies --with-install-group,
dnl use it, otherwise default to platform defaults
AC_REQUIRE([MP_CHECK_INSTALLUSER])
AC_ARG_WITH(install-group, [AS_HELP_STRING([--with-install-group=GROUP],[specify group ownership of installed files])], [ DSTGRP=$withval ] )
AC_MSG_CHECKING([for install group])
if test "x$DSTGRP" = "x" ; then
case $host_os in
darwin*)
DSTGRP="admin"
;;
freebsd*)
DSTGRP="wheel"
;;
linux*)
DSTGRP="root"
;;
*)
DSTGRP="wheel"
;;
esac
fi
AC_MSG_RESULT([$DSTGRP])
AC_SUBST(DSTGRP)
])
# MP_DIRECTORY_MODE
#-------------------------------------------------
AC_DEFUN([MP_DIRECTORY_MODE],[
dnl if the user specifies --with-directory-mode,
dnl use the specified permissions for ${prefix} directories,
dnl otherwise use 0755
AC_REQUIRE([MP_PATH_MPCONFIGDIR])
AC_ARG_WITH(directory-mode, [AS_HELP_STRING([--with-directory-mode=MODE],[specify directory mode of installed directories])], [ DSTMODE=$withval ] )
AC_MSG_CHECKING([what permissions to use for installation directories])
if test "x$DSTMODE" = "x" ; then
DSTMODE=0755
fi
AC_MSG_RESULT([$DSTMODE])
AC_SUBST(DSTMODE)
])
# MP_PATH_APPLICATIONS
#---------------------------------------
AC_DEFUN([MP_PATH_APPLICATIONS],[
AC_REQUIRE([MP_CHECK_INSTALLUSER])
AC_ARG_WITH(applications-dir,[AS_HELP_STRING([--with-applications-dir],[applications installation directory])], MPAPPLICATIONSDIR=${withval})
oldprefix=$prefix
if test "x$prefix" = "xNONE" ; then
prefix=$ac_default_prefix
fi
AC_MSG_CHECKING([for Applications installation directory])
if test "x$MPAPPLICATIONSDIR" = "x" ; then
if test "$DSTUSR" = "root" ; then
MPAPPLICATIONSDIR="/Applications/MacPorts"
else
MPAPPLICATIONSDIR="$(eval echo ~$DSTUSR)/Applications/MacPorts"
fi
fi
AC_MSG_RESULT([$MPAPPLICATIONSDIR])
AC_SUBST(MPAPPLICATIONSDIR)
prefix=$oldprefix
])
# MP_PATH_FRAMEWORKS
#---------------------------------------
AC_DEFUN([MP_PATH_FRAMEWORKS],[
AC_REQUIRE([MP_CHECK_INSTALLUSER])
AC_ARG_WITH(frameworks-dir,[AS_HELP_STRING([--with-frameworks-dir],[frameworks installation directory])], MPFRAMEWORKSDIR=${withval})
oldprefix=$prefix
if test "x$prefix" = "xNONE" ; then
prefix=$ac_default_prefix
fi
AC_MSG_CHECKING([for Frameworks installation directory])
if test "x$MPFRAMEWORKSDIR" = "x" ; then
MPFRAMEWORKSDIR="${prefix}/Library/Frameworks"
fi
AC_MSG_RESULT([$MPFRAMEWORKSDIR])
AC_SUBST(MPFRAMEWORKSDIR)
prefix=$oldprefix
])
# MP_CHECK_STARTUPITEMS
#-------------------------------------------------
AC_DEFUN([MP_CHECK_STARTUPITEMS],[
dnl if the user specifies --without-startupitems,
dnl set "startupitem_install no" in macports.conf
AC_ARG_WITH(startupitems, [AS_HELP_STRING([--without-startupitems],[set "startupitem_install no" in macports.conf])], [with_startupitems=$withval], [with_startupitems=yes] )
AC_MSG_CHECKING([for startupitem_install])
if test "x$with_startupitems" != "xno" ; then
startupitem_install="#startupitem_install yes"
else
startupitem_install="startupitem_install no"
fi
AC_MSG_RESULT([$with_startupitems])
AC_SUBST(startupitem_install)
])
# MP_UNIVERSAL_OPTIONS
#---------------------------------------
AC_DEFUN([MP_UNIVERSAL_OPTIONS],[
AC_ARG_WITH(universal-archs,[AS_HELP_STRING([--with-universal-archs="CPU"],[universal CPU architectures (space separated)])], UNIVERSAL_ARCHS=${withval})
if test "x$UNIVERSAL_ARCHS" = "x"; then
case "$MACOSX_VERSION" in
10.1[[0-3]]*)
UNIVERSAL_ARCHS="x86_64 i386"
;;
10.1[[4-9]]*)
UNIVERSAL_ARCHS="x86_64"
;;
10.[[0-5]]*)
UNIVERSAL_ARCHS="i386 ppc"
;;
*)
UNIVERSAL_ARCHS="x86_64 i386"
;;
esac
fi
UNIVERSAL_ARCHFLAGS=
for arch in $UNIVERSAL_ARCHS; do
UNIVERSAL_ARCHFLAGS="$UNIVERSAL_ARCHFLAGS -arch $arch"
done
AC_MSG_CHECKING([for Universal CPU architectures])
AC_MSG_RESULT([$UNIVERSAL_ARCHS])
AC_SUBST(UNIVERSAL_ARCHS)
AC_SUBST(UNIVERSAL_ARCHFLAGS)
])
# MP_LIB_MD5
#---------------------------------------
# Check for an md5 implementation
AC_DEFUN([MP_LIB_MD5],[
# Check for libmd from FreeBSD, which is preferred
AC_CHECK_LIB([md], [MD5File],[
AC_CHECK_HEADERS([md5.h sha.h], ,[
AC_MSG_ERROR([libmd was found, but md5.h or sha.h is missing.])
])
ac_save_LIBS="$LIBS"
LIBS="-lmd $LIBS"
AC_CHECK_FUNCS([SHA1_File])
LIBS="$ac_save_LIBS"
AC_CHECK_HEADERS([ripemd.h sha256.h])
AC_DEFINE([HAVE_LIBMD], ,[Define if you have the `md' library (-lmd).])
MD5_LIBS="-lmd"]
)
if test "x$MD5_LIBS" = "x"; then
# If libmd is not found, check for libcrypto from OpenSSL
AC_CHECK_LIB([crypto], [MD5_Update],[
AC_CHECK_HEADERS([openssl/md5.h openssl/sha.h], ,[
AC_MSG_ERROR([libcrypto was found, but openssl/md5.h or openssl/sha.h is missing.])
])
AC_CHECK_HEADERS([openssl/ripemd.h])
ac_save_LIBS="$LIBS"
LIBS="-lcrypto $LIBS"
AC_CHECK_FUNCS([SHA256_Update])
LIBS="$ac_save_LIBS"
AC_DEFINE([HAVE_LIBCRYPTO], ,[Define if you have the `crypto' library (-lcrypto).])
MD5_LIBS="-lcrypto"]
)
fi
if test "x$MD5_LIBS" = "x"; then
AC_MSG_ERROR([Neither CommonCrypto, libmd nor libcrypto were found. A working md5 implementation is required.])
fi
AC_SUBST([MD5_LIBS])
])
# MP_PROG_DAEMONDO
#---------------------------------------
AC_DEFUN([MP_PROG_DAEMONDO],[
AC_REQUIRE([MP_CHECK_FRAMEWORK_COREFOUNDATION])
AC_REQUIRE([MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION])
AC_REQUIRE([MP_CHECK_FRAMEWORK_IOKIT])
AC_REQUIRE([MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER])
AC_MSG_CHECKING(for whether we will build daemondo)
result=no
case $host_os in
darwin*)
if test "x$mp_cv_have_framework_corefoundation" == "xyes" &&
test "x$mp_cv_have_framework_systemconfiguration" == "xyes" &&
test "x$mp_cv_have_framework_iokit" == "xyes" &&
test "x$mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter" == "xyes"; then
result=yes
EXTRA_PROGS="$EXTRA_PROGS daemondo"
AC_CONFIG_FILES([src/programs/daemondo/Makefile])
fi
;;
*)
esac
AC_MSG_RESULT(${result})
])
# MP_LIBCURL_FLAGS
# Sets the flags to compile with libcurl.
#
# Arguments:
# None.
#
# Requires:
# curl-config or user parameters to define the flags.
#
# Results:
# defines some help strings.
# sets CFLAGS_LIBCURL and LDFLAGS_LIBCURL
#---------------------------------------
AC_DEFUN([MP_LIBCURL_FLAGS],[
AC_ARG_WITH(curlprefix,
[ --with-curlprefix base directory for the curl install ('/usr', '/usr/local', ...)],
[ curlprefix=$withval ])
if test "x$curlprefix" = "x"; then
AC_PATH_PROG([CURL_CONFIG], [curl-config])
else
AC_PATH_PROG([CURL_CONFIG], [curl-config], , [$curlprefix/bin])
fi
if test "x$CURL_CONFIG" = "x"; then
AC_MSG_ERROR([cannot find curl-config. Is libcurl installed?])
fi
CFLAGS_LIBCURL=$($CURL_CONFIG --cflags)
if test "x$curlprefix" = "x"; then
# System curl-config emits absurd output for --libs
# See rdar://7244457
LDFLAGS_LIBCURL="-lcurl"
else
# Due to a bug in dist, --arch flags are improperly supplied by curl-config.
# Get rid of them.
LDFLAGS_LIBCURL=$($CURL_CONFIG --libs | [sed 's/-arch [A-Za-z0-9_]* //g'])
fi
AC_SUBST(CFLAGS_LIBCURL)
AC_SUBST(LDFLAGS_LIBCURL)
])
# MP_SQLITE3_FLAGS
# Sets the flags to compile with libsqlite3 and tclsqlite3.
#
# Arguments:
# None.
#
# Requires:
# pkgconfig, libsqlite3 in /usr/lib, or user parameters to define the flags.
#
# Results:
# defines some help strings.
# sets CFLAGS_SQLITE3 and LDFLAGS_SQLITE3
#---------------------------------------
AC_DEFUN([MP_SQLITE3_FLAGS],[
# first sqlite3 itself
AC_ARG_WITH(sqlite3prefix,
[ --with-sqlite3prefix base directory for the sqlite3 install ('/usr', '/usr/local', ...)],
[ sqlite3prefix=$withval ])
if test "x$sqlite3prefix" = "x"; then
# see if it's somewhere like /usr that needs no extra flags
LDFLAGS_SQLITE3="-lsqlite3"
AC_CHECK_HEADER(sqlite3.h, [],[
# nope - try pkg-config
AC_PATH_PROG([PKG_CONFIG], [pkg-config])
if test "x$PKG_CONFIG" = "x" || ! $PKG_CONFIG --exists sqlite3; then
AC_MSG_ERROR([cannot find sqlite3 header])
else
CFLAGS_SQLITE3=$($PKG_CONFIG --cflags sqlite3)
LDFLAGS_SQLITE3=$($PKG_CONFIG --libs sqlite3)
# for tclsqlite below
mp_sqlite3_dir=$($PKG_CONFIG --variable=prefix sqlite3)
if test "x$mp_sqlite3_dir" != "x"; then
mp_sqlite3_dir=${mp_sqlite3_dir}/lib/sqlite3
fi
fi
])
else
CFLAGS_SQLITE3="-I${sqlite3prefix}/include"
LDFLAGS_SQLITE3="-L${sqlite3prefix}/lib -lsqlite3"
fi
# check if we have sqlite3ext.h, using the appropriate cppflags
CPPFLAGS_OLD="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${CFLAGS_SQLITE3}"
AC_CHECK_HEADERS(sqlite3ext.h)
CPPFLAGS="${CPPFLAGS_OLD}"
AC_SUBST(CFLAGS_SQLITE3)
AC_SUBST(LDFLAGS_SQLITE3)
])
dnl This macro tests if the compiler supports GCC's
dnl __attribute__ syntax for unused variables/parameters
AC_DEFUN([MP_COMPILER_ATTRIBUTE_UNUSED], [
AC_MSG_CHECKING([how to mark unused variables])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([[int a __attribute__ ((unused));]])],
[AC_DEFINE(UNUSED, [__attribute__((unused))], [Attribute to mark unused variables])],
[AC_DEFINE(UNUSED, [])])
AC_MSG_RESULT([])
])
dnl This macro ensures MP installation prefix paths are NOT in CFLAGS,
dnl CPPFLAGS, OBJCFLAGS, LDFLAGS for configure to prevent potential problems
dnl when base/ code is updated and ports are installed that would match needed
dnl items.
AC_DEFUN([MP_FLAGS_SCAN],[
AC_ARG_ENABLE(
[flag-sanitization],
AS_HELP_STRING([--disable-flag-sanitization], [do not sanitize CPPFLAGS, CFLAGS, OBJCFLAGS and LDFLAGS]),
[disable_mp_flags_scan=yes],
[disable_mp_flags_scan=no])
if test x"$disable_mp_flags_scan" != "xyes"; then
# Get a value for $prefix
oldprefix=$prefix
if test "x$prefix" = "xNONE" ; then
prefix=$ac_default_prefix
fi
mp_flags_scan_found=
# Clean CFLAGS CPPFLAGS OBJCFLAGS and LDFLAGS
for mp_flags_flagname in CFLAGS CPPFLAGS OBJCFLAGS LDFLAGS; do
mp_flags_scan_flag_cleaned=
eval "set x \$$mp_flags_flagname"
shift
for mp_flags_scan_val; do
case "$mp_flags_scan_val" in
-I$prefix/* | -L$prefix/*)
AC_MSG_NOTICE([Removing `$mp_flags_scan_val' from \$$mp_flags_flagname because it might cause a self-dependency])
mp_flags_scan_found=1
;; #(
*)
if test -z "$mp_flags_scan_flag_cleaned"; then
mp_flags_scan_flag_cleaned=$mp_flags_scan_val
else
AS_VAR_APPEND([mp_flags_scan_flag_cleaned], [" $mp_flags_scan_val"])
fi
;;
esac
done
if test -z "$mp_flags_scan_flag_cleaned"; then
(unset $mp_flags_flagname) >/dev/null 2>&1 && unset $mp_flags_flagname
(export -n $mp_flags_flagname) >/dev/null 2>&1 && export -n $mp_flags_flagname
else
eval "$mp_flags_flagname=\"$mp_flags_scan_flag_cleaned\""