Subject: Re: lib/9702: Makefile lossage for crypto-intl
To: None <tech-crypto@NetBSD.ORG>
From: Simon Burge <simonb@NetBSD.ORG>
List: tech-crypto
Date: 04/15/2000 04:51:30
Johan Danielsson wrote:

> Simon Burge <simonb@NetBSD.ORG> writes:
> 
> > Should we change asn1_compile to make an asn1.hx and check the same
> > way we do with the .x/.c files?
> 
> Probably yes.

The following works for me.  To get asn1.h built early enought, I 
nded up needing to list these dependancies:

	asn1.h: asn1.hx
	${SRCS}: asn1.h

Does this look ok?  If so, I'll also change the make variables
to use {} everywhere instead of a mixture of those and ().

Simon.
--
Index: dist/heimdal/lib/asn1/gen.c
===================================================================
RCS file: /cvsroot/cryptosrc-intl/crypto-intl/dist/heimdal/lib/asn1/gen.c,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 gen.c
--- gen.c	2000/01/16 01:52:56	1.1.1.1
+++ gen.c	2000/04/14 18:47:47
@@ -49,7 +49,7 @@ init_generate (char *filename, char *bas
     orig_filename = filename;
     if(base)
 	strcpy(headerbase, base);
-    sprintf(header, "%s.h", headerbase);
+    snprintf(header, sizeof(header), "%s.hx", headerbase);
     headerfile = fopen (header, "w");
     if (headerfile == NULL)
 	err (1, "open %s", header);
Index: lib/libasn1/Makefile
===================================================================
RCS file: /cvsroot/cryptosrc-intl/crypto-intl/lib/libasn1/Makefile,v
retrieving revision 1.2
diff -p -u -r1.2 Makefile
--- Makefile	2000/01/17 21:18:05	1.2
+++ Makefile	2000/04/14 18:47:47
@@ -82,29 +82,27 @@ CPPFLAGS+= -I. \
 	 -I${DIST}/heimdal/lib/com_err \
 	 -DHAVE_CONFIG_H
 
-$(gen_files) asn1.h: asn1_files
+$(gen_files) asn1.hx: asn1_files
 
 ASN1COMPILE!=	cd ${.CURDIR}/asn1_compile && ${MAKE} print-objdir
 
-asn1_files: k5.asn1 ${ASN1COMPILE}/asn1_compile
+asn1_files: k5.asn1 all-asn1_compile
 	${ASN1COMPILE}/asn1_compile ${DIST}/heimdal/lib/asn1/k5.asn1
 
-${ASN1COMPILE}/asn1_compile: FORCE
-	cd ${.CURDIR}/asn1_compile && $(MAKE) asn1_compile
+asn1.h:	asn1.hx
+${SRCS}: asn1.h
 
-FORCE: .NOTMAIN
-.PHONY: FORCE
+CLEANFILES = $(BUILT_SOURCES) $(gen_files) asn1_files asn1.h asn1.hx
 
-$(SRCS:.c=.o): asn1.h
-
-CLEANFILES = $(BUILT_SOURCES) $(gen_files) asn1_files asn1.h
-
 SUBDIR=	asn1_compile
 
 .include <bsd.lib.mk>
 .include <bsd.subdir.mk>
 
-.SUFFIXES: .x
+.SUFFIXES: .hx .x
 
 .x.c:
+	@cmp -s $< $@ 2> /dev/null || cp $< $@
+
+.hx.h:
 	@cmp -s $< $@ 2> /dev/null || cp $< $@