4
1
mirror of https://github.com/pfloos/quack synced 2024-11-09 07:33:55 +01:00
quack/src/Makefile

62 lines
1.2 KiB
Makefile
Raw Normal View History

2020-09-30 09:59:18 +02:00
QUACK_ROOT=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))/..))
export QUACK_ROOT
SDIR=$(QUACK_ROOT)/src
2020-09-30 00:10:57 +02:00
ALL_DIRS=$(filter-out modules,$(patsubst %/,%,$(wildcard */)))
# Rules for Modules
###################
MOD_DIRS=numgrid
# Rules for Libraries
#####################
2020-09-30 09:59:18 +02:00
LDIR =$(QUACK_ROOT)/lib
2020-09-30 00:10:57 +02:00
LIB_DIRS=$(filter-out $(MAIN_DIRS), $(ALL_DIRS))
FORCE:
2020-09-30 09:59:18 +02:00
$(SDIR)/%/Makefile: FORCE
2020-10-02 13:42:21 +02:00
@(echo QUACK_ROOT=$(QUACK_ROOT) > $@)
@(echo TARGET=$*.a >> $@)
@(echo 'include $$(QUACK_ROOT)/src/Makefile.include' >> $@)
2020-09-30 00:10:57 +02:00
2020-09-30 09:59:18 +02:00
$(LDIR)/%.a: FORCE $(SDIR)/%/Makefile $(MOD_DIRS)
$(MAKE) -C $(SDIR)/$* lib
2020-09-30 00:10:57 +02:00
# Rules for executables
#######################
MAIN_DIRS=QuAcK eDFT
2020-09-30 09:59:18 +02:00
BDIR=$(QUACK_ROOT)/bin
2020-09-30 00:10:57 +02:00
ALL_EXEC=$(patsubst %, $(BDIR)/%, $(MAIN_DIRS) )
2020-09-30 09:59:18 +02:00
$(BDIR)/%: $(patsubst %,$(LDIR)/%.a,$(LIB_DIRS)) $(SDIR)/%/Makefile
$(MAKE) -C $* $@
2020-09-30 00:10:57 +02:00
# Rules for both
################
2020-09-30 09:59:18 +02:00
default: $(ALL_EXEC) $(wildcard $(SDIR)/*/Makefile)
debug:
DEBUG=1 $(MAKE) default
2020-09-30 00:10:57 +02:00
.DEFAULT_GOAL := default
2020-09-30 09:59:18 +02:00
.PHONY: default debug
2020-09-30 00:10:57 +02:00
.PRECIOUS: $(LDIR)/%.a %/Makefile
clean:
rm -f -- $(patsubst %/,$(LDIR)/%.a,$(wildcard */)) ; \
rm -f -- $(ALL_EXEC) ; \
for i in $(MAIN_DIRS) $(LIB_DIRS) ; do rm -f -- $$i/obj/* ; done