Skip to content

Commit

Permalink
Cygwin dependency removed from MSVC build
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrojnar committed Jan 19, 2016
1 parent bd52f4a commit 0a67ed8
Show file tree
Hide file tree
Showing 25 changed files with 139 additions and 99 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ stamp-h*
*.gz
*.bz2
*.out
*.exp
*.obj

m4/ltoptions.m4
m4/ltsugar.m4
Expand Down
37 changes: 37 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# libp11 Installation

## Unix Build

Install the OpenSSL development package. On Debian/Ubuntu use:

sudo apt-get install libssl-dev

Build and install libp11:

./configure && make && sudo make install

## Windows Build

Download and install OpenSSL, for example:

* https://slproweb.com/download/Win32OpenSSL-1_0_2e.exe
* https://slproweb.com/download/Win64OpenSSL-1_0_2e.exe

### MSVC

To build libp11 use:

nmake -f Makefile.mak

In case your OpenSSL is installed in a different directory, use:

nmake -f Makefile.mak OPENSSL_DIR=\your\openssl\directory

### Mingw

TODO

### Cygwin

TODO

4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ MAINTAINERCLEANFILES = \
$(srcdir)/m4/ltversion.m4 $(srcdir)/m4/lt~obsolete.m4 \
$(srcdir)/m4/ltoptions.m4 \
$(srcdir)/packaged
EXTRA_DIST = .gitignore Makefile.mak winconfig.h README.md
EXTRA_DIST = .gitignore Makefile.mak README.md

dist_noinst_DATA = COPYING bootstrap
dist_noinst_DATA = COPYING INSTALL.md

dist_doc_DATA = NEWS

Expand Down
5 changes: 0 additions & 5 deletions Makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ SUBDIRS = src

all::

all:: config.h

config.h: winconfig.h
@copy /y winconfig.h config.h

all depend install clean::
@for %i in ( $(SUBDIRS) ) do \
@cmd /c "cd %i && $(MAKE) /nologo /f Makefile.mak $@"
8 changes: 1 addition & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ install:
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
- date /T & time /T
- set PATH=C:\cygwin\bin;%PATH%
- set OPENSSL_VER=1_0_2e
- ps: >-
If ($env:Platform -Match "x86") {
Expand All @@ -40,18 +39,13 @@ install:
}
- ps: >-
If ($env:Configuration -Like "*Debug*") {
$env:NMAKE_EXTRA="DEBUG_DEF=/DDEBUG ${env:NMAKE_EXTRA}"
$env:NMAKE_EXTRA="DEBUG=yes ${env:NMAKE_EXTRA}"
}
- ps: $env:VSCOMNTOOLS=(Get-Content ("env:VS" + "$env:VSVER" + "0COMNTOOLS"))
- echo "Using Visual Studio %VSVER%.0 at %VSCOMNTOOLS%"
- call "%VSCOMNTOOLS%\..\..\VC\vcvarsall.bat" %VCVARS_PLATFORM%
- uname -a

build_script:
- bash -c "exec 0</dev/null && ./bootstrap"
# disable features to speed up the script
- bash -c "exec 0</dev/null && ./configure OPENSSL_CFLAGS=\"-IC:\OpenSSL-Win32\include -IC:\OpenSSL-Win64\include\" OPENSSL_LIBS=\"-LC:\OpenSSL-Win32 -LC:\OpenSSL-Win64 -leay\" || cat config.log"
- cp winconfig.h config.h
- nmake /f Makefile.mak %NMAKE_ARCH% %NMAKE_EXTRA%
- appveyor PushArtifact src\libp11.dll
- appveyor PushArtifact src\libp11.lib
Expand Down
11 changes: 0 additions & 11 deletions bootstrap

This file was deleted.

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define([PACKAGE_SUFFIX], [_git])

AC_INIT([libp11],[PACKAGE_VERSION_MAJOR.PACKAGE_VERSION_MINOR.PACKAGE_VERSION_FIX[]PACKAGE_SUFFIX])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([subdir-objects])

Expand Down
72 changes: 38 additions & 34 deletions make.rules.mak
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
!IF "$(BUILD_FOR)" == "WIN64"
OPENSSL_DIR = C:\OpenSSL-Win64
!ELSE
OPENSSL_DIR = C:\OpenSSL-Win32
!ENDIF
OPENSSL_INC = /I$(OPENSSL_DIR)\include

#define OPENSSL_STATIC if you have visual studio compatible with OpenSSL's static binaries
#OPENSSL_STATIC_DIR = static

!IF "$(DEBUG_DEF)" == "/DDEBUG"
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libeay32MTd.lib user32.lib advapi32.lib crypt32.lib gdi32.lib
!ELSE
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libeay32MT.lib user32.lib advapi32.lib crypt32.lib gdi32.lib
!ENDIF

