From: j8takagi Date: Tue, 22 Jan 2013 02:35:22 +0000 (+0900) Subject: Makefileの修正 X-Git-Tag: v0.2p7 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8993a52e06e3f33aad16c8bb842f62307cae8063;p=YACASL2.git Makefileの修正 --- diff --git a/Makefile b/Makefile index d4014fc..b074511 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,15 @@ .PHONY: all build gtags check doc info html doc-inner install uninstall install-info uninstall-info install-casl2lib uninstall-casl2lib version gittag clean clean-src clean-gtags clean-test clean-doc clean-doc-inner -GTAGS := gtags -RMF := rm -f -WHICH := which +CMD := casl2 comet2 dumpword + +CAT := cat +CP := cp ECHO := echo +GITTAG := git tag +GTAGS := gtags INSTALL := install SED := sed -CAT := cat -XARGS := xargs -GITTAG := git tag +WHICH := which prefix ?= ~ bindir ?= $(prefix)/bin @@ -16,13 +17,21 @@ bindir ?= $(prefix)/bin VERSION = $(shell $(CAT) VERSION) VERSIONFILES = include/package.h test/system/casl2/opt_v/0.txt test/system/comet2/opt_v/0.txt test/system/dumpword/opt_v/0.txt -all: build docall gtags +all: build doc gtags -build: +build: version $(MAKE) -C src all + $(CP) $(addprefix src/,$(CMD)) ./ gtags: - @$(WHICH) $(GTAGS) >/dev/null && $(GTAGS) || $(ECHO) "$(GTAGS): not found" + $(if $(strip $(shell $(WHICH) $(GTAGS))),$(GTAGS),@$(ECHO) '$(GTAGS): not found') + +doc: + $(MAKE) -C doc base + $(MAKE) INSTALL + +INSTALL: doc/install.txt + $(CP) $< $@ docall: $(MAKE) -C doc all @@ -41,10 +50,10 @@ check: install: casl2 comet2 dumpword install-info install-casl2lib $(INSTALL) -d $(bindir) - $(INSTALL) casl2 comet2 dumpword $(bindir)/ + $(INSTALL) $(CMD) $(bindir)/ uninstall: uninstall-info uninstall-casl2lib - $(RMF) $(bindir)/casl2 $(bindir)/comet2 $(bindir)/dumpword + $(RM) $(prefix $(bindir)/,$(CMD)) install-info: $(MAKE) -C doc install-info @@ -62,18 +71,21 @@ version: $(VERSIONFILES) @$(ECHO) "YACASL2 Version: $(VERSION)" $(VERSIONFILES): VERSION - $(SED) -e "s/@@VERSION@@/$(VERSION)/g" $@.version >$@ + @$(SED) -e "s/@@VERSION@@/$(VERSION)/g" $@.version >$@ gittag: VERSION $(GITTAG) $(VERSION) -clean: clean-src clean-gtags clean-doc clean-doc-inner clean-version +clean: clean-cmd clean-src clean-gtags clean-doc clean-doc-inner clean-version + +clean-cmd: + @$(RM) $(CMD) clean-src: @$(MAKE) -sC src clean clean-gtags: - @$(RMF) GPATH GRTAGS GSYMS GTAGS + @$(RM) GPATH GRTAGS GSYMS GTAGS clean-doc: @$(MAKE) -sC doc clean @@ -81,8 +93,8 @@ clean-doc: clean-doc-inner: @$(MAKE) -sC doc_inner clean +clean-version: + @$(RM) $(VERSIONFILES) + clean-test: @$(MAKE) -sC test clean - -clean-version: - @$(RMF) $(VERSIONFILES) diff --git a/VERSION b/VERSION index a85796d..95b983f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.2p6 +v0.2p7 diff --git a/doc/Makefile b/doc/Makefile index 93fbeed..10c8bff 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,80 +1,68 @@ -MANUAL = manual -INSTALLDOC = install -CASL2SPEC = casl2_spec -MANUAL_SYSINFO = yacasl2.info -CSS = style.css - -MV ?= mv -CP ?= cp -MKDIR ?= mkdir -RMF = rm -f -RMRF ?= rm -rf -PTEX ?= ptex -TEXI2DVI ?= texi2dvi -DVI2PDF ?= dvipdfmx -MAKEINFO ?= gmakeinfo -INSTALL ?= install -INSTALL-INFO ?= ginstall-info -GZIP = gzip +DOCS := install manual + +CSS := style.css + +CP := cp +DVIPDFMX := dvipdfmx +GZIP := gzip +INSTALL := install +INSTALL-INFO := install-info +MKDIR := mkdir +RMR := rm -rf +TEX := ptex +TEXI2DVI := TEX=ptex texi2dvi +TEX2DVI_FLAGS = -q --texinfo=@afourpaper prefix ?= ~ infodir ?= $(prefix)/share/info -.PHONY: all info html htmls pdf install-info uninstall-info clean clean-textmp +.PHONY: base all info html htmls pdf install-info uninstall-info clean clean-textmp .INTERMEDIATE: *.dvi -base: ../INSTALL $(MANUAL_SYSINFO) $(MANUAL).html +base: install.txt info html -all: info html htmls pdf ../INSTALL $(MANUAL_SYSINFO) +all: base htmls pdf -info: $(MANUAL_SYSINFO) $(INSTALLDOC).info +info: yacasl2.info -html: $(MANUAL).html $(INSTALLDOC).html +html: $(addsuffix .html,$(DOCS)) -htmls: $(MANUAL)_html +htmls: $(addsuffix _html,$(DOCS)) -pdf: $(INSTALLDOC).pdf $(MANUAL).pdf +pdf: $(addsuffix .pdf,$(DOCS)) -$(MANUAL_SYSINFO): $(MANUAL).texi - $(MAKEINFO) $< +yacasl2.info: manual.texi + $(MAKEINFO) $(MAKEINFO_FLAGS) $< -%.html: %.texi $(CSS) +$(addsuffix .html,$(DOCS)) $(addsuffix _html,$(DOCS)): $(CSS) + +%.html: %.texi $(MAKEINFO) -o $@ --no-split --html --css-include=$(CSS) $< -%_html: %.texi $(CSS) - $(INSTALL) -d $@ - $(INSTALL) $(CSS) $@/ +%_html: %.texi + if test ! -e $@; then $(MKDIR) $@; fi + $(CP) $(CSS) $@/ $(MAKEINFO) -o $@ --html --css-ref=$(CSS) $< %.pdf: %.dvi - $(DVI2PDF) $< - -%.dvi: %.texi - TEX=$(PTEX) $(TEXI2DVI) -q --texinfo=@afourpaper -o $@ $< - @$(MAKE) clean-textmp + $(DVIPDFMX) $< %.txt: %.texi $(MAKEINFO) --no-headers --disable-encoding -o $@ $< -install-info: $(MANUAL_SYSINFO) +install-info: yacasl2.info $(INSTALL) -d $(infodir) - $(INSTALL) $(MANUAL_SYSINFO) $(infodir)/ - $(INSTALL-INFO) $(infodir)/$(MANUAL_SYSINFO) $(infodir)/dir - $(GZIP) -f $(infodir)/$(MANUAL_SYSINFO) - -uninstall-info: $(MANUAL).info - $(INSTALL-INFO) --delete $(infodir)/$(MANUAL_SYSINFO) $(infodir)/dir - $(RMF) $(infodir)/$(MANUAL_SYSINFO)* - -$(INSTALLDOC).html: $(INSTALLDOC).texi $(CSS) - $(MAKEINFO) -o $@ --no-split --html --css-include=$(CSS) $< + $(INSTALL) $< $(infodir)/ + $(INSTALL-INFO) $(infodir)/$< $(infodir)/dir + $(GZIP) -f $(infodir)/$< -../INSTALL: $(INSTALLDOC).txt - $(CP) $< $@ +uninstall-info: + $(INSTALL-INFO) --delete $(infodir)/yacasl2.info $(infodir)/dir + $(RM) $(infodir)/yacasl2.info clean: clean-textmp - @$(RMRF) *_html *.info *.html *.pdf *.dvi *.txt + @$(RMR) *_html *.info *.html *.pdf *.dvi *.txt clean-textmp: - @$(RMF) *.aux *.cp *.cps *.fn *.ky *.log *.pg *.pgs *.tmp *.toc *.tp *.vr + @$(RM) *.aux *.cp *.cps *.fn *.ky *.log *.pg *.pgs *.tmp *.toc *.tp *.vr diff --git a/src/Makefile b/src/Makefile index 1da58bf..7b7f1f5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,58 +1,62 @@ -CC ?= gcc -CFLAGS ?= -g -Wall -Wextra -I $(INCLUDE) -RMF ?= rm -f -WHICH ?= which -CTAGS ?= ctags -ETAGS ?= etags -SED ?= sed +INCLUDEDIR := ../include +INCLUDE = -I $(INCLUDEDIR) -INCLUDE := ../include +# コマンド +CC := gcc +CFLAGS := -g -Wall -Wextra $(INCLUDE) +CTAGS := ctags +ETAGS := etags +SED := sed +WHICH := which -COMMONSRC := word.c cmem.c cerr.c -CASL2SRC := struct.c hash.c -ASSRC := assemble.c token.c label.c -EXECSRC := exec.c dump.c +# ソースの分類 +CMDOBJ := casl2 comet2 dumpword +COMMONOBJ := word cmem cerr +CASL2OBJ := struct hash +ASOBJ := assemble token label +EXECOBJ := exec dump -.PHONY: all version clean +.PHONY: all build tag clean -all: version ../casl2 ../comet2 ../dumpword ctags etags +all: build tag -version: - $(MAKE) -C .. version +# ヘッダファイルの依存関係を.dファイルに出力する +%.d: %.c + @($(CC) -MM -I $(INCLUDEDIR) $< | $(SED) 's/\($*\.o\):/\1 $@:/g' >$@ && echo '$@ is created from $<') -../casl2: casl2.o $(subst .c,.o,$(COMMONSRC) $(CASL2SRC) $(ASSRC) $(EXECSRC)) - $(CC) $(CFLAGS) -o $@ $^ - @$(RMF) *.d +# .dファイルからヘッダファイルの依存関係を取得する +# ターゲットに clean が含まれている場合は除く +ifneq ($(findstring $(MAKECMDGOALS),clean),clean) + -include $(addsuffix .d,$(CMDOBJ) $(COMMONOBJ) $(CASL2OBJ) $(ASOBJ) $(EXECOBJ)) +endif -../comet2: comet2.o $(subst .c,.o,$(COMMONSRC) $(CASL2SRC) $(EXECSRC)) - $(CC) $(CFLAGS) -o $@ $^ - @$(RMF) *.d +# casl2、comet2、dumpwordのビルド +build: $(CMDOBJ) -../dumpword: dumpword.o $(subst .c,.o,$(COMMONSRC)) - $(CC) $(CFLAGS) -o $@ $^ - @$(RMF) *.d +casl2: casl2.o $(addsuffix .o,$(COMMONOBJ) $(CASL2OBJ) $(ASOBJ) $(EXECOBJ)) -%.o: %.c - $(CC) -c $(CFLAGS) $< +comet2: comet2.o $(addsuffix .o,$(COMMONOBJ) $(CASL2OBJ) $(EXECOBJ)) -%.d: %.c - @$(CC) -MM -I $(INCLUDE) $< | $(SED) 's/\($*\.o\):/\1 $@:/g' >$@ +dumpword: dumpword.o $(addsuffix .o,$(COMMONOBJ)) --include $(subst .c,.d,casl2.c comet2.c dumpword.c $(COMMONSRC) $(CASL2SRC) $(ASSRC) $(EXECSRC)) +# tagファイル作成 - ctags & etags +# コマンドがない場合はなにもしない +tag: tags TAGS -ctags: $(INCLUDE)/*.h *.c - @$(WHICH) $(CTAGS) >/dev/null && $(CTAGS) $^ +tags: $(INCLUDEDIR)/*.h *.c + $(if $(strip $(shell $(WHICH) $(CTAGS))),$(CTAGS) $^,@$(ECHO) '$(CTAGS): not found') -etags: $(INCLUDE)/*.h *.c - @$(WHICH) $(ETAGS) >/dev/null && $(ETAGS) $^ +TAGS: $(INCLUDEDIR)/*.h *.c + $(if $(strip $(shell $(WHICH) $(ETAGS))),$(ETAGS) $^,@$(ECHO) '$(ETAGS): not found') -clean: clean_cmd clean_build clean_tags +# makeで生成したファイルの削除 +clean: clean-cmd clean-work clean-tag -clean_cmd: - @$(RMF) ../casl2 ../comet2 ../dumpword +clean-cmd: + @$(RM) casl2 comet2 dumpword -clean_build: - @$(RMF) *.o *.d +clean-work: + @$(RM) *.o *.d -clean_tags: - @$(RMF) TAGS tags +clean-tag: + @$(RM) TAGS tags