Source

SmallCC / src / Makefile

Full commit
TARGET			=	../scc

LEX					= ocamllex
YACC				= ocamlyacc
OCAML				=	ocamlopt

CFLAGS			=
LDFLAGS			= -ccopt -L. unix.cmxa

SRCSLEX			=	lexer.mll
SRCSYACC		=	parser.mly

SRCS				= $(SRCSLEX:.mll=.ml) $(SRCSYACC:.mly=.ml)
SRCS				+= option.ml main.ml

OBJS				= $(SRCS:.ml=.cmx)

FILES				= ast.cmi $(SRCSLEX:.mll=.ml) $(SRCSYACC:.mly=.ml) $(OBJS)

ifeq ($(V), 1)
		MAKEFLAGS	=
		echo			=
else
		MAKEFLAGS	= --silent --no-print-directory
		echo			=	echo -e $(1)
endif

all: $(TARGET)

$(TARGET): $(FILES)
	$(call echo, "LD\t$@")
	$(OCAML) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@

%.cmi: %.mli
	$(call echo, "OCAML\t$@")
	$(OCAML) $(CFLAGS) -c $< -o $@

%.cmx: %.ml
	$(call echo, "OCAML\t$@")
	$(OCAML) $(CFLAGS) -c $< -o $@

%.ml: %.mly
	$(call echo, "YACC\t$@")
	$(YACC) $<
	$(OCAML) $(CFLAGS) -c $@i

%.ml: %.mll
	$(call echo, "LEX\t$@")
	$(LEX) $<

clean:
	$(call echo, "RM\t$(FILES) parser.mli")
	rm -rf $(FILES) parser.mli *.o *.cmi

distclean: clean
	$(call echo, "RM\t$(TARGET)")
	rm -rf $(TARGET)