summaryrefslogtreecommitdiff
path: root/vendor/tree-sitter-odin/Makefile
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-22 12:23:25 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-22 12:23:25 +0100
commit59b30c1305ff6bcb63c673898893edcda19e27e4 (patch)
treeb02b357f3f7a70f916284663ae94f57d64ac1d92 /vendor/tree-sitter-odin/Makefile
parent8375f459638f942d51948d466d9365eaa0c2a500 (diff)
downloadcrep-59b30c1305ff6bcb63c673898893edcda19e27e4.tar.gz
Add Odin grammar
Diffstat (limited to 'vendor/tree-sitter-odin/Makefile')
-rw-r--r--vendor/tree-sitter-odin/Makefile109
1 files changed, 109 insertions, 0 deletions
diff --git a/vendor/tree-sitter-odin/Makefile b/vendor/tree-sitter-odin/Makefile
new file mode 100644
index 0000000..c32b41a
--- /dev/null
+++ b/vendor/tree-sitter-odin/Makefile
@@ -0,0 +1,109 @@
1VERSION := 0.19.0
2
3# Repository
4SRC_DIR := src
5
6PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin )
7PARSER_NAME := odin
8
9ifeq (, $(PARSER_URL))
10 PARSER_URL := $(subst :,/,$(PARSER_REPO_URL))
11 PARSER_URL := $(subst git@,https://,$(PARSER_URL))
12 PARSER_URL := $(subst .git,,$(PARSER_URL))
13endif
14
15UPPER_PARSER_NAME := $(shell echo $(PARSER_NAME) | tr a-z A-Z )
16
17# install directory layout
18PREFIX ?= /usr/local
19INCLUDEDIR ?= $(PREFIX)/include
20LIBDIR ?= $(PREFIX)/lib
21PCLIBDIR ?= $(LIBDIR)/pkgconfig
22
23# collect C++ sources, and link if necessary
24CPPSRC := $(wildcard $(SRC_DIR)/*.cc)
25
26ifeq (, $(CPPSRC))
27 ADDITIONALLIBS :=
28else
29 ADDITIONALLIBS := -lc++
30endif
31
32# collect sources
33SRC := $(wildcard $(SRC_DIR)/*.c)
34SRC += $(CPPSRC)
35OBJ := $(addsuffix .o,$(basename $(SRC)))
36
37# ABI versioning
38SONAME_MAJOR := 0
39SONAME_MINOR := 0
40
41CFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR)
42CXXFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR)
43override CFLAGS += -std=gnu99 -fPIC
44override CXXFLAGS += -fPIC
45
46# OS-specific bits
47ifeq ($(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
56else
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)
65endif
66ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
67 PCLIBDIR := $(PREFIX)/libdata/pkgconfig
68endif
69
70all: libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXTVER) bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc
71
72libtree-sitter-$(PARSER_NAME).a: $(OBJ)
73 $(AR) rcs $@ $^
74
75libtree-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
80bindings/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
85bindings/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
94install: 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
105clean:
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