-.PHONY: all build gtags check doc doc_inner clean clean_cmd clean_gtags clean_src clean_test clean_doc clean_doc_inner
+.PHONY: all build gtags check doc doc_inner clean clean_src clean_gtags clean_test clean_doc clean_doc_inner
+
GTAGS ?= gtags
RMF ?= rm -f
-all: build gtags doc
+WHICH ?= which
+
+all: build doc doc_inner
build:
$(MAKE) -C src
gtags:
- @(which $(GTAGS) && $(GTAGS)) >/dev/null
+ ($(WHICH) $(GTAGS) && $(GTAGS)) >/dev/null
check:
- @$(MAKE) -sC test/system
+ $(MAKE) -C test/system
doc:
- @$(MAKE) -sC $@
+ $(MAKE) -C $@
doc_inner:
- @$(MAKE) -sC $@
+ $(MAKE) -C $@
-clean: clean_cmd clean_gtags clean_src clean_test clean_doc clean_doc_inner
+clean: clean_src clean_gtags clean_test clean_doc clean_doc_inner
-clean_cmd:
- @$(RMF) casl2 comet2 dumpword
+clean_src:
+ @$(MAKE) -sC src clean
clean_gtags:
@$(RMF) GPATH GRTAGS GSYMS GTAGS
-clean_src:
- @$(MAKE) -sC src clean
-
clean_test:
@$(MAKE) -sC test clean
SRC = $(DOCNAME).texi
CSS = style.css
+MV = mv
+CP = cp
+MKDIR = mkdir
+RMRF = rm -rf
PTEX = ptex
TEXI2DVI = texi2dvi
DVI2PDF = dvipdfmx
MAKEINFO = makeinfo
-MV = mv
-.PHONY: doc info htmlnosplit html pdf clean
+.PHONY: doc info htmlnosplit html pdf clean clean_docs clean_tex_tmp
.INTERMEDIATE: $(DOCNAME).dvi
doc: info htmlnosplit html pdf
+info: $(DOCNAME).info
+
htmlnosplit: $(DOCNAME).html
$(MV) $< index.html
html: $(SRC) $(CSS)
- @if test ! -s $@; then mkdir $@; fi;
- @cp $(CSS) $@/$(CSS)
- @$(MAKEINFO) -o $@ --html --css-ref=style.css $(SRC)
+ if test ! -e $@; then $(MKDIR) $@; fi;
+ $(CP) $(CSS) $@/$(CSS)
+ $(MAKEINFO) -o $@ --html --css-ref=$(CSS) $(SRC)
pdf: $(DOCNAME).pdf
-info: $(DOCNAME).info
-
-$(DOCNAME).info: $(SRC)
- @$(MAKEINFO) -o $@ $^
-
$(DOCNAME).html: $(SRC) $(CSS)
- @$(MAKEINFO) -o $@ --no-split --html --css-include=$(CSS) $(SRC)
+ $(MAKEINFO) -o $@ --no-split --html --css-include=$(CSS) $(SRC)
$(DOCNAME).pdf: $(DOCNAME).dvi
- @$(DVI2PDF) $^
+ $(DVI2PDF) $^
$(DOCNAME).dvi: $(SRC)
- @TEX=$(PTEX) $(TEXI2DVI) -q --texinfo=@afourpaper -o $@ $<
- @rm -rf $(DOCNAME).aux $(DOCNAME).cp $(DOCNAME).cps $(DOCNAME).fn $(DOCNAME).ky $(DOCNAME).log $(DOCNAME).pg $(DOCNAME).pgs $(DOCNAME).tmp $(DOCNAME).toc $(DOCNAME).tp $(DOCNAME).vr
+ TEX=$(PTEX) $(TEXI2DVI) -q --texinfo=@afourpaper -o $@ $<
+ @$(MAKE) clean_tex_tmp
+
+clean: clean_docs clean_tex_tmp
+
+clean_docs:
+ @$(RMRF) html $(DOCNAME).info $(DOCNAME).pdf $(DOCNAME).html
-clean:
- @rm -rf html $(DOCNAME).info $(DOCNAME).pdf $(DOCNAME).html $(DOCNAME).dvi
- @rm -rf $(DOCNAME).aux $(DOCNAME).cp $(DOCNAME).cps $(DOCNAME).fn $(DOCNAME).ky $(DOCNAME).log $(DOCNAME).pg $(DOCNAME).pgs $(DOCNAME).tmp $(DOCNAME).toc $(DOCNAME).tp $(DOCNAME).vr
+clean_tex_tmp:
+ @$(RMRF) $(DOCNAME).aux $(DOCNAME).cp $(DOCNAME).cps $(DOCNAME).fn $(DOCNAME).ky $(DOCNAME).log $(DOCNAME).pg $(DOCNAME).pgs $(DOCNAME).tmp $(DOCNAME).toc $(DOCNAME).tp $(DOCNAME).vr
# ../Doxyfileで設定された以下のディレクトリーの下のhtmlディレクトリー
# OUTPUT_DIRECTORY = doc_inner
$(DOXYGEN_DIR): ../Doxyfile
- @($(WHICH) $(DOXYGEN) && $(CD) .. && $(DOXYGEN) && $(CD) - && $(MV) html $@) >/dev/null
+ ($(WHICH) $(DOXYGEN) && $(CD) .. && $(DOXYGEN) && $(CD) - && $(MV) html $@) >/dev/null
# htagsのHTMLドキュメント作成先は、
# 引数DIRで指定されたディレクトリーの下のHTMLディレクトリー
$(GNU_GLOBAL_DIR):
- @$(MAKE) -sC .. gtags
- @($(WHICH) $(HTAGS) && $(CD) .. && $(HTAGS) -anosx doc_inner && $(CD) - && $(MV) HTML $@) >/dev/null
+ $(MAKE) -C .. gtags
+ ($(WHICH) $(HTAGS) && $(CD) .. && $(HTAGS) -anosx doc_inner && $(CD) - && $(MV) HTML $@) >/dev/null
clean: clean_doxygen clean_gnu_global
+CC ?= gcc
+CFLAGS ?= -g -Wall -Wextra -I $(INCLUDE)
+RMF ?= rm -f
+WHICH ?= which
+CTAGS ?= ctags
+ETAGS ?= etags
+
INCLUDE := ../include
-CC := gcc
-CFLAGS := -g -Wall -Wextra -I $(INCLUDE)
-RM := rm -f
COMMONSRC := word.c cmem.c cerr.c
CASL2SRC := struct.c hash.c
.PHONY: all clean
-all: ../casl2 ../comet2 ../dumpword
+all: ../casl2 ../comet2 ../dumpword ctags etags
../casl2: casl2.o $(subst .c,.o,$(COMMONSRC) $(CASL2SRC) $(ASSRC) $(EXECSRC))
$(CC) $(CFLAGS) -o $@ $^
- @rm -f *.d
+ @$(RMF) *.d
../comet2: comet2.o $(subst .c,.o,$(COMMONSRC) $(CASL2SRC) $(EXECSRC))
$(CC) $(CFLAGS) -o $@ $^
- @rm -f *.d
+ @$(RMF) *.d
../dumpword: dumpword.o $(subst .c,.o,$(COMMONSRC))
$(CC) $(CFLAGS) -o $@ $^
- @rm -f *.d
+ @$(RMF) *.d
%.o: %.c
$(CC) -c $(CFLAGS) $<
-include $(subst .c,.d,casl2.c comet2.c dumpword.c $(COMMONSRC) $(CASL2SRC) $(ASSRC) $(EXECSRC))
-TAGS: $(INCLUDE)/*.h *.c
- @if test `which etags`; then etags $^; fi
+ctags: $(INCLUDE)/*.h *.c
+ @($(WHICH) $(CTAGS) && $(CTAGS) $^) >/dev/null
+
+etags: $(INCLUDE)/*.h *.c
+ @($(WHICH) $(ETAGS) && $(ETAGS) $^) >/dev/null
+
+clean: clean_cmd clean_build clean_tags
+
+clean_cmd:
+ @$(RMF) ../casl2 ../comet2 ../dumpword
+
+clean_build:
+ @$(RMF) *.o *.d
-clean:
- @rm -f ../casl2 ../comet2 ../dumpword
- @rm -f *.o *.d
+clean_tags:
+ @$(RMF) TAGS tags