From: Chip Black Date: Mon, 7 Nov 2011 04:25:27 +0000 (-0600) Subject: Add autoconf system provided by Boris Manojlovic X-Git-Tag: v1.6.1~1 X-Git-Url: http://git.bytex64.net/?a=commitdiff_plain;h=a88ac56feb7930b575668d20f31285d83da95893;p=blerg.git Add autoconf system provided by Boris Manojlovic --- diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..2ea41ec --- /dev/null +++ b/Makefile.am @@ -0,0 +1,47 @@ +# +ACLOCAL_AMFLAGS = -I m4 +cgidir=@CGIBINDIR@ +cgi_PROGRAMS=blerg.cgi rss.cgi +bin_PROGRAMS=blergtool blerglatest blerg.httpd + +noinst_LIBRARIES=libblerg.a +libblerg_a_SOURCES=database/database.c database/tags.c database/util.c database/subscription.c common/stringbucket.c +libblerg_a_CFLAGS=-I$(top_srcdir)/common + +blergtool_SOURCES=tools/blergtool.c +blergtool_LDADD=libblerg.a +blergtool_CFLAGS=-I$(top_srcdir)/database -I$(top_srcdir)/common + +blerglatest_SOURCES=tools/blerglatest.c common/json.c +blerglatest_LDADD=libblerg.a @YAJL_LIBS@ +blerglatest_CFLAGS=-I$(top_srcdir)/database -I$(top_srcdir)/common @YAJL_CFLAGS@ + +blerg_httpd_SOURCES=http/http_blerg.c http/canned_responses.c common/app.c common/json.c common/auth.c common/md5.c +blerg_httpd_LDADD=libblerg.a @MICROHTTPD_LIBS@ @YAJL_LIBS@ +blerg_httpd_CFLAGS=-I$(top_srcdir)/common -I$(top_srcdir)/database @MICROHTTPD_CFLAGS@ @YAJL_CFLAGS@ +blerg_httpd_SHORTNAME=http + +blerg_cgi_SOURCES=cgi/cgi_blerg.c cgi/canned_responses.c common/app.c common/json.c common/auth.c common/md5.c +blerg_cgi_LDADD=libblerg.a @YAJL_LIBS@ @CGIUTIL_LIBS@ +blerg_cgi_CFLAGS=-I$(top_srcdir)/common -I$(top_srcdir)/database @YAJL_CFLAGS@ @CGIUTIL_CFLAGS@ +blerg_cgi_SHORTNAME=cgi + +rss_cgi_SOURCES=cgi/rss.c cgi/canned_responses.c common/app.c common/escapery.c +rss_cgi_LDADD=libblerg.a @YAJL_LIBS@ @CGIUTIL_LIBS@ +rss_cgi_CFLAGS=-I$(top_srcdir)/common -I$(top_srcdir)/database @CGIUTIL_CFLAGS@ +rss_cgi_SHORTNAME=rss + +############# IMPORTANT +# add all header files here so they will be added to tar archive with make dist +EXTRA_DIST = common/stringbucket.h database/tags.h database/database.h database/util.h database/subscription.h database/blergref.h common/escapery.h \ + common/auth.h database/tags.h database/database.h database/util.h database/subscription.h database/blergref.h common/escapery.h common/auth.h \ + common/stringbucket.h common/app.h common/json.h common/md5.h http/canned_responses.h cgi/canned_responses.h + +# Data and documentation + +dist_doc_DATA = README ChangeLog COPYING +wwwdir=@datadir@/blerg +nobase_dist_www_DATA = www/favicon.gif www/doc/changelog.html www/doc/index.html www/index.html www/images/rss.png www/images/play.png www/css/doc.css\ + www/images/blerglogo.png www/js/blerg.js www/js/Bytex64.FX.js www/js/blergmedia.js www/js/prototype.js www/favicon.ico www/css/blerg.css +htaccessdir=@datadir@/blerg +dist_htaccess_DATA=www-configs/htaccess diff --git a/README b/README index 74b8ad1..dc3bf08 100644 --- a/README +++ b/README @@ -12,3 +12,5 @@ The RSS feed icon is from http://feedicons.com/. The puking bird logo is Copyright (C) 2010 James Watson, and is used with permission. + +Autoconf support was graciously added by Boris Manojlovic. diff --git a/add-autoconf b/add-autoconf new file mode 100755 index 0000000..28ce61e --- /dev/null +++ b/add-autoconf @@ -0,0 +1,7 @@ +#!/bin/sh +set -x +aclocal -I m4 +autoconf +touch NEWS AUTHORS ChangeLog # needed by automake... +autoheader # generate config.h.in +automake -a -c # install missing files diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..bdd9cc1 --- /dev/null +++ b/configure.in @@ -0,0 +1,186 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.65]) +AC_INIT(config.h) +AM_INIT_AUTOMAKE([blerg], [1.6]) +AC_PROG_RANLIB +AC_CONFIG_SRCDIR([common/app.c]) +AC_CONFIG_HEADERS([config.h]) + +# Checks for programs. +AC_PROG_CC +AM_PROG_CC_C_O +PKG_PROG_PKG_CONFIG + +# Checks for libraries. +AC_CHECK_LIB([pthread], [main]) +AX_CHECK_YAJL +AX_CHECK_CGIUTIL +PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd]) +AC_SUBST([MICROHTTPD_CFLAGS]) +AC_SUBST([MICROHTTPD_LIBS]) + + +# Checks for header files. +AC_CHECK_HEADERS([fcntl.h memory.h stdint.h stdlib.h string.h sys/file.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T + +# Checks for library functions. +AC_FUNC_MALLOC +AC_FUNC_MMAP +AC_FUNC_REALLOC +AC_CHECK_FUNCS([ftruncate memset mkdir munmap select strchr strtoull]) + +# Needed variables for programs to function... +AC_ARG_WITH([blerg-data-path], +AC_HELP_STRING([--with-blerg-data-path=@<:@DIR@:>@], +[Where database files will be stored default=data] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([DATA_PATH], ["$withval"], [Where data is located]) +else + AC_MSG_ERROR(blerg-data-path MUST be defined) +fi +], +[AC_DEFINE([DATA_PATH], ["data"], [Where data is located])] +) + +AC_ARG_WITH([blerg-hash-tags-path], +AC_HELP_STRING([--with-blerg-hash-tags-path=@<:@DIR@:>@], +[Where hash tags files will be stored default=hash_tags] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([HASH_TAGS_PATH], ["$withval"], [Where tags will be saved]) +else + AC_MSG_ERROR(blerg-hash-tags-path MUST be defined) +fi +], +[AC_DEFINE([HASH_TAGS_PATH], ["hash_tags"], [Where tags will be saved])] +) + + +AC_ARG_WITH([blerg-ref-tags-path], +AC_HELP_STRING([--with-blerg-ref-tags-path=@<:@DIR@:>@], +[Where ref tags files will be stored default=ref_tags] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([REF_TAGS_PATH], ["$withval"], [Where refs will be saved]) +else + AC_MSG_ERROR(blerg-ref-tags-path MUST be defined) +fi +], +[AC_DEFINE([REF_TAGS_PATH], ["ref_tags"], [Where reffering tags will be save])] +) + +AC_ARG_WITH([blerg-baseurl], +AC_HELP_STRING([--with-blerg-baseurl=@<:@URL@:>@], +[Baseurl is used for generating urls from cgi default=http://blerg.dominionofawesome.com/] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([BASEURL], ["$withval"], [Base url for cgi]) +else + AC_MSG_ERROR(blerg-baseurl MUST be defined) +fi +], +[AC_DEFINE([BASEURL], ["http://blerg.dominionofawesome.com/"], [Base URL for this blerg instance])] +) + +AC_ARG_WITH([blerg-http-port], +AC_HELP_STRING([--with-blerg-http-port=@<:@INT@:>@], +[Listening port number default=8080] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([HTTP_BLERG_PORT], [$withval], [Port number for blerg.http]) +else + AC_MSG_ERROR(blerg-http-port MUST be defined) +fi +], +[AC_DEFINE([HTTP_BLERG_PORT], [8080], [Blerg listening port])] +) + +AC_ARG_WITH([blerg-records-per-segment], +AC_HELP_STRING([--with-blerg-records-per-segment=@<:@INT@:>@], +[Records per segment default=65536] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([RECORDS_PER_SEGMENT], [$withval], [Database setting]) +else + AC_MSG_ERROR(blerg-records-per-segment MUST be defined) +fi +], +[AC_DEFINE([RECORDS_PER_SEGMENT], [65536], [Database settings])] +) + +AC_ARG_WITH([blerg-max-record-size], +AC_HELP_STRING([--with-blerg-max-record-size=@<:@INT@:>@], +[Max record size default=65535] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([MAX_RECORD_SIZE], [$withval], [Database setting]) +else + AC_MSG_ERROR(blerg-max-record-size MUST be defined) +fi +], +[AC_DEFINE([MAX_RECORD_SIZE], [65535], [No greater than 65535])] +) + +AC_ARG_WITH([blerg-max-tag-length], +AC_HELP_STRING([--with-blerg-max-tag-length=@<:@INT@:>@], +[Max size of tag default=64] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([MAX_TAG_LENGTH], [$withval], [Length of tags]) +else + AC_MSG_ERROR(blerg-max-tag-length MUST be defined) +fi +], +[AC_DEFINE([MAX_TAG_LENGTH], [64],[Length of tags])] +) + +AC_ARG_WITH([blerg-max-tags-per-record], +AC_HELP_STRING([--with-blerg-max-tags-per-record=@<:@INT@:>@], +[Number of tags per record default=1024] +), +[ +if test "$withval" != "no"; then + AC_DEFINE_UNQUOTED([MAX_TAGS_PER_RECORD], [$withval], [Tags per record]) +else + AC_MSG_ERROR(blerg-max-tags-per-record MUST be defined) +fi +], +[AC_DEFINE([MAX_TAGS_PER_RECORD], [1024],[Tags per record])] +) + +AC_ARG_WITH([cgi-bin-dir], +AC_HELP_STRING([--with-cgi-bin-dir=@<:@DIR@:>@], +[Path where to install cgi programs default=/srv/www/cgi-bin] +), +[ +if test "$withval" != "no"; then + CGIBINDIR="$withval" +else + AC_MSG_ERROR(cgi-bin-dir MUST be set) +fi +], +[CGIBINDIR="/srv/www/cgi-bin/"] +) + +AC_SUBST(CGIBINDIR) + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/m4/cgiutil.m4 b/m4/cgiutil.m4 new file mode 100644 index 0000000..6c79df0 --- /dev/null +++ b/m4/cgiutil.m4 @@ -0,0 +1,102 @@ +# =========================================================================== +# URL +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_CGIUTIL() +# +# DESCRIPTION +# +# +# LICENSE +# +# Copyright (c) 2011 Boris Manojlovic +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program 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 General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 1 + +AU_ALIAS([CHECK_CGIUTIL], [AX_CHECK_CGIUTIL]) +AC_DEFUN([AX_CHECK_CGIUTIL], +# +# Handle user hints +# +[AC_ARG_WITH(cgi-util, +[ + --with-cgi-util=DIR root directory path of cgi-util installation [defaults to + /usr/local or /usr if not found in /usr/local] + --without-cgi-util to disable cgi-util usage completely], +[ +if test "$withval" != "no"; then + if test -d "$withval" ; then + WANT_CGIUTIL="yes" + cgi_util_places="$withval" + else + AC_MSG_WARN([Sorry, $withval does not exist]) + fi +fi +],[ +dnl just provide default places where it most probably could be found +cgi_util_places="/usr/local /usr /opt/local /sw" +]) + +# +# Locate cgi-util +# + +if test -n "$cgi_util_places" ; then + # check the user supplied or any other more or less 'standard' place: + # Most UNIX systems : /usr/local and /usr + # MacPorts / Fink on OSX : /opt/local respectively /sw + for CGIUTIL_HOME in ${cgi_util_places} ; do + if test -f "${CGIUTIL_HOME}/include/cgi-util.h"; then break; fi + CGIUTIL_HOME="" + done + + # if cgi-util.h was nowhere to be found, give a notice and bail out + if test ! -n "${CGIUTIL_HOME}"; then + AC_MSG_ERROR(No cgi-util.h in any include directory of ${cgi_util_places}: either specify a valid cgi-util installation with --with-cgi-util=DIR or disable cgi-util usage with --without-cgi-util) + fi + + AC_LANG_SAVE + AC_LANG_C + AC_CHECK_LIB(cgi-util, cgi_init, [cgi_util_cv_libcgi_util=yes], [cgi_util_cv_libcgi_util=no]) + AC_CHECK_HEADER(cgi-util.h, [cgiutil_cv_cgiutil_h=yes], [cgi_util_cv_cgi_util_h=no]) + AC_LANG_RESTORE + CGIUTIL_LIBS="-lcgi-util" + CGIUTIL_CFLAGS="-I${CGIUTIL_HOME}/include" + if test "$cgi_util_cv_libcgi_util" != "yes" -a "$cgiutil_cv_cgiutil_h" != "yes" + then + # If either header or library was not found, revert and bomb + AC_MSG_ERROR(either specify a valid cgi-util installation with --with-cgi-util=DIR or disable cgi-util usage with --without-cgi-util) + fi +fi +AC_SUBST(CGIUTIL_LIBS) +AC_SUBST(CGIUTIL_CFLAGS) +AC_SUBST(CGIUTIL_LDFLAGS) dnl no really use for this library +]) diff --git a/m4/yajl.m4 b/m4/yajl.m4 new file mode 100644 index 0000000..a946666 --- /dev/null +++ b/m4/yajl.m4 @@ -0,0 +1,100 @@ +# =========================================================================== +# URL +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_YAJL() +# +# DESCRIPTION +# +# +# LICENSE +# +# Copyright (c) 2011 Boris Manojlovic +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program 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 General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 1 + +AU_ALIAS([CHECK_YAJL], [AX_CHECK_YAJL]) +AC_DEFUN([AX_CHECK_YAJL], +# +# Handle user hints +# +[AC_ARG_WITH(yajl, +[ + --with-yajl=DIR root directory path of yajl installation [defaults to + /usr/local or /usr if not found in /usr/local] + --without-yajl to disable yajl usage completely], +[ +if test "$withval" != "no"; then + if test -d "$withval" ; then + WANT_YAJL="yes" + yajl_places="$withval" + else + AC_MSG_WARN([Sorry, $withval does not exist]) + fi +fi +],[ +dnl just provide default places where it most probably could be found +yajl_places="/usr/local /usr /opt/local /sw" +]) + +# +# Locate yajl +# + +if test -n "$yajl_places" ; then + # check the user supplied or any other more or less 'standard' place: + for YAJL_HOME in ${yajl_places} ; do + if test -f "${YAJL_HOME}/include/yajl/yajl_parse.h"; then break; fi + YAJL_HOME="" + done + + # if yajl.h was nowhere to be found, give a notice and bail out + if test ! -n "${YAJL_HOME}"; then + AC_MSG_ERROR(No yajl.h in any include directory of ${yajl_places}: either specify a valid yajl installation with --with-yajl=DIR or disable yajl usage with --without-yajl) + fi + + AC_LANG_SAVE + AC_LANG_C + AC_CHECK_LIB(yajl, yajl_parse, [yajl_cv_libyajl=yes], [yajl_cv_libyajl=no]) + AC_CHECK_HEADER(yajl/yajl_parse.h, [yajl_cv_yajl_parse_h=yes], [yajl_cv_yajl_parse_h=no]) + AC_LANG_RESTORE + YAJL_LIBS="-lyajl" + YAJL_CFLAGS="-I${YAJL_HOME}/include" + if test "$yajl_cv_libyajl" != "yes" -a "$yajl_cv_yajl_parse_h" != "yes" + then + # If either header or library was not found, revert and bomb + AC_MSG_ERROR(either specify a valid yajl installation with --with-yajl=DIR or disable yajl usage with --without-yajl) + fi +fi +AC_SUBST(YAJL_LIBS) +AC_SUBST(YAJL_CFLAGS) +AC_SUBST(YAJL_LDFLAGS) dnl no really use for this library +]) diff --git a/www/doc/index.html b/www/doc/index.html index 9dc8c07..5a170e6 100644 --- a/www/doc/index.html +++ b/www/doc/index.html @@ -86,10 +86,15 @@ sense of humor, requires ruby to compile)

Configuring

-

I know I'm gonna get shit for not using an autoconf-based system, but -I really didn't want to spend time figuring it out. You should edit -libs.mk and put in the paths where you can find headers and libraries -for the above requirements. +

There is now an experimental autoconf build system. If you run +add-autoconf, it'll do the magic and create a +configure script that'll do the familiar things. If I ever +get around to distributing source packages, you should find that this +has already been done. + +

If you'd rather stick with the manual system, you should edit libs.mk +and put in the paths where you can find headers and libraries for the +above requirements.

Also, further apologies to BSD folks — I've probably committed several unconscious Linux-isms. It would not surprise me if the