Skip to content

Commit

Permalink
Merge pull request #73 from stuart-knock/makefile
Browse files Browse the repository at this point in the history
Extend Makefile
  • Loading branch information
Paula authored Oct 17, 2016
2 parents 300c96a + 483200a commit 01bda8c
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 76 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Ignore files associated with compiling
bin/
obj/
dep/

# Ignore files associated with doxygen docs
Documentation/html/
Documentation/latex/
doc/html/
doc/latex/

# Ignore NeuroField output files
*.output
Expand Down
258 changes: 196 additions & 62 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,69 +1,203 @@
# Standard Linux (gcc must be > 4.9) performance
CXX = g++
CXXFLAGS = -g -lm -Wall -O3 -Wextra -pedantic -std=c++11 -msse -msse2 -msse3 -mfpmath=sse -march=native -mtune=native -funroll-loops -flto #-m64

# Mac OS
# CXX = g++-4.9
# CXXFLAGS = -lm -Wall -O3 -std=c++11


# Windows
# CXX = x86_64-w64-mingw32-g++
# CXXFLAGS = -lm -Wall -O3 -msse -msse2 -msse3 -mfpmath=sse -funroll-loops -flto -m64 -std=gnu++11 -static -static-libgcc -static-libstdc++

# Debugging
# CXX = g++
# CXXFLAGS = g++ -g -lm -Wall -Wextra -pedantic -std=c++11 -msse -msse2 -msse3


