From fa174455732c4c7fd807412897e38934b44c0f32 Mon Sep 17 00:00:00 2001 From: Yann Weber Date: Wed, 3 Jul 2019 17:10:03 +0200 Subject: [PATCH] Add autotools & checks --- Licence.txt => COPYING | 0 Makefile | 17 --------- Makefile.am | 1 + README.txt => README | 0 autogen.sh | 11 ++++++ configure.ac | 54 +++++++++++++++++++++++++++++ {src => include}/conf.h | 0 src/config.h => include/config.h.in | 0 {src => include}/logger.h | 0 {src => include}/pyworker.h | 0 {src => include}/responder.h | 0 src/Makefile | 25 ------------- src/Makefile.am | 11 ++++++ tests/Makefile.am | 5 +++ 14 files changed, 82 insertions(+), 42 deletions(-) rename Licence.txt => COPYING (100%) delete mode 100644 Makefile create mode 100644 Makefile.am rename README.txt => README (100%) create mode 100755 autogen.sh create mode 100644 configure.ac rename {src => include}/conf.h (100%) rename src/config.h => include/config.h.in (100%) rename {src => include}/logger.h (100%) rename {src => include}/pyworker.h (100%) rename {src => include}/responder.h (100%) delete mode 100644 src/Makefile create mode 100644 src/Makefile.am create mode 100644 tests/Makefile.am diff --git a/Licence.txt b/COPYING similarity index 100% rename from Licence.txt rename to COPYING diff --git a/Makefile b/Makefile deleted file mode 100644 index 110747c..0000000 --- a/Makefile +++ /dev/null @@ -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__ diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..a459377 --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src tests diff --git a/README.txt b/README similarity index 100% rename from README.txt rename to README diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..5956789 --- /dev/null +++ b/autogen.sh @@ -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 diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..84616ae --- /dev/null +++ b/configure.ac @@ -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 diff --git a/src/conf.h b/include/conf.h similarity index 100% rename from src/conf.h rename to include/conf.h diff --git a/src/config.h b/include/config.h.in similarity index 100% rename from src/config.h rename to include/config.h.in diff --git a/src/logger.h b/include/logger.h similarity index 100% rename from src/logger.h rename to include/logger.h diff --git a/src/pyworker.h b/include/pyworker.h similarity index 100% rename from src/pyworker.h rename to include/pyworker.h diff --git a/src/responder.h b/include/responder.h similarity index 100% rename from src/responder.h rename to include/responder.h diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index bfe9821..0000000 --- a/src/Makefile +++ /dev/null @@ -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) diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..8161529 --- /dev/null +++ b/src/Makefile.am @@ -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) + diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..43ee4e0 --- /dev/null +++ b/tests/Makefile.am @@ -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@