forked from josephalevin/fson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
53 lines (38 loc) · 923 Bytes
/
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
SRC=src
DIST=dist
BUILD=build
F95=.f95
OBJ=.o
EXE=
LIBTARGET=$(DIST)/fson-lib.so
FC = gfortran
FCFLAGS = -g -fbounds-check
FMFLAGS = -J$(BUILD)
LDFLAGS=
AR = ar
ARFLAGS= r
# "make" builds all
all: lib examples
# List of example programs
EXAMPLES = basic example1
examples: $(patsubst %, $(DIST)/examples/%$(EXE), $(EXAMPLES)) json
JSON = $(shell find src -name '*.json')
json: $(patsubst $(SRC)%, $(DIST)%, $(JSON))
FSON = fson_string_m fson_value_m fson_path_m fson
OBJECTS = $(patsubst %, $(BUILD)/%.o, $(FSON))
$(LIBTARGET) : $(OBJECTS)
mkdir -p `dirname $@`
$(AR) $(ARFLAGS) $@ $^
lib: $(LIBTARGET)
$(DIST)/%.json : $(SRC)/%.json
cp -f $< $@
$(DIST)/%$(EXE) : $(BUILD)/%$(OBJ) $(OBJECTS)
mkdir -p `dirname $@`
$(FC) $(FCFLAGS) -o $@ $^ $(LDFLAGS)
$(BUILD)/%$(OBJ): $(SRC)/%$(F95)
mkdir -p `dirname $@`
$(FC) $(FCFLAGS) $(FMFLAGS) -c $< -o $@
clean:
rm -rf $(BUILD)
clobber: clean
rm -rf $(DIST)