-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (49 loc) · 1.86 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
.POSIX:
.SUFFIXES:
CC = gcc
FC = gfortran
AR = ar
DEBUG = -g -O0 -Wall -fmax-errors=1
RELEASE = -O2 -march=native
CFLAGS = $(RELEASE) `pkg-config --cflags lua-5.4`
FFLAGS = $(RELEASE) `pkg-config --cflags lua-5.4`
ARFLAGS = rcs
LDFLAGS = `pkg-config --libs-only-L lua-5.4`
LDLIBS = `pkg-config --libs-only-l lua-5.4`
INCDIR = $(PREFIX)/include/libfortran-lua54
LIBDIR = $(PREFIX)/lib
MODULE = lua.mod
TARGET = libfortran-lua54.a
.PHONY: all clean examples install test
all: $(TARGET)
test: types
examples: fibonacci fortran.so string table
$(TARGET): src/lua.f90
$(FC) $(FFLAGS) -fPIC -c src/lua.f90
$(AR) $(ARFLAGS) $(TARGET) lua.o
types: test/types.c
$(CC) $(CFLAGS) -o types test/types.c $(LDFLAGS)
fibonacci: $(TARGET) examples/fibonacci/fibonacci.f90
$(FC) $(FFLAGS) $(LDFLAGS) -o fibonacci examples/fibonacci/fibonacci.f90 $(TARGET) $(LDLIBS)
fortran.so: $(TARGET) examples/library/fortran.f90
$(FC) $(FFLAGS) $(LDFLAGS) -shared -fPIC -o fortran.so examples/library/fortran.f90 $(TARGET)
string: $(TARGET) examples/string/string.f90
$(FC) $(FFLAGS) $(LDFLAGS) -o string examples/string/string.f90 $(TARGET) $(LDLIBS)
table: $(TARGET) examples/table/table.f90
$(FC) $(FFLAGS) $(LDFLAGS) -o table examples/table/table.f90 $(TARGET) $(LDLIBS)
install: $(TARGET)
@echo "--- Installing $(TARGET) to $(LIBDIR)/ ..."
install -d $(LIBDIR)
install -m 644 $(TARGET) $(LIBDIR)/
@echo "--- Installing module files to $(INCDIR)/ ..."
install -d $(INCDIR)
install -m 644 $(MODULE) $(INCDIR)/
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 fortran.so ]; then rm fortran.so; fi
if [ -e string ]; then rm string; fi
if [ -e table ]; then rm table; fi