-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.SUBlink
87 lines (68 loc) · 2.12 KB
/
Makefile.SUBlink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#******************************************************************************* -*- Makefile -*-
#****e* /Makefile.SUBlink
# NAME
# Makefile.SUBlink
# PURPOSE
# Sub-Makefile for the GiBUU code, used in all diriectories besides 'objects'
# and 'testRun'.
#
# This is a template, which is copied as a local "Makefile"
# into every directory in the "code" tree besides the
# testRun directories.
#*******************************************************************************
.SUFFIXES: # Delete the default suffixes
export SHELL := /bin/bash
### LOCAL VARIABLES:
ifeq ($(wildcard Makefile.local),)
include $(shell pwd)/Makefile.local # generate error message with full path if Makefile.local is missing
else
include Makefile.local
endif
### FILES:
SRCf90 := $(wildcard *.f90)
SRCF90 := $(wildcard *.F90)
SRCf77 := $(wildcard *.f)
SRCinc := $(wildcard *.inc)
SRC := $(SRCf90) $(SRCF90) $(SRCf77) $(SRCinc)
SRC := $(filter-out $(FILEEXCL), $(SRC))
SRC := $(filter-out $(EXEFILE), $(SRC))
OBJEXCL := $(patsubst %.f90, %.o, $(FILEEXCL))
OBJEXCL := $(patsubst %.F90, %.o, $(OBJEXCL))
OBJEXCL := $(patsubst %.f, %.o, $(OBJEXCL))
### SUBDIRS:
SUBDIR := $(sort $(notdir $(shell $(FIND) -maxdepth 1 ! -name ".*" -type d)))
SUBDIR := $(filter-out $(SUBDIREXCL), $(SUBDIR))
### RULES:
# This is the target called without any arguments:
# (empty target in order to ensure clean programming)
all: ;
iterate: subdirs linking unlinking
objects: $(OBJ)
# this creates softlinks for all source files:
linking:
@for X in $(SRC); do\
(ln -sf $(CURDIR)/$$X $(OBJDIR)/$$X;)\
done
# this deletes softlinks to all non-used source files:
unlinking:
@for X in $(FILEEXCL); do\
(rm -f $(OBJDIR)/$$X;)\
done
@for X in $(OBJEXCL); do\
(rm -f $(OBJDIR)/$$X;)\
done
@for X in $(EXEFILE); do\
(rm -f $(OBJDIR)/$$X;)\
done
print:
@echo "!!! CURDIR =" $(CURDIR)
@echo "!!! SUBDIR =" $(SUBDIR)
@echo "!!! SRC =" $(SRC)
subdirs:
@for X in $(SUBDIR); do\
(cd $$X && $(MAKE) $(noPrintDirectory) iterate;)\
done
Makefiles: #print
@for X in $(SUBDIR); do\
(cp $(ROOTDIR)/Makefile.SUBlink $$X/Makefile; cd $$X && $(MAKE) Makefiles;)\
done