Commit e2502377 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: improve net/khttpd file generation

Make the helper make_times_h output the code to stdout, so
we can redirect it into the file we want easily.
parent f83003da
...@@ -12,7 +12,11 @@ host-progs := make_times_h ...@@ -12,7 +12,11 @@ host-progs := make_times_h
include $(TOPDIR)/Rules.make include $(TOPDIR)/Rules.make
# Dependencies on generated files need to be listed explicitly
rfc_time.o: times.h rfc_time.o: times.h
# Generated files
times.h: make_times_h times.h: make_times_h
./make_times_h ./$< >$@
...@@ -64,59 +64,52 @@ static int WeekGetDay(int D,int M,int Y) ...@@ -64,59 +64,52 @@ static int WeekGetDay(int D,int M,int Y)
int main(void) int main(void)
{ {
int M,Y; int M,Y;
FILE *file;
file=fopen("times.h","w"); printf("static time_t TimeDays[10][13] = { \n");
if (file==NULL)
return 0;
fprintf(file,"static time_t TimeDays[10][13] = { \n");
Y=1997; Y=1997;
while (Y<2007) while (Y<2007)
{ {
M=0; M=0;
fprintf(file," { "); printf(" { ");
while (M<12) while (M<12)
{ {
fprintf(file,"%i",(int)GetDay(1,M,Y)); printf("%i",(int)GetDay(1,M,Y));
fprintf(file,",\t"); printf(",\t");
M++; M++;
} }
fprintf(file,"%i } ",(int)GetDay(1,0,Y+1)); printf("%i } ",(int)GetDay(1,0,Y+1));
if (Y!=2006) fprintf(file,","); if (Y!=2006) printf(",");
fprintf(file,"\n"); printf("\n");
Y++; Y++;
} }
fprintf(file,"};\n"); printf("};\n");
fprintf(file,"static int WeekDays[10][13] = { \n"); printf("static int WeekDays[10][13] = { \n");
Y=1997; Y=1997;
while (Y<2007) while (Y<2007)
{ {
M=0; M=0;
fprintf(file," { "); printf(" { ");
while (M<12) while (M<12)
{ {
fprintf(file,"%i",(int)WeekGetDay(1,M,Y)); printf("%i",(int)WeekGetDay(1,M,Y));
fprintf(file,",\t"); printf(",\t");
M++; M++;
} }
fprintf(file,"%i } ",(int)WeekGetDay(1,0,Y+1)); printf("%i } ",(int)WeekGetDay(1,0,Y+1));
if (Y!=2006) fprintf(file,","); if (Y!=2006) printf(",");
fprintf(file,"\n"); printf("\n");
Y++; Y++;
} }
fprintf(file,"};\n"); printf("};\n");
fprintf(file,"#define KHTTPD_YEAROFFSET 1997\n"); printf("#define KHTTPD_YEAROFFSET 1997\n");
fprintf(file,"#define KHTTPD_NUMYEARS 10\n"); printf("#define KHTTPD_NUMYEARS 10\n");
(void)fclose(file);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment