ruby-changes:43200
From: nobu <ko1@a...>
Date: Sat, 4 Jun 2016 11:40:09 +0900 (JST)
Subject: [ruby-changes:43200] nobu:r55274 (trunk): des_tables.c: generation rule
nobu 2016-06-04 11:40:04 +0900 (Sat, 04 Jun 2016) New Revision: 55274 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55274 Log: 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. Modified files: trunk/common.mk trunk/defs/gmake.mk trunk/missing/crypt.c trunk/missing/des_tables.c Index: common.mk =================================================================== --- common.mk (revision 55273) +++ common.mk (revision 55274) @@ -748,14 +748,6 @@ $(NEWLINE_C): $(srcdir)/enc/trans/newlin https://github.com/ruby/ruby/blob/trunk/common.mk#L748 $(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 Index: missing/crypt.c =================================================================== --- missing/crypt.c (revision 55273) +++ missing/crypt.c (revision 55274) @@ -93,6 +93,15 @@ static char sccsid[] = "@(#)crypt.c 8.1 https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L93 # 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]; https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L362 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) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L889 { 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) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L960 printf("\t},\n"); } printf("};\n\n"); + printf("#define HAVE_DES_TABLES 1\n""#endif\n"); return 0; } Index: missing/des_tables.c =================================================================== --- missing/des_tables.c (revision 55273) +++ missing/des_tables.c (revision 55274) @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/missing/des_tables.c#L1 +#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 https://github.com/ruby/ruby/blob/trunk/missing/des_tables.c#L1612 }, }; +#define HAVE_DES_TABLES 1 +#endif Index: defs/gmake.mk =================================================================== --- defs/gmake.mk (revision 55273) +++ defs/gmake.mk (revision 55274) @@ -77,3 +77,15 @@ sudo-precheck: test https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L77 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/