-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
55 lines (42 loc) · 1.59 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
.POSIX:
CC = gcc
FC = gfortran
AR = ar
DEBUG = #-g -O0 -Wall -fmax-errors=1
CFLAGS = $(DEBUG) `pkg-config --cflags lua-5.3`
FFLAGS = $(DEBUG) `pkg-config --cflags lua-5.3`
ARFLAGS = rcs
LDFLAGS = `pkg-config --libs-only-L lua-5.3`
LDLIBS = `pkg-config --libs-only-l lua-5.3`
TARGET = libfortran-lua53.a
TYPES = types
FIBONACCI = examples/fibonacci/fibonacci
LIBRARY = examples/library/fortran.so
STRING = examples/string/string
TABLE = examples/table/table
.PHONY: all clean examples
all: $(TARGET) $(TYPES)
test: $(TYPES)
examples: $(FIBONACCI) $(LIBRARY) $(STRING) $(TABLE)
$(TARGET):
$(FC) $(FFLAGS) -fPIC -c src/lua.f90
$(AR) $(ARFLAGS) $(TARGET) lua.o
$(TYPES):
$(CC) $(CFLAGS) -o $(TYPES) test/types.c $(LDFLAGS)
$(FIBONACCI): $(TARGET)
$(FC) $(FFLAGS) $(LDFLAGS) -o $(FIBONACCI) examples/fibonacci/fibonacci.f90 $(TARGET) $(LDLIBS)
$(LIBRARY): $(TARGET)
$(FC) $(FFLAGS) $(LDFLAGS) -shared -fPIC -o $(LIBRARY) examples/library/fortran.f90 $(TARGET)
$(STRING): $(TARGET)
$(FC) $(FFLAGS) $(LDFLAGS) -o $(STRING) examples/string/string.f90 $(TARGET) $(LDLIBS)
$(TABLE): $(TARGET)
$(FC) $(FFLAGS) $(LDFLAGS) -o $(TABLE) examples/table/table.f90 $(TARGET) $(LDLIBS)
clean:
if [ `ls -1 *.mod 2>/dev/null | wc -l` -gt 0 ]; then rm *.mod; fi
if [ `ls -1 *.o 2>/dev/null | wc -l` -gt 0 ]; then rm *.o; fi
if [ -e $(TARGET) ]; then rm $(TARGET); fi
if [ -e $(TYPES) ]; then rm $(TYPES); fi
if [ -e $(FIBONACCI) ]; then rm $(FIBONACCI); fi
if [ -e $(LIBRARY) ]; then rm $(LIBRARY); fi
if [ -e $(STRING) ]; then rm $(STRING); fi
if [ -e $(TABLE) ]; then rm $(TABLE); fi