ALL_INCLUDES= $(OPENSSL_INC)

!IF "$(DEBUG_DEF)" == "/DDEBUG"
LINKDEBUGFLAGS = /NODEFAULTLIB:LIBCMT /DEBUG
CODE_OPTIMIZATION =
COPTS = /GS /W3 /D_CRT_SECURE_NO_DEPRECATE /MTd /nologo $(ALL_INCLUDES) /I..\ /I. /D_WIN32_WINNT=0x0502 /DWIN32_LEAN_AND_MEAN /DDEBUG /Zi /Od
!ELSE
LINKDEBUGFLAGS = /NODEFAULTLIB:LIBCMTD
COPTS = /GS /W3 /D_CRT_SECURE_NO_DEPRECATE /MT /nologo $(ALL_INCLUDES) /I..\ /I. /D_WIN32_WINNT=0x0502 /DWIN32_LEAN_AND_MEAN
!ENDIF

!IF "$(BUILD_FOR)" == "WIN64"
LINKFLAGS = /NOLOGO /INCREMENTAL:NO /MACHINE:X64 /MANIFEST:NO /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:MSVCRT /NXCOMPAT /DYNAMICBASE $(LINKDEBUGFLAGS)
LIBFLAGS = /nologo /machine:x64
!ELSE
LINKFLAGS = /NOLOGO /INCREMENTAL:NO /MACHINE:X86 /MANIFEST:NO /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:MSVCRT /NXCOMPAT /DYNAMICBASE $(LINKDEBUGFLAGS)
LIBFLAGS = /nologo /machine:x86
!ENDIF
#define OPENSSL_STATIC if you have visual studio compatible with OpenSSL's static binaries
#OPENSSL_STATIC_DIR = static

!IF "$(DEBUG)" != ""
DEBUG_SUFFIX = d
DEBUG_COMPILE = /DDEBUG /Zi /Od
DEBUG_LINK = /DEBUG
!ENDIF

!IF "$(BUILD_FOR)" == "WIN64"
MACHINE = /MACHINE:X64
!IF "$(OPENSSL_DIR)" == ""
OPENSSL_DIR = C:\OpenSSL-Win64
!ENDIF
!ELSE
MACHINE = /MACHINE:X86
!IF "$(OPENSSL_DIR)" == ""
OPENSSL_DIR = C:\OpenSSL-Win32
!ENDIF
!ENDIF

!IF "$(OPENSSL_INC)" == ""
OPENSSL_INC = /I$(OPENSSL_DIR)\include
!ENDIF

!IF "$(OPENSSL_STATIC_DIR)" == ""
OPENSSL_LIB = $(OPENSSL_DIR)\lib\libeay32.lib
!ELSE
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\static\libeay32MT$(DEBUG_SUFFIX).lib
!ENDIF

LIBS = $(OPENSSL_LIB) user32.lib advapi32.lib crypt32.lib gdi32.lib

CFLAGS = /nologo /GS /W3 /D_CRT_SECURE_NO_DEPRECATE /MT$(DEBUG_SUFFIX) $(OPENSSL_INC) /D_WIN32_WINNT=0x0502 /DWIN32_LEAN_AND_MEAN $(DEBUG_COMPILE)

LINKFLAGS = /NOLOGO /INCREMENTAL:NO $(MACHINE) /MANIFEST:NO /NXCOMPAT /DYNAMICBASE $(DEBUG_LINK)

LIBFLAGS = /NOLOGO $(MACHINE)
13 changes: 5 additions & 8 deletions src/Makefile.mak
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
TOPDIR = ..

!INCLUDE $(TOPDIR)\Make.rules.mak
!INCLUDE $(TOPDIR)\make.rules.mak

TARGET = libp11.dll
TARGET = libp11.dll

OBJECTS = libpkcs11.obj p11_attr.obj p11_cert.obj \
OBJECTS = libpkcs11.obj p11_attr.obj p11_cert.obj \
p11_err.obj p11_key.obj p11_load.obj p11_misc.obj p11_rsa.obj \
p11_ec.obj p11_slot.obj p11_ops.obj

Expand All @@ -15,17 +15,14 @@ RSC_PROJ=/l 0x809 /r /fo"versioninfo.res"
versioninfo.res: versioninfo.rc
rc $(RSC_PROJ) versioninfo.rc

versioninfo.rc: versioninfo.rc.in
@copy /y versioninfo.rc.in versioninfo.rc

.c.obj::
cl $(COPTS) /c $<
cl $(CFLAGS) /c $<

$(TARGET): $(OBJECTS) versioninfo.res
echo LIBRARY $* > $*.def
echo EXPORTS >> $*.def
type $*.exports >> $*.def
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:$(TARGET) \
$(OBJECTS) $(OPENSSL_LIB) versioninfo.res
$(OBJECTS) $(LIBS) versioninfo.res
if EXIST $*.dll.manifest mt -manifest $*.dll.manifest -outputresource:$*.dll;2

