forked from klei1984/le_disasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
158 lines (124 loc) · 4.42 KB
/
configure.ac
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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
m4_define([ver_major], [1])
m4_define([ver_minor], [0])
m4_define([ver_release], [2])
# Set build number to commit count only if ".git" folder is present
m4_define([ver_build], m4_if(m4_esyscmd_s([ls -1 -d ".git" 2>&1]),.git,[m4_esyscmd_s([git rev-list --count HEAD])],[0]))
m4_define([ledisasm_version],
[ver_major.ver_minor.ver_release.ver_build])
AC_INIT([LE Disassembler], [ledisasm_version], [unavowed@vexillium.org], [le_disasm])
AC_CONFIG_SRCDIR([src/disassembler.cpp])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_MACRO_DIRS([m4])
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([foreign])
ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_DEFINE([VER_MAJOR], [ver_major], [Major version number])
AC_DEFINE([VER_MINOR], [ver_minor], [Minor version number])
AC_DEFINE([VER_RELEASE], [ver_release], [Release number])
AC_DEFINE([VER_BUILD], [ver_build], [Build number])
# M4 defines __unix__ to be the empty string on UNIX-like systems. This
# causes AC_DEFINE to fail if it is used to define __unix__. This seems to
# fix the problem.
ifdef([__unix__], define([__unix__], [[__unix__]]))
# Set the proper prefix
AS_IF([test "$prefix" = "NONE"], [
prefix="$ac_default_prefix"
])
AS_IF([test "$exec_prefix" = "NONE"], [
exec_prefix="$prefix"
])
# Checks for programs.
AC_PROG_CXX
PKG_PROG_PKG_CONFIG
AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", "windres", :)
AC_PROG_SED # `sed` is used in Makefile for packaging shared libraries on Windows
# Checks for libraries.
AC_MSG_CHECKING([[if we need a __unix__ define]])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#ifndef __unix__
# if defined __APPLE__ /* add other known platforms here */
# error should have __unix__ but it is not set
# endif
#endif
])], [AC_MSG_RESULT([no])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([__unix__], 1,
[Define to 1 if running on a UNIX-like system where __unix__ is missing])
])
have_posix=yes
have_windows=no
have_darwin=no
case "$host" in
*-*-mingw*)
have_windows=yes
have_posix=no
;;
*-*-darwin*)
have_darwin=yes
;;
esac
AM_CONDITIONAL([TARGET_WINDOWS], [test "$have_windows" = "yes"])
# On Windows, we can optionaly include resources in the executable.
AM_CONDITIONAL([HAS_WINDRES], [test -n "${WINDRES}" -a "$have_windows" = "yes"])
# If a library is found after checking or searching like below, the
# LIBS variable is updated to include that library while linking.
AC_CHECK_LIB([intl], [libintl_version], [], [
AC_MSG_WARN([library libintl not found, either built into glibc or missing])
])
# Required by libbfd
AC_CHECK_LIB([iberty], [lrealpath], [], [
AC_MSG_FAILURE([library libiberty not found])
])
# Required by libbfd from binutils >= 2.40
AC_SEARCH_LIBS([sframe_encode], [sframe], [], [
AC_MSG_WARN([unable to find function sframe_encode(), libbfd may require it])
])
# Required by libbfd from binutils <= 2.39
AC_CHECK_LIB([z], [deflate], [], [
AC_MSG_WARN([library zlib not found, libbfd may require it])
])
# Required by libbfd from binutils >= 2.40
AC_CHECK_LIB([zstd], ZSTD_decompress, [], [
AC_MSG_WARN([library zstd not found, libbfd may require it])
])
AC_CHECK_HEADERS([zstd.h])
AC_CHECK_LIB([bfd], [bfd_init], [], [
AC_MSG_FAILURE([library libbfd not found])
])
AC_CHECK_HEADERS([bfd.h])
AC_CHECK_LIB([opcodes], [print_i386_disassembler_options], [], [
AC_MSG_FAILURE([library libopcodes not found])
])
# For libopcodes from binutils >= 2.40 there is a style support
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
# include <bfd.h>
# include <dis-asm.h>
], [
init_disassemble_info(NULL, NULL, NULL, NULL);
])], [
AC_DEFINE([HAVE_LIBOPCODES_DISASSEMBLER_STYLE], [1],
[Define to 1 if your libbfd init_disassemble_info() takes styled printf func as last argument.])
])
# Arguments
#AC_ARG_ENABLE([debug],
# AS_HELP_STRING([--enable-debug=@<:@no|yes|full@:>@],
# [enable debugging options]),
# [use_debug=$enableval], [use_debug=no])
# Flags
CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter"
CFLAGS="$CFLAGS -include \"\$(top_builddir)/src/config.h\""
AC_SUBST([WINDRES])
# Prepare makefiles from `.in` templates
AC_CONFIG_FILES([Makefile src/Makefile])
# Prepare files for Windows build
AC_CONFIG_LINKS([
res/ledisasm-icon128.ico:res/ledisasm-icon128.ico
])
# Done - generate and execute `config.status`
AC_OUTPUT
echo