diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-04 02:40:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-04 02:40:04 +0000 |
commit | b1b1f3ded2e0150fbbbd26a6dd9ef3bc41714ecb (patch) | |
tree | b41a9db77eec21cf58039e275fda96ab2b17b2bb | |
parent | 1f3ec6d858e649808079e57fe10ca93a943e1647 (diff) |
des_tables.c: generation rule
* defs/gmake.mk (missing/des_tables.c): move the recipe from
common.mk. this is less common.
* missing/crypt.c (init_des): if des_tables.c is empty, initialize
DES tables at runtime.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | common.mk | 8 | ||||
-rw-r--r-- | defs/gmake.mk | 12 | ||||
-rw-r--r-- | missing/crypt.c | 16 | ||||
-rw-r--r-- | missing/des_tables.c | 4 |
4 files changed, 28 insertions, 12 deletions
@@ -748,14 +748,6 @@ $(NEWLINE_C): $(srcdir)/enc/trans/newline.trans $(srcdir)/tool/transcode-tblgen. $(Q) $(BASERUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo $@ $(srcdir)/enc/trans/newline.trans enc/trans/newline.$(OBJEXT): $(NEWLINE_C) -{$(VPATH)}missing/des_tables.c: $(srcdir)/missing/crypt.c - @$(ECHO) building make_des_table - $(Q) $(PURIFY) $(CC) $(CPPFLAGS) -DDUMP $(LDFLAGS) $(XLDFLAGS) $(LIBS) $(OUTFLAG)make_des_table $(srcdir)/missing/crypt.c - @$(ECHO) generating $@ - $(Q) $(MAKEDIRS) $(@D) - $(Q) ./make_des_table > $@ - $(Q) $(RMALL) make_des_table* - verconf.h: $(srcdir)/template/verconf.h.tmpl $(srcdir)/tool/generic_erb.rb $(ECHO) creating $@ $(Q) $(BOOTSTRAPRUBY) "$(srcdir)/tool/generic_erb.rb" -o $@ $(srcdir)/template/verconf.h.tmpl diff --git a/defs/gmake.mk b/defs/gmake.mk index b5acb48576..ba68dc19b9 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -77,3 +77,15 @@ sudo-precheck: test install-prereq: sudo-precheck yes-test-all no-test-all: install endif + +$(srcdir)/missing/des_tables.c: $(srcdir)/missing/crypt.c +ifeq ($(if $(CC),$(CROSS_COMPILING),yes),yes) + touch $@ +else + @$(ECHO) building make_des_table + $(Q) $(PURIFY) $(CC) $(CPPFLAGS) -DDUMP $(LDFLAGS) $(XLDFLAGS) $(LIBS) $(OUTFLAG)make_des_table $(srcdir)/missing/crypt.c + @$(ECHO) generating $@ + $(Q) $(MAKEDIRS) $(@D) + $(Q) ./make_des_table > $@ + $(Q) $(RMALL) make_des_table* +endif diff --git a/missing/crypt.c b/missing/crypt.c index 22be52fbf0..f523aa51e6 100644 --- a/missing/crypt.c +++ b/missing/crypt.c @@ -93,6 +93,15 @@ static char sccsid[] = "@(#)crypt.c 8.1 (Berkeley) 6/4/93"; # define INIT_DES 0 # endif #endif +#if !INIT_DES +# include "des_tables.c" +# ifdef HAVE_DES_TABLES +# define init_des() ((void)0) +# else +# undef INIT_DES +# define INIT_DES 1 +# endif +#endif /* * Convert twenty-four-bit long in host-order @@ -353,10 +362,6 @@ static des_tables_t des_tables[1]; STATIC void init_des(void); STATIC void init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS], unsigned char p[64], int chars_in, int chars_out); - -#else -#include "des_tables.c" -#define init_des() ((void)0) #endif static const C_block constdatablock = {{0}}; /* encryption constant */ @@ -884,6 +889,8 @@ main(void) { int i, j, k; init_des(); + + printf("#ifndef HAVE_DES_TABLES\n\n"); printf("/* Initial key schedule permutation */\n"); printf("static const C_block PC1ROT[64/CHUNKBITS][1<<CHUNKBITS] = {\n"); for (i = 0; i < numberof(PC1ROT); ++i) { @@ -953,6 +960,7 @@ main(void) printf("\t},\n"); } printf("};\n\n"); + printf("#define HAVE_DES_TABLES 1\n""#endif\n"); return 0; } diff --git a/missing/des_tables.c b/missing/des_tables.c index 051659d553..ab6b1d1883 100644 --- a/missing/des_tables.c +++ b/missing/des_tables.c @@ -1,3 +1,5 @@ +#ifndef HAVE_DES_TABLES + /* Initial key schedule permutation */ static const C_block PC1ROT[64/CHUNKBITS][1<<CHUNKBITS] = { { @@ -1610,3 +1612,5 @@ static const C_block CF6464[64/CHUNKBITS][1<<CHUNKBITS] = { }, }; +#define HAVE_DES_TABLES 1 +#endif |