3 changes: 1 addition & 2 deletions src/atfork.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
*
*/

#include <config.h>

#include "libp11-int.h"
#include <sys/socket.h>
#include <errno.h>
#include <sys/stat.h>
Expand Down
2 changes: 0 additions & 2 deletions src/atfork.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#ifndef ATFORK_H
# define ATFORK_H

#include <config.h>

extern unsigned int P11_forkid;

#if defined(HAVE___REGISTER_ATFORK)
Expand Down
6 changes: 5 additions & 1 deletion src/libp11-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
#ifndef _LIBP11_INT_H
#define _LIBP11_INT_H

#ifndef _WIN32
#include "config.h"
#endif

#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/x509.h>

#define CRYPTOKI_EXPORTS
#include <pkcs11.h>
#include "pkcs11.h"

extern void *C_LoadModule(const char *name, CK_FUNCTION_LIST_PTR_PTR);
extern CK_RV C_UnloadModule(void *module);
Expand Down
3 changes: 1 addition & 2 deletions src/libpkcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Copyright (C) 2002 Olaf Kirch <[email protected]>
*/

#include <config.h>
#include "libp11-int.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Expand All @@ -32,7 +32,6 @@
#else
#include <dlfcn.h>
#endif
#include "libp11-int.h"

#define MAGIC 0xd00bed00

Expand Down
4 changes: 1 addition & 3 deletions src/p11_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
* Copyright (C) 2002, Olaf Kirch <[email protected]>
*/

#include <config.h>
#include "libp11-int.h"
#include <assert.h>
#include <string.h>

#include "libp11-int.h"

/*
* Query pkcs11 attributes
*/
Expand Down
3 changes: 1 addition & 2 deletions src/p11_cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
* Copyright (C) 2002, Olaf Kirch <[email protected]>
*/

#include <config.h>
#include <string.h>
#include "libp11-int.h"
#include <string.h>

static int pkcs11_find_certs(PKCS11_TOKEN *);
static int pkcs11_next_cert(PKCS11_CTX *, PKCS11_TOKEN *, CK_SESSION_HANDLE);
Expand Down
8 changes: 3 additions & 5 deletions src/p11_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* PKCS11 token
*/

#include <config.h>
#include "libp11-int.h"
#include <string.h>
#include <openssl/opensslv.h>
#include <openssl/opensslconf.h>
Expand Down Expand Up @@ -82,8 +82,6 @@

#if !defined(LIBP11_BUILD_WITHOUT_ECDSA)

#include "libp11-int.h"

static ECDSA_METHOD *ops = NULL;
static int ecdsa_ex_index = 0;

Expand Down Expand Up @@ -317,14 +315,14 @@ PKCS11_KEY_ops *pkcs11_ec_ops = {&pkcs11_ec_ops_s};

#else /* LIBP11_BUILD_WITHOUT_ECDSA */

void *pkcs11_ec_ops = {NULL};
PKCS11_KEY_ops *pkcs11_ec_ops = {NULL};

/* if not built with EC or OpenSSL does not support ECDSA
* add these routines so engine_pkcs11 can be built now and not
* require further changes */
#warning "ECDSA support not built with libp11"

void * PKCS11_get_ecdsa_method(void)
ECDSA_METHOD *PKCS11_get_ecdsa_method(void)
{
return NULL;
}
Expand Down
1 change: 0 additions & 1 deletion src/p11_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <config.h>
#include "libp11-int.h"

/* BEGIN ERROR CODES */
Expand Down
3 changes: 1 addition & 2 deletions src/p11_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <config.h>
#include <string.h>
#include "libp11-int.h"
#include <string.h>

#ifdef _WIN32
#define strncasecmp strnicmp
Expand Down
3 changes: 1 addition & 2 deletions src/p11_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <config.h>
#include <string.h>
#include "libp11-int.h"
#include <string.h>

static void *handle = NULL;

Expand Down
3 changes: 1 addition & 2 deletions src/p11_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <config.h>
#include "libp11-int.h"
#include <string.h>
#include <openssl/crypto.h>
#include "libp11-int.h"

/* PKCS11 strings are fixed size blank padded,
* so when strduping them we must make sure
Expand Down
3 changes: 1 addition & 2 deletions src/p11_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@

/* this file does certain cryptographic operations via the pkcs11 library */

#include <config.h>
#include <string.h>
#include "libp11-int.h"
#include <string.h>

int
PKCS11_ecdsa_sign(const unsigned char *m, unsigned int m_len,
Expand Down
Loading

0 comments on commit 0a67ed8

Please sign in to comment.