all:clang.lisp

SWIG=/data/languages/swig/bin/swig
INCLUDES=-I/usr/include
DEFINES=-DCINDEX_LINKAGE= -DCINDEX_DEPRECATED=
SWIG_OPTIONS=-cffi -swig-lisp -generate-typedef

clang-raw.lisp:clang.i Makefile
	$(SWIG) $(SWIG_OPTIONS) $(INCLUDES) $(DEFINES) clang.i
	sed \
		-e 's/(cl:defconstant CINDEX_VERSION .*)/(cl:defconstant CINDEX_VERSION (cl:+ (cl:* CINDEX_VERSION_MAJOR 10000) (cl:* CINDEX_VERSION_MINOR 1)))/' \
		-e 's/#\.(cl:logior CXGlobalOpt_ThreadBackgroundPriorityForIndexing CXGlobalOpt_ThreadBackgroundPriorityForEditing)/3/' \
		-e 's/#\.CXTUResourceUsage_AST/1/' \
		-e 's/#\.CXTUResourceUsage_Preprocessor_HeaderSearch/14/' \
		-e 's/#\.CXCursor_UnexposedDecl/1/' \
		-e 's/#\.CXCursor_CXXAccessSpecifier/39/' \
		-e 's/#\.CXCursor_VariableRef/50/' \
		-e 's/#\.CXCursor_InvalidCode/73/' \
		-e 's/#\.CXCursor_ObjCBoolLiteralExpr/145/' \
		-e 's/#\.CXCursor_GCCAsmStmt/215/' \
		-e 's/#\.CXCursor_DeclStmt/231/' \
		-e 's/#\.CXCursor_AsmLabelAttr/407/' \
		-e 's/#\.CXCursor_MacroExpansion/502/' \
		-e 's/#\.CXCursor_PreprocessingDirective/500/' \
		-e 's/#\.CXCursor_InclusionDirective/503/' \
		-e 's/#\.CXCursor_ModuleImportDecl/600/' \
		-e 's/#\.CXType_Void/2/' \
		-e 's/#\.CXType_ObjCSel/29/' \
	< clang.lisp > clang-raw.lisp
	rm clang.lisp

clang.lisp:clang-raw.lisp Makefile lispify-clang
	./lispify-clang < clang-raw.lisp > clang.lisp

clean:
	- rm -f clang-raw.lisp


CC=/opt/llvm/bin/clang
ast:ast.c Makefile
	$(CC) -I. -L. -g3 -ggdb3 -o ast ast.c

test-ast:ast
	./ast example.c

#### THE END ####
ViewGit