From 06cb40722aaf87d7ff7b7d168114191cfa33b312 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Sun, 15 Jan 2017 18:24:24 +0100 Subject: [PATCH] build: create an organized directory structure Signed-off-by: Bartosz Golaszewski --- Makefile.am | 43 +--------------------- configure.ac | 13 +++++-- include/Makefile.am | 9 +++++ gpiod.h => include/gpiod.h | 0 src/Makefile.am | 15 ++++++++ src/lib/Makefile.am | 14 +++++++ core.c => src/lib/core.c | 2 +- src/tools/Makefile.am | 26 +++++++++++++ gpiodetect.c => src/tools/gpiodetect.c | 2 +- gpiofind.c => src/tools/gpiofind.c | 2 +- gpioget.c => src/tools/gpioget.c | 2 +- gpioinfo.c => src/tools/gpioinfo.c | 2 +- gpiomon.c => src/tools/gpiomon.c | 2 +- gpioset.c => src/tools/gpioset.c | 2 +- tools-common.c => src/tools/tools-common.c | 2 +- tools-common.h => src/tools/tools-common.h | 0 16 files changed, 83 insertions(+), 53 deletions(-) create mode 100644 include/Makefile.am rename gpiod.h => include/gpiod.h (100%) create mode 100644 src/Makefile.am create mode 100644 src/lib/Makefile.am rename core.c => src/lib/core.c (99%) create mode 100644 src/tools/Makefile.am rename gpiodetect.c => src/tools/gpiodetect.c (98%) rename gpiofind.c => src/tools/gpiofind.c (98%) rename gpioget.c => src/tools/gpioget.c (99%) rename gpioinfo.c => src/tools/gpioinfo.c (99%) rename gpiomon.c => src/tools/gpiomon.c (99%) rename gpioset.c => src/tools/gpioset.c (99%) rename tools-common.c => src/tools/tools-common.c (98%) rename tools-common.h => src/tools/tools-common.h (100%) diff --git a/Makefile.am b/Makefile.am index fa2c23a..6151e59 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,47 +7,8 @@ # AUTOMAKE_OPTIONS = foreign -LIBS = - -AM_CPPFLAGS = -I$(top_srcdir) -include $(top_srcdir)/config.h -Wextra -AM_CPPFLAGS += -fvisibility=hidden -D_GNU_SOURCE - -include_HEADERS = gpiod.h - -lib_LTLIBRARIES = libgpiod.la -libgpiod_la_SOURCES = core.c -libgpiod_la_CFLAGS = -g -libgpiod_la_LDFLAGS = -version-number $(subst .,:,$(PACKAGE_VERSION)) - -if WITH_TOOLS - -bin_PROGRAMS = gpiodetect gpioinfo gpioget gpioset gpiomon gpiofind - -gpiodetect_SOURCES = gpiodetect.c tools-common.c -gpiodetect_LDFLAGS = -lgpiod -gpiodetect_DEPENDENCIES = libgpiod.la - -gpioinfo_SOURCES = gpioinfo.c tools-common.c -gpioinfo_LDFLAGS = -lgpiod -gpioinfo_DEPENDENCIES = libgpiod.la - -gpioget_SOURCES = gpioget.c tools-common.c -gpioget_LDFLAGS = -lgpiod -gpioget_DEPENDENCIES = libgpiod.la - -gpioset_SOURCES = gpioset.c tools-common.c -gpioset_LDFLAGS = -lgpiod -gpioset_DEPENDENCIES = libgpiod.la - -gpiomon_SOURCES = gpiomon.c tools-common.c -gpiomon_LDFLAGS = -lgpiod -gpiomon_DEPENDENCIES = libgpiod.la - -gpiofind_SOURCES = gpiofind.c tools-common.c -gpiofind_LDFLAGS = -lgpiod -gpiofind_DEPENDENCIES = libgpiod.la - -endif +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = include src doc: @(cat Doxyfile; echo PROJECT_NUMBER = $(PACKAGE_VERSION)) | doxygen - diff --git a/configure.ac b/configure.ac index 5420682..7520eb1 100644 --- a/configure.ac +++ b/configure.ac @@ -9,11 +9,13 @@ AC_PREREQ(2.61) AC_INIT([libgpiod], 0.0.0) AC_CONFIG_AUX_DIR([autostuff]) -AM_INIT_AUTOMAKE([foreign -Wall -Werror subdir-objects]) +AM_INIT_AUTOMAKE([foreign subdir-objects]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +AC_CONFIG_SRCDIR([src]) AC_CONFIG_HEADER([config.h]) +AC_CONFIG_MACRO_DIR([m4]) AC_ARG_ENABLE([tools], [AC_HELP_STRING([--enable-tools], @@ -29,6 +31,7 @@ AC_ARG_ENABLE([tools], [with_tools = false]) AM_CONDITIONAL([WITH_TOOLS], [test x$with_tools = xtrue]) +AM_PROG_AR AC_PROG_CC AC_PROG_LIBTOOL AC_PROG_INSTALL @@ -49,8 +52,10 @@ AC_CHECK_HEADERS([dirent.h], [], [AC_MSG_ERROR([dirent.h header not found])]) AC_CHECK_HEADERS([linux/gpio.h], [], [AC_MSG_ERROR([linux/gpio.h header not found])]) -AC_CONFIG_FILES([Makefile]) - -CFLAGS="$CFLAGS -Wall" +AC_CONFIG_FILES([Makefile + include/Makefile + src/Makefile + src/lib/Makefile + src/tools/Makefile]) AC_OUTPUT diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..74566a8 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,9 @@ +# +# Copyright (C) 2017 Bartosz Golaszewski +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# + +include_HEADERS = gpiod.h diff --git a/gpiod.h b/include/gpiod.h similarity index 100% rename from gpiod.h rename to include/gpiod.h diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..ccbe7dc --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,15 @@ +# +# Copyright (C) 2017 Bartosz Golaszewski +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# + +if WITH_TOOLS + +TOOLS_SUBDIR = tools + +endif + +SUBDIRS = . lib $(TOOLS_SUBDIR) diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 0000000..35b8e70 --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,14 @@ +# +# Copyright (C) 2017 Bartosz Golaszewski +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# + +lib_LTLIBRARIES = libgpiod.la +libgpiod_la_SOURCES = core.c +libgpiod_la_CFLAGS = -Wall -Wextra -g -D_GNU_SOURCE +libgpiod_la_CFLAGS += -fvisibility=hidden -I$(top_srcdir)/include/ +libgpiod_la_CFLAGS += -include $(top_srcdir)/config.h +libgpiod_la_LDFLAGS = -version-number $(subst .,:,$(PACKAGE_VERSION)) diff --git a/core.c b/src/lib/core.c similarity index 99% rename from core.c rename to src/lib/core.c index ddd19ae..776ed9e 100644 --- a/core.c +++ b/src/lib/core.c @@ -8,7 +8,7 @@ * published by the Free Software Foundation. */ -#include "gpiod.h" +#include #include #include diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am new file mode 100644 index 0000000..35e5f22 --- /dev/null +++ b/src/tools/Makefile.am @@ -0,0 +1,26 @@ +# +# Copyright (C) 2017 Bartosz Golaszewski +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# + +AM_CFLAGS = -I$(top_srcdir)/include/ -include $(top_srcdir)/config.h +AM_CFLAGS += -Wall -Wextra -g -D_GNU_SOURCE -L$(top_srcdir)/src/lib +AM_LDFLAGS = -lgpiod +DEPENDENCIES = libgpiod.la + +bin_PROGRAMS = gpiodetect gpioinfo gpioget gpioset gpiomon gpiofind + +gpiodetect_SOURCES = gpiodetect.c tools-common.c + +gpioinfo_SOURCES = gpioinfo.c tools-common.c + +gpioget_SOURCES = gpioget.c tools-common.c + +gpioset_SOURCES = gpioset.c tools-common.c + +gpiomon_SOURCES = gpiomon.c tools-common.c + +gpiofind_SOURCES = gpiofind.c tools-common.c diff --git a/gpiodetect.c b/src/tools/gpiodetect.c similarity index 98% rename from gpiodetect.c rename to src/tools/gpiodetect.c index 507605a..6291340 100644 --- a/gpiodetect.c +++ b/src/tools/gpiodetect.c @@ -8,7 +8,7 @@ * published by the Free Software Foundation. */ -#include "gpiod.h" +#include #include "tools-common.h" #include diff --git a/gpiofind.c b/src/tools/gpiofind.c similarity index 98% rename from gpiofind.c rename to src/tools/gpiofind.c index f390672..0467f58 100644 --- a/gpiofind.c +++ b/src/tools/gpiofind.c @@ -8,7 +8,7 @@ * published by the Free Software Foundation. */ -#include "gpiod.h" +#include #include "tools-common.h" #include diff --git a/gpioget.c b/src/tools/gpioget.c similarity index 99% rename from gpioget.c rename to src/tools/gpioget.c index 41ccb9c..b7d4ac9 100644 --- a/gpioget.c +++ b/src/tools/gpioget.c @@ -8,7 +8,7 @@ * published by the Free Software Foundation. */ -#include "gpiod.h" +#include #include "tools-common.h" #include diff --git a/gpioinfo.c b/src/tools/gpioinfo.c similarity index 99% rename from gpioinfo.c rename to src/tools/gpioinfo.c index 8609b77..d91c6ca 100644 --- a/gpioinfo.c +++ b/src/tools/gpioinfo.c @@ -8,7 +8,7 @@ * published by the Free Software Foundation. */ -#include "gpiod.h" +#include #include "tools-common.h" #include diff --git a/gpiomon.c b/src/tools/gpiomon.c similarity index 99% rename from gpiomon.c rename to src/tools/gpiomon.c index 54da482..48eaa65 100644 --- a/gpiomon.c +++ b/src/tools/gpiomon.c @@ -8,7 +8,7 @@ * published by the Free Software Foundation. */ -#include "gpiod.h" +#include #include "tools-common.h" #include diff --git a/gpioset.c b/src/tools/gpioset.c similarity index 99% rename from gpioset.c rename to src/tools/gpioset.c index 65dd70e..8ae288e 100644 --- a/gpioset.c +++ b/src/tools/gpioset.c @@ -8,7 +8,7 @@ * published by the Free Software Foundation. */ -#include "gpiod.h" +#include #include "tools-common.h" #include diff --git a/tools-common.c b/src/tools/tools-common.c similarity index 98% rename from tools-common.c rename to src/tools/tools-common.c index 1ba234a..a4c96fc 100644 --- a/tools-common.c +++ b/src/tools/tools-common.c @@ -8,7 +8,7 @@ * published by the Free Software Foundation. */ -#include "gpiod.h" +#include #include "tools-common.h" #include diff --git a/tools-common.h b/src/tools/tools-common.h similarity index 100% rename from tools-common.h rename to src/tools/tools-common.h -- 2.30.2