Browse Source

extra files for Unix

doc_update_sequoia
vb 8 years ago
parent
commit
311125816b
6 changed files with 264 additions and 0 deletions
  1. +33
    -0
      Makefile
  2. +7
    -0
      Makefile.conf
  3. +123
    -0
      src/Makefile
  4. +66
    -0
      src/platform_unix.c
  5. +2
    -0
      src/platform_unix.h
  6. +33
    -0
      src/update.sql

+ 33
- 0
Makefile View File

@ -0,0 +1,33 @@
include Makefile.conf
all:
$(MAKE) -C src all
.PHONY: clean build_test test package install uninstall
install:
$(MAKE) -C src install
uninstall:
$(MAKE) -C src uninstall
clean:
$(MAKE) -C src clean
$(MAKE) -C test clean
test: all
$(MAKE) -C test test
package: clean
cd .. ; COPYFILE_DISABLE=true tar cjf pEpEngine.tar.bz2 pEpEngine
windist:
ifneq ($(BUILD_FOR),Windoze)
@echo use BUILD_FOR=Windoze \(did you forget -e ?\)
else
make clean
$(MAKE) all
$(MAKE) -C test all
zip -j pEpEngine-dist.zip src/pEpEngine.h src/keymanagement.h src/pEpEngine.dll src/pEpEngine.def test/pEpEngineTest.exe test/*.asc test/*.key db/*.db test/*.txt test/*.asc src/*.sql
endif

+ 7
- 0
Makefile.conf View File

@ -0,0 +1,7 @@
BUILD_ON=$(shell uname)
BUILD_FOR=$(BUILD_ON)
#OPTIMIZE=-g -O0
OPTIMIZE=-O3 -DNDEBUG
# the next two lines are not for Windoze
SYSTEM_DB=/usr/local/share/pEp/system.db
PREFIX=$(HOME)

+ 123
- 0
src/Makefile View File

@ -0,0 +1,123 @@
include ../Makefile.conf
ifeq ($(BUILD_ON),Darwin)
ifeq ($(BUILD_FOR),Darwin)
TARGET=libpEpEngine.dylib
MACOSX_VERSION_MIN=10.6
GPGME_IN=$(HOME)
LIBGPGME=libgpgme-pthread.dylib
CC=gcc -std=c99
CFLAGS=-I$(GPGME_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" -DSQLITE_THREADSAFE=1
LDFLAGS=-lc -macosx_version_min $(MACOSX_VERSION_MIN) -dylib -arch x86_64
else ifeq ($(BUILD_FOR),Windoze)
TARGET=pEpEngine.dll
GPGME_IN=$(HOME)
LIBGPGME=libgpgme-11.dll
CC=i686-w64-mingw32-gcc -std=c99
CXX=i686-w64-mingw32-g++
LD=i686-w64-mingw32-gcc
CFLAGS=-I$(HOME)/i686-w64-mingw32/include -I$(GPGME_IN)/include $(OPTIMIZE) -pedantic \
-DLIBGPGME=\"$(LIBGPGME)\" -DWIN32 -DSQLITE_THREADSAFE=1
LDFLAGS=-shared -L$(HOME)/i686-w64-mingw32/lib -llibstdc++ \
-Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
else ifeq ($(BUILD_ON),Linux)
ifeq ($(BUILD_FOR),Linux)
TARGET=libpEpEngine.so
GPGME_IN=$(HOME)
LIBGPGME=libgpgme.so.11
CC=gcc -std=c99
CFLAGS=-I$(GPGME_IN)/include $(OPTIMIZE) -fPIC -pedantic \
-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" -DSQLITE_THREADSAFE=1
LDFLAGS=-L$(GPGME_IN) -shared -lc -ldl
else ifeq ($(BUILD_FOR),Windoze)
TARGET=pEpEngine.dll
GPGME_IN=$(HOME)
LIBGPGME=libgpgme-11.dll
CC=i686-w64-mingw32-gcc -std=c99
CXX=i686-w64-mingw32-g++
LD=i686-w64-mingw32-gcc
CFLAGS=-I/usr/i686-w64-mingw32/include -I$(GPGME_IN)/include $(OPTIMIZE) -pedantic \
-DLIBGPGME=\"$(LIBGPGME)\" -DWIN32 -DSQLITE_THREADSAFE=1
LDFLAGS=-shared -L/usr/i686-w64-mingw32/lib -llibstdc++ \
-Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
else ifeq ($(BUILD_ON),MINGW32_NT-6.1)
TARGET=pEpEngine.dll
GPGME_IN=/c/Program\ Files/GNU/GnuPG
LIBGPGME=libgpgme-11.dll
CC=gcc -std=gnu99
CFLAGS=-I$(GPGME_IN)/include $(OPTIMIZE) -pedantic -DWIN32 -DSQLITE_THREADSAFE=1
LD=gcc
LDFLAGS=-shared -llibstdc++ -Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
ifeq ($(BUILD_FOR),Windoze)
ALL_SOURCE=$(filter-out platform_unix.c,$(wildcard *.c))
else ifeq ($(BUILD_FOR),MINGW32_NT-6.1)
ALL_SOURCE=$(filter-out platform_unix.c,$(wildcard *.c))
else
ALL_SOURCE=$(wildcard *.c)
endif
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
ifeq ($(BUILD_FOR),Windoze)
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE)) platform_windows.o
else ifeq ($(BUILD_FOR),MINGW32_NT-6.1)
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE)) platform_windows.o
else
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
endif
all: $(TARGET)
%.d: %.c
@set -e; rm -f $@; \
$(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
-include $(DEPENDS)
platform_windows.o: platform_windows.cpp
$(CXX) $(CXX_FLAGS) -o $@ -c $<
$(TARGET): libpEpEngine.a
$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
objects: $(ALL_OBJECTS)
libpEpEngine.a: $(ALL_OBJECTS)
ar -r $@ $(ALL_OBJECTS)
.PHONY: clean
clean:
rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
install: $(TARGET)
cp $< $(PREFIX)/lib/
uninstall:
rm -f $(PREFIX)/lib/$(TARGET)

+ 66
- 0
src/platform_unix.c View File

@ -0,0 +1,66 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "platform_unix.h"
#define MAX_PATH 1024
#define LOCAL_DB_FILENAME ".pEp_management.db"
#ifndef bool
#define bool int
#define true 1
#define false 0
#endif
const char *unix_local_db(void)
{
static char buffer[MAX_PATH];
static bool done = false;
if (!done) {
char *p = stpncpy(buffer, getenv("HOME"), MAX_PATH);
size_t len = MAX_PATH - (p - buffer) - 2;
if (len < strlen(LOCAL_DB_FILENAME)) {
assert(0);
return NULL;
}
*p++ = '/';
strncpy(p, LOCAL_DB_FILENAME, len);
done = true;
}
return buffer;
}
static const char *gpg_conf_path = ".gnupg";
static const char *gpg_conf_name = "gpg.conf";
const char *gpg_conf(void)
{
static char buffer[MAX_PATH];
static bool done = false;
if (!done) {
char *p = stpncpy(buffer, getenv("HOME"), MAX_PATH);
size_t len = MAX_PATH - (p - buffer) - 3;
if (len < strlen(gpg_conf_path) + strlen(gpg_conf_name))
{
assert(0);
return NULL;
}
*p++ = '/';
strncpy(p, gpg_conf_path, len);
p += strlen(gpg_conf_path);
len -= strlen(gpg_conf_path) - 1;
*p++ = '/';
strncpy(p, gpg_conf_name, len);
done = true;
}
return buffer;
}

+ 2
- 0
src/platform_unix.h View File

@ -0,0 +1,2 @@
const char *unix_local_db(void);
const char *gpg_conf(void);

+ 33
- 0
src/update.sql View File

@ -0,0 +1,33 @@
create table trust (
user_id text references person (id) on delete cascade,
pgp_keypair_fpr text references pgp_keypair (fpr) on delete cascade,
comm_type integer not null,
comment text
);
create unique index trust_index on trust (
user_id,
pgp_keypair_fpr
);
insert into trust (user_id, pgp_keypair_fpr, comm_type)
select user_id, main_key_id, comm_type from identity;
alter table identity rename to identity_old;
create table identity (
address text primary key,
user_id text
references person (id)
on delete cascade,
main_key_id text
references pgp_keypair (fpr)
on delete set null,
comment text
);
insert into identity (address, user_id, main_key_id)
select address, user_id, main_key_id from identity_old;
drop table identity_old;

Loading…
Cancel
Save