-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
126 lines (101 loc) · 4.04 KB
/
Makefile
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
OS?=linux64
ENV?=gfortran64
include compile/$(OS)-$(ENV).make
BIN_DIR = bin
LIB_NAME = $(BIN_DIR)/$(COMPILE_LIB_NAME)
all: compile
compile: $(LIB_NAME)
#------------------------------------------------------------------------------
# Version information
# RELEASE : Git version description (tag if possible, else commit hash).
# REV : Git "revision number". Will increase between releases.
#------------------------------------------------------------------------------
HAS_GIT=$(shell if [ -e .git ] ; then echo 1 ; else echo 0; fi)
ifeq ($(HAS_GIT),1)
RELEASE ?= $(shell git describe --always)
REV ?= $(shell git rev-list --count --first-parent HEAD)
else
RELEASE ?= "UNKNOWN"
REV ?= -1
endif
BUILD_DATE=$(shell date +%Y-%m-%dT%H:%M)
SRC_DIR = source
$(SRC_DIR)/fortran_version.inc :
@echo "Creating $@ for version $(REV). Set REV to override."
@echo " INTEGER*4 FORTRAN_VERSION ! generated by Makefile $(BUILD_DATE)" > $@
@echo " PARAMETER (FORTRAN_VERSION = $(REV) ) ! Generated by Makefile" >> $@
$(SRC_DIR)/fortran_release.inc :
@echo "Creating $@ for release $(RELEASE) Set RELEASE to override."
@echo " CHARACTER*80 FORTRAN_RELEASE ! Generated by Makefile $(BUILD_DATE)" > $@
@echo " PARAMETER (FORTRAN_RELEASE = '$(RELEASE)')" >> $@
.PHONY : $(SRC_DIR)/fortran_version.inc $(SRC_DIR)/fortran_release.inc
# Help text (as per README.install)
all.help:
@if `type -p more > /dev/null 2>&1` ; then \
more compile/Help.all ; \
else \
less compile/Help.all ; \
fi
install.help:
@if `type -p more > /dev/null 2>&1` ; then \
more compile/Help.install ; \
else \
less compile/Help.install ; \
fi
test.help:
@if `type -p more > /dev/null 2>&1` ; then \
more compile/Help.test ; \
else \
less compile/Help.test ; \
fi
#------------------------------------------------------------------------------
# myOwnMagField
# Set the MYOWNMAGFIELD_DIR parameter to directory containing the fields
#------------------------------------------------------------------------------
MYOWNMAGFIELD_DIR?=./src_desp
myOwnMagField-pre :
@if [ -d "$(MYOWNMAGFIELD_DIR)" ] ; then \
echo "Found magnetic field in $(MYOWNMAGFIELD_DIR) - copying"; \
mv $(SRC_DIR)/myOwnMagField.f $(SRC_DIR)/myOwnMagField.f.default; \
mv $(SRC_DIR)/myOwnMagField_init.f $(SRC_DIR)/myOwnMagField_init.f.default; \
cp $(MYOWNMAGFIELD_DIR)/myOwnMagField*.f $(SRC_DIR); \
fi
myOwnMagField-post : $(LIB_NAME)
@if [ -d "$(MYOWNMAGFIELD_DIR)" ] ; then \
echo "Restoring magnetic field"; \
mv $(SRC_DIR)/myOwnMagField.f.default $(SRC_DIR)/myOwnMagField.f; \
mv $(SRC_DIR)/myOwnMagField_init.f.default $(SRC_DIR)/myOwnMagField_init.f; \
fi
.PHONY: myOwnMagField-pre myOwnMagField-post
compile: myOwnMagField-post
$(SRC_DIR)/myOwnMagField.f : myOwnMagField-pre
$(SRC_DIR)/myOwnMagField_init.f : myOwnMagField-pre
#------------------------------------------------------------------------------
# Sources and compilation rules
#------------------------------------------------------------------------------
F77_SOURCES = $(wildcard $(SRC_DIR)/*.f)
C99_SOURCES = $(wildcard $(SRC_DIR)/*.c)
F77_OBJS = $(patsubst $(SRC_DIR)/%.f,$(BIN_DIR)/%.o,$(F77_SOURCES))
C99_OBJS = $(patsubst $(SRC_DIR)/%.c,$(BIN_DIR)/%.o,$(C99_SOURCES))
$(BIN_DIR)/onera_desp_lib.o : $(SRC_DIR)/fortran_version.inc $(SRC_DIR)/fortran_release.inc
$(BIN_DIR)/%.o : $(SRC_DIR)/%.f
$(FC) $(FFLAGS) -c -o $@ $<
$(BIN_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(LIB_NAME) : $(F77_OBJS) $(C99_OBJS)
$(LD) $(LDFLAGS) -o $@ $^
#------------------------------------------------------------------------------
# Install
#------------------------------------------------------------------------------
INSTALLDIR?=.
install : $(LIB_NAME)
@echo Installing
@echo Creating $(INSTALLDIR)
@mkdir -p $(INSTALLDIR)
@echo Installing $(LIB_NAME) to $(INSTALLDIR)/$(INSTALL_LIB_NAME)
@install $(LIB_NAME) $(INSTALLDIR)/$(INSTALL_LIB_NAME)
@echo Installing done
clean:
rm -f $(BIN_DIR)/*.o
rm -f $(LIB_NAME)
.PHONY: clean all compile install