git » sdk » commit e73bfc1

Two ways to generate a makefile

author Stephen Paul Weber
2026-03-10 15:37:50 UTC
committer Stephen Paul Weber
2026-03-10 15:37:50 UTC
parent c57bcf38825d231453f47da123d736255fd30d29

Two ways to generate a makefile

cpp/configure.haxe +21 -0
cpp/configure.simple +11 -0
cpp/make.xslt +74 -0

diff --git a/cpp/configure.haxe b/cpp/configure.haxe
new file mode 100755
index 0000000..71a76bc
--- /dev/null
+++ b/cpp/configure.haxe
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Make a Makefile mostly from the haxe build XML
+
+echo ".PHONY: all" > Makefile
+echo "all: libborogove.so" >> Makefile
+
+echo "CXXFLAGS = -Wno-invalid-offsetof -fPIC -O2 -DHX_LINUX -DHX_SMART_STRINGS=1 -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS" >> Makefile
+echo 'LDFLAGS = -shared -lmbedtls $$(pkg-config --libs sqlite3) $$(pcre2-config --libs16 --libs8)' >> Makefile
+
+xsltproc make.xslt Build.xml >> Makefile
+xsltproc make.xslt $(haxelib libpath hxcpp)toolchain/haxe-target.xml >> Makefile
+xsltproc --stringparam DIR src/hx/libs/std/ make.xslt $(haxelib libpath hxcpp)src/hx/libs/std/Build.xml >> Makefile
+
+echo 'SRCS += src/hx/libs/ssl/SSL.cpp src/hx/libs/sqlite/Sqlite.cpp src/hx/libs/regexp/RegExp.cpp' >> Makefile
+echo 'CXXFLAGS += -DHXCPP_API_LEVEL=$(HXCPP_API_LEVEL)' >> Makefile
+
+echo >> Makefile
+echo 'OBJS = $(SRCS:.cpp=.o)' >> Makefile
+echo 'libborogove.so: $(OBJS)' >> Makefile
+echo '	$(CXX) -o $@ $^ $(LDFLAGS)' >> Makefile
diff --git a/cpp/configure.simple b/cpp/configure.simple
new file mode 100755
index 0000000..9aad884
--- /dev/null
+++ b/cpp/configure.simple
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Create a Makefile just from the sources
+
+echo 'CXXFLAGS=-Wno-invalid-offsetof -fPIC -O2 -DHX_LINUX -DHX_SMART_STRINGS=1 -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=430 -Iinclude' > Makefile
+echo 'LDFLAGS=-shared -lmbedtls -ldatachannel $$(pkg-config --libs sqlite3 opus libstrophe) $$(pcre2-config --libs16 --libs8)' >> Makefile
+echo >> Makefile
+
+printf "libborogove.so: " >> Makefile
+find src -name '*.cpp' -print0 | xargs -0 | sed -e's/\.cpp/\.o/g' >> Makefile
+echo '	$(CXX) -o $@ $^ $(LDFLAGS)' >> Makefile
diff --git a/cpp/make.xslt b/cpp/make.xslt
new file mode 100644
index 0000000..aa5daf9
--- /dev/null
+++ b/cpp/make.xslt
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:param name="DIR" select="''"/>
+  <xsl:output method="text" encoding="utf-8"/>
+
+  <xsl:template match="/xml">
+
+<xsl:for-each select="set[@name and @value]">
+  <xsl:value-of select="@name"/>
+  <xsl:text> = </xsl:text>
+  <xsl:value-of select="@value"/>
+  <xsl:text>
+</xsl:text>
+</xsl:for-each>
+
+<xsl:text>CXXFLAGS += </xsl:text>
+<xsl:value-of select="//compilerflag[1]/@value"/>
+<xsl:text>
+</xsl:text>
+
+<xsl:text>LDFLAGS += </xsl:text>
+<xsl:for-each select="//target/lib[not(@if)]">
+  <xsl:text> </xsl:text>
+  <xsl:value-of select="@name"/>
+</xsl:for-each>
+<xsl:text>
+</xsl:text>
+
+<xsl:text>SRCS += </xsl:text>
+<xsl:for-each select="//files[not(@id='__main__') and not(@id='cppia') and not(@id='tracy')]//file[contains(@name,'.cpp') and not(@if) and not(@unless='HXCPP_TRACY')]">
+<xsl:variable name="src">
+  <xsl:choose>
+    <xsl:when test="starts-with(@name,'${HXCPP}/')">
+      <xsl:value-of select="substring-after(@name,'${HXCPP}/')"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="@name"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+  <xsl:value-of select="concat($DIR, $src)"/>
+  <xsl:text> </xsl:text>
+</xsl:for-each>
+<xsl:text>
+</xsl:text>
+
+<!--
+<xsl:for-each select="//files[not(@id='__main__') and not(@id='cppia') and not(@id='tracy')]//file[contains(@name,'.cpp') and not(@if) and not(@unless='HXCPP_TRACY')]">
+<xsl:variable name="src">
+  <xsl:choose>
+    <xsl:when test="starts-with(@name,'${HXCPP}/')">
+      <xsl:value-of select="substring-after(@name,'${HXCPP}/')"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="@name"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+  <xsl:variable name="obj" select="concat(substring-before($src,'.cpp'),'.o')"/>
+  <xsl:value-of select="$obj"/>
+  <xsl:text>: </xsl:text>
+  <xsl:value-of select="concat($DIR, $src)"/>
+  <xsl:for-each select="depend">
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="@name"/>
+  </xsl:for-each>
+  <xsl:text>
+</xsl:text>
+</xsl:for-each>
+-->
+
+  </xsl:template>
+</xsl:stylesheet>