Add Makefiles to build binaries and docs

This commit is contained in:
2025-06-21 21:17:27 +03:00
parent fc774fd0ff
commit 7662c3e32b
8 changed files with 404 additions and 1 deletions

1
.gitignore vendored
View File

@@ -4,7 +4,6 @@ CMakeCache.txt
CMakeFiles CMakeFiles
CMakeScripts CMakeScripts
Testing Testing
Makefile
cmake_install.cmake cmake_install.cmake
install_manifest.txt install_manifest.txt
compile_commands.json compile_commands.json

24
Makefile Normal file
View File

@@ -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

49
Makefile.gnu Normal file
View File

@@ -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

50
Makefile.mingw Normal file
View File

@@ -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

50
Makefile.osx Normal file
View File

@@ -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

91
Makefile.srcs Normal file
View File

@@ -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

70
doc/Manual/en/Makefile Normal file
View File

@@ -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

70
doc/Manual/ru/Makefile Normal file
View File

@@ -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