Update README.md, update makefiles, add .bat scripts for msvc

This commit is contained in:
Roman Chistokhodov 2017-12-09 00:16:29 +03:00
parent f9267125c1
commit e6ea89705f
6 changed files with 291 additions and 15 deletions

View File

@ -6,22 +6,41 @@ Half-Life SDK for Xash3D & GoldSource with some fixes.
### CMake as most universal way
```
mkdir build && cd build
cmake ../
```
mkdir build && cd build
cmake ../
make
You may enable or disable some build options by -Dkey=value. All available build options are defined in CMakeLists.txt at root directory.
See below if you want to build the GoldSource compatible libraries.
See below, if CMake is not suitable for you:
### Windows
#### Using msvc
We use compilers provided with Microsoft Visual Studio 6. There're `compile.bat` scripts in both `cl_dll` and `dlls` directories.
Before running any of those files you must define `MSVCDir` variable which is the path to your msvc installation.
set MSVCDir=C:\Program Files\Microsoft Visual Studio
compile.bat
These scripts also can be ran via wine:
MSVCDir="z:\home\$USER\.wine\drive_c\Program Files\Microsoft Visual Studio" wine cmd /c compile.bat
The libraries built this way are always GoldSource compatible.
There're dsp projects for MVS 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer MVS versions.
#### Using mingw
TODO
### Linux
TODO
(cd dlls && make)
(cd cl_dll && make)
### OS X
@ -29,14 +48,65 @@ TODO
### FreeBSD
```
cd dlls
gmake CXX=clang++ CC=clang
cd ../cl_dll
gmake CXX=clang++ CC=clang
```
(cd dlls && gmake CXX=clang++ CC=clang)
(cd cl_dll && gmake CXX=clang++ CC=clang)
### Android
Just typical `ndk-build`.
TODO: describe what it is.
### Building GoldSource-compatible libraries
To enable building the goldsource compatible client library add GOLDSOURCE_SUPPORT flag when calling cmake:
cmake .. -DGOLDSOURCE_SUPPORT=ON
or when using make without cmake:
make GOLDSOURCE_SUPPORT=1
Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d.
Note for **Linux**: GoldSource requires libraries (both client and server) to be compiled with libstdc++ bundled with g++ of major version 4 (versions from 4.6 to 4.9 should work).
If your Linux distribution does not provide compatible g++ version you have several options.
#### Method 1: Statically build with c++ library
This one is the most simple but has a drawback.
cmake ../ -DGOLDSOURCE_SUPPORT=ON -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc"
The drawback is that the compiled libraries will be larger in size.
#### Method 2: Create and use chroot with older distro that includes g++ 4.
Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Debian (and similar) you can use debootstrap.
sudo debootstrap --arch=i386 jessie /var/chroot/jessie-debian-i386 # On Ubuntu type trusty instead of jessie
sudo chroot /var/chroot/jessie-debian-i386
Inside chroot install cmake, make, g++ and libsdl2-dev. Then exit the chroot.
On the host system install schroot. Then create and adapt the following config in /etc/schroot/chroot.d/jessie.conf (you can choose a different name):
```
[jessie]
type=directory
description=Debian jessie i386
directory=/var/chroot/debian-jessie-i386/
users=yourusername
groups=yourusername
root-groups=root
preserve-environment=true
personality=linux32
```
Insert your actual user name in place of `yourusername`. Then prepend any make or cmake call with `schroot -c jessie --`:
schroot -c jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON
schroot -c jessie -- make
#### Method 3: Install the needed g++ version yourself
TODO: describe steps.

View File

@ -105,7 +105,9 @@ LOCAL_CFLAGS += $(DEFINES) $(INCLUDES)
ifeq ($(GOLDSOURCE_SUPPORT),1)
DEFINES += -DGOLDSOURCE_SUPPORT
LOCAL_LDLIBS += -lSDL2
ifeq ($(shell uname -s),Linux)
LOCAL_LDLIBS += -ldl
endif
endif
LOCAL_SRC_FILES := $(SRCS) $(SRCS_C)

View File

@ -75,7 +75,6 @@ OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o)
LIBS=-lm
ifeq ($(GOLDSOURCE_SUPPORT),1)
DEFINES += -DGOLDSOURCE_SUPPORT
LIBS += -lSDL2
endif
ifeq ($(shell uname -s),Linux)

84
cl_dll/compile.bat Normal file
View File

