From 43a8fae35436910946742e551ff46a1549e2d262 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Sun, 25 Sep 2022 11:39:54 +0200 Subject: Add compile options and adjust README.md Signed-off-by: TheJackiMonster --- Makefile.am | 2 ++ README.md | 16 ++++++++++++---- configure.ac | 9 +++++++++ src/Makefile.am | 10 ++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 30e4c19..e8d6340 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,6 +9,8 @@ SUBDIRS = \ src \ tests +ACLOCAL_AMFLAGS = -I m4 + docs: mkdir -p doc doxygen diff --git a/README.md b/README.md index 79c2cbd..56b7119 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,25 @@ The following dependencies are required and need to be installed to build the li - [gnunet](https://git.gnunet.org/gnunet.git/): For using GNUnet services and its datatypes -Then you can simply use the provided Makefile as follows: +Then you can simply use [Autotools](https://www.gnu.org/software/automake/) as follows: +``` +./bootstrap # Generate the configure script +./configure # Configure the Makefiles for your system +make # Build the library using the Makefiles +sudo make install # Install the library +``` - - `make` to just compile everything with default parameters +Here is a list of some useful build targets in the Makefile: + + - `make` to just compile everything with configured parameters - `make clean` to cleanup build files in case you want to recompile - - `make debug` to compile everything with debug parameters - - `make release` to compile everything with build optimizations enabled - `make install` to install the compiled files (you might need sudo permissions to install) - `make dist` to create a tar file for distribution - `make docs` to build Doxygen documentation ([Doxygen](https://www.doxygen.nl/index.html) is required to do that) - `make check` to test the library with automated unit tests ([Check](https://libcheck.github.io/check/) is required to do that) +If you want to change the installation location, use the `--prefix=` parameter in the `configure` script. Also you can enable debugging builds by adding `--enable-debug` as parameter when running the `configure` script. + ## Contribution If you want to contribute to this project as well, the following options are available: diff --git a/configure.ac b/configure.ac index 9fb9c7d..fc58e40 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,15 @@ LT_INIT([disable-static dlopen]) AS_IF([test "x$enable_shared" = "xno"], [AC_MSG_ERROR([GNUnet works only with shared libraries, sorry])]) +AC_ARG_ENABLE([debug], +[ --enable-debug turn on debugging], +[case "${enableval}" in + yes) debug=true ;; + no) debug=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; +esac],[debug=false]) +AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) + AC_CONFIG_FILES([ Makefile include/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 38e2cdd..f87788e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,3 +27,13 @@ libgnunetchat_la_LIBADD = \ -lgnunetregex \ -lgnunetutil +libgnunetchat_la_CFLAGS = \ + -fPIC -pedantic -Wall -Wextra + +if DEBUG +libgnunetchat_la_CFLAGS += \ + -O0 -D _DEBUG -ggdb3 +else +libgnunetchat_la_CFLAGS += \ + -O2 -D NDEBUG +endif -- cgit v1.2.3