On Thu, Aug 25, 2011 at 04:07:08PM +0200, [email protected] wrote:
> Sure. Here is a subset of the actual Makefile:
> 
> ----BEGIN----
> 
> OPENSSL = openssl
> KEYSIZE = 2048
> SUBJECT = /CN=foobar
> 
> .EXPORT_ALL_VARIABLES:
> 
> %.key:
>         $(OPENSSL) genrsa -out $@ $(KEYSIZE)
> 
> %.req: %.key
>         $(OPENSSL) req -out $@ -key $< -subj $(SUBJECT) -new -batch
> 
> carbon.req: carbon.key
> 
> hydrogen.req: SUBJECT = /CN=hydrogen.example.com
> hydrogen.req: myrsa2048.key
> 
> ----END----
> 
> When 'make carbon.req' is executed, 'carbon.key' is first created if
> not already present (first pattern rule), and then 'carbon.req'
> 
> However, when 'make hydrogen.req' is executed, 'myrsa2048.key' is
> not taken into account since the pattern rule is meant to match
> 'hydrogen.req: hydrogen.key'.
> 
> The only solution I found so far is to use canned recipes instead of
> pattern rules. But that's not that elegant...

----BEGIN----

OPENSSL = openssl
KEYSIZE = 2048
SUBJECT = /CN=foobar
.EXPORT_ALL_VARIABLES:

%.key:
        $(OPENSSL) genrsa -out $@ $(KEYSIZE)
%.req:
        $(OPENSSL) req -out $@ -key $(call depWithDefault,$<,$*) -subj 
$(SUBJECT) -new -batch

carbon.req: carbon.key
hydrogen.req: SUBJECT = /CN=hydrogen.example.com
hydrogen.req: myrsa2048.key

depWithDefault=$(if $1,$1,$2.key)

----END----

$ make hydrogen.req carbon.req lawrencium.req -n
openssl genrsa -out myrsa2048.key 2048
openssl req -out hydrogen.req -key myrsa2048.key -subj /CN=hydrogen.example.com 
-new -batch
openssl genrsa -out carbon.key 2048
openssl req -out carbon.req -key carbon.key -subj /CN=foobar -new -batch
openssl req -out lawrencium.req -key lawrencium.key -subj /CN=foobar -new -batch

HTH,

--
Semen

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to