Skip to content

Commit

Permalink
Update Makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
zoziha committed May 27, 2022
1 parent b86491d commit d823af7
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 34 deletions.
21 changes: 12 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
LIB = dfftpack

FC = gfortran
FFLAGS = -O2
FFLAGS = -O2 -fPIC

export LIB
export FC
export FFLAGS

.PHONY: all clean test
.PHONY: build clean test

all:
$(MAKE) -f Makefile --directory=src
$(MAKE) -f Makefile --directory=test
build:
$(MAKE) -f Makefile $@ --directory=src

test:
$(MAKE) -f Makefile --directory=test
test: build
$(MAKE) -f Makefile $@ --directory=test

bench: build
$(MAKE) -f Makefile $@ --directory=example

clean:
$(MAKE) -f Makefile clean --directory=src
$(MAKE) -f Makefile clean --directory=test
$(MAKE) -f Makefile $@ --directory=src
$(MAKE) -f Makefile $@ --directory=test
$(MAKE) -f Makefile $@ --directory=example
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fftpack = { git="https://github.com/fortran-lang/fftpack.git" }
Alternatively, you can build using provided `Makefile`:
```bash
make
make test
```

## Links
Expand Down
18 changes: 18 additions & 0 deletions example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SRCF90 = \
bench1.f90

OBJ = $(SRCF90:%.f90=%.o)

build: bench1.x

bench: build
./bench1.x

bench1.x: $(OBJ)
$(FC) $(FFLAGS) $(OBJ) -L../src -l$(LIB) -I../src -o $@

%.o: %.f90
$(FC) $(FFLAGS) -I../src -c $<

clean:
rm -f -r *.o *.x
22 changes: 12 additions & 10 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SRCF = \
SRCF90 = \
zfftb.f90\
cfftb1.f90\
zfftf.f90\
Expand Down Expand Up @@ -47,9 +47,7 @@ SRCF = \
dsinqi.f90\
dsint.f90\
sint1.f90\
dsinti.f90

SRCF90 = \
dsinti.f90\
fftpack.f90\
fftpack_fft.f90\
fftpack_ifft.f90\
Expand All @@ -59,16 +57,20 @@ SRCF90 = \
fftpack_ifftshift.f90\
fftpack_qct.f90\
fftpack_iqct.f90\
fftpack_dct.f90\
fftpack_dct.f90

SRCFPP = \
rk.F90

OBJF := $(SRCF:.f90=.o)
OBJF90 := $(SRCF90:.f90=.o)
OBJ = $(SRCF90:.f90=.o)
OBJ += $(SRCFPP:.F90=.o)

build: lib$(LIB).a lib$(LIB).so

lib$(LIB).a: $(OBJF) $(OBJF90)
ar -rcs lib$(LIB).a $(OBJF) $(OBJF90)
lib$(LIB).a: $(OBJ)
ar -rcs lib$(LIB).a $(OBJ)

shared: $(OBJ)
lib$(LIB).so: $(OBJ)
$(FC) -shared -o lib$(LIB).so $(OBJ)

clean:
Expand Down
34 changes: 19 additions & 15 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
FETCH = curl -L

SRC = \
SRCF90 = \
test_fftpack_fft.f90 \
test_fftpack_rfft.f90 \
test_fftpack_qct.f90 \
test_fftpack_dct.f90 \
test_fftpack_utils.f90 \
test_fftpack.f90 \
test_fftpack.f90

SRCFPP = \
test_fftpack_qct.F90 \
test_fftpack_dct.F90 \
testdrive.F90

OBJ = $(SRC:.f90=.o)
OBJ := $(OBJ:.F90=.o)

all: tstfft \
test_fftpack
OBJ = $(SRCF90:%.f90=%.o)
OBJ += $(SRCFPP:%.F90=%.o)

build: tstfft.x \
test_fftpack.x

test: build
./tstfft.x
./test_fftpack.x

# Orginal test
tstfft: tstfft.f
$(FC) $(FFLAGS) $< -L../src -l$(LIB) -I../src -o $@.x
time ./tstfft.x
tstfft.x: tstfft.f
$(FC) $(FFLAGS) $< -L../src -l$(LIB) -I../src -o $@

# `fftpack` fft routines
test_fftpack: $(OBJ)
$(FC) $(FFLAGS) $(OBJ) -L../src -l$(LIB) -I../src -o $@.x
./test_fftpack.x
test_fftpack.x: $(OBJ)
$(FC) $(FFLAGS) $(OBJ) -L../src -l$(LIB) -I../src -o $@

testdrive.F90:
$(FETCH) https://github.com/fortran-lang/test-drive/raw/v0.4.0/src/testdrive.F90 > $@
Expand Down

0 comments on commit d823af7

Please sign in to comment.