Tuesday, January 03, 2023

Re: hlsteam - new attempt at hashlink steam middleware library

On 2023/01/01 21:32, Thomas Frohwein wrote:
> Hi,
>
> This is an updated version of my original submission a year ago [1].
> I'm keeping it shorter this time - this does the same as the recently
> committed libcsteamworks [2] for hashlink. This replaces the stub
> library that is part of steamworks-nosteam. Net benefit is improved
> support and maintainability of keeping the following indie games
> runnable on OpenBSD: Dead Cells, Northgard, Dice Tribes: Ambitions,
> Nuclear Blaze, Evoland Legendary Edition, Voidrun, possibly future
> titles.
>
> ok to import?
>
> [1] https://marc.info/?l=openbsd-ports&m=163554939711525&w=2
> [2] https://marc.info/?l=openbsd-ports&m=166753024405818&w=2

Diff on top; this moves from using SUBST_CMD on Makefile to passing
in variables, and uses c++ instead of cc to compile/link which fixes
the recorded deps.

If this still works for you (I have only tested building not runtime)
then OK sthen@

diff --git games/hlsteam/Makefile games/hlsteam/Makefile
index 2d08b83..505ca5a 100644
--- games/hlsteam/Makefile
+++ games/hlsteam/Makefile
@@ -10,21 +10,21 @@ MAINTAINER = Thomas Frohwein <thfr@openbsd.org>

# MIT
PERMIT_PACKAGE = Yes
-WANTLIB += ${COMPILER_LIBCXX} hl steam_api
+
+WANTLIB += ${COMPILER_LIBCXX} hl m steam_api

FIX_CRLF_FILES = Makefile native/gameserver.cpp

-# uses libc++
COMPILER = base-clang ports-gcc
LIB_DEPENDS = games/goldberg_emulator \
lang/hashlink
USE_GMAKE = Yes
NO_TEST = Yes
-SUBST_VARS += CFLAGS LDFLAGS
-CFLAGS += -I${LOCALBASE}/include/goldberg_emulator

-do-gen:
- ${SUBST_CMD} ${WRKSRC}/Makefile
+MAKE_ENV = LDFLAGS="-L${LOCALBASE}/lib" \
+ CXX="${CXX}"
+CFLAGS += -I${LOCALBASE}/include \
+ -I${LOCALBASE}/include/goldberg_emulator

do-install:
${INSTALL_DATA} ${WRKSRC}/steam.hdll ${PREFIX}/lib/
diff --git games/hlsteam/patches/patch-Makefile games/hlsteam/patches/patch-Makefile
index 788e608..6c03fd3 100644
--- games/hlsteam/patches/patch-Makefile
+++ games/hlsteam/patches/patch-Makefile
@@ -1,49 +1,37 @@
-honor CFLAGS, LDFLAGS, and LOCALBASE
-use parentheses to not clash with SUBST_CMD
-
Index: Makefile
--- Makefile.orig
+++ Makefile
-@@ -1,30 +1,11 @@
--LBITS := $(shell getconf LONG_BIT)
-+CFLAGS = ${CFLAGS} -Wall -I src -I native/include -fPIC -I ../sdk/public -I${LOCALBASE}/include
-+LFLAGS = ${LDFLAGS} -lhl -lsteam_api -lstdc++ -L${LOCALBASE}/lib
+@@ -2,7 +2,7 @@ LBITS := $(shell getconf LONG_BIT)
+
+ UNAME := $(shell uname)

--UNAME := $(shell uname)
--
-CFLAGS = -Wall -O3 -I src -I native/include -fPIC -I ../sdk/public
--
--ifndef ARCH
-- ARCH = $(LBITS)
--endif
--
--LIBARCH=$(ARCH)
--ifeq ($(UNAME),Darwin)
--OS=osx
--# universal lib in osx32 dir
--LIBARCH=32
--else
--OS=linux
--CFLAGS += -std=c++0x
--endif
--
++CFLAGS += -Wall -I src -I native/include -fPIC -I ../sdk/public
+
+ ifndef ARCH
+ ARCH = $(LBITS)
+@@ -18,13 +18,13 @@ OS=linux
+ CFLAGS += -std=c++0x
+ endif
+
-LFLAGS = -lhl -lsteam_api -lstdc++ -L native/lib/$(OS)$(LIBARCH) -L ../sdk/redistributable_bin/$(OS)$(ARCH)
--
++LFLAGS = ${LDFLAGS} -lhl -lsteam_api
+
SRC = native/cloud.o native/common.o native/controller.o native/friends.o native/gameserver.o \
native/matchmaking.o native/networking.o native/stats.o native/ugc.o

all: ${SRC}
- ${CC} ${CFLAGS} -shared -o steam.hdll ${SRC} ${LFLAGS}
-+ $(CC) $(CFLAGS) -shared -o steam.hdll ${SRC} $(LFLAGS)
++ ${CXX} ${CFLAGS} -shared -o steam.hdll ${SRC} ${LFLAGS}

install:
cp steam.hdll /usr/lib
-@@ -33,7 +14,7 @@ install:
+@@ -33,7 +33,7 @@ install:
.SUFFIXES : .cpp .o

.cpp.o :
- ${CC} ${CFLAGS} -o $@ -c $<
-+ $(CC) $(CFLAGS) -o $@ -c $<
++ ${CXX} ${CFLAGS} -o $@ -c $<

clean_o:
rm -f ${SRC}

No comments:

Post a Comment