Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autotools build #25

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@ doc
*.dev
*.win
*.user

Makefile.in
aclocal.m4
ar-lib
autom4te.cache
compile
config.guess
config.h.in
config.sub
configure
install-sh
ltmain.sh
*.m4
missing
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ACLOCAL_AMFLAGS=-I m4

SUBDIRS = slope \
demos
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sudo apt-get install build-essential cmake libgtk-3-dev
sudo dnf install gcc cmake gtk3-devel
```

Compile and install slope:
Compile and install slope with cmake:
```bash
mkdir build
cd build
Expand All @@ -31,6 +31,14 @@ make
sudo make install
```

compile and install slope with autotools:
```bash
autoreconf -i
./configure --prefix=<installdir>
make
make install
```

## Using the library

After the library is installed you can compile your applications adding the -lslope
Expand Down
61 changes: 61 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Copyright (C) 2017 Elvis Teixeira
#
# This source code is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any
# later version.
#
# This source code is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU Lesser General Public License for
# more details.
#
# You should have received a copy of the GNU Lesser General
# Public License along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#

m4_define([slope_major_version], [2])
m4_define([slope_minor_version], [6])
m4_define([slope_patch_version], [0])
m4_define([slope_version],
[slope_major_version.slope_minor_version.slope_patch_version])

AC_INIT([slope], [slope_version])

# Will be generated
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
AM_INIT_AUTOMAKE([foreign no-dependencies subdir-objects])
AC_PROG_CC
AM_PROG_AR
LT_INIT
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_LIBTOOL

# define version via command line
AX_APPEND_FLAG(
[-DSLOPE_MAJOR_VERSION=slope_major_version])
AX_APPEND_FLAG(
[-DSLOPE_MINOR_VERSION=slope_minor_version])
AX_APPEND_FLAG(
[-DSLOPE_PATCH_VERSION=slope_patch_version])
AX_APPEND_FLAG(
[-DSLOPE_VERSION_STRING=slope_version])

# check for gtk
PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.0])

AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([slope/Makefile])
AC_CONFIG_FILES([slope/source/Makefile])
AC_CONFIG_FILES([slope/source/slope/Makefile])
AC_CONFIG_FILES([slope/include/Makefile])
AC_CONFIG_FILES([slope/include/slope/Makefile])
AC_CONFIG_FILES([demos/Makefile])

AC_OUTPUT
24 changes: 24 additions & 0 deletions demos/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
bin_PROGRAMS = animation \
plot_stack \
simple \
widgets

AM_CFLAGS = -I${top_srcdir}/slope/include/ \
-I${top_srcdir}/slope/source/
AM_LDFLAGS = -L$(top_builddir)/slope/source/slope/.libs/ -lslope -lm

animation_SOURCES = animation.c
animation_CFLAGS = $(AM_CFLAGS) @GTK_CFLAGS@
animation_LDFLAGS = $(AM_LDFLAGS) @GTK_LIBS@

plot_stack_SOURCES = plot_stack.c
plot_stack_CFLAGS = $(AM_CFLAGS) @GTK_CFLAGS@
plot_stack_LDFLAGS = $(AM_LDFLAGS) @GTK_LIBS@

simple_SOURCES = simple.c
simple_CFLAGS = $(AM_CFLAGS) @GTK_CFLAGS@
simple_LDFLAGS = $(AM_LDFLAGS) @GTK_LIBS@

widgets_SOURCES = widgets.c
widgets_CFLAGS = $(AM_CFLAGS) @GTK_CFLAGS@
widgets_LDFLAGS = $(AM_LDFLAGS) @GTK_LIBS@
50 changes: 50 additions & 0 deletions m4/ax_append_flag.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
#
# DESCRIPTION
#
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
# added in between.
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
# FLAG.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <[email protected]>
# Copyright (c) 2011 Maarten Bosmans <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 8

AC_DEFUN([AX_APPEND_FLAG],
[dnl
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
AS_VAR_SET_IF(FLAGS,[
AS_CASE([" AS_VAR_GET(FLAGS) "],
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
[
AS_VAR_APPEND(FLAGS,[" $1"])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
],
[
AS_VAR_SET(FLAGS,[$1])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
AS_VAR_POPDEF([FLAGS])dnl
])dnl AX_APPEND_FLAG
2 changes: 2 additions & 0 deletions slope/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUBDIRS = include \
source
1 change: 1 addition & 0 deletions slope/include/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBDIRS = slope
13 changes: 13 additions & 0 deletions slope/include/slope/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include_HEADERS = chart.h \
figure.h \
item.h \
sampler.h \
slope.h \
xyaxis.h \
xyseries.h \
drawing.h \
global.h \
legend.h \
scale.h \
view.h \
xyscale.h
1 change: 1 addition & 0 deletions slope/source/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBDIRS = slope
20 changes: 20 additions & 0 deletions slope/source/slope/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
lib_LTLIBRARIES = libslope.la

libslope_la_SOURCES = chart.c \
figure.c \
item.c \
legend.c \
scale.c \
view.c \
xyscale.c \
drawing.c \
figure_p.h \
item_p.h \
sampler.c \
scale_p.h \
xyaxis.c \
xyseries.c
libslope_la_CFLAGS = -I${top_srcdir}/slope/include/ \
-I${top_srcdir}/slope/source/ \
@GTK_CFLAGS@
libslope_la_LDFLAGS = @GTK_LIBS@ -rdynamic -lm