summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-04 21:44:15 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-04 21:44:15 -0400
commit7371d1028b20e72991cba0fd85469f8dd953ca1d (patch)
treec83eb340df3eb33e924cb94e436de55def2f0d74
parent9ddd0a948238ba910710321401674a01df874ba6 (diff)
build: Restructured project
-rw-r--r--.gitmodules3
-rw-r--r--Makefile28
-rw-r--r--example/Makefile18
-rw-r--r--example/example.mat (renamed from example.mat)bin192 -> 192 bytes
-rw-r--r--example/libMatfile-test.m4
-rw-r--r--example/main.c (renamed from src/main.c)2
m---------mk0
-rw-r--r--src/Makefile18
-rw-r--r--test.matbin224 -> 0 bytes
9 files changed, 52 insertions, 21 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..e4be46b
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "mk"]
+ path = mk
+ url = https://git.mcdonnell.dev/gnu-make-templates.git
diff --git a/Makefile b/Makefile
index 7746ba9..4bb3bef 100644
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,9 @@
-CC = gcc-15
-CFLAGS = -std=c17 \
- -Wall \
- -Werror \
- -Wextra \
- -Wpedantic \
- -Iinclude
-SRCS = src/main.c \
- src/matfile.c
-PROG = main
-
-all: $(PROG)
-
-$(PROG): $(SRCS)
- $(CC) $(CFLAGS) -o $@ $^
-
-clean:
- rm -rf $(PROG)
-
-.PHONY: all clean
+#
+# Copyright (c) 2026 Jacob McDonnell
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+SUBDIRS = src example
+
+include mk/mk/mcd.subdir.mk
diff --git a/example/Makefile b/example/Makefile
new file mode 100644
index 0000000..6284df3
--- /dev/null
+++ b/example/Makefile
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2026 Jacob McDonnell
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+PROG = main
+SRCS = main.c
+CFLAGS = -Wall \
+ -Werror \
+ -Wextra \
+ -Wpedantic \
+ -I../include
+ -std=c17
+LDFLAGS = -L../src \
+ -lMatfile
+
+include ../mk/mk/mcd.prog.mk
+
diff --git a/example.mat b/example/example.mat
index 28494a0..28494a0 100644
--- a/example.mat
+++ b/example/example.mat
Binary files differ
diff --git a/example/libMatfile-test.m b/example/libMatfile-test.m
new file mode 100644
index 0000000..51870db
--- /dev/null
+++ b/example/libMatfile-test.m
@@ -0,0 +1,4 @@
+load "test.mat"
+disp(A);
+disp(doubles);
+
diff --git a/src/main.c b/example/main.c
index dda67fe..bda4c89 100644
--- a/src/main.c
+++ b/example/main.c
@@ -1,7 +1,7 @@
#include <assert.h>
+#include <matfile.h>
#include <stdio.h>
#include <string.h>
-#include "matfile.h"
double floats[5] = {0.0, 1.0, 3.14, 2.72, 5.5};
diff --git a/mk b/mk
new file mode 160000
+Subproject d28e14493a7938a1bf63623a724edb665eb196c
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..2068926
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2026 Jacob McDonnell
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+LIB = Matfile
+SHLIB_MAJOR = 1
+SHLIB_MINOR = 1
+CFLAGS = -Wall \
+ -Werror \
+ -Wextra \
+ -Wpedantic \
+ -std=c17 \
+ -I../include
+SRCS = matfile.c
+
+include ../mk/mk/mcd.lib.mk
+
diff --git a/test.mat b/test.mat
deleted file mode 100644
index a338ead..0000000
--- a/test.mat
+++ /dev/null
Binary files differ