examples/Makefile
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 27 Sep 2015 07:07:46 +0100
changeset 19 7597503194b8
permissions -rw-r--r--
First shot of libt and some examples libt serves (well, might serve at some point) as a basic library for Tea language. Added directory with examples demostration Tea (and libt) Both includes makefiles to compile libt and examples to compile them down to machine code. This also demonstrates how to use `teak`, a standalone Tea compiler.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
# Sources 
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
SOURCES = $(wildcard *.tea)
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
OBJECTS = $(patsubst %.tea,%.o,$(SOURCES))
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
LIBT = ../libt/libt.bc
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
# Tools
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
AR=ar
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
LD=ld
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
CC=gcc
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
TEAK = ../compiler/cli/teak
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
LLVM_CONFIG ?= llvm-config-3.8
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
LLVM_BINDIR  = $(shell $(LLVM_CONFIG) --bindir)
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
LLVM_LLC  = $(LLVM_BINDIR)/llc
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
LLVM_LINK = $(LLVM_BINDIR)/llvm-link
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
LLVM_OPT  = $(LLVM_BINDIR)/opt
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
# Flags
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
LLVM_OPT_FLAGS = -O2
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
all: $(OBJECTS)
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
# ----------vvvvvvvvvv should be replace by real dependendies of .tea file
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
%.bc: %.tea
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	$(TEAK) $(SOURCES)
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
%.all.bc: %.bc
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
	$(LLVM_LINK) -o=$@ $< $(LIBT)
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
%.opt.bc: %.all.bc	
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
	$(LLVM_OPT) $(LLVM_OPT_FLAGS) -o=$@ $<	
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
%.o: %.opt.bc
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
	$(LLVM_LLC) -filetype=obj -o=$@ $<
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
        
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
clean:
7597503194b8 First shot of libt and some examples
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
	rm -f *.bc *.o