From: j8takagi Date: Thu, 25 Oct 2012 14:18:59 +0000 (+0900) Subject: Makefileの整理 X-Git-Tag: v0.1p49 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3f91f53a0a715249df3582be19d064f831619a0;p=YACASL2.git Makefileの整理 --- diff --git a/Makefile b/Makefile index bb304d1..4969245 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,34 @@ -.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 diff --git a/doc/Makefile b/doc/Makefile index 00c54eb..3c9b3be 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,43 +2,47 @@ DOCNAME = yacasl2 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 diff --git a/doc_inner/Makefile b/doc_inner/Makefile index ff9e405..5c59ef2 100644 --- a/doc_inner/Makefile +++ b/doc_inner/Makefile @@ -17,13 +17,13 @@ all: $(DOXYGEN_DIR) $(GNU_GLOBAL_DIR) # ../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 diff --git a/src/.gitignore b/src/.gitignore index 2477ac1..c3a9946 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,3 +1,4 @@ *.d *.o TAGS +tags diff --git a/src/Makefile b/src/Makefile index a394531..ab66853 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,11 @@ +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 @@ -10,19 +14,19 @@ EXECSRC := exec.c dump.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) $< @@ -32,9 +36,19 @@ all: ../casl2 ../comet2 ../dumpword -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