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

Convert build system to autotools, and enable building the shared library #116

Open
wants to merge 1 commit 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
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*~
*.pc
*.la
*.o
libtool
ltmain.sh
missing
install-sh
depcomp
configure
config.*
*.lo
autom4te.cache
ar-lib
compile
test-driver
aclocal.m4
Makefile
Makefile.in
.deps
*.log
.libs
ii
*.tar*
/jsondump
/simple_example
/test_*
.dirstamp
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: c
sudo: false
script:
- make test
- ./autogen.sh
- ./configure
- make all simple_example check
41 changes: 0 additions & 41 deletions Makefile

This file was deleted.

53 changes: 53 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2017 Luke Dashjr
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the standard MIT license. See COPYING for more details.

lib_LTLIBRARIES = libjsmn.la
libjsmn_la_SOURCES = jsmn.c
libjsmn_la_LDFLAGS = -version-info $(LIBJSMN_SO_VERSION) -no-undefined

libjsmn_includedir = $(includedir)
libjsmn_include_HEADERS = jsmn.h

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = jsmn.pc

dist_noinst_SCRIPTS = autogen.sh
dist_doc_DATA = LICENSE README.md

jsondump_SOURCES = example/jsondump.c
jsondump_LDADD = libjsmn.la

simple_example_SOURCES = example/simple.c
simple_example_LDADD = libjsmn.la

if USE_TOOL
bin_PROGRAMS = jsondump
endif

if NEVER_ENABLED
noinst_PROGRAMS = simple_example
endif

TESTS = test_default test_strict test_links test_strict_links
if NEVER_ENABLED
noinst_PROGRAMS += $(TESTS)
endif

test_default_SOURCES = test/tests.c

test_strict_SOURCES = test/tests.c
test_strict_CPPFLAGS = -DJSMN_STRICT=1

test_links_SOURCES = test/tests.c
test_links_CPPFLAGS = -DJSMN_PARENT_LINKS=1

test_strict_links_SOURCES = test/tests.c
test_strict_links_CPPFLAGS = -DJSMN_STRICT=1 -DJSMN_PARENT_LINKS=1

# Compatibility with old Makefile:

test: check

.PHONY: test
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ To clone the repository you should have Git installed. Just run:
$ git clone https://github.com/zserge/jsmn

Repository layout is simple: jsmn.c and jsmn.h are library files, tests are in
the jsmn\_test.c, you will also find README, LICENSE and Makefile files inside.
test/tests.c; you will also find README, LICENSE and autotools build files
inside.

To build the library, run `make`. It is also recommended to run `make test`.
Let me know, if some tests fail.
To build the library, run `./configure && make`. It is also recommended to run
`make test`. Let me know if any tests fail.

If build was successful, you should get a `libjsmn.a` library.
If build was successful, you should get a `libjsmn.a` and `libjsmn.so*`
libraries in the `.libs` directory.
The header file you should include is called `"jsmn.h"`.

You can install the libraries to your system by running `make install`.

API
---

Expand Down
11 changes: 11 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh -e
# Written by Luke Dashjr in 2012
# This program is released under the terms of the Creative Commons "CC0 1.0 Universal" license and/or copyright waiver.

if test -z "$srcdir"; then
srcdir=`dirname "$0"`
if test -z "$srcdir"; then
srcdir=.
fi
fi
autoreconf --force --install --verbose "$srcdir"
38 changes: 38 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
dnl * Copyright 2012-2017 Luke Dashjr
dnl *
dnl * This program is free software; you can redistribute it and/or modify it
dnl * under the terms of the standard MIT license. See COPYING for more details.

AC_INIT(
[jsmn],
[0.1.0],
[[email protected]],
[jsmn])
AC_CONFIG_AUX_DIR([.])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([1.11 -Wall dist-xz foreign subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

AC_PROG_CC_C99
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
LT_INIT([])

# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
AC_SUBST([LIBJSMN_SO_VERSION], [0:0:0])

AC_CONFIG_FILES([Makefile
jsmn.pc:jsmn.pc.in
])

AC_ARG_ENABLE([tool],
[AC_HELP_STRING([--disable-tool],[Compile command line jsmndump tool (default enabled)])],
[use_tool=$enableval],
[use_tool=auto])
if test x$use_tool != xno; then
use_tool=yes
fi
AM_CONDITIONAL([USE_TOOL], [test x$use_tool = xyes])

AM_CONDITIONAL([NEVER_ENABLED], [false])

AC_OUTPUT
10 changes: 10 additions & 0 deletions jsmn.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

Name: @PACKAGE_NAME@
Description: A minimalistic JSON parser in C.
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -ljsmn
Cflags: -I${includedir}