Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile113
1 files changed, 113 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9fe6bd8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,113 @@
+## Copyright 2016 Ian Jauslin
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+
+# whether to link dynamically
+# if static=0 then link dynamically
+# if static=2 then link statically
+# if static=1 then link libinum statically but other libraries dynamically
+STATIC=1
+
+# whether to compile libinum
+LIBINUM_COMPILE=1
+
+VERSION=1.0
+LIBINUM_VERSION=1.0.1
+
+# products of the compilation
+PROJECT_BINS= hhtop
+
+# debug and optimization flags
+#DB= -ggdb
+OPT= -O3
+
+# warning flags
+WARNINGS= -Wall -Wextra -Wno-strict-overflow -std=c99 -pedantic
+
+# compiler
+CC=/usr/bin/gcc
+LD=$(CC)
+AR=/usr/bin/ar
+
+# directories
+INCLUDE =
+LIB =
+
+# flags
+# do not override CLI flags (so they can be pushed to libinum)
+LDFLAGS_HH =$(LDFLAGS) $(LIB)
+CFLAGS_HH =$(CFLAGS) $(INCLUDE) $(DB) $(OPT) $(WARNINGS)
+
+# build directories
+BUILDDIR=./build
+SRCDIR=./src
+OBJDIR=./objs
+
+# objects
+OBJS = $(addprefix $(OBJDIR)/, hh_integral.o hh_root.o hhtop.o parser.o ss_integral.o zz_integral.o hh_integral_double.o hh_root_double.o ss_integral_double.o zz_integral_double.o double_util.o)
+
+# flags which depend on whether to link statically or dynamically
+# lib flag for libinum
+LIBINUM_FLAG=
+# additional library required for static linking
+XTRA_LIBS=
+
+ifeq ($(STATIC),0)
+ XTRA_LIBS=-lm -lmpfr -lgmp -lpthread
+ LIBINUM_FLAG=-linum
+else ($(STATIC),1)
+ # libinum is linked against libm, libmpfr, libgmp and libpthread
+ XTRA_LIBS=-lm -lmpfr -lgmp -lpthread
+ # link binaries using the static library
+ LIBINUM_FLAG=-l:libinum.a
+else ifeq ($(STATIC),2)
+ # libinum is linked against libm, libmpfr, libgmp and libpthread
+ XTRA_LIBS=-lm -lmpfr -lgmp -lpthread
+ LIBINUM_FLAG=-linum
+ # link binaries statically
+ LDFLAGS_HH += -static
+endif
+
+
+LIBINUM_COMPILE_COMMAND=
+ifeq ($(LIBINUM_COMPILE),1)
+ LIBINUM_COMPILE_COMMAND=libinum
+ LDFLAGS_HH += -L./libinum-$(LIBINUM_VERSION)/build
+ CFLAGS_HH += -I./libinum-$(LIBINUM_VERSION)/include
+endif
+
+
+
+all: $(LIBINUM_COMPILE_COMMAND) init hhtop
+
+# compile libinum
+libinum:
+ tar xzf ./libinum-$(LIBINUM_VERSION).tar.gz
+ make STATIC=0 CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" AR="$(AR)" OPT="$(OPT)" DB="$(DB)" INCLUDE="$(INCLUDE)" LIB="$(LIB)" -C ./libinum-$(LIBINUM_VERSION)
+
+# create dirs
+init:
+ @[ -d $(OBJDIR) ] || /bin/mkdir $(OBJDIR)
+ @[ -d $(BUILDDIR) ] || /bin/mkdir $(BUILDDIR)
+
+
+hhtop: $(OBJS)
+ $(LD) $(LDFLAGS_HH) -o $(BUILDDIR)/$@ $^ $(LIBINUM_FLAG) $(XTRA_LIBS)
+
+%.o : ../$(SRCDIR)/%.c
+ $(CC) -c $(CFLAGS_HH) $< -o $@
+
+clean:
+ @rm -rf $(OBJDIR)
+ @rm -rf $(BUILDDIR)
+ @rm -rf libinum-$(LIBINUM_VERSION)