Skip to content

Commit

Permalink
Attempt to compress/futureproof global Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 26, 2024
1 parent ee2118b commit 15d09b2
Showing 1 changed file with 37 additions and 73 deletions.
110 changes: 37 additions & 73 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,58 @@ PY?=python3
PROXY?=
BLUE=\033[0;34m
NC=\033[0m # No Color
SPHINX_BUILD_OPTIONS = html dirhtml singlehtml epub latex htmlhelp qthelp devhelp applehelp man texinfo text gettext doctest linkcheck xml pseudoxml
DIR_PREFIX_MAP = \
c_:c \
cp_:cplusplus \
cs_:csharp \
fr_:fortran \
ja_:java \
js_:javascript \
lu_:lua \
py_:python \
rs_:rust

.PHONY: help
help: LICENSE
@echo "This project has a number of recipes that are delegated to other Makefiles. The following jobs are available with no prefix"
@echo " $(BLUE)clean$(NC)"
@echo " $(BLUE)html$(NC)"
@echo " $(BLUE)dirhtml$(NC)"
@echo " $(BLUE)singlehtml$(NC)"
@echo " $(BLUE)epub$(NC)"
@echo " $(BLUE)latex$(NC)"
@echo " $(BLUE)clean$(NC) Cleans up any stray files"
@$(foreach option,$(SPHINX_BUILD_OPTIONS), \
echo " $(BLUE)$(option)$(NC) Forwarded to sphinx in the docs dir"; \
)
@echo "All other inputs are redirected to the all_ prefix, which will run it for each language. Note that this may error if the target is not found in all languages"
@echo
@echo "The following jobs are available under the docs_ prefix"
@$(MAKE) docs_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the c_ prefix"
@$(MAKE) c_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the cp_ prefix"
@$(MAKE) cp_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the cs_ prefix"
@$(MAKE) cs_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the fr_ prefix"
@$(MAKE) fr_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the ja_ prefix"
@$(MAKE) ja_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the js_ prefix"
@$(MAKE) js_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the lu_ prefix"
@$(MAKE) lu_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the py_ prefix"
@$(MAKE) py_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the rs_ prefix"
@$(MAKE) rs_help $(MFLAGS) --no-print-directory
@$(foreach mapping,$(DIR_PREFIX_MAP), \
echo "The following jobs are available under the $(word 1,$(subst :, ,$(mapping))) prefix"; \
$(MAKE) $(word 1,$(subst :, ,$(mapping)))help $(MFLAGS) --no-print-directory; \
echo; \
)

.PHONY: html dirhtml singlehtml epub latex
html dirhtml singlehtml epub latex: LICENSE
.PHONY: $(SPHINX_BUILD_OPTIONS)
$(SPHINX_BUILD_OPTIONS): LICENSE
@$(MAKE) docs_$@ $(MFLAGS) --no-print-directory

.PHONY: clean
clean:
@$(MAKE) cs_clean cp_clean c_clean fr_clean ja_clean js_clean py_clean rs_clean docs_clean $(MFLAGS) -j --no-print-directory

.PHONY: cs_%
cs_%: LICENSE
@$(MAKE) -C csharp $* $(MFLAGS) --no-print-directory

.PHONY: cp_%
cp_%: LICENSE
@$(MAKE) -C cplusplus $* $(MFLAGS) --no-print-directory

.PHONY: c_%
c_%: LICENSE
@$(MAKE) -C c $* $(MFLAGS) --no-print-directory

.PHONY: docs_%
docs_%: LICENSE
@$(MAKE) -C docs $* $(MFLAGS) --no-print-directory

.PHONY: fr_%
fr_%: LICENSE
@$(MAKE) -C fortran $* $(MFLAGS) --no-print-directory

.PHONY: ja_%
ja_%: LICENSE
@$(MAKE) -C java $* $(MFLAGS) --no-print-directory

.PHONY: js_%
js_%: LICENSE
@$(MAKE) -C javascript $* $(MFLAGS) --no-print-directory
@$(MAKE) all_clean docs_clean -j --no-print-directory $(MFLAGS)

.PHONY: lu_%
lu_%: LICENSE
@$(MAKE) -C lua $* $(MFLAGS) --no-print-directory
# This definition generates our prefix rules
define make_prefix_rule
.PHONY: $(1)%
$(1)%: LICENSE
@$(MAKE) -C $(2) $$* $(MFLAGS) --no-print-directory
endef

.PHONY: py_%
py_%: LICENSE
@$(MAKE) -C python $* $(MFLAGS) --no-print-directory
# Generate rules for each directory in the mapping
$(eval $(call make_prefix_rule,docs_,docs))
$(foreach mapping,$(DIR_PREFIX_MAP),$(eval $(call make_prefix_rule,$(word 1,$(subst :, ,$(mapping))),$(word 2,$(subst :, ,$(mapping))))))

.PHONY: rs_%
rs_%: LICENSE
@$(MAKE) -C rust $* $(MFLAGS) --no-print-directory
.PHONY: all_%
all_%:
@$(MAKE) $(foreach mapping,$(DIR_PREFIX_MAP),$(word 1,$(subst :, ,$(mapping)))$*) $(MFLAGS) --no-print-directory

%:
@$(MAKE) c_$* cp_$* cs_$* fr_$* ja_$* js_$* lu_$* py_$* rs_$* $(MFLAGS) --no-print-directory
@$(MAKE) all_$* $(MFLAGS) --no-print-directory

0 comments on commit 15d09b2

Please sign in to comment.