Skip to content

Commit

Permalink
allow debugging from luarocks build
Browse files Browse the repository at this point in the history
  • Loading branch information
jkl1337 committed Feb 27, 2024
1 parent dc36e71 commit 55a3aa1
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,54 @@ LUA_INCDIR := /usr/include

SRCDIR := .

SANITIZE_FLAGS := -fsanitize=undefined -fsanitize=address -fsanitize=alignment \
-fsanitize=shift -fsanitize=unreachable -fsanitize=bool -fsanitize=enum

ifdef FDEBUG
OPTFLAG := -O2
else
OPTFLAG := -Og -g
endif

COVERAGE_FLAGS := --coverage
LTO_FLAGS := -flto=auto

ifeq ($(OS),Windows_NT)
is_clang = $(filter %clang++,$(CXX))
is_gcc = $(filter %g++,$(CXX))

ifdef FSANITIZE
$(error "FSANITIZE is not supported on Windows")
endif
else
uname_s := $(shell uname -s)
ifeq ($(uname_s),Darwin)
is_clang = 1
is_gcc =

CC := env MACOSX_DEPLOYMENT_TARGET=11.0 gcc
CXX := env MACOSX_DEPLOYMENT_TARGET=11.0 g++
LIBFLAG := -bundle -undefined dynamic_lookup
is_clang = 1
is_gcc =

else
is_clang = $(filter %clang++,$(CXX))
is_gcc = $(filter %g++,$(CXX))

SANITIZE_FLAGS += -fsanitize=bounds-strict
endif
endif

OPTFLAG := -O2
SANITIZE_FLAGS := -fsanitize=undefined -fsanitize=address -fsanitize=alignment -fsanitize=bounds-strict \
-fsanitize=shift -fsanitize=unreachable -fsanitize=bool \
-fsanitize=enum

COVERAGE_FLAGS := --coverage
LTO_FLAGS := -flto=auto

-include config.mk

ifeq ($(origin LUAROCKS), command line)
ifdef FCOV
CCFLAGS := $(patsubst -O%,,$(CFLAGS))
else
CCFLAGS := $(CFLAGS)
ifdef FDEBUG
CCFLAGS := $(patsubst -O%,,$(CFLAGS)) -Og -g
else
CCFLAGS := $(CFLAGS)
endif
endif
override CFLAGS := -std=c99 $(CCFLAGS)

Expand Down Expand Up @@ -115,7 +131,7 @@ install:
$(CP) -f kiwi.lua $(INST_LUADIR)/kiwi.lua

mostlyclean:
$(RM) -f ljkiwi.$(LIB_EXT) $(objs)
$(RM) -f ljkiwi.$(LIB_EXT) $(objs) $(objs:.o=.gcda) $(objs:.o=.gcno)

clean: mostlyclean
$(RM) -f $(PCH)
Expand Down

0 comments on commit 55a3aa1

Please sign in to comment.