screensaver/Makefile

84 lines
1.8 KiB
Makefile
Raw Normal View History

# Taken from: https://stackoverflow.com/questions/2214575/passing-arguments-to-make-run
# If the first argument is "new"...
ifeq (new,$(firstword $(MAKECMDGOALS)))
2021-01-26 15:39:04 +01:00
# use the rest as arguments for "new"
NEW_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(NEW_ARGS):;@:)
endif
2020-10-24 17:57:45 +02:00
BIN := $(shell basename $$(pwd))
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
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
LDLIBS := -lm -lscgui -lSDL2 -lcairo -lscerror -lscstring -lscscreensaver -ldl -lscnumerics
2020-10-24 17:57:45 +02: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
$(BIN): $(OBJS) $(DEPS)
$(CXX) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $(BIN)
%.o: %.cpp %.d Makefile
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
-include *.d
%.d: ;
new:
@./newmodule $(NEW_ARGS)
2020-10-27 15:27:46 +01:00
modules: $(PLUGINS)
mkdir -p plugins
@for plug in $(PLUGINS) ;\
do \
cd $$plug && $(MAKE) && $(MAKE) install ;\
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)
2021-02-07 17:05:19 +01:00
$(INSTALL) -m 444 $(MANPAGE) $(MANDIR)$(MANSECTION)
$(INSTALL) -d $(DATADIR)/$(BIN)/plugins
$(INSTALL) -m 444 plugins/* $(DATADIR)/$(BIN)/plugins/