summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 68c5fa4639e8a73cbe2ebb7fef8bd8b9c6763f5f (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
dnl Process this file with autoconf to produce a configure script.
AC_INIT(main.c)

AC_ARG_ENABLE(sdl,
	[  --enable-sdl            build SDL chroma],
        [with_sdl=$enableval],
        [with_sdl=yes],
)

AC_ARG_ENABLE(curses,
	[  --enable-curses         build curses chroma],
        [with_curses=$enableval],
        [with_curses=yes],
)

dnl Check for programs
AC_PROG_CC
AC_PROG_INSTALL

dnl Check for SDL
if test "$with_sdl" = "yes"; then
    AC_PATH_PROG(SDLCONFIG, sdl-config, no)
    if test "$SDLCONFIG" = "no"; then
        AC_MSG_ERROR([*** Unable to find sdl-config])
    else
        CFLAGS="$CFLAGS "`sdl-config --cflags`
        LDFLAGS="$LDFLAGS "`sdl-config --libs`
    fi
fi

dnl Check for SDL_image library
if test "$with_sdl" = "yes"; then
    AC_CHECK_LIB(SDL_image, IMG_LoadPNG_RW)
    if test "$ac_cv_lib_SDL_image_IMG_LoadPNG_RW" != "yes"; then
        AC_MSG_ERROR([*** Unable to find SDL_image library with PNG support])
    fi
fi

dnl Check for the FreeType 2 library
if test "$with_sdl" = "yes"; then
    AC_ARG_WITH(freetype-prefix,[  --with-freetype-prefix=PFX   Prefix where FREETYPE is installed (optional)], freetype_prefix="$withval", freetype_prefix="")
    AC_ARG_WITH(freetype-exec-prefix,[  --with-freetype-exec-prefix=PFX Exec prefix where FREETYPE is installed (optional)], freetype_exec_prefix="$withval", freetype_exec_prefix="")
    if test x$freetype_exec_prefix != x ; then
        freetype_args="$freetype_args --exec-prefix=$freetype_exec_prefix"
        if test x${FREETYPE_CONFIG+set} != xset ; then
            FREETYPE_CONFIG=$freetype_exec_prefix/bin/freetype-config
        fi
    fi
    if test x$freetype_prefix != x ; then
        freetype_args="$freetype_args --prefix=$freetype_prefix"
        if test x${FREETYPE_CONFIG+set} != xset ; then
        FREETYPE_CONFIG=$freetype_prefix/bin/freetype-config
        fi
    fi
    AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no)
    no_freetype=""
    if test "$FREETYPE_CONFIG" = "no" ; then
        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        if test "$PKG_CONFIG" = "no" ; then
            AC_MSG_ERROR([*** Unable to find FreeType2 library (http://www.freetype.org/)])
        else
            CFLAGS="$CFLAGS `$PKG_CONFIG freetype2 --cflags`"
            LIBS="$LIBS `$PKG_CONFIG freetype2 --libs`"
        fi
    else
        CFLAGS="$CFLAGS `$FREETYPE_CONFIG $freetypeconf_args --cflags`"
        LIBS="$LIBS `$FREETYPE_CONFIG $freetypeconf_args --libs`"
    fi
fi

dnl Check for curses library
if test "$with_curses" = "yes"; then
    CURSES="ncurses"
    AC_CHECK_LIB(ncurses, initscr)
    if test "$ac_cv_lib_ncurses_initscr" != "yes"; then
        CURSES="curses"
        AC_CHECK_LIB(curses, initscr)
        if test "$ac_cv_lib_curses_initscr" != "yes"; then
            CURSES=""
        fi
    fi
    if test "$CURSES" = ""; then
    AC_MSG_ERROR([*** Unable to find curses / ncurses library])
    fi
fi

dnl Check for gettext library
AC_SEARCH_LIBS(gettext, intl)

dnl Determine targets to build
TARGETS=""
TARGETSCLEAN=""
TARGETSINSTALL=""
if test "$with_sdl" = "yes"; then
TARGETS="$TARGETS chroma-sdl"
TARGETSCLEAN="$TARGETSCLEAN clean-sdl";
TARGETSINSTALL="$TARGETSINSTALL install-sdl";
fi
if test "$with_curses" = "yes"; then
TARGETS="$TARGETS chroma-curses"
TARGETSCLEAN="$TARGETSCLEAN clean-curses";
TARGETSINSTALL="$TARGETSINSTALL install-curses";
fi
if test "$TARGETS" = ""; then
AC_MSG_ERROR([*** Nothing to build - specify either --enable-sdl and/or --enable-curses])
fi

AC_SUBST(CURSES)
AC_SUBST(TARGETS)
AC_SUBST(TARGETSCLEAN)
AC_SUBST(TARGETSINSTALL)
AC_OUTPUT(Makefile)