Subject: Re: ifdef in Makefile.inc?

Re: ifdef in Makefile.inc?

From: Simon Josefsson <simon_at_josefsson.org>
Date: Mon, 07 Sep 2009 14:35:46 +0200

Daniel Stenberg <daniel_at_haxx.se> writes:

> On Mon, 7 Sep 2009, Simon Josefsson wrote:
>
>> As far as I know, 'ifdef' is not permitted in automake makefiles.
>>
>> I'm not able to build libssh2 without this patch to Makefile.inc:
>
> The .inc files should also carefully be crafted to be used by differnt
> make implementaitons so it should ideally not use ifdefs _at all_
> methinks.
>
>> How do we make things work?
>
> I think we should let the .inc file assign two different variables,
> and then the conditional would be in the actual makefile that would
> use one or the other of the variables. So that the .inc file has no
> conditionals at all.

Below is a starting pointer.

I don't know how to fix the nw/win32 files -- you can use either
libgcrypt and OpenSSL under Windows, and possibly also on netware.
Perhaps having separate VC project files for both variants?

/Simon

diff --git a/Makefile.inc b/Makefile.inc
index 658b1d6..5812f3e 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -2,10 +2,8 @@ CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
  packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \
  version.c knownhost.c
 
-ifdef LIBGCRYPT
-CSOURCES += libgcrypt.c pem.c
-else
-CSOURCES += openssl.c
-endif
+# You also need ONE of these.
+GCRYPT_CSOURCES = libgcrypt.c pem.c
+OPENSSL_CSOURCES = openssl.c
 
 HHEADERS = libssh2_priv.h openssl.h libgcrypt.h transport.h channel.h comp.h mac.h misc.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 53fb4e8..7369942 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,11 @@ AUTOMAKE_OPTIONS = foreign nostdinc
 include ../Makefile.inc
 
 libssh2_la_SOURCES = $(CSOURCES) $(HHEADERS)
+if LIBGCRYPT
+CSOURCES += $(GCRYPT_CSOURCES)
+else
+CSOURCES += $(OPENSSL_CSOURCES)
+endif
 
 EXTRA_DIST = libssh2_config.h.in NMakefile
 
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2009-09-07