Home | History | Annotate | Line # | Download | only in dist
Makefile revision 1.2
      1 # $Id: Makefile,v 1.2 2015/12/17 22:31:12 christos Exp $
      2 #
      3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps (at] bsd.lv>
      4 # Copyright (c) 2011, 2013, 2014, 2015 Ingo Schwarze <schwarze (at] openbsd.org>
      5 #
      6 # Permission to use, copy, modify, and distribute this software for any
      7 # purpose with or without fee is hereby granted, provided that the above
      8 # copyright notice and this permission notice appear in all copies.
      9 #
     10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     17 
     18 VERSION = 1.13.3
     19 
     20 # === LIST OF FILES ====================================================
     21 
     22 TESTSRCS	 = test-dirent-namlen.c \
     23 		   test-fgetln.c \
     24 		   test-fts.c \
     25 		   test-getsubopt.c \
     26 		   test-mmap.c \
     27 		   test-ohash.c \
     28 		   test-reallocarray.c \
     29 		   test-sqlite3.c \
     30 		   test-sqlite3_errstr.c \
     31 		   test-strcasestr.c \
     32 		   test-strlcat.c \
     33 		   test-strlcpy.c \
     34 		   test-strptime.c \
     35 		   test-strsep.c \
     36 		   test-strtonum.c \
     37 		   test-wchar.c
     38 
     39 SRCS		 = att.c \
     40 		   cgi.c \
     41 		   chars.c \
     42 		   compat_fgetln.c \
     43 		   compat_fts.c \
     44 		   compat_getsubopt.c \
     45 		   compat_ohash.c \
     46 		   compat_reallocarray.c \
     47 		   compat_sqlite3_errstr.c \
     48 		   compat_strcasestr.c \
     49 		   compat_strlcat.c \
     50 		   compat_strlcpy.c \
     51 		   compat_strsep.c \
     52 		   compat_strtonum.c \
     53 		   demandoc.c \
     54 		   eqn.c \
     55 		   eqn_html.c \
     56 		   eqn_term.c \
     57 		   html.c \
     58 		   lib.c \
     59 		   main.c \
     60 		   man.c \
     61 		   man_hash.c \
     62 		   man_html.c \
     63 		   man_macro.c \
     64 		   man_term.c \
     65 		   man_validate.c \
     66 		   mandoc.c \
     67 		   mandoc_aux.c \
     68 		   mandocdb.c \
     69 		   manpage.c \
     70 		   manpath.c \
     71 		   mansearch.c \
     72 		   mansearch_const.c \
     73 		   mdoc.c \
     74 		   mdoc_argv.c \
     75 		   mdoc_hash.c \
     76 		   mdoc_html.c \
     77 		   mdoc_macro.c \
     78 		   mdoc_man.c \
     79 		   mdoc_term.c \
     80 		   mdoc_validate.c \
     81 		   msec.c \
     82 		   out.c \
     83 		   preconv.c \
     84 		   read.c \
     85 		   roff.c \
     86 		   st.c \
     87 		   tbl.c \
     88 		   tbl_data.c \
     89 		   tbl_html.c \
     90 		   tbl_layout.c \
     91 		   tbl_opts.c \
     92 		   tbl_term.c \
     93 		   term.c \
     94 		   term_ascii.c \
     95 		   term_ps.c \
     96 		   tree.c \
     97 		   $(TESTSRCS)
     98 
     99 DISTFILES	 = INSTALL \
    100 		   LICENSE \
    101 		   Makefile \
    102 		   Makefile.depend \
    103 		   NEWS \
    104 		   TODO \
    105 		   apropos.1 \
    106 		   cgi.h.example \
    107 		   chars.in \
    108 		   compat_fts.h \
    109 		   compat_ohash.h \
    110 		   configure \
    111 		   configure.local.example \
    112 		   demandoc.1 \
    113 		   eqn.7 \
    114 		   example.style.css \
    115 		   gmdiff \
    116 		   html.h \
    117 		   lib.in \
    118 		   libman.h \
    119 		   libmandoc.h \
    120 		   libmdoc.h \
    121 		   libroff.h \
    122 		   main.h \
    123 		   makewhatis.8 \
    124 		   man-cgi.css \
    125 		   man.1 \
    126 		   man.7 \
    127 		   man.cgi.8 \
    128 		   man.h \
    129 		   mandoc.1 \
    130 		   mandoc.3 \
    131 		   mandoc.db.5 \
    132 		   mandoc.h \
    133 		   mandoc_aux.h \
    134 		   mandoc_char.7 \
    135 		   mandoc_escape.3 \
    136 		   mandoc_headers.3 \
    137 		   mandoc_html.3 \
    138 		   mandoc_malloc.3 \
    139 		   manpath.h \
    140 		   mansearch.3 \
    141 		   mansearch.h \
    142 		   mchars_alloc.3 \
    143 		   mdoc.7 \
    144 		   mdoc.h \
    145 		   msec.in \
    146 		   out.h \
    147 		   predefs.in \
    148 		   roff.7 \
    149 		   st.in \
    150 		   style.css \
    151 		   tbl.3 \
    152 		   tbl.7 \
    153 		   term.h \
    154 		   $(SRCS)
    155 
    156 LIBMAN_OBJS	 = man.o \
    157 		   man_hash.o \
    158 		   man_macro.o \
    159 		   man_validate.o
    160 
    161 LIBMDOC_OBJS	 = att.o \
    162 		   lib.o \
    163 		   mdoc.o \
    164 		   mdoc_argv.o \
    165 		   mdoc_hash.o \
    166 		   mdoc_macro.o \
    167 		   mdoc_validate.o \
    168 		   st.o
    169 
    170 LIBROFF_OBJS	 = eqn.o \
    171 		   roff.o \
    172 		   tbl.o \
    173 		   tbl_data.o \
    174 		   tbl_layout.o \
    175 		   tbl_opts.o
    176 
    177 LIBMANDOC_OBJS	 = $(LIBMAN_OBJS) \
    178 		   $(LIBMDOC_OBJS) \
    179 		   $(LIBROFF_OBJS) \
    180 		   chars.o \
    181 		   mandoc.o \
    182 		   mandoc_aux.o \
    183 		   msec.o \
    184 		   preconv.o \
    185 		   read.o
    186 
    187 COMPAT_OBJS	 = compat_fgetln.o \
    188 		   compat_fts.o \
    189 		   compat_getsubopt.o \
    190 		   compat_ohash.o \
    191 		   compat_reallocarray.o \
    192 		   compat_sqlite3_errstr.o \
    193 		   compat_strcasestr.o \
    194 		   compat_strlcat.o \
    195 		   compat_strlcpy.o \
    196 		   compat_strsep.o \
    197 		   compat_strtonum.o
    198 
    199 MANDOC_HTML_OBJS = eqn_html.o \
    200 		   html.o \
    201 		   man_html.o \
    202 		   mdoc_html.o \
    203 		   tbl_html.o
    204 
    205 MANDOC_MAN_OBJS  = mdoc_man.o
    206 
    207 MANDOC_TERM_OBJS = eqn_term.o \
    208 		   man_term.o \
    209 		   mdoc_term.o \
    210 		   term.o \
    211 		   term_ascii.o \
    212 		   term_ps.o \
    213 		   tbl_term.o
    214 
    215 BASE_OBJS	 = $(MANDOC_HTML_OBJS) \
    216 		   $(MANDOC_MAN_OBJS) \
    217 		   $(MANDOC_TERM_OBJS) \
    218 		   main.o \
    219 		   manpath.o \
    220 		   out.o \
    221 		   tree.o
    222 
    223 MAIN_OBJS	 = $(BASE_OBJS)
    224 
    225 DB_OBJS		 = mandocdb.o \
    226 		   mansearch.o \
    227 		   mansearch_const.o
    228 
    229 CGI_OBJS	 = $(MANDOC_HTML_OBJS) \
    230 		   cgi.o \
    231 		   mansearch.o \
    232 		   mansearch_const.o \
    233 		   out.o
    234 
    235 MANPAGE_OBJS	 = manpage.o mansearch.o mansearch_const.o manpath.o
    236 
    237 DEMANDOC_OBJS	 = demandoc.o
    238 
    239 WWW_MANS	 = apropos.1.html \
    240 		   demandoc.1.html \
    241 		   man.1.html \
    242 		   mandoc.1.html \
    243 		   mandoc.3.html \
    244 		   mandoc_escape.3.html \
    245 		   mandoc_headers.3.html \
    246 		   mandoc_html.3.html \
    247 		   mandoc_malloc.3.html \
    248 		   mansearch.3.html \
    249 		   mchars_alloc.3.html \
    250 		   tbl.3.html \
    251 		   mandoc.db.5.html \
    252 		   eqn.7.html \
    253 		   man.7.html \
    254 		   mandoc_char.7.html \
    255 		   mdoc.7.html \
    256 		   roff.7.html \
    257 		   tbl.7.html \
    258 		   makewhatis.8.html \
    259 		   man.cgi.8.html \
    260 		   man.h.html \
    261 		   mandoc.h.html \
    262 		   mandoc_aux.h.html \
    263 		   manpath.h.html \
    264 		   mansearch.h.html \
    265 		   mdoc.h.html
    266 
    267 WWW_OBJS	 = mdocml.tar.gz \
    268 		   mdocml.sha256
    269 
    270 # === USER CONFIGURATION ===============================================
    271 
    272 -include Makefile.local
    273 
    274 # === DEPENDENCY HANDLING ==============================================
    275 
    276 all: base-build $(BUILD_TARGETS) Makefile.local
    277 
    278 base-build: mandoc demandoc
    279 
    280 cgi-build: man.cgi
    281 
    282 install: base-install $(INSTALL_TARGETS)
    283 
    284 www: $(WWW_OBJS) $(WWW_MANS)
    285 
    286 $(WWW_MANS): mandoc
    287 
    288 .PHONY: base-install cgi-install db-install install www-install
    289 .PHONY: clean distclean depend
    290 
    291 include Makefile.depend
    292 
    293 # === TARGETS CONTAINING SHELL COMMANDS ================================
    294 
    295 distclean: clean
    296 	rm -f Makefile.local config.h config.h.old config.log config.log.old
    297 
    298 clean:
    299 	rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
    300 	rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
    301 	rm -f man.cgi $(CGI_OBJS)
    302 	rm -f manpage $(MANPAGE_OBJS)
    303 	rm -f demandoc $(DEMANDOC_OBJS)
    304 	rm -f $(WWW_MANS) $(WWW_OBJS)
    305 	rm -rf *.dSYM
    306 
    307 base-install: base-build
    308 	mkdir -p $(DESTDIR)$(BINDIR)
    309 	mkdir -p $(DESTDIR)$(EXAMPLEDIR)
    310 	mkdir -p $(DESTDIR)$(LIBDIR)
    311 	mkdir -p $(DESTDIR)$(INCLUDEDIR)
    312 	mkdir -p $(DESTDIR)$(MANDIR)/man1
    313 	mkdir -p $(DESTDIR)$(MANDIR)/man3
    314 	mkdir -p $(DESTDIR)$(MANDIR)/man7
    315 	$(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
    316 	ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
    317 	$(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
    318 	$(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h \
    319 		$(DESTDIR)$(INCLUDEDIR)
    320 	$(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
    321 	$(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
    322 	$(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
    323 		mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
    324 	$(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
    325 	$(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
    326 	$(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
    327 	$(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
    328 	$(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
    329 	$(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
    330 	$(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
    331 
    332 db-install: base-build
    333 	mkdir -p $(DESTDIR)$(BINDIR)
    334 	mkdir -p $(DESTDIR)$(SBINDIR)
    335 	mkdir -p $(DESTDIR)$(MANDIR)/man1
    336 	mkdir -p $(DESTDIR)$(MANDIR)/man3
    337 	mkdir -p $(DESTDIR)$(MANDIR)/man5
    338 	mkdir -p $(DESTDIR)$(MANDIR)/man8
    339 	ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
    340 	ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
    341 	ln -f $(DESTDIR)$(BINDIR)/mandoc \
    342 		$(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
    343 	$(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
    344 	ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
    345 		$(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
    346 	$(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
    347 	$(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
    348 	$(INSTALL_MAN) makewhatis.8 \
    349 		$(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
    350 
    351 cgi-install: cgi-build
    352 	mkdir -p $(DESTDIR)$(CGIBINDIR)
    353 	mkdir -p $(DESTDIR)$(HTDOCDIR)
    354 	mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
    355 	mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
    356 	$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
    357 	$(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
    358 	$(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
    359 	$(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
    360 	$(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
    361 
    362 Makefile.local config.h: configure ${TESTSRCS}
    363 	@echo "$@ is out of date; please run ./configure"
    364 	@exit 1
    365 
    366 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
    367 	$(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
    368 
    369 mandoc: $(MAIN_OBJS) libmandoc.a
    370 	$(CC) $(LDFLAGS) -o $@ $(MAIN_OBJS) libmandoc.a $(DBLIB)
    371 
    372 manpage: $(MANPAGE_OBJS) libmandoc.a
    373 	$(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
    374 
    375 man.cgi: $(CGI_OBJS) libmandoc.a
    376 	$(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
    377 
    378 demandoc: $(DEMANDOC_OBJS) libmandoc.a
    379 	$(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
    380 
    381 # --- maintainer targets ---
    382 
    383 www-install: www
    384 	mkdir -p $(HTDOCDIR)/snapshots
    385 	$(INSTALL_DATA) $(WWW_MANS) style.css $(HTDOCDIR)
    386 	$(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
    387 	$(INSTALL_DATA) mdocml.tar.gz \
    388 		$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
    389 	$(INSTALL_DATA) mdocml.sha256 \
    390 		$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
    391 
    392 depend: config.h
    393 	mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
    394 	perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
    395 		s|\\\n||g; s|  +| |g; s| $$||mg; print;' \
    396 		Makefile.depend > Makefile.tmp
    397 	mv Makefile.tmp Makefile.depend
    398 
    399 mdocml.sha256: mdocml.tar.gz
    400 	sha256 mdocml.tar.gz > $@
    401 
    402 mdocml.tar.gz: $(DISTFILES)
    403 	mkdir -p .dist/mdocml-$(VERSION)/
    404 	$(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
    405 	chmod 755 .dist/mdocml-$(VERSION)/configure
    406 	( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
    407 	rm -rf .dist/
    408 
    409 # === SUFFIX RULES =====================================================
    410 
    411 .SUFFIXES:	 .1       .3       .5       .7       .8       .h
    412 .SUFFIXES:	 .1.html  .3.html  .5.html  .7.html  .8.html  .h.html
    413 
    414 .h.h.html:
    415 	highlight -I $< > $@
    416 
    417 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
    418 	./mandoc -Thtml -Wall,stop \
    419 		-Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@
    420