223 lines (203 with data), 7.9 kB
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#
# Only two files are truly needed: configure.ac and Makefile.am.
# The config.h.in can be generated by autoheader, plus the extra contents.
# The m4 directory can be empty if there was "AC_CONFIG_MACRO_DIR([m4])" in
# configure.ac and "ACLOCAL_AMFLAGS = -I m4 --install" in Makefile.am
#
# Using "autoreconf -i" to generate all files, not "autoconf".
#
# Test plan:
# *) configure --enable-debug-build=yes
# should be "-g -DDEBUG=3 -O0" in compiling
# *) configure --enable-debug-build=0
# same to --enable-debug-build=no, "-O4" in compiling
# *) configure --enable-debug-build=6
# should be "-g -DDEBUG=6 -O0" in compiling
# In MinGW, the installer should be created also:
# *) configure --with-gui=no && make release
# should build the command line tool renamex.exe only, no renamex_win.exe
# *) configure --with-gui=gtk2 && make release
# other options are same, which build both renamex.exe and renamex_win.exe
# In a clean Debian box
# *) configure --with-gui=yes && make
# should issue a warning and build a command line version
# *) configure --with-gui=gtk && make release
# same to above; the release only includes source codes.
# Install gtk2-dev
# *) configure --with-gui=no && make
# should build a command line only version
# *) configure --with-gui=gtk3 && make
# should issue a warning but build a gtk2 version instead
# Install gtk3-dev
# *) configure && make
# should link default gui mode with gtk3
# *) configure --with-gui=gtk2 && make
# should link gtk2
# make gnome-install
# install the icon and binary to gnome environment
# make gnome-uninstall
# revoke the install operation
AC_PREREQ([2.68])
AC_INIT([renamex], [2.11], [xuming@users.sourceforge.net])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_ARG_ENABLE([debug-build],
AS_HELP_STRING([--enable-debug-build],
[Enable the debug output (yes,no,0-7)]))
AS_CASE([$enable_debug_build],
[yes|Yes|YES], [CFLAGS="-Wall -Wextra -Wno-cast-function-type -g -DDEBUG=3 -O0"],
[1|2|3|4|5|6|7], [CFLAGS="-Wall -Wextra -Wno-cast-function-type -g -DDEBUG=$enable_debug_build -O0"],
[CFLAGS="-Wall -Wextra -Wno-cast-function-type -O3"])
AC_ARG_WITH([gui],
AS_HELP_STRING([--with-gui],
[Build with the Graphic User Interface [yes]]))
# Checks for library functions.
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memmove memset strchr strrchr strstr strtol])
case "$host_os" in
cygwin | mingw*)
SYSTOOL=mingw
AS_CASE([$with_gui], [no|No|NO], [SYSGUI=CFG_GUI_OFF], [
SYSGUI=CFG_GUI_ON
PREFLIB=renamex_win])
# Checks for WIN32 programs.
AC_CHECK_PROG([WINDRES], [windres], [windres],
[AC_MSG_ERROR([windres not found.])])
AC_CHECK_PROG([NSIS], [makensis], [makensis],
[AC_MSG_WARN([NSIS package not installed. \
You may not be able to create the installer executables.])])
CFLAGS="$CFLAGS -mms-bitfields"
SYSDEFS="-DUNICODE -D_UNICODE -D_WIN32_IE=0x0500 -DWINVER=0x500"
LIBS="$LIBS -mconsole"
EXTLIBS="$EXTLIBS -liup -liupimglib -lm"
case "$MSYSTEM" in
MINGWXP) WIN_UNAME=win32
CPPFLAGS="$CPPFLAGS -I./external/iup-porting/WinXP_mingw4_lib/include"
LDFLAGS="$LDFLAGS -L./external/iup-porting/WinXP_mingw4_lib"
;;
MINGW32) WIN_UNAME=win32
EXTARGET="$EXTARGET libregex"
EXTCLEAN="$EXTCLEAN libregex_clean"
CPPFLAGS="$CPPFLAGS -I./external/iup-porting/Win32_mingw6_lib/include"
LDFLAGS="$LDFLAGS -L./external/iup-porting/Win32_mingw6_lib"
;;
UCRT64) WIN_UNAME=ucrt64
EXTARGET="$EXTARGET libregex"
EXTCLEAN="$EXTCLEAN libregex_clean"
CPPFLAGS="$CPPFLAGS -I./external/iup-porting/Win64_mingw6_lib/include"
LDFLAGS="$LDFLAGS -L./external/iup-porting/Win64_mingw6_lib"
;;
*) WIN_UNAME=win64
EXTARGET="$EXTARGET libregex"
EXTCLEAN="$EXTCLEAN libregex_clean"
CPPFLAGS="$CPPFLAGS -I./external/iup-porting/Win64_mingw6_lib/include"
LDFLAGS="$LDFLAGS -L./external/iup-porting/Win64_mingw6_lib"
;;
esac
CPPFLAGS="$CPPFLAGS -I./external/regex-20090805/lib"
LDFLAGS="$LDFLAGS -L./external/regex-20090805/.libs"
EXTLIBS="$EXTLIBS -lregex"
AC_SUBST(WIN_UNAME)
;;
*)
SYSTOOL=unix
AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [])
if test "x$PKGCONFIG" = x; then
SYSGUI=CFG_GUI_OFF
AC_MSG_WARN([pkg-config is not found -- command line interface only])
else
SYSGUI=CFG_GUI_ON
AS_CASE([$with_gui],
[no|No|NO],
[SYSGUI=CFG_GUI_OFF],
[2|gtk2|Gtk2|GTK2],
[PKG_CHECK_MODULES([GTK], [gtk+-2.0], [
AC_MSG_RESULT([gtk+-2.0])
IUPCFG="USE_GTK2=1"],
[PKG_CHECK_MODULES([GTK], [gtk+-3.0],
[AC_MSG_WARN([Gtk 2.0 not found. Using Gtk 3.0 instead])],
[SYSGUI=CFG_GUI_OFF])]
)],
[3|gtk3|Gtk3|GTK3],
[PKG_CHECK_MODULES([GTK], [gtk+-3.0], ,
[PKG_CHECK_MODULES([GTK], [gtk+-2.0], [
AC_MSG_WARN([Gtk 3.0 not found. Using Gtk 2.0 instead])
IUPCFG="USE_GTK2=1"],
[SYSGUI=CFG_GUI_OFF])]
)],
[PKG_CHECK_MODULES([GTK], [gtk+-3.0],
[AC_MSG_NOTICE([gtk+-3.0 found])],
[PKG_CHECK_MODULES([GTK], [gtk+-2.0],
[AC_MSG_NOTICE([gtk+-2.0 found])
IUPCFG="USE_GTK2=1"],
[SYSGUI=CFG_GUI_OFF])]
)])
# IUP 3.30 requires -lm
AS_IF([! test "$SYSGUI" = CFG_GUI_OFF], [
CPPFLAGS="$CPPFLAGS $GTK_CFLAGS -I./external/iup-porting/iup/include"
LIBS="$LIBS $GTK_LIBS -lX11"
EXTARGET="$EXTARGET libiup"
EXTCLEAN="$EXTCLEAN libiup_clean"
LDFLAGS="$LDFLAGS -L./external/iup-porting/lib"
EXTLIBS="$EXTLIBS -liup -liupimglib -lm"
])
fi
SYSDEFS="-D$SYSGUI"
;;
esac
EXTARGET="$EXTARGET libcsoup"
EXTCLEAN="$EXTCLEAN libcsoup_clean"
CPPFLAGS="$CPPFLAGS -I./external/libcsoup"
LDFLAGS="$LDFLAGS -L./external/libcsoup"
EXTLIBS="$EXTLIBS -lcsoup"
# Do NOT check libregex
# For Windows XP, it's included in the IUP porting
# For Windows 32/64, the MSYS2 libregex is not natively portable, which requires libsystre-0.dll
# So no need to check libregex, always have it rebuilt in MSYS2
#AC_CHECK_LIB([regex], [regcomp], [
# EXTLIBS="$EXTLIBS -lregex"
#], [
# EXTARGET="$EXTARGET libregex"
# EXTCLEAN="$EXTCLEAN libregex_clean"
# CPPFLAGS="$CPPFLAGS -I./external/regex-20090805/lib"
# LDFLAGS="$LDFLAGS -L./external/regex-20090805/.libs"
# EXTLIBS="$EXTLIBS -lregex"
#])
AM_CONDITIONAL([XAM_MSWIN], [test x$SYSTOOL = xmingw])
AM_CONDITIONAL([XAM_GUI], [test x$SYSGUI = xCFG_GUI_ON])
PREFLIB="extlib $PREFLIB"
# Checks for header files.
# AC_INCLUDES_DEFAULT can not output header defines automatically
# You need to add these include files manually in your C codes.
AC_CHECK_HEADERS([sys/time.h],,,[AC_INCLUDES_DEFAULT])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Just for checking the function of AC_DEFINE().
# It can add an object in config.h.in by autoheader and output what I need.
# AC_DEFINE([HAVE_GUI],[1],[GUI is required])
AC_SUBST(IUPCFG)
AC_SUBST(SYSDEFS)
AC_SUBST(PREFLIB)
AC_SUBST(EXTARGET)
AC_SUBST(EXTCLEAN)
# This is for Win32 GUI porting only
WIN32GUI="$EXTLIBS -mwindows -lkernel32 -luser32 -lgdi32 -lwinspool \
-lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32"
AC_SUBST(WIN32GUI)
# This can be the requirement for Win32 console (IUP doesn't matter)
LIBS="$EXTLIBS $LIBS"
AC_CONFIG_FILES([Makefile])
AC_OUTPUT