summaryrefslogtreecommitdiffstats
path: root/cpukit/aclocal/rtems-top.m4
blob: b0cdaaa4d7438642db01748bcde9969ad53836ec (plain) (blame)
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
# AC_DISABLE_OPTION_CHECKING is not available before 2.62
AC_PREREQ(2.62)

dnl
dnl RTEMS_TOP($1)
dnl 
dnl $1 .. relative path from this configure.ac to the toplevel configure.ac
dnl
AC_DEFUN([RTEMS_TOP],
[dnl
AC_REQUIRE([RTEMS_VERSIONING])
AC_REQUIRE([AM_SET_LEADING_DOT])
AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])
AC_CONFIG_AUX_DIR([$1])
AC_CHECK_PROGS(MAKE, gmake make)
AC_BEFORE([$0], [AM_INIT_AUTOMAKE])dnl

AC_PREFIX_DEFAULT([/opt/rtems-][_RTEMS_API])

AC_SUBST([RTEMS_TOPdir],["$1"])

# HACK: The sed pattern below strips of "../", corresponding to "cpukit/"
rtems_updir=m4_if([$2],[],[`echo "$1/" | sed 's,^\.\.\/,,'`],[$2/])

AS_IF([test -n "$with_multisubdir"],
  [MULTIBUILDTOP=`echo "/$with_multisubdir" | sed 's,/[[^\\/]]*,../,g'`])
AC_SUBST(MULTIBUILDTOP)
 
AS_IF([test -n "$with_multisubdir"],
  [MULTISUBDIR="/$with_multisubdir"])
AC_SUBST(MULTISUBDIR)

AC_ARG_WITH([project-root],[
AS_HELP_STRING(--with-project-root,directory to pre-install files into)],[
## Make sure to have a terminating '/'
case "${with_project_root}" in
*/) ;;
*) with_project_root="${with_project_root}/" ;;
esac

case "${with_project_root}" in
  [[\\/$]]* | ?:[[\\/]]* ) # absolute directory
   PROJECT_ROOT=${with_project_root}
   ;;
  *) # relative directory
   sav0dir=`pwd` && cd ./${rtems_updir}
   sav1dir=`pwd` && cd ../${MULTIBUILDTOP}
   sav2dir=`pwd` && cd "$sav0dir"
   mydir=`echo "$sav1dir" | sed "s,^$sav2dir${MULTISUBDIR}/,,"`
   PROJECT_ROOT='$(top_builddir)'/${rtems_updir}'../$(MULTIBUILDTOP)'${mydir}/${with_project_root}
   ;;
esac],[
## Defaults: Note: Two different defaults!
## ../ for multilib
## '.' for non-multilib
AS_IF([test "$enable_multilib" = "yes"],[ 
  PROJECT_ROOT='$(top_builddir)'/${rtems_updir}'../$(MULTIBUILDTOP)'],[
  PROJECT_ROOT='$(top_builddir)'/${rtems_updir}])
])

AC_SUBST([PROJECT_INCLUDE],["${PROJECT_ROOT}lib/include"])
AC_SUBST([PROJECT_LIB],["${PROJECT_ROOT}lib\$(MULTISUBDIR)"])

libdir="${libdir}\$(MULTISUBDIR)"

AC_SUBST([project_libdir],["\$(libdir)"])
AC_SUBST([project_includedir],["\$(includedir)"])

AC_SUBST([dirstamp],[\${am__leading_dot}dirstamp])
])dnl