Skip to content

Commit

Permalink
refactor(Makefile): organise Makefile better
Browse files Browse the repository at this point in the history
  • Loading branch information
xcb-xwii committed Apr 16, 2024
1 parent a852f26 commit 98672a5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ SRC := $(wildcard src/*.c) $(wildcard src/query/*.c) $(wildcard src/range/*.c)
SRC += tree-sitter/lib/src/lib.c
OBJ := $(SRC:.c=.o)

INC := -Iinclude -Itree-sitter/lib/include
LUA_INC :=
INC :=
LTS_INC := -Iinclude -Itree-sitter/lib/include
TS_INC := -Itree-sitter/lib/include -Itree-sitter/lib/src

CFLAGS := -O3 -Wall -Wextra -Werror -fPIC -fvisibility=hidden -flto=auto
LTS_CFLAGS := -std=c99 -pedantic
TS_CFLAGS := -std=gnu99
CFLAGS := -O3 -fPIC -flto=auto
LTS_CFLAGS := -std=c99 -pedantic -Wall -Wextra -Werror -fvisibility=hidden
TS_CFLAGS := -std=gnu99 -fvisibility=hidden

LIBS := -llua
POSIX_LIBS := -ldl
LDFLAGS :=
POSIX_LDFLAGS := -shared -ldl

lua_tree_sitter.so: $(OBJ)
$(CC) -shared -o $@ $^ $(CFLAGS) $(LIBS) $(POSIX_LIBS)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(POSIX_LDFLAGS)

lua_tree_sitter.dll: $(OBJ)
$(CC) -shared -o $@ $^ $(CFLAGS) $(LIBS)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)

%.o: %.c
$(CC) -c -o $@ $(CFLAGS) $(LTS_CFLAGS) $(LUA_INC) $(INC) $<
$(CC) -c -o $@ $(CFLAGS) $(LTS_CFLAGS) $(INC) $(LTS_INC) $<

tree-sitter/%.o: tree-sitter/%.c
$(CC) -c -o $@ $(CFLAGS) $(TS_CFLAGS) $(TS_INC) $<
Expand Down

0 comments on commit 98672a5

Please sign in to comment.