diff --git a/Makefile b/Makefile index b7f72ba..7830fc9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # t2p: build a PDF file out of one or more TIFF Class F Group 4 files # Makefile -# $Id: Makefile,v 1.22 2003/03/11 22:39:22 eric Exp $ +# $Id: Makefile,v 1.23 2003/03/11 22:57:46 eric Exp $ # Copyright 2001, 2002, 2003 Eric Smith # # This program is free software; you can redistribute it and/or modify @@ -73,9 +73,9 @@ DISTFILES = $(MISC) $(HDRS) $(CSRCS) $(OSRCS) DISTNAME = $(PACKAGE)-$(VERSION) -AUTO_CSRCS = scanner.c parser.tab.c bitblt_tables.c -AUTO_HDRS = parser.tab.h g4_tables.h -AUTO_MISC = parser.output bitblt_tables.h +AUTO_CSRCS = scanner.c parser.tab.c bitblt_tables.c g4_tables.c +AUTO_HDRS = parser.tab.h bitblt_tables.h g4_tables.h +AUTO_MISC = parser.output -include Maketest @@ -85,7 +85,7 @@ all: $(TARGETS) $(TEST_TARGETS) t2p: t2p.o scanner.o semantics.o parser.tab.o \ - bitblt.o bitblt_g4.o bitblt_tables.o \ + bitblt.o bitblt_g4.o bitblt_tables.o g4_tables.o \ pdf.o pdf_util.o pdf_prim.o pdf_bookmark.o pdf_name_tree.o \ pdf_g4.o $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ @@ -103,7 +103,10 @@ bitblt_tables.c: bitblt_table_gen bitblt_table_gen: bitblt_table_gen.o g4_tables.h: g4_table_gen - ./g4_table_gen >g4_tables.h + ./g4_table_gen -h >g4_tables.h + +g4_tables.c: g4_table_gen + ./g4_table_gen -c >g4_tables.c g4_table_gen: g4_table_gen.o diff --git a/g4_table_gen.c b/g4_table_gen.c index 1972e40..68db2ea 100644 --- a/g4_table_gen.c +++ b/g4_table_gen.c @@ -4,7 +4,7 @@ * will be compressed using ITU-T T.6 (G4) fax encoding. * * G4 table generator - * $Id: g4_table_gen.c,v 1.2 2003/03/05 12:44:33 eric Exp $ + * $Id: g4_table_gen.c,v 1.3 2003/03/11 22:57:46 eric Exp $ * Copyright 2003 Eric Smith * * This program is free software; you can redistribute it and/or modify @@ -81,11 +81,19 @@ char *long_makeup_code [12] = }; -void print_long_makeup_code (void) +void print_long_makeup_code (bool header) { int i; - printf ("static g4_bits g4_long_makeup_code [12] =\n"); + if (header) + printf ("extern "); + printf ("const g4_bits g4_long_makeup_code [12]"); + if (header) + { + printf (";\n"); + return; + } + printf (" =\n"); printf (" {\n"); for (i = 0; i < 12; i++) emit_code (4, long_makeup_code [i], i == 11, 1, i * 64 + 1792); @@ -125,11 +133,19 @@ char *makeup_code [64][2] = }; -void print_makeup_code (void) +void print_makeup_code (bool header) { int i; - printf ("static g4_bits g4_makeup_code [2] [27] =\n"); + if (header) + printf ("extern "); + printf ("const g4_bits g4_makeup_code [2] [27]"); + if (header) + { + printf (";\n"); + return; + } + printf (" =\n"); printf (" {\n"); printf (" {\n"); printf (" /* white */\n"); @@ -214,11 +230,19 @@ char *h_code [64][2] = }; -void print_h_code (void) +void print_h_code (bool header) { int i; - printf ("static g4_bits g4_h_code [2] [64] =\n"); + if (header) + printf ("extern "); + printf ("const g4_bits g4_h_code [2] [64]"); + if (header) + { + printf (";\n"); + return; + } + printf (" =\n"); printf (" {\n"); printf (" {\n"); printf (" /* white */\n"); @@ -246,11 +270,19 @@ char *v_code [7] = }; -void print_v_code (void) +void print_v_code (bool header) { int i; - printf ("static g4_bits g4_vert_code [7] =\n"); + if (header) + printf ("extern "); + printf ("const g4_bits g4_vert_code [7]"); + if (header) + { + printf (";\n"); + return; + } + printf ("=\n"); printf (" {\n"); for (i = 0; i <= 6; i++) emit_code (4, v_code [i], i == 6, 1, i - 3); @@ -260,25 +292,51 @@ void print_v_code (void) int main (int argc, char *argv []) { + bool header; + + if (argc != 2) + { + fprintf (stderr, "wrong arg count\n"); + exit (2); + } + if (strcmp (argv [1], "-h") == 0) + header = 1; + else if (strcmp (argv [1], "-c") == 0) + header = 0; + else + { + fprintf (stderr, "wrong args\n"); + exit (2); + } + printf ("/* This file is automatically generated; do not edit */\n"); printf ("\n"); - printf ("typedef struct\n"); - printf ("{\n"); - printf (" uint32_t count;\n"); - printf (" uint32_t bits;\n"); - printf ("} g4_bits;\n"); + + if (header) + { + printf ("typedef struct\n"); + printf ("{\n"); + printf (" uint32_t count;\n"); + printf (" uint32_t bits;\n"); + printf ("} g4_bits;\n"); + } + else + { + printf ("#include \n"); + printf ("#include \"g4_tables.h\"\n"); + } printf ("\n"); - print_long_makeup_code (); + print_long_makeup_code (header); printf ("\n"); - print_makeup_code (); + print_makeup_code (header); printf ("\n"); - print_h_code (); + print_h_code (header); printf ("\n"); - print_v_code (); + print_v_code (header); exit (0); }