aboutsummaryrefslogtreecommitdiff
blob: 12b669efb3e7bb7221b81ea94783721bd29621e1 (plain)
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
dnl Process this file with autoconf to produce a configure script.
AC_INIT([portage-prefix],[@version@],[prefix@gentoo.org])

AC_PREREQ([2.71])

case "${prefix}" in
	'') 	AC_MSG_ERROR([bad value ${prefix} for --prefix, must not be empty]) ;;
	*/)		AC_MSG_ERROR([bad value ${prefix} for --prefix, must not end with '/']) ;;
	/*|NONE) ;;
	*) 		AC_MSG_ERROR([bad value ${prefix} for --prefix, must start with /]) ;;
esac

AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

AM_INIT_AUTOMAKE

dnl Checks for programs.
dnl store cflags prior, otherwise it's not propagated.
if test "x$CFLAGS" != "x"
then
	CFLAGS=$CFLAGS
fi

AC_PREFIX_DEFAULT([/usr])

AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_EGREP

GENTOO_PATH_XCU_ID()
GENTOO_PATH_PYTHON([2.7])

AC_PATH_PROG(PORTAGE_RM, [rm], no)
AC_PATH_PROG(PORTAGE_MV, [mv], no)
AC_PATH_PROG(PORTAGE_BASENAME, [basename], no)
AC_PATH_PROG(PORTAGE_DIRNAME, [dirname], no)
dnl avoid bash internal variable messing up things here
GENTOO_PATH_GNUPROG(PORTAGE_BASH, [bash])
GENTOO_PATH_GNUPROG(PORTAGE_SED, [sed])
GENTOO_PATH_GNUPROG(PORTAGE_WGET, [wget])
GENTOO_PATH_GNUPROG(PORTAGE_FIND, [find])
GENTOO_PATH_GNUPROG(PORTAGE_XARGS, [xargs])
GENTOO_PATH_GNUPROG(PORTAGE_GREP, [grep])

AC_ARG_WITH(portage-user,
AS_HELP_STRING([--with-portage-user=myuser],[use user 'myuser' as portage owner (default portage)]),
[case "${withval}" in
  ""|yes) AC_MSG_ERROR(bad value ${withval} for --with-portage-user);;
  *) portageuser="${withval}";;
esac],
[portageuser="portage"])

AC_ARG_WITH(portage-group,
AS_HELP_STRING([--with-portage-group=mygroup],[use group 'mygroup' as portage users group (default portage)]),
[case "${withval}" in
  ""|yes) AC_MSG_ERROR(bad value ${withval} for --with-portage-group);;
  *) portagegroup="${withval}";;
esac],
[portagegroup="portage"])

AC_ARG_WITH(root-user,
AS_HELP_STRING([--with-root-user=myuser],[uses 'myuser' as owner of installed files (default is portage-user)]),
[case "${withval}" in
  ""|yes) AC_MSG_ERROR(bad value ${withval} for --with-root-user);;
  *) rootuser="${withval}";;
esac],
[rootuser="${portageuser}"])

AC_MSG_CHECKING([for user id of ${rootuser}])
dnl grab uid of rootuser
rootuid=`${XCU_ID} -u "${rootuser}"`
if test "x`echo ${rootuid} | ${EGREP} '^[[0-9]]+$'`" != "x"
then
	AC_MSG_RESULT([${rootuid}])
else
	AC_MSG_ERROR([error finding the user id of ${rootuser}])
fi
AC_MSG_CHECKING([for group id of ${rootuser}])
rootgid=`${XCU_ID} -g "${rootuser}"`
if test "x`echo ${rootgid} | ${EGREP} '^[[0-9]]+$'`" != "x"
then
	AC_MSG_RESULT([${rootgid}])
else
	AC_MSG_ERROR([error finding the group id of ${rootuser}])
fi

AC_ARG_WITH(offset-prefix, 
AS_HELP_STRING([--with-offset-prefix],[specify the installation prefix for all packages, defaults to an empty string]),
			   [PORTAGE_EPREFIX=$withval],
			   [PORTAGE_EPREFIX=''])

if test "x$PORTAGE_EPREFIX" != "x"
then
	PORTAGE_EPREFIX=`${PREFIX_PORTAGE_PYTHON} -c "import os; print(os.path.normpath('$PORTAGE_EPREFIX'))"`
fi

AC_SUBST(portageuser)
AC_SUBST(portagegroup)
AC_SUBST(rootuser)
AC_SUBST(rootuid)
AC_SUBST(rootgid)
AC_SUBST(PORTAGE_EPREFIX)
AC_SUBST(PORTAGE_BASE,['${exec_prefix}/lib/portage'])

AC_SUBST(PORTAGE_RM)
AC_SUBST(PORTAGE_MV)
AC_SUBST(PORTAGE_BASENAME)
AC_SUBST(PORTAGE_DIRNAME)
AC_SUBST(PORTAGE_BASH)
AC_SUBST(PORTAGE_SED)
AC_SUBST(PORTAGE_WGET)
AC_SUBST(PORTAGE_FIND)
AC_SUBST(PORTAGE_XARGS)
AC_SUBST(PORTAGE_GREP)

AC_CONFIG_FILES([subst-install], [chmod +x subst-install])
AC_CONFIG_FILES([
				 Makefile
				 man/Makefile
				 bin/Makefile
				 lib/Makefile
				 cnf/Makefile
])

AC_OUTPUT