Browse Source

Fix makefile and gitignore.

Stefano Cossu 2 years ago
parent
commit
f817cc648e
2 changed files with 22 additions and 17 deletions
  1. 3 3
      .gitignore
  2. 19 14
      Makefile

+ 3 - 3
.gitignore

@@ -110,9 +110,9 @@ sandbox/
 
 # Lexer and parser artifacts.
 
-src/codec/*_grammar.c
-src/codec/*_grammar.h
-src/codec/*_parser.c
+src/codec/grammar_*.c
+src/codec/grammar_*.h
+src/codec/parser_*.c
 
 # IDE
 .syntastic*

+ 19 - 14
Makefile

@@ -29,10 +29,13 @@ DBG_CFLAGS = -Itest -O0 -g3 -DDEBUG
 LDFLAGS = -L. -L$(libdir) -llmdb -lxxhash -luuid
 
 CODEC_DIR = src/codec
-CODEC_SRC = $(wildcard src/codec/grammar_*.c) \
-	  		$(wildcard src/codec/parser_*.c)
+CODEC_SRC = $(wildcard src/codec_*.c)
 CODEC_OBJ = $(CODEC_SRC:.c=.o)
 CODEC_DBG_OBJ = $(CODEC_SRC:.c=_dbg.o)
+PARSER_SRC = $(CODEC_SRC:src/codec_%=src/codec/parser_%)
+PARSER_OBJ = $(PARSER_SRC:.c=.o)
+
+
 
 # External sources compiled in core object.
 EXT_SRC = $(wildcard ext/log/src/*.c) \
@@ -48,9 +51,9 @@ LSUP_SRC = $(wildcard src/*.c)
 SRC = $(EXT_SRC) $(LSUP_SRC)
 TEST_SRC = $(wildcard test/*.c) test.c
 
-EXT_OBJ = $(EXT_SRC:.c=.o) 
-OBJ = $(EXT_OBJ) $(CODEC_OBJ) $(LSUP_SRC:.c=.o)
-DBG_OBJ = $(EXT_OBJ) $(CODEC_DBG_OBJ) $(LSUP_SRC:.c=_dbg.o)
+EXT_OBJ = $(EXT_SRC:.c=.o)
+OBJ = $(EXT_OBJ) $(PARSER_OBJ) $(CODEC_OBJ) $(LSUP_SRC:.c=.o)
+DBG_OBJ = $(EXT_OBJ) $(PARSER_OBJ) $(CODEC_DBG_OBJ) $(LSUP_SRC:.c=_dbg.o)
 
 DEPLIBS = libxxhash liblmdb
 LIBS = liblsuprdf.a liblsuprdf.so
@@ -71,7 +74,7 @@ export LD_LIBRARY_PATH = .:$(libdir)
 
 .DEFAULT_GOAL := lib
 
-# Extract all rule comment into a help message.
+# Extract all rule comments into a help message.
 .PHONY: help
 help:
 	@echo "Command overview:"; echo; \
@@ -111,18 +114,18 @@ liblsuprdf_dbg.so: $(DBG_OBJ)
 	$(CC) $(CFLAGS) $(DBG_CFLAGS) $(LDFLAGS) -c $^ -o $@
 
 
-# Codecs.
-$(CODEC_OBJ): $(CODEC_SRC)
-
+.PHONY: parsers
+parsers: $(PARSER_SRC) ## Make intermediate parser sources for development.
 
+# Codecs.
 # Parser C sources.
-parser_%.c: lexer_%.re grammar_%.c
+$(CODEC_DIR)/parser_%.c: $(CODEC_DIR)/lexer_%.re $(CODEC_DIR)/grammar_%.c $(CODEC_DIR)/grammar_%.h
 	$(LEXER) $< -o $@ -T --case-ranges
 
 
 # Parser generators.
-grammar_%.c: grammar_%.y
-	$(PARSER) $< -q -m -T$(CODEC_DIR)/lempar.c -d$(CODEC_DIR)
+$(CODEC_DIR)/grammar_%.c $(CODEC_DIR)/grammar_%.h: $(CODEC_DIR)/grammar_%.y
+	$(PARSER) $< -q -T$(CODEC_DIR)/lempar.c -d$(CODEC_DIR)
 
 
 # Ext libraries.
@@ -154,11 +157,13 @@ debug_install: install debug ## Install standard and debug libraries.
 
 .PHONY: clean ## Clean up artifacts.
 clean:
-	rm -rf src/*.[aod] ./*[aod] src/codec/*[aod]
+	rm -f src/*.[aod] ./*[aod] src/codec/*[aod]
 
 
-.PHONY: deepclean ## Clean up artifacts in external libraries as well.
+.PHONY: deepclean ## Clean up external libraries and language parsers as well.
 deepclean: clean
+	rm -f src/codec/grammar_*.{c,h}
+	rm -f src/codec/parser_*.c
 	cd $(MDB_DIR); make clean
 	cd $(XXHASH_DIR); make clean