X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2FMakefile;h=afb82a661bcc34367fe6933318281ec673a4741f;hp=187a690a55291b513c797d799d9b2886238f1e19;hb=8b76a2371ab7fc325f11b9164a73e899f98072f0;hpb=d1f82970bf7d41db2fea11b08cd8e308f6cb8138 diff --git a/src/Makefile b/src/Makefile index 187a690..afb82a6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,35 +1,55 @@ -INCLUDE = ../include -CC = gcc -CFLAGS = -g -Wall -I $(INCLUDE) +CC ?= gcc +CFLAGS ?= -g -Wall -Wextra -I $(INCLUDE) +RMF ?= rm -f +WHICH ?= which +CTAGS ?= ctags +ETAGS ?= etags +SED ?= sed -COMMONSRC = word.c cmem.c cerr.c -CASL2SRC = struct.c cmd.c hash.c -ASSRC = assemble.c token.c label.c -EXECSRC = exec.c dump.c +INCLUDE := ../include + +COMMONSRC := word.c cmem.c cerr.c +CASL2SRC := struct.c hash.c +ASSRC := assemble.c token.c label.c +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 $@ $^ + @$(RMF) *.d ../comet2: comet2.o $(subst .c,.o,$(COMMONSRC) $(CASL2SRC) $(EXECSRC)) $(CC) $(CFLAGS) -o $@ $^ + @$(RMF) *.d ../dumpword: dumpword.o $(subst .c,.o,$(COMMONSRC)) $(CC) $(CFLAGS) -o $@ $^ + @$(RMF) *.d %.o: %.c $(CC) -c $(CFLAGS) $< %.d: %.c - @$(CC) -MM -I $(INCLUDE) $< | sed 's/\($*\.o\):/\1 $@:/g' >$@ + @$(CC) -MM -I $(INCLUDE) $< | $(SED) 's/\($*\.o\):/\1 $@:/g' >$@ -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) >/dev/null && $(CTAGS) $^ + +etags: $(INCLUDE)/*.h *.c + @$(WHICH) $(ETAGS) >/dev/null && $(ETAGS) $^ + +clean: clean_cmd clean_build clean_tags + +clean_cmd: + @$(RMF) ../casl2 ../comet2 ../dumpword + +clean_build: + @$(RMF) *.o *.d -clean: - @rm -f ../casl2 ../comet2 ../dumpword *.o *.d +clean_tags: + @$(RMF) TAGS tags