Add autotools & checks

This commit is contained in:
Yann Weber 2019-07-03 17:10:03 +02:00
commit fa17445573
14 changed files with 82 additions and 42 deletions

View file

@ -1,17 +0,0 @@
all:
+make -C src
doc:
doxygen
.PHONY: distclean clean __pycache__clean doc
distclean: __pycache__clean
-make -C src distclean;\
rm -Rvf doc/latex doc/html doc/man
clean: __pycache__clean
-make -C src clean;\
__pycache__clean:
rm -Rvf __pycache__

1
Makefile.am Normal file
View file

@ -0,0 +1 @@
SUBDIRS = src tests

View file

11
autogen.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
[ "$1" = "clean" ] && [ -f "Makefile" ] && make distclean # pour les .o
rm -fR configure aclocal.m4 autom4te.cache src/Makefile.in tests/Makefile.in Makefile.in compile depcomp install-sh missing
[ "$1" = "clean" ] && exit 0
aclocal
automake -a -c
autoconf

54
configure.ac Normal file
View file

@ -0,0 +1,54 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([PyFCGI], [0.0.1], [yann.weber@member.fsf.org])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([include/config.h])
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug], [Enable debug, disabling -Werror, etc.]))
# Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AC_CHECK_PROG(PYTHON_CONFIG, [python3-config], [yes])
if test x"${PYTHON_CONFIG}" == x"yes"; then
PYTHON_CFLAGS=`python3-config --includes`
PYTHON_LDFLAGS=`python3-config --libs`
AC_SUBST([PYTHON_CFLAGS])
AC_SUBST([PYTHON_LDFLAGS])
else
AC_MSG_ERROR([Unable to find python3-config])
fi
if test x"${enable_debug}" = x"yes"; then
AM_CFLAGS="-Wall -g"
else
AM_CFLAGS="-Wall -Werror -O2"
fi
AC_SUBST([AM_CFLAGS])
# Checks for libraries.
AC_CHECK_LIB([fcgi], [FCGI_Accept])
PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h syslog.h unistd.h sem.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([bzero getcwd gettimeofday memmove strdup strerror strndup semop clone])
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile
src/Makefile
tests/Makefile])
AC_OUTPUT

View file

@ -1,25 +0,0 @@
CC=gcc
CFLAGS=-c -Wall `python3-config --includes`
#CFLAGS=-c -Wall -Werror `python3-config --includes`
LDFLAGS=`python3-config --libs` -lfcgi
#LDFLAGS= -L`python3-config --configdir` `python3-config --libs` -lfcgi
BIN=pyfcgi
SRCS=$(wildcard *.c)
OBJS=$(SRCS:.c=.o)
all: $(BIN)
$(BIN): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) -o $@ $<
.PHONY: clean distclean
distclean: clean
-rm -v $(BIN)
clean:
-rm -v $(OBJS)

11
src/Makefile.am Normal file
View file

@ -0,0 +1,11 @@
bin_PROGRAMS = pyfcgi
noinst_LIBRARIES = libpyfcgi.a
libpyfcgi_a_SOURCES = logger.c pyworker.c responder.c
libpyfcgi_a_CFLAGS = $(PYTHON_CFLAGS)
pyfcgi_SOURCES = main.c $(libpyfcgi_a_SOURCES)
pyfcgi_CFLAGS = $(PYTHON_CFLAGS) $(AM_CFLAGS)
pyfcgi_LDADD = $(PYTHON_LDFLAGS)

5
tests/Makefile.am Normal file
View file

@ -0,0 +1,5 @@
TESTS = check_logger
check_PROGRAMS = check_logger
check_logger_SOURCES = check_logger.c $(top_builddir)/include/logger.h
check_logger_CFLAGS = @CHECK_CFLAGS@
check_logger_LDADD = $(top_builddir)/src/libpyfcgi.a @CHECK_LIBS@