| 1 | # Copyright (c) 1986-2007 Purdue University |
| 2 | # All rights reserved. |
| 3 | # |
| 4 | # Developed by: Daniel Trinkle |
| 5 | # Department of Computer Science, Purdue University |
| 6 | # http://www.cs.purdue.edu/ |
| 7 | # |
| 8 | # Permission is hereby granted, free of charge, to any person obtaining |
| 9 | # a copy of this software and associated documentation files (the |
| 10 | # "Software"), to deal with the Software without restriction, including |
| 11 | # without limitation the rights to use, copy, modify, merge, publish, |
| 12 | # distribute, sublicense, and/or sell copies of the Software, and to |
| 13 | # permit persons to whom the Software is furnished to do so, subject to |
| 14 | # the following conditions: |
| 15 | # |
| 16 | # o Redistributions of source code must retain the above copyright |
| 17 | # notice, this list of conditions and the following disclaimers. |
| 18 | # |
| 19 | # o Redistributions in binary form must reproduce the above copyright |
| 20 | # notice, this list of conditions and the following disclaimers in the |
| 21 | # documentation and/or other materials provided with the distribution. |
| 22 | # |
| 23 | # o Neither the names of Daniel Trinkle, Purdue University, nor the |
| 24 | # names of its contributors may be used to endorse or promote products |
| 25 | # derived from this Software without specific prior written |
| 26 | # permission. |
| 27 | # |
| 28 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 29 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 30 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 31 | # IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR |
| 32 | # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 33 | # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 34 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. |
| 35 | # |
| 36 | # |
| 37 | # Makefile for detex and delatex |
| 38 | # |
| 39 | # Detex is a program to remove TeX and LaTeX constructs from text source. |
| 40 | |
| 41 | UNAME_S := $(shell uname -s) |
| 42 | |
| 43 | # Installation directory |
| 44 | # |
| 45 | DESTDIR = /usr/local/bin |
| 46 | |
| 47 | # Specify you favorite compiler |
| 48 | # |
| 49 | #CC = gcc |
| 50 | |
| 51 | # Compile time flags, just uncomment the necessary lines |
| 52 | # Some say GNU make does not correctly handle += -- you may have to use := |
| 53 | # |
| 54 | DEFS = |
| 55 | # |
| 56 | # Add -traditional for GNU cc on ISC 386/ix system and possibly others |
| 57 | # (reported by [email protected]) |
| 58 | # |
| 59 | #DEFS += ${DEFS} -traditional |
| 60 | # |
| 61 | # Add -DHAVE_STRING_H for the SysV string manipulation routines |
| 62 | # |
| 63 | #DEFS += ${DEFS} -DHAVE_STRING_H |
| 64 | # |
| 65 | # Add -DMAXPATHLEN=<length> if it is not defined in /usr/include/sys/param.h |
| 66 | # |
| 67 | #DEFS += ${DEFS} -DMAXPATHLEN=1024 |
| 68 | # |
| 69 | # Add -DNO_MALLOC_DECL if your system does not like the malloc() declaration |
| 70 | # in detex.l (reported by [email protected]) |
| 71 | # |
| 72 | #DEFS += ${DEFS} -DNO_MALLOC_DECL |
| 73 | # |
| 74 | CFLAGS += -O -DVERSION=\"${VERSION}\" ${DEFS} -Wall |
| 75 | |
| 76 | # Use your favorite lexical scanner |
| 77 | # |
| 78 | #LEX = lex |
| 79 | LEX = flex |
| 80 | |
| 81 | #LFLAGS = -8 -C |
| 82 | |
| 83 | # scanner library |
| 84 | # |
| 85 | LEXLIB = -lfl |
| 86 | ifeq ($(UNAME_S),Darwin) |
| 87 | LEXLIB = -ll |
| 88 | endif |
| 89 | |
| 90 | LPR = lpr -p |
| 91 | |
| 92 | # Program names |
| 93 | # |
| 94 | PROGS = detex delatex |
| 95 | |
| 96 | # Header files |
| 97 | # |
| 98 | HDR = detex.h |
| 99 | |
| 100 | # Sources |
| 101 | # |
| 102 | SRC = detex.l |
| 103 | |
| 104 | # Objects for various programs |
| 105 | # |
| 106 | D_OBJ = detex.o |
| 107 | |
| 108 | VERSION = 2.8.11 |
| 109 | |
| 110 | all: ${PROGS} |
| 111 | |
| 112 | detex: ${D_OBJ} |
| 113 | ${CC} ${CFLAGS} -o $@ ${D_OBJ} ${LEXLIB} |
| 114 | |
| 115 | delatex: detex |
| 116 | cp detex delatex |
| 117 | |
| 118 | detex.c: detex.l |
| 119 | ${LEX} ${LFLAGS} detex.l |
| 120 | mv lex.yy.c detex.c |
| 121 | |
| 122 | man-page: |
| 123 | troff -man detex.1 |
| 124 | |
| 125 | # If you want detex available as delatex, uncomment the last two lines of |
| 126 | # this target |
| 127 | install: all |
| 128 | rm -f ${DESTDIR}/detex |
| 129 | install -c -m 775 -g staff -s detex ${DESTDIR} |
| 130 | install detex.1 /usr/local/share/man/man1 |
| 131 | # rm -f ${DESTDIR}/delatex |
| 132 | # ln ${DESTDIR}/detex ${DESTDIR}/delatex |
| 133 | |
| 134 | uninstall: |
| 135 | rm -f ${DESTDIR}/detex |
| 136 | rm -f ${DESTDIR}/delatex |
| 137 | rm -f /usr/local/share/man/man1/detex.* |
| 138 | |
| 139 | clean: |
| 140 | -rm -f a.out core *.s *.o ERRS errs .,* .emacs_[0-9]* |
| 141 | -rm -f ${PROGS} xxx.l lex.yy.c detex.c |
| 142 | -rm -f *.tar.bz2 |
| 143 | |
| 144 | print: ${HDR} ${SRC} |
| 145 | ${LPR} Makefile ${HDR} ${SRC} |
| 146 | |
| 147 | test: all |
| 148 | ./test.pl |
| 149 | |
| 150 | run: delatex |
| 151 | ./delatex in > out.txt |
| 152 | |
| 153 | package: clean detex.c |
| 154 | tar cjfv opendetex-${VERSION}.tar.bz2 --exclude='*.o' ChangeLog COPYRIGHT detex.* INSTALL Makefile README |
| 155 | |
| 156 | # Dependencies |
| 157 | # |
| 158 | detex.c: detex.h |
| 159 | detex.c: detex.l |
| 160 | |
| 161 | inpdf: |
| 162 | cd test && xelatex -interaction=nonstopmode in.tex || echo there were errors |
| 163 | rm -f test/*.toc test/*.log test/*.aux |
| 164 | mv test/in.pdf . |