aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Romanko <me@blankhex.com>2025-06-21 21:17:27 +0300
committerMikhail Romanko <me@blankhex.com>2025-06-21 21:17:27 +0300
commit7662c3e32bc621b2ad24c94d4282960638eab4c3 (patch)
tree345534a01c7c3ae993f535803fa763994ac8fc6c
parentfc774fd0ff6d06ceed25c5b8ba8a0d58cb77e52b (diff)
downloadbhlib-7662c3e32bc621b2ad24c94d4282960638eab4c3.tar.gz
Add Makefiles to build binaries and docs
-rw-r--r--.gitignore1
-rw-r--r--Makefile24
-rw-r--r--Makefile.gnu49
-rw-r--r--Makefile.mingw50
-rw-r--r--Makefile.osx50
-rw-r--r--Makefile.srcs91
-rw-r--r--doc/Manual/en/Makefile70
-rw-r--r--doc/Manual/ru/Makefile70
8 files changed, 404 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index f906edb..26e5a1b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,6 @@ CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
-Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..48ccd3e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+# Determine OS
+OS = $(shell uname)
+MAKEFILE = gnu
+
+ifeq ($(OS), Darwin)
+ MAKEFILE = osx
+endif
+ifeq ($(OS), windows32)
+ MAKEFILE = mingw
+endif
+
+
+# Targets
+default:
+ $(MAKE) -f Makefile.$(MAKEFILE)
+
+all:
+ $(MAKE) -f Makefile.$(MAKEFILE) all
+
+dist:
+ $(MAKE) -f Makefile.$(MAKEFILE) dist
+
+clean:
+ $(MAKE) -f Makefile.$(MAKEFILE) clean
diff --git a/Makefile.gnu b/Makefile.gnu
new file mode 100644
index 0000000..d8b039b
--- /dev/null
+++ b/Makefile.gnu
@@ -0,0 +1,49 @@
+# GNU makefile
+
+
+# User configuration
+DESTDIR ?= /local
+CFLAGS ?= -fPIC -O2 -Iinclude
+LDFLAGS ?= -lm
+TARGET = bh
+ENABLE_MT = 1
+
+
+# System configuration
+include Makefile.srcs
+
+SRCS += $(SRCS_POSIX)
+ifeq ($(ENABLE_MT), 1)
+ SRCS += $(SRCS_POSIX_MT)
+ CFLAGS += -pthread
+ LDFLAGS += -lpthread
+else
+ SRCS += $(SRCS_DUMMY_MT)
+endif
+
+INCDIR ?= $(DESTDIR)/usr/include
+INSTALLDIR ?= $(DESTDIR)/usr/lib
+STATICLIB = lib$(TARGET).a
+SHAREDLIB = lib$(TARGET).so
+OBJS = $(SRCS:.c=.o)
+
+
+# Targets
+all: $(STATICLIB) $(SHAREDLIB)
+
+dist: $(STATICLIB) $(SHAREDLIB)
+ mkdir -p dist
+ cp *.a dist/
+ cp *.so dist/
+
+$(STATICLIB): $(OBJS)
+ $(AR) r $@ $(OBJS)
+
+$(SHAREDLIB): $(OBJS)
+ $(CC) -s -shared $(LDFLAGS) -o $@ $(OBJS)
+
+.c.o:
+ $(CC) $(CFLAGS) -c $< -o $@
+
+clean:
+ -rm -rf $(OBJS) $(STATICLIB) $(SHAREDLIB) dist
diff --git a/Makefile.mingw b/Makefile.mingw
new file mode 100644
index 0000000..3345e77
--- /dev/null
+++ b/Makefile.mingw
@@ -0,0 +1,50 @@
+# GNU makefile
+
+
+# User configuration
+DESTDIR ?= /local
+CFLAGS ?= -fPIC -O2 -Iinclude
+LDFLAGS ?= -lm
+TARGET = bh
+ENABLE_MT = 1
+CC = gcc
+
+
+# System configuration
+include Makefile.srcs
+
+SRCS += $(SRCS_WIN32)
+ifeq ($(ENABLE_MT), 1)
+ SRCS += $(SRCS_WIN32_MT)
+ CFLAGS += -pthread
+ LDFLAGS += -lpthread
+else
+ SRCS += $(SRCS_DUMMY_MT)
+endif
+
+INCDIR ?= $(DESTDIR)/usr/include
+INSTALLDIR ?= $(DESTDIR)/usr/lib
+STATICLIB = lib$(TARGET).a
+SHAREDLIB = lib$(TARGET).so
+OBJS = $(SRCS:.c=.o)
+
+
+# Targets
+all: $(STATICLIB) $(SHAREDLIB)
+
+dist: $(STATICLIB) $(SHAREDLIB)
+ mkdir -p dist
+ cp *.a dist/
+ cp *.so dist/
+
+$(STATICLIB): $(OBJS)
+ $(AR) r $@ $(OBJS)
+
+$(SHAREDLIB): $(OBJS)
+ $(CC) -s -shared $(LDFLAGS) -o $@ $(OBJS)
+
+.c.o:
+ $(CC) $(CFLAGS) -c $< -o $@
+
+clean:
+ -rm -rf $(OBJS) $(STATICLIB) $(SHAREDLIB) dist
diff --git a/Makefile.osx b/Makefile.osx
new file mode 100644
index 0000000..6447a07
--- /dev/null
+++ b/Makefile.osx
@@ -0,0 +1,50 @@
+# GNU makefile
+
+
+# User configuration
+DESTDIR ?= /local
+CFLAGS ?= -fPIC -O2 -Iinclude
+LDFLAGS ?= -lm
+TARGET = bh
+ENABLE_MT = 1
+CC = clang
+
+
+# System configuration
+include Makefile.srcs
+
+SRCS += $(SRCS_POSIX)
+ifeq ($(ENABLE_MT), 1)
+ SRCS += $(SRCS_POSIX_MT)
+ CFLAGS += -pthread
+ LDFLAGS += -lpthread
+else
+ SRCS += $(SRCS_DUMMY_MT)
+endif
+
+INCDIR ?= $(DESTDIR)/usr/include
+INSTALLDIR ?= $(DESTDIR)/usr/lib
+STATICLIB = lib$(TARGET).a
+SHAREDLIB = lib$(TARGET).so
+OBJS = $(SRCS:.c=.o)
+
+
+# Targets
+all: $(STATICLIB) $(SHAREDLIB)
+
+dist: $(STATICLIB) $(SHAREDLIB)
+ mkdir -p dist
+ cp *.a dist/
+ cp *.so dist/
+
+$(STATICLIB): $(OBJS)
+ $(AR) r $@ $(OBJS)
+
+$(SHAREDLIB): $(OBJS)
+ $(CC) -s -shared $(LDFLAGS) -o $@ $(OBJS)
+
+.c.o:
+ $(CC) $(CFLAGS) -c $< -o $@
+
+clean:
+ -rm -rf $(OBJS) $(STATICLIB) $(SHAREDLIB) dist
diff --git a/Makefile.srcs b/Makefile.srcs
new file mode 100644
index 0000000..87b4ed3
--- /dev/null
+++ b/Makefile.srcs
@@ -0,0 +1,91 @@
+# Source files
+
+SRCS = src/Algo.c \
+ src/Args.c \
+ src/Buffer.c \
+ src/Bytes.c \
+ src/Hashmap.c \
+ src/IO.c \
+ src/Math/Box2f.c \
+ src/Math/Box3f.c \
+ src/Math/Line.c \
+ src/Math/Mat3f.c \
+ src/Math/Mat4f.c \
+ src/Math/Misc.c \
+ src/Math/Plane.c \
+ src/Math/Quat4f.c \
+ src/Math/Ray2f.c \
+ src/Math/Ray3f.c \
+ src/Math/Vec2f.c \
+ src/Math/Vec2i.c \
+ src/Math/Vec3f.c \
+ src/Math/Vec3i.c \
+ src/Math/Vec4f.c \
+ src/Math/Vec4i.c \
+ src/Platform/Spinlock.c \
+ src/Queue.c \
+ src/String/Float.c \
+ src/String/Int.c \
+ src/String/Unicode.c \
+ src/Util.c
+
+SRCS_DUMMY = src/Platform/Dummy/File.c
+
+SRCS_DUMMY_MT = src/Platform/Dummy/Condition.c \
+ src/Platform/Dummy/Mutex.c \
+ src/Platform/Dummy/Semaphore.c \
+ src/Platform/Dummy/Thread.c \
+ src/Platform/Dummy/Tss.c
+
+SRCS_POSIX = src/Platform/Posix/File.c
+
+SRCS_POSIX_MT = src/Platform/Posix/Condition.c \
+ src/Platform/Posix/Mutex.c \
+ src/Platform/Posix/Semaphore.c \
+ src/Platform/Posix/Thread.c \
+ src/Platform/Posix/Tss.c
+
+SRCS_WIN32 = src/Platform/Win32/File.c
+
+SRCS_WIN32_MT = src/Platform/Win32/Condition.c \
+ src/Platform/Win32/Mutex.c \
+ src/Platform/Win32/Semaphore.c \
+ src/Platform/Win32/Thread.c \
+ src/Platform/Win32/Tss.c
+
+INCS = include/BH/Algo.h \
+ include/BH/Args.h \
+ include/BH/Common.h \
+ include/BH/Hashmap.h \
+ include/BH/IO.h \
+ include/BH/Math/Box2f.h \
+ include/BH/Math/Box3f.h \
+ include/BH/Math/Line.h \
+ include/BH/Math/Mat3f.h \
+ include/BH/Math/Mat4f.h \
+ include/BH/Math/Misc.h \
+ include/BH/Math/Plane.h \
+ include/BH/Math/Quat.h \
+ include/BH/Math/Ray2f.h \
+ include/BH/Math/Ray3f.h \
+ include/BH/Math/Vec2f.h \
+ include/BH/Math/Vec2i.h \
+ include/BH/Math/Vec3f.h \
+ include/BH/Math/Vec3i.h \
+ include/BH/Math/Vec4f.h \
+ include/BH/Math/Vec4i.h \
+ include/BH/Queue.h \
+ include/BH/String.h \
+ include/BH/Thread.h \
+ include/BH/Unicode.h \
+ include/BH/Util.h
+
+INCS_DUMMY_MT = src/Platform/Dummy/Thread.h
+
+INCS_POSIX_MT = src/Platform/Posix/Thread.h
+
+INCS_WIN32_MT = src/Platform/Win32/Thread.h
+
+SRCS_UNIT = unit/src/Unit.c
+
+INCS_UNIT = unit/include/BH/Unit.h
diff --git a/doc/Manual/en/Makefile b/doc/Manual/en/Makefile
new file mode 100644
index 0000000..c42065a
--- /dev/null
+++ b/doc/Manual/en/Makefile
@@ -0,0 +1,70 @@
+POD2HTML = pod2html
+POD2MAN = pod2man
+
+HTMLS = BH_Algo.html \
+ BH_Args.html \
+ BH_Box2f.html \
+ BH_Box3f.html \
+ BH_Hashmap.html \
+ BH_IO.html \
+ BH_Line.html \
+ BH_Mat3f.html \
+ BH_Mat4f.html \
+ BH_Math.html \
+ BH_Plane.html \
+ BH_Quat.html \
+ BH_Queue.html \
+ BH_Ray2f.html \
+ BH_Ray3f.html \
+ BH_String.html \
+ BH_Thread.html \
+ BH_Unicode.html \
+ BH_Util.html \
+ BH_Vec2f.html \
+ BH_Vec2i.html \
+ BH_Vec3f.html \
+ BH_Vec3i.html \
+ BH_Vec4f.html \
+ BH_Vec4i.html
+
+MANS = BH_Algo.3 \
+ BH_Args.3 \
+ BH_Box2f.3 \
+ BH_Box3f.3 \
+ BH_Hashmap.3 \
+ BH_IO.3 \
+ BH_Line.3 \
+ BH_Mat3f.3 \
+ BH_Mat4f.3 \
+ BH_Math.3 \
+ BH_Plane.3 \
+ BH_Quat.3 \
+ BH_Queue.3 \
+ BH_Ray2f.3 \
+ BH_Ray3f.3 \
+ BH_String.3 \
+ BH_Thread.3 \
+ BH_Unicode.3 \
+ BH_Util.3 \
+ BH_Vec2f.3 \
+ BH_Vec2i.3 \
+ BH_Vec3f.3 \
+ BH_Vec3i.3 \
+ BH_Vec4f.3 \
+ BH_Vec4i.3
+
+all: $(MANS) $(HTMLS)
+
+%.3: %.pod
+ $(POD2MAN) -c "BHLib" -s 3 -r "0.1.0" $< $@
+
+%.html: %.pod
+ $(POD2HTML) --css ../style.css --htmlroot=. --podpath=. $< --outfile $@
+
+dist: $(MANS) $(HTMLS)
+ zip html.zip $(HTMLS)
+ zip man.zip $(MANS)
+
+clean:
+ -rm -f $(MANS) $(HTMLS) pod2htmd.tmp man.zip html.zip
+
diff --git a/doc/Manual/ru/Makefile b/doc/Manual/ru/Makefile
new file mode 100644
index 0000000..c42065a
--- /dev/null
+++ b/doc/Manual/ru/Makefile
@@ -0,0 +1,70 @@
+POD2HTML = pod2html
+POD2MAN = pod2man
+
+HTMLS = BH_Algo.html \
+ BH_Args.html \
+ BH_Box2f.html \
+ BH_Box3f.html \
+ BH_Hashmap.html \
+ BH_IO.html \
+ BH_Line.html \
+ BH_Mat3f.html \
+ BH_Mat4f.html \
+ BH_Math.html \
+ BH_Plane.html \
+ BH_Quat.html \
+ BH_Queue.html \
+ BH_Ray2f.html \
+ BH_Ray3f.html \
+ BH_String.html \
+ BH_Thread.html \
+ BH_Unicode.html \
+ BH_Util.html \
+ BH_Vec2f.html \
+ BH_Vec2i.html \
+ BH_Vec3f.html \
+ BH_Vec3i.html \
+ BH_Vec4f.html \
+ BH_Vec4i.html
+
+MANS = BH_Algo.3 \
+ BH_Args.3 \
+ BH_Box2f.3 \
+ BH_Box3f.3 \
+ BH_Hashmap.3 \
+ BH_IO.3 \
+ BH_Line.3 \
+ BH_Mat3f.3 \
+ BH_Mat4f.3 \
+ BH_Math.3 \
+ BH_Plane.3 \
+ BH_Quat.3 \
+ BH_Queue.3 \
+ BH_Ray2f.3 \
+ BH_Ray3f.3 \
+ BH_String.3 \
+ BH_Thread.3 \
+ BH_Unicode.3 \
+ BH_Util.3 \
+ BH_Vec2f.3 \
+ BH_Vec2i.3 \
+ BH_Vec3f.3 \
+ BH_Vec3i.3 \
+ BH_Vec4f.3 \
+ BH_Vec4i.3
+
+all: $(MANS) $(HTMLS)
+
+%.3: %.pod
+ $(POD2MAN) -c "BHLib" -s 3 -r "0.1.0" $< $@
+
+%.html: %.pod
+ $(POD2HTML) --css ../style.css --htmlroot=. --podpath=. $< --outfile $@
+
+dist: $(MANS) $(HTMLS)
+ zip html.zip $(HTMLS)
+ zip man.zip $(MANS)
+
+clean:
+ -rm -f $(MANS) $(HTMLS) pod2htmd.tmp man.zip html.zip
+