libt/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.

# Sources 
SOURCES = $(wildcard *.tea)
BITCODES = $(patsubst %.tea,%.bc,$(SOURCES))

# Tools
AR=ar
LD=ld
CC=gcc
TEAK = ../compiler/cli/teak
LLVM_CONFIG ?= llvm-config-3.8
LLVM_BINDIR  = $(shell $(LLVM_CONFIG) --bindir)
LLVM_LLC  = $(LLVM_BINDIR)/llc
LLVM_LINK  = $(LLVM_BINDIR)/llvm-link

# Artifacts...
LIBRARY_NAME=libt
LIBRARY = $(LIBRARY_NAME).so
ARCHIVE = $(LIBRARY_NAME).a



all: $(LIBRARY) $(ARCHIVE)	

$(LIBRARY): $(LIBRARY_NAME).o
	ld -shared -o $@ $<

$(ARCHIVE): $(LIBRARY_NAME).o	
	$(AR) r $@ $<

$(LIBRARY_NAME).o: $(LIBRARY_NAME).bc
	$(LLVM_LLC) -filetype=obj -o=$@ $<

$(LIBRARY_NAME).bc: $(BITCODES)
	$(LLVM_LINK) -o=$@ $(BITCODES)


# ----------vvvvvvvvvv should be replace by real dependendies of .tea file
%.bc: %.tea $(SOURCES)
	$(TEAK) $(SOURCES)

%.ll: %.tea $(SOURCES)
	$(TEAK) --output=$@ --emit-llvm-ir $<

        
clean:
	rm -f *.ll $(BITCODES) $(LIBRARY_NAME).o $(LIBRARY_NAME).bc $(LIBRARY) $(ARCHIVE)