ljclang

FORK: A LuaJIT-based interface to libclang
git clone https://git.neptards.moe/neptards/ljclang.git
Log | Files | Refs

Makefile (1764B)


      1 
      2 OS := $(shell uname -s)
      3 MINGW := $(findstring MINGW,$(OS))
      4 THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
      5 
      6 
      7 ########## PATHS ##########
      8 
      9 llvm_cflags = $(shell llvm-config --cflags --ldflags) -lclang
     10 ifeq ($(OS),Linux)
     11     llvm_cflags += -fPIC
     12     so := .so
     13 else
     14  ifeq ($(MINGW),MINGW)
     15     so := .dll
     16  else
     17     $(error unknown platform)
     18  endif
     19 endif
     20 
     21 luajit := luajit
     22 asciidoc := asciidoctor
     23 
     24 
     25 ########## OPTIONS ##########
     26 
     27 OPTLEV ?= 2
     28 DEBUG ?= 0
     29 SAN ?= 0
     30 WARN := -std=c99 -pedantic -Wall -Werror-implicit-function-declaration
     31 CFLAGS ?=
     32 CFLAGS += $(llvm_cflags)
     33 
     34 ifneq ($(SAN),0)
     35     CFLAGS += -fsanitize=address,undefined
     36 endif
     37 
     38 ifneq ($(DEBUG),0)
     39     CFLAGS += -g
     40 endif
     41 
     42 ########## RULES ##########
     43 
     44 libljclang_support$(so): ljclang_support.c Makefile
     45 	$(CC) $(CFLAGS) $(WARN) -O$(OPTLEV) -shared $< $(lib) -o $@
     46 
     47 
     48 .PHONY: clean bootstrap doc
     49 
     50 clean:
     51 	rm -f libljclang_support$(so)
     52 
     53 CKIND_LUA := ljclang_cursor_kind.lua
     54 EXTRACT_OPTS := -R -p '^CXCursor_' -x '_First' -x '_Last' -x '_GCCAsmStmt' -x '_MacroInstantiation' -s '^CXCursor_' \
     55     -1 'return { name={' -2 '}, }' -Q
     56 
     57 # Generate list of CXCursorKind names
     58 bootstrap:
     59 	@echo 'return {}' > $(CKIND_LUA)
     60 	LD_LIBRARY_PATH=$(THIS_DIR) $(luajit) ./extractdecls.lua $(EXTRACT_OPTS) $(incdir)/clang-c/Index.h > $(CKIND_LUA).tmp
     61 	@mv $(CKIND_LUA).tmp $(CKIND_LUA)
     62 	@printf "\033[1mGenerated $(CKIND_LUA)\033[0m\n"
     63 
     64 doc:
     65 	$(asciidoc) README.adoc
     66 
     67 # Usage example:
     68 # BINDIR=~/bin make install
     69 install:
     70 # XXX: MAKECMDGOALS is a list, i.e. will not be effective for e.g. "make install qwe"
     71 ifeq ($(MAKECMDGOALS),install)
     72 ifeq ($(BINDIR),)
     73     $(error "Must pass $$BINDIR with the environment")
     74 endif
     75 endif
     76 	sed "s|LJCLANG_DEV_DIR|$(THIS_DIR)|g" ./mgrep.sh.in > $(BINDIR)/mgrep
     77 	chmod +x $(BINDIR)/mgrep