Skip to content

Commit

Permalink
Work on autotools.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexispaz committed May 5, 2022
1 parent 349974a commit f5c45ea
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 99 deletions.
84 changes: 3 additions & 81 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,86 +1,8 @@

# We are not following the standard layout of a GNU proyect
AUTOMAKE_OPTIONS = foreign

EXTRA_DIST = LICENSE README.md

bin_PROGRAMS = dana

dana_SOURCES = dana.F90 \
Constants.F90 \
Cells.F90 \
Neighbor.F90 \
Elements.F90 \
Program_Types.F90 \
Errors.f90 \
Strings.f90 \
Groups.F90

# Fortran Preprocesor Templates
FPTDDS=$(top_srcdir)/lib/fpt/include/
AM_FCFLAGS = -I$(FPTDDS)
include_HEADERS = $(FPTDDS)/prep.inc \
$(FPTDDS)/vector_header.inc \
$(FPTDDS)/vector_body.inc \
$(FPTDDS)/list_header.inc \
$(FPTDDS)/list_body.inc \
$(FPTDDS)/dlist_header.inc \
$(FPTDDS)/dlist_body.inc \
$(FPTDDS)/cdlist_header.inc \
$(FPTDDS)/cdlist_body.inc \
$(FPTDDS)/arrayofptrs_header.inc

DEBUG_FLAGS = -g -O0 -p
PROF_FLAGS = -p

AM_FCFLAGS += $(OPENMP_CFLAGS)
AM_FCFLAGS += -DDIM3

if COMPILER_IS_GFORTRAN
DEBUG_FLAGS += -fbacktrace
DEBUG_FLAGS += -fcheck=all
DEBUG_FLAGS += -Wall
DEBUG_FLAGS += -fbounds-check
DEBUG_FLAGS += -fcheck-array-temporaries
DEBUG_FLAGS += -pedantic-errors
# F90DEBUG += -std=f2003 -pedantic

# Some times needed for valgrind
# F90DEBUG += -static

# To warn about use modules without only keyword
# F90DEBUG += -Wuse-without-only
endif

if COMPILER_IS_IFORT
DEBUG_FLAGS += -check all
DEBUG_FLAGS += -traceback
DEBUG_FLAGS += -warn all
DEBUG_FLAGS += -debug all
#F90DEBUG += "-Mprof=func"
#F90DEBUG += "-Mprof=line"
endif

if DEBUG
ENABLE_DEBUG=$(DEBUG_FLAGS)
endif

AM_FCFLAGS += $(ENABLE_DEBUG)



.PHONY: debug

debug:
make ENABLE_DEBUG="$(DEBUG_FLAGS)"

all: dana
SUBDIRS = lib/fpt src

Constants.o:
Strings.o: Constants.o
Errors.o: Constants.o Strings.o
Elements.o: Constants.o Strings.o Errors.o

Program_Types.o: Constants.o Errors.o Elements.o
dana.o: Groups.o Neighbor.o Errors.o
Program_Types.o: Constants.o Errors.o Elements.o
Groups.o: Constants.o Elements.o Errors.o Program_Types.o
Neighbor.o: Constants.o Groups.o Errors.o Cells.o
33 changes: 21 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,54 @@ AC_INIT([dana],
[m4_esyscmd_s([git describe --always --abbrev=4 --dirty])],
[[email protected]])

AC_CONFIG_SRCDIR(.)
AC_CONFIG_SRCDIR(src/)

AM_INIT_AUTOMAKE()
AM_INIT_AUTOMAKE([subdir-objects foreign])

# Avoid make to rebuild configure
AM_MAINTAINER_MODE

# Set OpenMP flags
# : ${enable_openmp=no}
AC_OPENMP

# To build libraries
AC_PROG_RANLIB

# Set AR
AM_PROG_AR

# Set FCFLAGS and FC
: ${FCFLAGS=""} # Override default (i.e. "-g -O2")
AC_PROG_FC

# External software
# =================

# subtrees
# --------
AC_CONFIG_SUBDIRS([
lib/fpt
])

# Debug options
# other options
# =============

AM_CONDITIONAL([COMPILER_IS_IFORT], [test x"$FC" = xifort])
AM_CONDITIONAL([COMPILER_IS_GFORTRAN], [test x"$FC" = xgfortran])

# Debug
# -----
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug],[Turn on debugging]),
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR([bad value "${enableval}" for --enable-debug]) ;;
esac],enable_debug=no)


# Usefull variables to use inside the Makefile.am files
AM_CONDITIONAL([COMPILER_IS_IFORT], [test x"$FC" = xifort])
AM_CONDITIONAL([COMPILER_IS_GFORTRAN], [test x"$FC" = xgfortran])
AM_CONDITIONAL([DEBUG], [test "x$enable_debug" = "xyes"])


AC_CONFIG_FILES([
Makefile
src/Makefile
])


