resources/examples/llvm-c-ext/Makefile
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 12 Aug 2015 07:32:13 +0100
changeset 43 9327987437ae
child 47 35c51ba4e4a7
permissions -rw-r--r--
Added mappings for LLVM C and LLVM C Extensions These are used to generate C callouts for jv:llvm_s project.

CC=gccxml
CFLAGS=-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
XSLTPROC=xsltproc
XML2DEF_XSL=../../styles/gccxml2def.xsl




INCLUDE_DIR=../../../../llvm_s/llvm_c_ext/include
INCLUDES=-I$(shell llvm-config-3.8 --includedir) -I$(INCLUDE_DIR)
HEADERS=CoreExt.h Intrinsics.h DIBuilder.h
DEFFILES=$(HEADERS:%.h=%.h.def)
DEFFILE=llvm-c-ext.def
XMLFILES=$(HEADERS:%.h=%.h.xml)

XSL_PARAMS=--stringparam c-header-file $(INCLUDE_DIR)/llvm-c-ext/$(<:%.h.xml=%.h)

XSLTPROC_FLAGS=$(XSL_PARAMS)

default: all

all: $(DEFFILE)

xml: $(XMLFILES)


$(DEFFILE): $(DEFFILES)
	cat $(DEFFILES) > $(DEFFILE)
#	sed -i -e 's/^(struct-foreign LLVM/(struct LLVM/g' $(DEFFILE)
#	sed -i -e 's/^(typedef-foreign LLVM/(typedef LLVM/g' $(DEFFILE)
#	sed -i -e 's/^(enum-foreign LLVM/(enum LLVM/g' $(DEFFILE)


%.h.def:%.h.xml
	$(XSLTPROC) $(XSLTPROC_FLAGS) -o $@ $(XML2DEF_XSL) $<

%.h.xml: $(INCLUDE_DIR)/llvm-c-ext/%.h
	$(CC) -m64 $(CFLAGS) $(INCLUDES) $< -fxml=$@

clean:
	rm -rf *.h.def *.h.xml

distclean: clean
	rm -rf $(DEFFILE)