aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-11-23 16:09:08 +0100
committerAnton Khirnov <anton@khirnov.net>2022-11-23 16:27:59 +0100
commitbda9a532a8edfbac51717979fc11117a9bdfee30 (patch)
tree25e8772b8cd86e4034c6c12dc6f6d31fef769e83
parent71c57b6bb58ac03699e0c9723c9a5765e2526690 (diff)
Preliminary make support.make
-rw-r--r--Makefile52
-rw-r--r--config.asm6
-rw-r--r--config.h10
3 files changed, 68 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ddf36c8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,52 @@
+TARGET = libmg2d.so
+
+CC = cc
+
+SRC_DIR = ./src/
+
+VPATH = $(SRC_DIR)
+
+CFLAGS = -std=c11 -fPIC
+CFLAGS += -g -O3
+CFLAGS += -D_XOPEN_SOURCE=700 # POSIX
+CFLAGS += -D_DEFAULT_SOURCE=1 # for random_r
+CFLAGS += -I$(SRC_DIR)/
+
+TARGET_LDFLAGS = -Wl,--version-script=$(SRC_DIR)/libmg2d.v -shared -lm -llapacke -lthreadpool -lndarray -lmpi
+TEST_LIBS = -lm -llapacke -lcblas -lpthread
+
+OBJS = \
+ bicgstab.c.o \
+ boundary.c.o \
+ components.c.o \
+ cpu.c.o \
+ cpuid.asm.o \
+ ell_grid_solve.c.o \
+ log.c.o \
+ mg2d.o \
+ ndarray.asm.o \
+ residual_calc.asm.o \
+ residual_calc.c.o \
+ step_control.c.o \
+ timer.c.o \
+ transfer.c.o \
+ transfer_interp.asm.o \
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS)
+ $(CC) -o $@ $(OBJS) ${TARGET_LDFLAGS}
+
+%.c.o: %.c
+ $(CC) $(CFLAGS) -MMD -MF $(@:.o=.d) -MT $@ -c -o $@ $<
+
+%.asm.o: %.asm
+ nasm -i $(SRC_DIR) -f elf64 -M $< > $(@:.o=.d)
+ nasm -i $(SRC_DIR) -f elf64 -o $@ $<
+
+clean:
+ -rm -f *.o *.d *.pyc $(TARGET)
+
+-include $(OBJS:.o=.d)
+
+.PHONY: clean
diff --git a/config.asm b/config.asm
new file mode 100644
index 0000000..9eaa8e4
--- /dev/null
+++ b/config.asm
@@ -0,0 +1,6 @@
+%define ARCH_X86 1
+
+%define ARCH_X86_32 0
+
+%define ARCH_X86_64 1
+
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..ab9aef0
--- /dev/null
+++ b/config.h
@@ -0,0 +1,10 @@
+#ifndef MG2D_CONFIG_H
+#define MG2D_CONFIG_H
+
+#define ARCH_X86 1
+
+#define ARCH_X86_64 1
+
+#define HAVE_EXTERNAL_ASM 1
+
+#endif // MG2D_CONFIG_H