Skip to content

Commit 3ffa142

Browse files
sapermgreter
authored andcommitted
Simplify autotools build
Generate sass_version.h Use $(EXEEXT) for executables No need for -lm and C++ library. They should be provided by libtool.
1 parent cfce077 commit 3ffa142

File tree

6 files changed

+47
-36
lines changed

6 files changed

+47
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Makefile.in
2626
/m4/ltsugar.m4
2727
/m4/ltversion.m4
2828
/m4/lt~obsolete.m4
29+
/script/ar-lib
2930
/script/compile
3031
/script/config.guess
3132
/script/config.sub

Makefile.am

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
ACLOCAL_AMFLAGS = -I m4
22

3-
AM_LDFLAGS = -lstdc++ -lm
4-
AM_CFLAGS = -Wall
5-
AM_CXXFLAGS = -Wall
3+
AM_COPT = -Wall -O2
4+
AM_COVLDFLAGS =
65

7-
if COMPILER_IS_MINGW32
8-
AM_CXXFLAGS += -std=gnu++0x
9-
else
10-
AM_CFLAGS += -fPIC
11-
AM_CXXFLAGS += -fPIC
12-
AM_CXXFLAGS += -std=c++0x
13-
AM_LDFLAGS += -ldl
6+
if ENABLE_COVERAGE
7+
AM_COPT = -O0 --coverage
8+
AM_COVLDFLAGS += -lgcov
149
endif
1510

16-
AM_CFLAGS += -DLIBSASS_VERSION="\"$(VERSION)\""
17-
AM_CXXFLAGS += -DLIBSASS_VERSION="\"$(VERSION)\""
11+
AM_CFLAGS = $(AM_COPT)
12+
AM_CXXFLAGS = $(AM_COPT)
13+
AM_LDFLAGS = $(AM_COPT) $(AM_COVLDFLAGS)
1814

19-
if ENABLE_COVERAGE
20-
AM_CFLAGS += -O0 --coverage
21-
AM_CXXFLAGS += -O0 --coverage
22-
AM_LDFLAGS += -O0 --coverage -lgcov
15+
if COMPILER_IS_MINGW32
16+
AM_CXXFLAGS += -std=gnu++0x
2317
else
24-
AM_CFLAGS += -O2
25-
AM_CXXFLAGS += -O2
26-
AM_LDFLAGS += -O2
18+
AM_CXXFLAGS += -std=c++0x
2719
endif
2820

2921
EXTRA_DIST = \
@@ -88,8 +80,6 @@ libsass_la_SOURCES = \
8880
utf8_string.cpp utf8_string.hpp \
8981
util.cpp util.hpp
9082

91-
libsass_la_CFLAGS = $(AM_CFLAGS)
92-
libsass_la_CXXFLAGS = $(AM_CXXFLAGS)
9383
libsass_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 0:9:0
9484

9585
include_HEADERS = sass2scss.h sass_context.h sass_functions.h sass_values.h sass.h
@@ -139,12 +129,7 @@ else
139129
endif
140130

141131
SASS_TESTER = $(RUBY) $(SASS_SPEC_PATH)/sass-spec.rb
142-
143-
if COMPILER_IS_MINGW32
144-
SASS_TESTER += -c $(SASS_LIBSASS_PATH)/tester.exe
145-
else
146-
SASS_TESTER += -c $(SASS_LIBSASS_PATH)/tester
147-
endif
132+
SASS_TESTER += -c $(SASS_LIBSASS_PATH)/tester$(EXEEXT)
148133

149134
test:
150135
$(SASS_TESTER) --ignore-todo $(LOG_FLAGS) $(SASS_SPEC_PATH) $(SASS_TEST_FLAGS)

configure.ac

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ AC_INIT([libsass], m4_esyscmd_s([./version.sh]), [[email protected]])
77
AC_CONFIG_SRCDIR([ast.hpp])
88
AC_CONFIG_MACRO_DIR([m4])
99
AC_CONFIG_HEADERS([config.h])
10+
AC_CONFIG_FILES([sass_version.h])
1011
AC_CONFIG_AUX_DIR([script])
11-
AM_INIT_AUTOMAKE([foreign parallel-tests])
12+
# These are flags passed to automake
13+
# Though they look like gcc flags!
14+
AM_INIT_AUTOMAKE([foreign parallel-tests -Wall])
1215
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
13-
LT_INIT
1416

1517
# Checks for programs.
1618
AC_PROG_CXX
17-
1819
AC_LANG([C++])
20+
LT_INIT([dlopen])
1921

2022
# Checks for header files.
2123
AC_CHECK_HEADERS([unistd.h])
@@ -31,6 +33,17 @@ AC_CHECK_FUNCS([floor getcwd strtol])
3133
AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests], [enable testing the build]),
3234
[enable_tests="$enableval"], [enable_tests=no])
3335

36+
AS_CASE([$host], [*-*-mingw32], [is_mingw32=yes], [is_mingw32=no])
37+
AM_CONDITIONAL(COMPILER_IS_MINGW32, test "x$is_mingw32" = "xyes")
38+
39+
dnl The dlopen() function is in the C library for *BSD and in
40+
dnl libdl on GLIBC-based systems
41+
if test "x$is_mingw32" != "xyes"; then
42+
AC_SEARCH_LIBS([dlopen], [dl dld], [], [
43+
AC_MSG_ERROR([unable to find the dlopen() function])
44+
])
45+
fi
46+
3447
if test "x$enable_tests" = "xyes"; then
3548
AC_PROG_CC
3649
AC_PROG_AWK
@@ -107,8 +120,7 @@ fi
107120

108121
AM_CONDITIONAL(ENABLE_COVERAGE, test "x$enable_cov" = "xyes")
109122

110-
AS_CASE([$host], [*-*-mingw32], [is_mingw32=yes], [is_mingw32=no])
111-
AM_CONDITIONAL(COMPILER_IS_MINGW32, test "x$is_mingw32" = "xyes")
123+
AC_SUBST(PACKAGE_VERSION)
112124

113125
AC_MSG_NOTICE([Building libsass ($VERSION)])
114126

sass.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@
3232

3333
#endif
3434

35-
#ifndef LIBSASS_VERSION
36-
#define LIBSASS_VERSION "[NA]"
37-
#endif
38-
3935
// include API headers
36+
#include "sass_version.h"
4037
#include "sass_values.h"
4138
#include "sass_functions.h"
4239

sass_version.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef SASS_VERSION_H
2+
#define SASS_VERSION_H
3+
4+
#ifndef LIBSASS_VERSION
5+
#define LIBSASS_VERSION "[NA]"
6+
#endif
7+
8+
#endif

sass_version.h.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef SASS_VERSION_H
2+
#define SASS_VERSION_H
3+
4+
#ifndef LIBSASS_VERSION
5+
#define LIBSASS_VERSION "@PACKAGE_VERSION@"
6+
#endif
7+
8+
#endif

0 commit comments

Comments
 (0)