Convert xml-protected spaces to real spaces
[odt2txt.git] / Makefile
blob9e624a616d0ba4baff5df936982f996963fe51c7
2 UNAME_S := $(shell uname -s 2>/dev/null || echo unknown)
3 UNAME_O := $(shell uname -o 2>/dev/null || echo unknown)
5 ifdef DEBUG
6 CFLAGS = -O0 -g -Wextra -DMEMDEBUG -DSTRBUF_CHECK
7 #LDFLAGS = -lefence
8 LDFLAGS += -g
9 else
10 CFLAGS = -O2
11 endif
13 ifdef NO_ICONV
14 CFLAGS += -DNO_ICONV
15 endif
17 LIBS = -lz
18 ZIP_OBJS =
19 ifdef USE_KUNZIP
20 CFLAGS += -DUSE_KUNZIP
21 ZIP_OBJS = kunzip/fileio.o kunzip/zipfile.o
22 else
23 LIBS += -lzip
24 endif
26 OBJ = odt2txt.o regex.o mem.o strbuf.o $(ZIP_OBJS)
27 TEST_OBJ = t/test-strbuf.o t/test-regex.o
28 ALL_OBJ = $(OBJ) $(TEST_OBJ)
30 INSTALL = install
31 GROFF = groff
33 DESTDIR = /usr/local
34 PREFIX =
35 BINDIR = $(PREFIX)/bin
36 MANDIR = $(PREFIX)/share/man
37 MAN1DIR = $(MANDIR)/man1
39 ifeq ($(UNAME_S),FreeBSD)
40 CFLAGS += -DICONV_CHAR="const char" -I/usr/local/include
41 LDFLAGS += -L/usr/local/lib
42 LIBS += -liconv
43 endif
44 ifeq ($(UNAME_S),OpenBSD)
45 CFLAGS += -DICONV_CHAR="const char" -I/usr/local/include
46 LDFLAGS += -L/usr/local/lib
47 LIBS += -liconv
48 endif
49 ifeq ($(UNAME_S),Darwin)
50 CFLAGS += -I/opt/local/include
51 LDFLAGS += -L/opt/local/lib
52 LIBS += -liconv
53 endif
54 ifeq ($(UNAME_S),NetBSD)
55 CFLAGS += -DICONV_CHAR="const char"
56 endif
57 ifeq ($(UNAME_S),SunOS)
58 ifeq ($(CC),cc)
59 ifdef DEBUG
60 CFLAGS = -v -g -DMEMDEBUG -DSTRBUF_CHECK
61 else
62 CFLAGS = -xO3
63 endif
64 endif
65 CFLAGS += -DICONV_CHAR="const char"
66 endif
67 ifeq ($(UNAME_S),HP-UX)
68 CFLAGS += -I$(ZLIB_DIR)
69 LIBS = $(ZLIB_DIR)/libz.a
70 endif
71 ifeq ($(UNAME_O),Cygwin)
72 CFLAGS += -DICONV_CHAR="const char"
73 LIBS += -liconv
74 EXT = .exe
75 endif
76 ifeq ($(UNAME_O),Msys)
77 CFLAGS += -I/mingw$(ARCH)/lib/libzip/include
78 LIBS += -liconv -llibzip -lzip -lz -L/mingw$(ARCH)/lib
79 EXT = .exe
80 endif
81 ifneq ($(MINGW32),)
82 CFLAGS += -I$(REGEX_DIR) -I$(ZLIB_DIR) -I$(ICONV_DIR)/include/ -I$(LIBZIP_DIR)/lib/
83 LIBS = $(REGEX_DIR)/regex.o
84 ifdef STATIC
85 CFLAGS += -DZIP_STATIC
86 LIBS += $(wildcard $(ICONV_DIR)/lib/.libs/*.o)
87 LIBS += $(LIBZIP_DIR)/lib/.libs/libzip.a
88 LIBS += $(ZLIB_DIR)/libz.a
89 else
90 LIBS += -liconv
91 endif
92 EXT = .exe
93 endif
95 BIN = odt2txt$(EXT)
96 MAN = odt2txt.1
98 $(BIN): $(OBJ)
99 $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
101 t/test-strbuf: t/test-strbuf.o strbuf.o mem.o
102 t/test-regex: t/test-regex.o regex.o strbuf.o mem.o
104 $(ALL_OBJ): Makefile
106 all: $(BIN)
107 @if [ -n "$(USE_KUNZIP)" ] ; then \
108 echo '' ; \
109 echo ' Please use libzip (http://www.nih.at/libzip) instead of' ; \
110 echo ' kunzip. It is a much more complete zip library and has' ; \
111 echo ' much better handling for exotic and/or broken documents.' ; \
112 echo '' ; \
115 install: $(BIN) $(MAN)
116 $(INSTALL) -d -m755 $(DESTDIR)$(BINDIR)
117 $(INSTALL) $(BIN) $(DESTDIR)$(BINDIR)
118 $(INSTALL) -d -m755 $(DESTDIR)$(MAN1DIR)
119 $(INSTALL) $(MAN) $(DESTDIR)$(MAN1DIR)
121 odt2txt.html: $(MAN)
122 $(GROFF) -Thtml -man $(MAN) > $@
124 odt2txt.ps: $(MAN)
125 $(GROFF) -Tps -man $(MAN) > $@
127 clean:
128 rm -fr $(OBJ) $(BIN) odt2txt.ps odt2txt.html
130 .PHONY: clean