replace wtih new build system

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@615 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-11-07 16:52:34 +00:00
parent bfdb585dcf
commit ca054c70dd
24 changed files with 218 additions and 250 deletions

14
m4/options/backend.m4 Normal file
View File

@@ -0,0 +1,14 @@
dnl $Id$
ifdef([use_x11],[add_cflag([-DUSE_X11])dnl
add_lib([-lX11 -lXrender -lXcursor])dnl
new_object([src/backend/x11.c])dnl
define([gl_lib],[-lGL -lGLU])])dnl
dnl
ifdef([use_gdi],[add_cflag([-DUSE_GDI])dnl
add_lib([-lgdi32])dnl
new_object([src/backend/gdi.c])dnl
define([gl_lib],[-lopengl32 -lglu32])])dnl
dnl
ifdef([use_darwin],[add_cflag([-DUSE_DARWIN -DSTBI_NO_THREAD_LOCALS])dnl
new_object([src/backend/mac/*.c])dnl
define([gl_lib],[])])dnl

9
m4/options/opengl.m4 Normal file
View File

@@ -0,0 +1,9 @@
dnl $Id$
ifdef([build_opengl],[new_object([src/widget/opengl.c])dnl
new_example([examples/gldemos/boing],[],[],[gl_lib])dnl
new_example([examples/gldemos/clock],[],[],[gl_lib])dnl
new_example([examples/gldemos/cube],[],[],[gl_lib])dnl
new_example([examples/gldemos/gears],[],[],[gl_lib])dnl
new_example([examples/gldemos/triangle],[],[],[gl_lib])dnl
new_example([examples/gldemos/tripaint],[],[],[gl_lib])dnl
])dnl

4
m4/options/vulkan.m4 Normal file
View File

@@ -0,0 +1,4 @@
dnl $Id$
ifdef([build_vulkan],[new_object([src/widget/vulkan.c])dnl
new_example([examples/vkdemos/vulkan])dnl
])dnl

17
m4/toplevel/options.m4 Normal file
View File

@@ -0,0 +1,17 @@
dnl $Id$
include(m4/options/backend.m4)dnl
include(m4/options/opengl.m4)dnl
include(m4/options/vulkan.m4)dnl
dnl
ifdef([use_stb_image],[add_cflag([-DUSE_STB_IMAGE])],[new_object([external/libz/src/*.c])dnl
new_object([external/libjpeg/src/*.c])dnl
new_object([external/libpng/src/*.c])dnl
add_cflag([-Iexternal/libz/include])dnl
add_cflag([-Iexternal/libjpeg/include])dnl
add_cflag([-Iexternal/libpng/include])])dnl
dnl
ifdef([use_stb_truetype],[add_cflag([-DUSE_STB_TRUETYPE])])dnl
dnl
ifdef([use_freetype2],[add_cflag([-DUSE_FREETYPE2])dnl
ifdef([cross_build],[],[add_cflag(esyscmd([pkg-config --cflags freetype2 | xargs printf '%s ']))dnl
add_lib(esyscmd([pkg-config --libs freetype2 | xargs printf '%s ']))])])dnl

51
m4/toplevel/rules.m4 Normal file
View File

@@ -0,0 +1,51 @@
dnl $Id$
changequote([,])dnl
include(m4/util/quote.m4)dnl
include(m4/util/arg.m4)dnl
include(m4/util/foreach.m4)dnl
include(m4/util/comma.m4)dnl
include(m4/util/default.m4)dnl
dnl
default_define([cc],[gcc])dnl
default_define([cflags],[-D_MILSKO])dnl
default_define([incdir],[-I include])dnl
default_define([ldflags],[])dnl
default_define([libdir],[])dnl
default_define([libs],[])dnl
default_define([math],[-lm])dnl
default_define([shared_flag],[-shared])dnl
dnl
define([object_suffix],[.o])dnl
define([library_prefix],[lib])dnl
define([library_suffix],[.so])dnl
define([executable_suffix],[])dnl
dnl
define([library_targets],[])dnl
define([library_objects],[])dnl
define([new_object],[pushdef([source])define([source],patsubst(patsubst(patsubst(esyscmd([ls -d $1]),[\..+$],object_suffix),[
],[ ]),[ $],[]))define([library_targets],ifelse(library_targets,[],[source],[library_targets source]))popdef([source])])dnl
define([print_library_targets],[foreach(x,space_to_comma(library_targets),[pushdef([source])define([source],[patsubst(x,[\]object_suffix[$],[.c])])dnl
x: source
$(CC) -c -fPIC $(INCDIR) $(CFLAGS) -o x source
popdef([source])])])dnl
dnl
define([examples_targets],[])dnl
define([new_example],[define($1[]_cflag,[$2])dnl
define($1[]_ldflag,[$3])dnl
define($1[]_lib,[$4])dnl
define([examples_targets],ifelse(examples_targets,[],[$1[]executable_suffix],[examples_targets $1[]executable_suffix]))])dnl
define([print_examples_targets],[foreach(x,space_to_comma(examples_targets),[pushdef(base)dnl
define([base],patsubst(x,[\..+$],[]))dnl
x: base[]object_suffix library
$(CC) -L src -Wl,-R./src $(LIBDIR) indir(base[]_ldflag) -o x base[]object_suffix -lMw $(MATH) indir(base[]_lib)
base[]object_suffix: base.c
$(CC) -c $(INCDIR) -o base[]object_suffix indir(base[]_cflag) base.c
popdef([base])])])dnl
dnl
define([add_incdir],[define([incdir],quote(incdir) [$*])])dnl
define([add_cflag],[define([cflags],quote(cflags) [$*])])dnl
define([add_libdir],[define([libdir],quote(libdir) [$*])])dnl
define([add_ldflag],[define([ldflags],quote(ldflags) [$*])])dnl
define([add_lib],[define([libs],quote(libs) [$*])])dnl
dnl

2
m4/util/arg.m4 Normal file
View File

@@ -0,0 +1,2 @@
dnl $Id$
define([arg1],[$1])dnl

3
m4/util/comma.m4 Normal file
View File

@@ -0,0 +1,3 @@
dnl $Id$
define([space_to_comma],[_space_to_comma(patsubst([$*],[ ],[,]))])dnl
define([_space_to_comma],[ifelse([$#],[0],[],[$#],[1],[$1],[$1[,]_space_to_comma(shift($@))])])dnl

2
m4/util/default.m4 Normal file
View File

@@ -0,0 +1,2 @@
dnl $Id$
define([default_define],[ifdef([$1],[],[define([$1],[$2])])])dnl

3
m4/util/foreach.m4 Normal file
View File

@@ -0,0 +1,3 @@
dnl $Id$
define([foreach],[pushdef([$1])_foreach($@)popdef([$1])])dnl
define([_foreach],[ifelse(quote($2),[],[],[define([$1],[arg1($2)])$3[]_foreach([$1],[shift($2)],[$3])])])dnl

2
m4/util/quote.m4 Normal file
View File

@@ -0,0 +1,2 @@
dnl $Id$
define([quote],[ifelse([$#],[0],[],[[$*]])])dnl