54 lines
1.0 KiB
Makefile
Raw Normal View History

include premake.make
# some important install locations
PREFIX ?= /usr/local
DATADIR ?= $(PREFIX)/share
INSTALLDIR ?= $(DATADIR)/$(INSTALLDIRNAME)
SRCS := $(wildcard *.cpp)
OBJS := $(SRCS:.cpp=.o)
DEPS := $(SRCS:.cpp=.dep)
CXX ?= g++
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -Wno-unused-parameter
CXXFLAGS += -g3 -std=c++20 -fPIC
ifeq ($(DEBUG),1)
CXXFLAGS += -D DEBUG -O0
else
CXXFLAGS += -D NDEBUG -O3
endif
%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ -MMD -MP -MT $@ -MF $*.dep -c $<
%.dep: ;
.PHONY: all clean install uninstall
all: $(PLUGIN)
$(PLUGIN): $(OBJS)
ifeq ($(UNAME_S),Darwin)
$(CXX) -g3 -dynamiclib -o $(PLUGIN) $(LDFLAGS) $(OBJS) $(LDLIBS)
else
$(CXX) -g3 -shared -o $(PLUGIN) $(LDFLAGS) $(OBJS) $(LDLIBS)
endif
-include $(DEPS)
clean:
rm -f $(OBJS) $(DEPS) $(PLUGIN)
$(INSTALLDIR):
install -m 0755 -d $@
install: $(INSTALLDIR)
install -m 0644 $(PLUGIN) $(INSTALLDIR)
ifdef EXTRAFILES
install -m 0644 $(EXTRAFILES) $(INSTALLDIR)
endif
uninstall:
rm -f $(INSTALLDIR)/$(PLUGIN) $(addprefix $(INSTALLDIR)/, $(EXTRAFILES))