-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.ac
More file actions
222 lines (203 loc) · 7.69 KB
/
configure.ac
File metadata and controls
222 lines (203 loc) · 7.69 KB
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
# -*- 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