Makefile stuff
authorvb
Sun, 22 Feb 2015 15:49:02 +0100
changeset 66805bfae3cdc4
parent 65 b4b2f063a7c4
child 67 65cc950ce03d
Makefile stuff
Makefile.conf
src/Makefile
src/cryptotech.c
src/pgp_gpg.c
test/Makefile
     1.1 --- a/Makefile.conf	Sun Feb 22 15:16:57 2015 +0100
     1.2 +++ b/Makefile.conf	Sun Feb 22 15:49:02 2015 +0100
     1.3 @@ -1,7 +1,10 @@
     1.4  BUILD_ON=$(shell uname)
     1.5  BUILD_FOR=$(BUILD_ON)
     1.6  OPTIMIZE=-g -O0
     1.7 -#OPTIMIZE=-O3 -DNDEBUG
     1.8 +#OPTIMIZE=-O3 -DNDEBUG -std=c99
     1.9 +LD=$(CC)
    1.10 +#CC=gcc-mp-4.9 -std=c99 -fstrict-aliasing -Wstrict-aliasing=3
    1.11 +#LD=gcc-mp-4.9
    1.12  # the next two lines are ignored on Windoze
    1.13  SYSTEM_DB=/usr/local/share/pEp/system.db
    1.14  PREFIX=$(HOME)
     2.1 --- a/src/Makefile	Sun Feb 22 15:16:57 2015 +0100
     2.2 +++ b/src/Makefile	Sun Feb 22 15:49:02 2015 +0100
     2.3 @@ -7,11 +7,11 @@
     2.4  MACOSX_VERSION_MIN=10.6
     2.5  GPGME_IN=$(HOME)
     2.6  LIBGPGME=libgpgme-pthread.dylib
     2.7 -CC=clang -std=c99 -pthread
     2.8 -LD=clang
     2.9 -CFLAGS=-I$(GPGME_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
    2.10 +CC?=clang -std=c99 -pthread
    2.11 +LD?=clang
    2.12 +CFLAGS?=-I$(GPGME_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
    2.13  	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\"
    2.14 -LDFLAGS=-lc -shared -arch x86_64 \
    2.15 +LDFLAGS?=-lc -shared -arch x86_64 \
    2.16  	-L/opt/local/lib -letpan -lgpgme-pthread -lsqlite3
    2.17  
    2.18  else
    2.19 @@ -24,10 +24,10 @@
    2.20  TARGET=libpEpEngine.so
    2.21  GPGME_IN=$(HOME)
    2.22  LIBGPGME=libgpgme.so.11
    2.23 -CC=gcc -std=c99
    2.24 -CFLAGS=-I$(GPGME_IN)/include $(OPTIMIZE) -fPIC -pedantic \
    2.25 +CC?=gcc -std=c99
    2.26 +CFLAGS?=-I$(GPGME_IN)/include $(OPTIMIZE) -fPIC -pedantic \
    2.27  	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" -DSQLITE_THREADSAFE=1
    2.28 -LDFLAGS=-L$(GPGME_IN) -shared -lc -ldl -letpan -lgpgme-pthread -lsqlite3
    2.29 +LDFLAGS?=-L$(GPGME_IN) -shared -lc -ldl -letpan -lgpgme-pthread -lsqlite3
    2.30  
    2.31  else
    2.32  $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
     3.1 --- a/src/cryptotech.c	Sun Feb 22 15:16:57 2015 +0100
     3.2 +++ b/src/cryptotech.c	Sun Feb 22 15:49:02 2015 +0100
     3.3 @@ -13,7 +13,7 @@
     3.4  PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first)
     3.5  {
     3.6      static PEP_cryptotech_t cryptotech[PEP_crypt__count];
     3.7 -    PEP_STATUS _status;
     3.8 +    PEP_STATUS status = PEP_STATUS_OK;
     3.9  
    3.10      assert(PEP_crypt__count == 2);
    3.11  
    3.12 @@ -42,12 +42,15 @@
    3.13  
    3.14      session->cryptotech = cryptotech;
    3.15  
    3.16 -    _status = pgp_init(session, in_first);
    3.17 -    assert(_status == PEP_STATUS_OK);
    3.18 -    if (_status != PEP_STATUS_OK)
    3.19 -        return _status;
    3.20 +    status = pgp_init(session, in_first);
    3.21 +    if (status != PEP_STATUS_OK)
    3.22 +        goto pep_error;
    3.23  
    3.24      return PEP_STATUS_OK;
    3.25 +
    3.26 +pep_error:
    3.27 +    pgp_release(session, in_first);
    3.28 +    return status;
    3.29  }
    3.30  
    3.31  void release_cryptotech(PEP_SESSION session, bool out_last)
     4.1 --- a/src/pgp_gpg.c	Sun Feb 22 15:16:57 2015 +0100
     4.2 +++ b/src/pgp_gpg.c	Sun Feb 22 15:49:02 2015 +0100
     4.3 @@ -56,6 +56,7 @@
     4.4  
     4.5  PEP_STATUS pgp_init(PEP_SESSION session, bool in_first)
     4.6  {
     4.7 +    PEP_STATUS status = PEP_STATUS_OK;
     4.8      static struct gpg_s gpg;
     4.9      static void *gpgme;
    4.10      gpgme_error_t gpgme_error;
    4.11 @@ -67,7 +68,8 @@
    4.12  
    4.13          gpgme = dlopen(LIBGPGME, RTLD_LAZY);
    4.14          if (gpgme == NULL) {
    4.15 -            return PEP_INIT_CANNOT_LOAD_GPGME;
    4.16 +            status = PEP_INIT_CANNOT_LOAD_GPGME;
    4.17 +            goto pep_error;
    4.18          }
    4.19  
    4.20          memset(&gpg, 0, sizeof(struct gpg_s));
    4.21 @@ -244,7 +246,8 @@
    4.22      gpgme_error = gpg.gpgme_new(&session->ctx);
    4.23      gpgme_error = _GPGERR(gpgme_error);
    4.24      if (gpgme_error != GPG_ERR_NO_ERROR) {
    4.25 -        return PEP_INIT_GPGME_INIT_FAILED;
    4.26 +        status = PEP_INIT_GPGME_INIT_FAILED;
    4.27 +        goto pep_error;
    4.28      }
    4.29      assert(session->ctx);
    4.30  
    4.31 @@ -255,6 +258,10 @@
    4.32      gpg.gpgme_set_armor(session->ctx, 1);
    4.33  
    4.34      return PEP_STATUS_OK;
    4.35 +
    4.36 +pep_error:
    4.37 +    pgp_release(session, in_first);
    4.38 +    return status;
    4.39  }
    4.40  
    4.41  void pgp_release(PEP_SESSION session, bool out_last)
     5.1 --- a/test/Makefile	Sun Feb 22 15:16:57 2015 +0100
     5.2 +++ b/test/Makefile	Sun Feb 22 15:49:02 2015 +0100
     5.3 @@ -1,10 +1,10 @@
     5.4  include ../Makefile.conf
     5.5  
     5.6 -CC=g++ -std=gnu++11 -pthread
     5.7 -CXX=g++ -std=gnu++11 -pthread
     5.8 -LD=$(CXX)
     5.9 -LDFLAGS=-L$(HOME)/lib -lpEpEngine -lstdc++
    5.10 -CXXFLAGS=-g -O0 -I../src
    5.11 +CC?=g++ -std=gnu++11 -pthread
    5.12 +CXX?=g++ -std=gnu++11 -pthread
    5.13 +LD?=$(CXX)
    5.14 +LDFLAGS?=-L$(HOME)/lib -lpEpEngine -lstdc++
    5.15 +CXXFLAGS?=-g -O0 -I../src
    5.16  # CXXFLAGS=-O3 -DNDEBUG
    5.17  
    5.18  TARGET=pEpEngineTest