mkproj/tpl/Makefile.plugin

52 lines
1015 B
Makefile
Raw Normal View History

2024-12-23 16:18:39 +01:00
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 -fPIC
ifeq ($(DEBUG),1)
CXXFLAGS += -DDEBUG -O0
else
CXXFLAGS += -DNDEBUG -O3
endif
%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ -MMD -MP -MT $@ -MF $*.dep -c $<
%.dep: ;
.PHONY: clean install uninstall
$(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 $(EXTRAFILES) $(INSTALLDIR)
endif
uninstall:
rm -f $(INSTALLDIR)/$(PLUGIN) $(addprefix $(INSTALLDIR)/, $(EXTRAFILES))