diff options
Diffstat (limited to 'vendor/tree-sitter-cuda/Makefile')
| -rw-r--r-- | vendor/tree-sitter-cuda/Makefile | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/vendor/tree-sitter-cuda/Makefile b/vendor/tree-sitter-cuda/Makefile new file mode 100644 index 0000000..61edcb8 --- /dev/null +++ b/vendor/tree-sitter-cuda/Makefile | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | VERSION := 0.19.0 | ||
| 2 | |||
| 3 | # Repository | ||
| 4 | SRC_DIR := src | ||
| 5 | |||
| 6 | PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin ) | ||
| 7 | PARSER_NAME := cuda | ||
| 8 | |||
| 9 | ifeq (, $(PARSER_URL)) | ||
| 10 | PARSER_URL := $(subst :,/,$(PARSER_REPO_URL)) | ||
| 11 | PARSER_URL := $(subst git@,https://,$(PARSER_URL)) | ||
| 12 | PARSER_URL := $(subst .git,,$(PARSER_URL)) | ||
| 13 | endif | ||
| 14 | |||
| 15 | UPPER_PARSER_NAME := $(shell echo $(PARSER_NAME) | tr a-z A-Z ) | ||
| 16 | |||
| 17 | # install directory layout | ||
| 18 | PREFIX ?= /usr/local | ||
| 19 | INCLUDEDIR ?= $(PREFIX)/include | ||
| 20 | LIBDIR ?= $(PREFIX)/lib | ||
| 21 | PCLIBDIR ?= $(LIBDIR)/pkgconfig | ||
| 22 | |||
| 23 | # collect C++ sources, and link if necessary | ||
| 24 | CPPSRC := $(wildcard $(SRC_DIR)/*.cc) | ||
| 25 | |||
| 26 | ifeq (, $(CPPSRC)) | ||
| 27 | ADDITIONALLIBS := | ||
| 28 | else | ||
| 29 | ADDITIONALLIBS := -lc++ | ||
| 30 | endif | ||
| 31 | |||
| 32 | # collect sources | ||
| 33 | SRC := $(wildcard $(SRC_DIR)/*.c) | ||
| 34 | SRC += $(CPPSRC) | ||
| 35 | OBJ := $(addsuffix .o,$(basename $(SRC))) | ||
| 36 | |||
| 37 | # ABI versioning | ||
| 38 | SONAME_MAJOR := 0 | ||
| 39 | SONAME_MINOR := 0 | ||
| 40 | |||
| 41 | CFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR) | ||
| 42 | CXXFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR) | ||
| 43 | override CFLAGS += -std=c11 -fPIC | ||
| 44 | override CXXFLAGS += -fPIC | ||
| 45 | |||
| 46 | # OS-specific bits | ||
| 47 | ifeq ($(shell uname),Darwin) | ||
| 48 | SOEXT = dylib | ||
| 49 | SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib | ||
| 50 | SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib | ||
| 51 | LINKSHARED := $(LINKSHARED)-dynamiclib -Wl, | ||
| 52 | ifneq ($(ADDITIONALLIBS),) | ||
| 53 | LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS), | ||
| 54 | endif | ||
| 55 | LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/libtree-sitter-$(PARSER_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks | ||
| 56 | else | ||
| 57 | SOEXT = so | ||
| 58 | SOEXTVER_MAJOR = so.$(SONAME_MAJOR) | ||
| 59 | SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR) | ||
| 60 | LINKSHARED := $(LINKSHARED)-shared -Wl, | ||
| 61 | ifneq ($(ADDITIONALLIBS),) | ||
| 62 | LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS), | ||
| 63 | endif | ||
| 64 | LINKSHARED := $(LINKSHARED)-soname,libtree-sitter-$(PARSER_NAME).so.$(SONAME_MAJOR) | ||
| 65 | endif | ||
| 66 | ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly)) | ||
| 67 | PCLIBDIR := $(PREFIX)/libdata/pkgconfig | ||
| 68 | endif | ||
| 69 | |||
| 70 | all: libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXTVER) bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc | ||
| 71 | |||
| 72 | libtree-sitter-$(PARSER_NAME).a: $(OBJ) | ||
| 73 | $(AR) rcs $@ $^ | ||
| 74 | |||
| 75 | libtree-sitter-$(PARSER_NAME).$(SOEXTVER): $(OBJ) | ||
| 76 | $(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@ | ||
| 77 | ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXT) | ||
| 78 | ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) | ||
| 79 | |||
| 80 | bindings/c/$(PARSER_NAME).h: | ||
| 81 | sed -e 's|@UPPER_PARSERNAME@|$(UPPER_PARSER_NAME)|' \ | ||
| 82 | -e 's|@PARSERNAME@|$(PARSER_NAME)|' \ | ||
| 83 | bindings/c/tree-sitter.h.in > $@ | ||
| 84 | |||
| 85 | bindings/c/tree-sitter-$(PARSER_NAME).pc: | ||
| 86 | sed -e 's|@LIBDIR@|$(LIBDIR)|;s|@INCLUDEDIR@|$(INCLUDEDIR)|;s|@VERSION@|$(VERSION)|' \ | ||
| 87 | -e 's|=$(PREFIX)|=$${prefix}|' \ | ||
| 88 | -e 's|@PREFIX@|$(PREFIX)|' \ | ||
| 89 | -e 's|@ADDITIONALLIBS@|$(ADDITIONALLIBS)|' \ | ||
| 90 | -e 's|@PARSERNAME@|$(PARSER_NAME)|' \ | ||
| 91 | -e 's|@PARSERURL@|$(PARSER_URL)|' \ | ||
| 92 | bindings/c/tree-sitter.pc.in > $@ | ||
| 93 | |||
| 94 | install: all | ||
| 95 | install -d '$(DESTDIR)$(LIBDIR)' | ||
| 96 | install -m755 libtree-sitter-$(PARSER_NAME).a '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).a | ||
| 97 | install -m755 libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER) | ||
| 98 | ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) | ||
| 99 | ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXT) | ||
| 100 | install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter | ||
| 101 | install -m644 bindings/c/$(PARSER_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/ | ||
| 102 | install -d '$(DESTDIR)$(PCLIBDIR)' | ||
| 103 | install -m644 bindings/c/tree-sitter-$(PARSER_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/ | ||
| 104 | |||
| 105 | clean: | ||
| 106 | rm -f $(OBJ) libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXT) libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) libtree-sitter-$(PARSER_NAME).$(SOEXTVER) | ||
| 107 | rm -f bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc | ||
| 108 | |||
| 109 | .PHONY: all install clean | ||