HEADER = $(wildcard src/*.h)
CPP = $(wildcard src/*.cpp)
OBJ = $(addprefix obj/,$(notdir $(CPP:.cpp=.o)))

# target: default - compile bin/neurofield
default: bin/neurofield

debugmode: CXXFLAGS = -g -ggdb3 -lm -Wall -Wextra -pedantic -std=c++11 -msse -msse2 -msse3

debugmode: bin/neurofield

bin/neurofield: $(OBJ)
@mkdir -p bin
@echo "$(CXX) $(CXXFLAGS) $(OBJ) -o $@"
@$(CXX) $(CXXFLAGS) $(OBJ) -o $@ || (echo "mycommand failed $$?"; exit 1)
#Makefile for neurofield
#
# Type 'make help' for a list of possible targets with brief descriptions.
# If you're having problems, the Makefile itself can be debugged using the
# option -d, eg 'make -d help'. Also 'make info' will display the contents
# of key variables in the Makefile, to help with debugging.
#

#Specify our directories.
SRCDIR := src/
OBJDIR := obj/
BINDIR := bin/
DOCDIR := doc/
DEPDIR := dep/

#Default to *nix, suffix-less, binary.
BIN := neurofield

#User-manual files
USER_MANUAL := NeurofieldManual.pdf
USER_MANUAL_SRC := NeurofieldManual.tex

#Default to *nix commands.
MV := mv -f
RM := rm -f
RMDIR := rm -rf
GREP := egrep
CAT := cat

# Standard Linux (gcc must be >= 4.8.5) performance
ifeq ($(shell uname -s), Linux)
CXX := g++
CXXFLAGS := -std=c++11 -lm -Wall -Wextra -pedantic -msse -msse2 -msse3 -mfpmath=sse -march=native -mtune=native -funroll-loops -flto -O3
DEBUG := -std=c++11 -ggdb3 -Og -lm -Wall -Wextra -pedantic -msse -msse2 -msse3 -mfpmath=sse -march=native -mtune=native -funroll-loops
DEPFLAGS = -std=c++11 -MM -MP -MT $(OBJDIR)$*.o
endif

# Mac OS, default to clang++
ifeq ($(shell uname -s), Darwin)
CXX := clang++
CXXFLAGS := -std=c++11 -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -fdiagnostics-fixit-info -Wdocumentation -march=native -funroll-loops -flto -O3
DEBUG := -std=c++11 -glldb -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -fdiagnostics-fixit-info -Wdocumentation
DEPFLAGS = -std=c++11 -MM -MP -MT $(OBJDIR)$*.o
endif

# Source and header files
HEADER := $(wildcard $(SRCDIR)*.h)
CPP := $(wildcard $(SRCDIR)*.cpp)
OBJ := $(addprefix $(OBJDIR),$(notdir $(CPP:.cpp=.o)))
DEP := $(addprefix $(DEPDIR),$(notdir $(CPP:.cpp=.d)))

#Targets that don't need the dependencies evaluated/included.
NO_DEPS := make_bin_dir make_obj_dir make_dep_dir help help-dev docs info $(DOCDIR)$(USER_MANUAL) reference-manual user-manual
NO_DEPS += clean-user-manual clean-reference-manual clean-docs clean-deps clean-objs clean-bin clean clean-all

# Delete the default suffixes
.SUFFIXES:
# Define our suffix list
.SUFFIXES: .o .d .cpp .h .tex

.PHONY: neurofield debug all clang make_bin_dir make_obj_dir make_dep_dir help help-dev info docs user-manual reference-manual \
clean-user-manual clean-reference-manual clean-docs clean-deps clean-objs clean-bin clean clean-all

# target: neurofield - compile neurofield placing the executable in the bin directory.
neurofield: $(BINDIR)$(BIN)

# target: debug - compile neurofield with debugging enabled.
debug: CXXFLAGS := $(DEBUG)
debug: neurofield

# target: all - compile neurofield and build all documentation.
all: neurofield docs

# target: clang - Build using clang++, redundant on MacOS as clang++ is default.
ifeq ($(MAKECMDGOALS), clang)
CXX := $(shell command -v clang++ 2> /dev/null)
ifndef CXX
$(error "You don't appear to have clang++ installed. If it is installed make sure it's in your PATH.")
endif
CXXFLAGS := -std=c++11 -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -fdiagnostics-fixit-info -Wdocumentation -march=native -funroll-loops -flto -O3
DEPFLAGS = -std=c++11 -MM -MP -MT $(OBJDIR)$*.o
endif
clang: neurofield

# target: icc - Build using intel C++ compiler.
ifeq ($(MAKECMDGOALS), icc)
CXX := $(shell command -v icc 2> /dev/null)
ifndef CXX
$(error "You don't appear to have icc installed. If it is installed make sure it's in your PATH.")
endif
#TODO: consider/test -ipp -mkl -unroll-aggressive -static
CXXFLAGS := -std=c++11 -Wall -Wremarks -Wchecks -Weffec++ -xHost -funroll-loops -ipo -O3
DEPFLAGS = -std=c++11 -MM -MP -MT $(OBJDIR)$*.o
endif
icc: neurofield

# target: $(BINDIR)$(BIN) - Main target for the final build, linking objects into an executable.
$(BINDIR)$(BIN): $(OBJ) | make_bin_dir
$(CXX) $(CXXFLAGS) $(OBJ) -o $@
@echo "====="
@cat license.txt
@$(CAT) license.txt
@echo "====="
@echo "USE OF NEUROFIELD CONSTITUTES ACCEPTANCE OF THE LICENSE CONDITIONS ABOVE"

# target: make_bin_dir - Create the directory $BINDIR if it doesn't already exist.
make_bin_dir:
@test -d $(BINDIR) || { mkdir $(BINDIR) ; echo "mkdir $(BINDIR)"; }

# target: make_obj_dir - Create the directory $OBJDIR if it doesn't already exist.
make_obj_dir:
@test -d $(OBJDIR) || { mkdir $(OBJDIR) ; echo "mkdir $(OBJDIR)"; }

# target: make_dep_dir - Create the directory $DEPDIR if it doesn't already exist.
make_dep_dir:
@test -d $(DEPDIR) || { mkdir $(DEPDIR) ; echo "mkdir $(DEPDIR)"; }

#Only create and include dependencies if the current target requires them.
ifeq (, $(filter $(MAKECMDGOALS), $(NO_DEPS)))
#Create obj/*.d header dependencies
$(DEPDIR)%.d: $(SRCDIR)%.cpp | make_dep_dir
$(CXX) $(DEPFLAGS) $< > $(DEPDIR)$*.d
# Include any existing dependencies in the build
-include $(OBJ:.o=.d)

# Build object code and also create obj/*.d header dependencies
obj/%.o: src/%.cpp
@mkdir -p obj
@$(CXX) $(CXXFLAGS) -c $< -o $@
@$(CXX) -MM $(CXXFLAGS) $< > obj/$*.d
@echo "CXX $<"
@mv -f obj/$*.d obj/$*.d.tmp
@sed -e 's|.*:|$@:|' < obj/$*.d.tmp > obj/$*.d
@sed -e 's/.*://' -e 's/\\$$//' < obj/$*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> obj/$*.d
@rm -f obj/$*.d.tmp

# Build documentation: compile tex file and produce html docs from code
build_docs:
cd Documentation && pdflatex neurofield && pdflatex neurofield && cd ../ && doxygen Doxyfile

.PHONY: clean doc help

# target: help - Print this message
help:
@egrep "^# target:" Makefile
-include $(DEP)
endif

# target: doc - compile Documentation/neurofield.pdf
doc: Documentation/neurofield.pdf
# Build object code
$(OBJDIR)%.o: $(SRCDIR)%.cpp | make_obj_dir
$(CXX) $(CXXFLAGS) -c $< -o $@

# target: clean - Delete ./bin/, ./obj/, and LaTeX temporary files in ./Documentation/
clean:
@-rm -rf bin obj Documentation/{user,developer}.{aux,log,out,toc} Documentation/x.log
# target: help - Print this message.
help:
@echo "Available Makefile targets, call as 'make target', eg. make all"
@$(GREP) "^# target:" Makefile

# target: help-dev - Print an extended list of targets.
help-dev: help
@echo "Additional targets, mainly useful for developers."
@$(GREP) "^# target:" Makefile

# target: info - A convenience target for debugging the Makefile.
info:
@echo " SHELL: $(SHELL)"
@echo " MAKE_VERSION: $(MAKE_VERSION)"
@echo " .VARIABLES: $(.VARIABLES)"
@echo " .DEFAULT_GOAL: $(.DEFAULT_GOAL)"
@echo " SRCDIR: $(SRCDIR)"
@echo " OBJDIR: $(OBJDIR)"
@echo " BINDIR: $(BINDIR)"
@echo " DOCDIR: $(DOCDIR)"
@echo " HEADER: $(HEADER)"
@echo " CPP: $(CPP)"
@echo " OBJ: $(OBJ)"
@echo " DEP: $(DEP)"
@echo " CXX: $(CXX)"
@echo " CXXFLAGS: $(CXXFLAGS)"
@echo " DEBUG: $(DEBUG)"
@echo " NO_DEPS: $(NO_DEPS)"

# target: docs - Build user and reference manuals.
docs: user-manual reference-manual

# target: user-manual - Build only the user-manual.
user-manual: $(DOCDIR)$(USER_MANUAL)

# target: $(DOCDIR)$(USER_MANUAL) - target that actually builds the user manual.
$(DOCDIR)$(USER_MANUAL): $(DOCDIR)$(USER_MANUAL_SRC)
cd $(DOCDIR) && \
pdflatex $(USER_MANUAL_SRC) && \
pdflatex $(USER_MANUAL_SRC)

# target: reference-manual - Build only the reference-manual.
reference-manual:
doxygen Doxyfile

# target: clean-docs - Delete temporary LaTeX files and Doxygen generated reference-manual.
clean-docs: clean-user-manual clean-reference-manual

# target: clean-user-manual - Delete temporary LaTeX files generated when building the user-manual.
clean-user-manual:
-$(RM) $(DOCDIR)$(USER_MANUAL_SRC:.tex=).{aux,log,out,toc}

# target: clean-reference-manual - Delete Doxygen generated reference-manual.
clean-reference-manual:
-$(RMDIR) $(DOCDIR)html
-$(RMDIR) $(DOCDIR)latex

# target: clean-deps - Delete the dependencies created during build.
clean-deps:
-$(RM) $(DEP)

# target: clean-objs - Delete the objects created during build.
clean-objs:
-$(RM) $(OBJ)

# target: clean-bin - Delete the executable generated by the build.
clean-bin:
-$(RM) $(BINDIR)$(BIN)

# target: clean - Delete dependency files, temporary build objects and temporary LaTeX files.
clean: clean-deps clean-objs clean-user-manual

# target: clean-all - Same as clean but also delete Doxygen generated docs, and the executable.
clean-all: clean-deps clean-objs clean-bin clean-docs
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
### Quick start

make ./bin/neurofield -i configs/example.conf -o example.output
doxygen Doxyfile

The html files will be place under `doc/html`
To build the executable on Linux or Mac, open a terminal in the neurofield directory and type:

make

this produces the executable (bin/neurofield). The user-manual is available as doc/NeurofieldManual.pdf.

To build the reference manual, generated from the code, type:

make reference-manual

The html files for the reference-manual will be place under `doc/html`, point your browser at the index.html file in that directory.

For a brief description of available Makefile targets, type:

make help

### Setup guide

**Please check the [NeuroField wiki](https://github.com/BrainDynamicsUSYD/neurofield/wiki) for the setup walkthrough. The instructions below are a standalone summary if you do not have internet access. More detailed instructions are also included in the PDF documentation**

1. Ensure you have a compiler that supports the `C++11` standard. We recommend GCC 4.8 or higher.

2. Type `make` to build the binary `Release/NeuroField`. More information about [cross platform for non-Linux](https://github.com/BrainDynamicsUSYD/neurofield/wiki/Cross-platform-support) systems is also available.
2. Type `make` to build the binary `bin/neurofield`. More information about [cross platform for non-Linux](https://github.com/BrainDynamicsUSYD/neurofield/wiki/Cross-platform-support) systems is also available.

3. Example configurations including examples for published results are available in the `configs` folder.

Expand Down
Binary file modified doc/NeurofieldManual.pdf
Binary file not shown.
26 changes: 19 additions & 7 deletions doc/NeurofieldManual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ \subsection{Directory layout}
\begin{tabular}{l p{13cm}}
\type{src/}& \type{C++} source code.\\
\type{(obj/)}& This folder is created during compilation and stores intermediate object code.\\
\type{(dep/)}& This folder is created during compilation and stores dependency information.\\
\type{(bin/)}& The compiled binary \type{neurofield} is created here.\\
\type{configs/}& Stores example configuration files for \NF.\\
\type{doc/}& Contains this manual.\\
\type{doc/}& Contains this manual and the reference manual once it's built.\\
\type{+nf/}& Matlab package folder containing \NF helper scripts.\\
\type{test/}& Directory for development testing and is irrelevant for users.\\
\end{tabular}
Expand All @@ -128,17 +129,26 @@ \subsection{Compiling NeuroField}
make
\end{lstlisting}

from the root directory. The compiler command is specified in \type{Makefile} and should be edited if you wish to use a different compiler, or if your compiler does not support some of the compiler flags. To run \NF on Windows, we suggest cross-compiling using MinGW on a Unix-like system. Example compiler flags for this are included in \type{Makefile}. Compiling with the Microsoft Visual \type{C++} compiler has not been tested.
from the root directory. The compiler command is specified in \type{Makefile}. On Linux this defaults to \type{g++} and on Mac it defaults to \type{clang++}. To run \NF on Windows, we suggest cross-compiling using MinGW on a Unix-like system. Example compiler flags for this are included in \type{Makefile}. Compiling with the Microsoft Visual \type{C++} compiler has not been tested.

The \type{Makefile} also provides two additional commands. This documentation can be generated by running
The \type{Makefile} also provides a number of additional commands. This documentation along with the reference-manual can be generated by running
\begin{lstlisting}
make doc
make docs
\end{lstlisting}
which will compile the \LaTeX\ files in the \type{doc/} directory. To delete the \NF binary files, object code, and temporary \LaTeX\ files (e.g., to perform a clean compile of the program), you can use
which will recompile the \LaTeX\ files in the \type{doc/} directory if they've been updated since the last time this .pdf was generated, and run doxygen to generate the reference-manual from the source code. The reference manual can then be viewed by pointing your web-browser at

\begin{lstlisting}
doc/html/index.html
\end{lstlisting}

To delete the dependency files, object code, and temporary \LaTeX\ files (e.g., to perform a clean compile of the program), you can use
\begin{lstlisting}
make clean
\end{lstlisting}
which will delete the \type{bin} and \type{obj} folders, as well as the temporary files in \type{doc/}.
which will delete the \type{dep/*.d} and \type{obj/*.o} files, as well as the temporary \LaTeX\ files in \type{doc/}. For a list of additional make targets, including brief descriptions of their function, run
\begin{lstlisting}
make help
\end{lstlisting}

\section{Running NeuroField}
\label{sec:running}
Expand Down Expand Up @@ -544,12 +554,14 @@ \subsubsection{Couple Classes}
\begin{lstlisting}
CaDP - nu: 13e-6 nu_max: 80e-6 Dth: .25e-6 Pth: .45e-6 xyth: 1e-4 x: 2.3e-2 y: 2e-2 B: 30e3 glu_0: 200e-6 gNMDA: 2e-3 t_BCM: 7
\end{lstlisting}
\item[DiffArctan]\ \\

\item[DiffArctan]\ \\
This type of coupling allows the connection strength $\nu_{ab}$ to vary as a function of time, such that $\nu$ can be smoothly ramped up and down.
\begin{lstlisting}
DiffArctan - nu_min: 0.002 nu_max: 0.006 delta: 10 t_half_up:50 t_half_down:100
\end{lstlisting}
where \type{nu\_min} and \type{nu\_max} are the min and max $\nu$'s respectively. \type{delta} determines the slope of the ramp (1/\type{delta}) and is the time interval in which the connection strenght increases (decreases) from 0.25 to 0.75 of \type{nu\_max}. \type{t\_half\_up} and \type{t\_half\_down} are the half way times to maximum and minimum amplitude, respectively.

\end{description}
\end{itemize}

Expand Down

0 comments on commit 01bda8c

Please sign in to comment.