2020-10-24 17:57:45 +02:00
|
|
|
BIN := $(shell basename $$(pwd))
|
2021-01-25 19:56:38 +01:00
|
|
|
PLUGINS := $(wildcard modules/*)
|
2020-10-27 17:18:33 +01:00
|
|
|
|
|
|
|
MAKE += --no-print-directory
|
2020-10-24 17:57:45 +02:00
|
|
|
|
|
|
|
MANSECTION := 1
|
|
|
|
MANPAGE := $(BIN).$(MANSECTION)
|
|
|
|
|
|
|
|
SRCS := $(wildcard *.cpp)
|
|
|
|
OBJS := $(subst .cpp,.o,$(SRCS))
|
|
|
|
DEPS := $(subst .cpp,.d,$(SRCS))
|
|
|
|
|
|
|
|
CXX ?= g++
|
|
|
|
PKG_CONFIG ?= pkg-config
|
|
|
|
|
|
|
|
PREFIX ?= /usr/local
|
|
|
|
BINDIR ?= $(PREFIX)/bin
|
|
|
|
CONFIGDIR ?= $(PREFIX)/etc
|
|
|
|
DATADIR ?= $(PREFIX)/share
|
|
|
|
MANDIR ?= $(DATADIR)/man/man
|
|
|
|
DOCDIR ?= $(DATADIR)/$(BIN)/doc
|
|
|
|
|
|
|
|
RM := /bin/rm -f
|
|
|
|
INSTALL := /usr/bin/install -c
|
|
|
|
|
2021-11-13 19:14:19 +01:00
|
|
|
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17
|
2020-10-24 17:57:45 +02:00
|
|
|
ifeq ($(DEBUG),1)
|
|
|
|
CXXFLAGS += -D DEBUG -O0
|
|
|
|
else
|
|
|
|
CXXFLAGS += -D NDEBUG -O3
|
|
|
|
endif
|
|
|
|
|
2023-02-13 11:31:54 +01:00
|
|
|
LDLIBS := -lm -lscgui -lcairo -lscerror -lscstring -lscscreensaver -lscnumerics
|
|
|
|
|
|
|
|
LDLIBS += $(shell pkg-config sdl2 --libs)
|
|
|
|
CXXFLAGS += $(shell pkg-config sdl2 --cflags)
|
|
|
|
|
2022-10-17 12:11:23 +02:00
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
LDLIBS += -ldl
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
LDLIBS += -ldl
|
|
|
|
endif
|
2020-10-24 17:57:45 +02:00
|
|
|
|
2021-01-26 15:36:22 +01:00
|
|
|
.PHONY: all clean install modules new
|
2020-10-24 17:57:45 +02:00
|
|
|
|
2020-10-27 17:18:33 +01:00
|
|
|
all: $(BIN) modules
|
2020-10-24 17:57:45 +02:00
|
|
|
|
2023-02-13 11:31:54 +01:00
|
|
|
$(BIN): $(OBJS)
|
2024-03-28 15:25:10 +01:00
|
|
|
$(CXX) $(OBJS) $(LDFLAGS) -o $(BIN) $(LDLIBS)
|
2020-10-24 17:57:45 +02:00
|
|
|
|
2023-02-13 11:31:54 +01:00
|
|
|
%.o %.d: %.cpp
|
2020-10-24 17:57:45 +02:00
|
|
|
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
|
|
|
|
2023-02-13 11:31:54 +01:00
|
|
|
-include $(DEPS)
|
2020-10-24 17:57:45 +02:00
|
|
|
|
2020-10-27 15:27:46 +01:00
|
|
|
modules: $(PLUGINS)
|
|
|
|
mkdir -p plugins
|
|
|
|
@for plug in $(PLUGINS) ;\
|
|
|
|
do \
|
|
|
|
cd $$plug && $(MAKE) && $(MAKE) install ;\
|
2021-01-25 19:56:38 +01:00
|
|
|
cd ../.. ;\
|
2020-10-27 15:27:46 +01:00
|
|
|
done
|
|
|
|
|
2020-10-24 17:57:45 +02:00
|
|
|
clean:
|
|
|
|
$(RM) $(OBJS) $(DEPS) $(BIN)
|
2020-10-27 15:27:46 +01:00
|
|
|
$(RM) -r plugins
|
|
|
|
@for plug in $(PLUGINS) ;\
|
|
|
|
do \
|
|
|
|
$(MAKE) -C $$plug clean ;\
|
|
|
|
done
|
2020-10-24 17:57:45 +02:00
|
|
|
|
|
|
|
install: $(BIN)
|
|
|
|
$(INSTALL) -d $(BINDIR)
|
|
|
|
$(INSTALL) $(BIN) $(BINDIR)
|
|
|
|
$(INSTALL) -d $(MANDIR)$(MANSECTION)
|
2024-09-02 15:15:31 +02:00
|
|
|
$(INSTALL) -m 644 $(MANPAGE) $(MANDIR)$(MANSECTION)
|
2021-02-07 17:05:19 +01:00
|
|
|
$(INSTALL) -d $(DATADIR)/$(BIN)/plugins
|
2024-09-02 15:15:31 +02:00
|
|
|
$(INSTALL) -m 644 plugins/* $(DATADIR)/$(BIN)/plugins/
|