@ -0,0 +1,84 @@
@echo off
echo Setting environment for minimal Visual C++ 6
set INCLUDE=%MSVCDir%\VC98\Include
set LIB=%MSVCDir%\VC98\Lib
set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH%
echo -- Compiler is MSVC6
set XASH3DSRC=..\..\Xash3D_original
set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public -I../external -I../dlls -I../utils/false_vgui/include
set SOURCES=../dlls/crossbow.cpp^
../dlls/crowbar.cpp^
../dlls/egon.cpp^
../dlls/gauss.cpp^
../dlls/handgrenade.cpp^
../dlls/hornetgun.cpp^
../dlls/mp5.cpp^
../dlls/python.cpp^
../dlls/rpg.cpp^
../dlls/satchel.cpp^
../dlls/shotgun.cpp^
../dlls/squeakgrenade.cpp^
../dlls/tripmine.cpp^
../dlls/glock.cpp^
ev_hldm.cpp^
hl/hl_baseentity.cpp^
hl/hl_events.cpp^
hl/hl_objects.cpp^
hl/hl_weapons.cpp^
ammo.cpp^
ammo_secondary.cpp^
ammohistory.cpp^
battery.cpp^
cdll_int.cpp^
com_weapons.cpp^
death.cpp^
demo.cpp^
entity.cpp^
ev_common.cpp^
events.cpp^
flashlight.cpp^
GameStudioModelRenderer.cpp^
geiger.cpp^
health.cpp^
hud.cpp^
hud_msg.cpp^
hud_redraw.cpp^
hud_spectator.cpp^
hud_update.cpp^
in_camera.cpp^
input.cpp^
input_goldsource.cpp^
input_mouse.cpp^
input_xash3d.cpp^
menu.cpp^
message.cpp^
overview.cpp^
parsemsg.cpp^
../pm_shared/pm_debug.c^
../pm_shared/pm_math.c^
../pm_shared/pm_shared.c^
saytext.cpp^
status_icons.cpp^
statusbar.cpp^
studio_util.cpp^
StudioModelRenderer.cpp^
text_message.cpp^
train.cpp^
tri.cpp^
util.cpp^
view.cpp^
scoreboard.cpp^
MOTD.cpp
set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT
set LIBS=user32.lib Winmm.lib
set OUTNAME=client.dll
set DEBUG=/debug
cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG%
echo -- Compile done. Cleaning...
del *.obj *.exp *.lib *.ilk
echo -- Done.

View File

@ -129,13 +129,13 @@ OBJ = \
$(DLL_OBJDIR)/multiplay_gamerules.o \
$(DLL_OBJDIR)/nihilanth.o \
$(DLL_OBJDIR)/nodes.o \
$(DLL_OBJDIR)/observer.cpp \^M
$(DLL_OBJDIR)/observer.o \
$(DLL_OBJDIR)/osprey.o \
$(DLL_OBJDIR)/pathcorner.o \
$(DLL_OBJDIR)/plane.o \
$(DLL_OBJDIR)/plats.o \
$(DLL_OBJDIR)/player.o \
$(DLL_OBJDIR)/playermonster.o \^M
$(DLL_OBJDIR)/playermonster.o \
$(DLL_OBJDIR)/python.o \
$(DLL_OBJDIR)/rat.o \
$(DLL_OBJDIR)/roach.o \

121
dlls/compile.bat Normal file
View File

@ -0,0 +1,121 @@
@echo off
echo Setting environment for minimal Visual C++ 6
set INCLUDE=%MSVCDir%\VC98\Include
set LIB=%MSVCDir%\VC98\Lib
set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH%
echo -- Compiler is MSVC6
set XASH3DSRC=..\..\Xash3D_original
set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public
set SOURCES=agrunt.cpp^
airtank.cpp^
aflock.cpp^
animating.cpp^
animation.cpp^
apache.cpp^
barnacle.cpp^
barney.cpp^
bigmomma.cpp^
bloater.cpp^
bmodels.cpp^
bullsquid.cpp^
buttons.cpp^
cbase.cpp^
client.cpp^
combat.cpp^
controller.cpp^
crossbow.cpp^
crowbar.cpp^
defaultai.cpp^
doors.cpp^
effects.cpp^
egon.cpp^
explode.cpp^
flyingmonster.cpp^
func_break.cpp^
func_tank.cpp^
game.cpp^
gamerules.cpp^
gargantua.cpp^
gauss.cpp^
genericmonster.cpp^
ggrenade.cpp^
globals.cpp^
glock.cpp^
gman.cpp^
h_ai.cpp^
h_battery.cpp^
h_cine.cpp^
h_cycler.cpp^
h_export.cpp^
handgrenade.cpp^
hassassin.cpp^
headcrab.cpp^
healthkit.cpp^
hgrunt.cpp^
hornet.cpp^
hornetgun.cpp^
houndeye.cpp^
ichthyosaur.cpp^
islave.cpp^
items.cpp^
leech.cpp^
lights.cpp^
maprules.cpp^
monstermaker.cpp^
monsters.cpp^
monsterstate.cpp^
mortar.cpp^
mp5.cpp^
multiplay_gamerules.cpp^
nihilanth.cpp^
nodes.cpp^
observer.cpp^
osprey.cpp^
pathcorner.cpp^
plane.cpp^
plats.cpp^
player.cpp^
playermonster.cpp^
python.cpp^
rat.cpp^
roach.cpp^
rpg.cpp^
satchel.cpp^
schedule.cpp^
scientist.cpp^
scripted.cpp^
shotgun.cpp^
singleplay_gamerules.cpp^
skill.cpp^
sound.cpp^
soundent.cpp^
spectator.cpp^
squadmonster.cpp^
squeakgrenade.cpp^
subs.cpp^
talkmonster.cpp^
teamplay_gamerules.cpp^
tempmonster.cpp^
tentacle.cpp^
triggers.cpp^
tripmine.cpp^
turret.cpp^
util.cpp^
weapons.cpp^
world.cpp^
xen.cpp^
zombie.cpp^
../pm_shared/pm_debug.c ../pm_shared/pm_math.c ../pm_shared/pm_shared.c
set DEFINES=/DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR
set LIBS=user32.lib
set OUTNAME=hl.dll
set DEBUG=/debug
cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% /def:".\hl.def"
echo -- Compile done. Cleaning...
del *.obj *.exp *.lib *.ilk
echo -- Done.