2012-03-18 18:24:12 +02:00
|
|
|
#
|
|
|
|
# Makefile - BOOM's Makefile
|
|
|
|
#
|
|
|
|
# Copyright 2012 by Werner Almesberger
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
2012-04-20 02:06:02 +03:00
|
|
|
SHELL = /bin/bash
|
|
|
|
|
2012-05-24 01:33:10 +03:00
|
|
|
CFLAGS = -g \
|
|
|
|
-Wall -Wextra -Wshadow -Wmissing-prototypes -Wmissing-declarations \
|
|
|
|
$(shell pkg-config --cflags glib-2.0)
|
2012-03-18 18:24:12 +02:00
|
|
|
SLOPPY = -Wno-unused -Wno-implicit-function-declaration
|
2012-05-23 22:05:24 +03:00
|
|
|
OBJS = bom.o boom.o chr.o comp.o db.o dump.o eval.o param.o relop.o \
|
2012-05-21 05:04:41 +03:00
|
|
|
subex.o subst.o util.o \
|
2012-05-21 02:53:34 +03:00
|
|
|
vstring.o lex.yy.o y.tab.o
|
2012-03-18 18:24:12 +02:00
|
|
|
LDLIBS = -lfl $(shell pkg-config --libs glib-2.0)
|
|
|
|
|
|
|
|
YACC = bison -y
|
|
|
|
YYFLAGS = -v
|
|
|
|
|
|
|
|
CC_normal := $(CC)
|
|
|
|
YACC_normal := $(YACC)
|
|
|
|
LEX_normal := $(LEX)
|
|
|
|
DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
|
|
|
|
|
|
|
|
CC_quiet = @echo " CC " $@ && $(CC_normal)
|
|
|
|
YACC_quiet = @echo " YACC " $@ && $(YACC_normal)
|
|
|
|
LEX_quiet = @echo " LEX " $@ && $(LEX_normal)
|
|
|
|
GEN_quiet = @echo " GENERATE " $@ &&
|
|
|
|
DEPEND_quiet = @$(DEPEND_normal)
|
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
CC = $(CC_normal)
|
|
|
|
LEX = $(LEX_normal)
|
|
|
|
YACC = $(YACC_normal)
|
|
|
|
GEN =
|
|
|
|
DEPEND = $(DEPEND_normal)
|
|
|
|
else
|
|
|
|
CC = $(CC_quiet)
|
|
|
|
LEX = $(LEX_quiet)
|
|
|
|
YACC = $(YACC_quiet)
|
|
|
|
GEN = $(GEN_quiet)
|
|
|
|
DEPEND = $(DEPEND_quiet)
|
|
|
|
endif
|
|
|
|
|
2012-05-22 22:09:22 +03:00
|
|
|
MKDEP = $(DEPEND) $(1).c | \
|
|
|
|
sed -e \
|
|
|
|
'/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
|
|
|
|
-e '$${g;p;}' -e d >$(1).d; \
|
|
|
|
[ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $(1).d; exit 1; }
|
|
|
|
|
2012-04-29 04:52:09 +03:00
|
|
|
.PHONY: all clean spotless try
|
2012-03-18 18:24:12 +02:00
|
|
|
|
|
|
|
all: boom
|
|
|
|
|
|
|
|
boom: $(OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
|
|
|
|
|
|
|
lex.yy.c: lang.l y.tab.h
|
|
|
|
$(LEX) lang.l
|
|
|
|
|
|
|
|
lex.yy.o: lex.yy.c y.tab.h
|
|
|
|
$(CC) -c $(CFLAGS) $(SLOPPY) lex.yy.c
|
2012-05-22 22:09:22 +03:00
|
|
|
$(call MKDEP, lex.yy)
|
2012-03-18 18:24:12 +02:00
|
|
|
|
|
|
|
y.tab.c y.tab.h: lang.y
|
|
|
|
$(YACC) $(YYFLAGS) -d lang.y
|
|
|
|
|
|
|
|
y.tab.o: y.tab.c
|
|
|
|
$(CC) -c $(CFLAGS) $(SLOPPY) y.tab.c
|
2012-05-22 22:09:22 +03:00
|
|
|
$(call MKDEP, y.tab)
|
2012-03-18 18:24:12 +02:00
|
|
|
|
2012-04-20 02:06:02 +03:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) -c $(CFLAGS) $*.c -o $*.o
|
2012-05-22 22:09:22 +03:00
|
|
|
$(call MKDEP, $*)
|
2012-04-20 02:06:02 +03:00
|
|
|
|
|
|
|
-include $(OBJS:.o=.d)
|
|
|
|
|
2012-03-18 18:24:12 +02:00
|
|
|
clean:
|
2012-04-20 02:06:02 +03:00
|
|
|
rm -f $(OBJS) $(OBJS:.o=.d)
|
2012-04-20 02:08:25 +03:00
|
|
|
rm -f lex.yy.c y.tab.c y.tab.h y.output
|
2012-04-20 02:09:18 +03:00
|
|
|
|
|
|
|
spotless: clean
|
|
|
|
rm -f boom
|
2012-04-29 04:52:09 +03:00
|
|
|
|
|
|
|
# ----- Experiments -----------------------------------------------------------
|
|
|
|
|
|
|
|
try:
|
2012-05-30 18:58:29 +03:00
|
|
|
$(VALGRIND) ./boom -v HIERARCHY -c CHAR -x CURR -p PROVIDER -i INV \
|
2012-05-20 17:18:18 +03:00
|
|
|
-s SUBST
|
2012-05-30 18:02:14 +03:00
|
|
|
|
|
|
|
# ----- Tests -----------------------------------------------------------------
|
|
|
|
|
|
|
|
test tests: all
|
2012-05-31 18:38:32 +03:00
|
|
|
LANG= bash -c \
|
2012-05-30 18:02:14 +03:00
|
|
|
'passed=0 && cd test && \
|
|
|
|
for n in [a-z]*; do \
|
|
|
|
[ $$n != core ] && SCRIPT=$$n . ./$$n; done; \
|
|
|
|
echo "Passed all $$passed tests"'
|
|
|
|
|
|
|
|
valgrind:
|
|
|
|
VALGRIND="valgrind -q" $(MAKE) tests
|