Expand Down
6 changes: 2 additions & 4 deletions lib/fpt/configure.ac
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_INIT([fpt-dds],
[m4_esyscmd_s([git describe --always --abbrev=4 --dirty])],
[[email protected]])
AC_INIT([fpt-dds],[m4_esyscmd_s([git describe --always --abbrev=4 --dirty])],[[email protected]])

AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/)
Expand All @@ -26,7 +24,7 @@ AC_PROG_FC

# Debug options
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug],[Turn on debugging]),
AS_HELP_STRING([--enable-debug],[Turn on debugging]),
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
Expand Down
3 changes: 1 addition & 2 deletions lib/fpt/include/cdlist_header.inc
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#include "prep.inc"

#define _Constructor _PASTE(_NODE,_constructor)
#define _Alloc _PASTE(_NODE,_alloc)
#define _Source _PASTE(_NODE,_source)
#define _Point _PASTE(_NODE,_point)
#define _Destroy _PASTE(_NODE,_destroy)

#define _Constructor _PASTE(_NODE,_constructor)
#define _AddAfter _PASTE(_NODE,_add_after)
#define _AddBefore _PASTE(_NODE,_add_before)
#define _Append _PASTE(_NODE,_append)
#define _DestroyAll _PASTE(_NODE,_destroy_all)
#define _Deattach _PASTE(_NODE,_deattach)

Expand Down
1 change: 1 addition & 0 deletions lib/fpt/include/vector_header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private _Put
private _Delete
private _Destroy
private _Increase
private _Assign

#undef _NODE
#undef _TYPE
Expand Down
1 change: 1 addition & 0 deletions lib/fpt/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include_HEADERS = $(top_srcdir)/include/arrayofptrs_header.inc \
$(top_srcdir)/include/list_body.inc \
$(top_srcdir)/include/list_header.inc \
$(top_srcdir)/include/prep.inc \
$(top_srcdir)/include/object.inc \
$(top_srcdir)/include/vector_body.inc \
$(top_srcdir)/include/vector_header.inc

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
95 changes: 95 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
bin_PROGRAMS = dana

dana_SOURCES = dana.F90 \
Constants.F90 \
Cells.F90 \
Neighbor.F90 \
Elements.F90 \
Program_Types.F90 \
Errors.f90 \
Strings.f90 \
Groups.F90

# zeros...
dana_LDADD =
AM_FCFLAGS =

AM_FCFLAGS += $(OPENMP_CFLAGS)
AM_FCFLAGS += -DDIM3

# External software
# =================

# Note on local vs external libraries:
# > We recommend that you avoid using -l options in LDADD or prog_LDADD when
# referring to libraries built by your package. Instead, write the file name of
# the library explicitly as in the above cpio example. Use -l only to list
# third-party libraries. If you follow this rule, the default value of
# prog_DEPENDENCIES will list all your local libraries and omit the other ones.
# [source](https://www.gnu.org/software/automake/manual/html_node/Linking.html)

# Fortran Preprocesor Templates
# -----------------------------
AM_FCFLAGS += -I$(top_srcdir)/lib/fpt/include/

# Debug
# =====

DEBUG_FLAGS = -g -O0 -p
PROF_FLAGS = -p

if COMPILER_IS_GFORTRAN
DEBUG_FLAGS += -fbacktrace
DEBUG_FLAGS += -fcheck=all
DEBUG_FLAGS += -Wall
DEBUG_FLAGS += -fbounds-check
DEBUG_FLAGS += -fcheck-array-temporaries
DEBUG_FLAGS += -pedantic-errors
# F90DEBUG += -std=f2003 -pedantic

# Some times needed for valgrind
# F90DEBUG += -static

# To warn about use modules without only keyword
# F90DEBUG += -Wuse-without-only
endif

if COMPILER_IS_IFORT
DEBUG_FLAGS += -check all
DEBUG_FLAGS += -traceback
DEBUG_FLAGS += -warn all
DEBUG_FLAGS += -debug all
#F90DEBUG += "-Mprof=func"
#F90DEBUG += "-Mprof=line"
endif

if DEBUG
ENABLE_DEBUG=$(DEBUG_FLAGS)
endif

AM_FCFLAGS += $(ENABLE_DEBUG)



.PHONY: debug

debug:
make ENABLE_DEBUG="$(DEBUG_FLAGS)"

all: dana


Constants.o:
Strings.o: Constants.o
Errors.o: Constants.o Strings.o
Elements.o: Constants.o Strings.o Errors.o

Program_Types.o: Constants.o Errors.o Elements.o
dana.o: Groups.o Neighbor.o Errors.o Elements.o Constants.o
Program_Types.o: Constants.o Errors.o Elements.o
Groups.o: Constants.o Elements.o Errors.o Program_Types.o
Neighbor.o: Constants.o Groups.o Errors.o Cells.o

clean-local:
rm -f *.mod

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f5c45ea

Please sign in to comment.