Skip to content

Commit

Permalink
Merge remote-tracking branch 'williamd67/migrate-to-sdl2' into dbgAlex
Browse files Browse the repository at this point in the history
  • Loading branch information
LynxAbraxas committed May 20, 2020
2 parents 96b9242 + d2d03db commit 88ba108
Show file tree
Hide file tree
Showing 82 changed files with 3,731 additions and 1,940 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
language: cpp
sudo: true
dist: trusty
dist: bionic
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl1.2-dev
- libsdl-mixer1.2-dev
- libsdl-image1.2-dev
- libsdl2-dev
- libsdl2-mixer-dev
- libsdl2-image-dev
- libtiff-dev
- libavcodec-dev
- libavformat-dev
- libswscale-dev
- byacc
- gtk+-2.0-dev
- gcc-5
- g++-5

Expand Down
39 changes: 4 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ RUN useradd -m $USERNAME && \
FROM system as builder

RUN apt-get update && apt-get install -y --no-install-recommends \
libsdl1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev byacc libgtk2.0-dev gcc-5 g++-5 \
automake libtool unzip flex git ca-certificates
libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev libtiff-dev libavcodec-dev libavformat-dev libswscale-dev \
byacc gcc-5 g++-5 automake libtool unzip flex git ca-certificates

### set default compilers
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100 && \
Expand All @@ -29,31 +29,6 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100 && \
c++ --version && \
cpp --version

### build ffmpeg
RUN git clone --depth 1 -b v0.5.2 http://github.com/FFmpeg/FFmpeg/ && \
cd FFmpeg && \
./configure \
--prefix=/usr/local/ \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver && \
make -j"$(nproc)" && \
make install

### ffmpeg built

### build SDL_ffmpeg
RUN git clone -b v0.9.0 http://github.com/lynxabraxas/SDL_ffmpeg && \
cd /SDL_ffmpeg/trunk/ && \
sed -i 's/CFLAGS=-I$INCDIR/CFLAGS="$CFLAGS -I$INCDIR"/' configure && \
sed -i 's/LDFLAGS=-L$LIBDIR/LDFLAGS="$LDFLAGS -L$LIBDIR"/' configure && \
LDFLAGS="-lm" \
./configure --prefix=/usr/local/ --static=yes && \
make && \
make install

### SDL_ffmpeg built

ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:/usr/local/lib"

## ctp2CD/ copy not done in builder stage such that stages before are compatible with travis docker build
Expand All @@ -67,12 +42,10 @@ ARG BTYP

RUN cd /ctp2 \
&& ./autogen.sh \
&& CPPFLAGS="-I/usr/local/include/SDL/" \
CC=/usr/bin/gcc-5 \
&& CC=/usr/bin/gcc-5 \
CXX=/usr/bin/g++-5 \
CFLAGS="$CFLAGS -w $( [ "${BTYP##*debug*}" ] && echo -O3 || echo -ggdb -rdynamic ) -fuse-ld=gold" \
CXXFLAGS="$CXXFLAGS -fpermissive -w $( [ "${BTYP##*debug*}" ] && echo -O3 || echo -ggdb -rdynamic ) -fuse-ld=gold" \
LDFLAGS="$LDFLAGS -L/usr/local/lib" \
./configure --prefix=/opt/ctp2 --bindir=/opt/ctp2/ctp2_program/ctp --enable-silent-rules $( [ "${BTYP##*debug*}" ] || echo --enable-debug ) \
&& make -j"$(nproc)" \
&& make -j"$(nproc)" install \
Expand All @@ -89,15 +62,11 @@ FROM system as install
ARG BTYP

RUN apt-get update && apt-get install -y --no-install-recommends \
libsdl1.2debian libsdl-mixer1.2 libsdl-image1.2 libgtk2.0-0 \
libsdl2-2.0 libsdl2-mixer-2.0 libsdl2-image-2.0 libavcodec57 libavformat57 libswscale4 && \
gdb libstdc++-5-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

## copy libs first since they are less likely to change
COPY --from=builder /usr/local/lib /usr/local/lib
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:/usr/local/lib"

## ctp2CD/ copy done in install stage such that stages before are compatible with travis docker build, results in one additional layer in the final DI (incr. DI download size)
COPY ctp2CD/ /opt/ctp2/
## ctp2/ copy has to be after ctp2CD/ to overwrite with newer versions from civctp2
Expand Down
9 changes: 9 additions & 0 deletions GNUmakefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ bootstrap bootstrap-anet doc local playtest: $(top_srcdir)/Makefile
.PHONY: purge bootstrap doc local playtest

if DEBUG
all-local:
nm --demangle --defined-only --numeric-sort $(top_srcdir)/ctp2_code/ctp/ctp2 > $(top_srcdir)/ctp2_code/ctp/ctp2linux.map

install-data-hook:
nm --demangle --defined-only --numeric-sort $(DESTDIR)$(bindir)/ctp2 > $(DESTDIR)$(bindir)/ctp2linux.map
endif

clean-local:
rm -f $(top_srcdir)/ctp2_code/ctp/ctp2linux.map

uninstall-local:
rm -f $(DESTDIR)$(bindir)/ctp2linux.map
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ Note that the game files are not included in this repo, you can get them from th

![screenshot](screenshot.png "screenshot of CTP2 running on Linux")

This version should support CD Audio music, and also supports Ripped CD Audio compressed as ogg (like found in the GoG version). The Audio tracks should be named `Track02.ogg` to `Track11.ogg` and be in the `ctp2_program/ctp/music` folder.
The Windows version supports CD Audio music, and the Linux version supports Ripped CD Audio compressed as ogg (like found in the GoG version). The Audio tracks should be named `Track02.ogg` to `Track11.ogg` and be in the `ctp2_program/ctp/music` folder.

As the Linux version does not support direct play from CD-rom, you need to rip the assets-files from the CD and put them on your disk.

## Building on Linux

You will probably need GCC 5.x or later to build. The code doesn't seem to build on GCC 4.8.

You will need SDL 1.2, SDL_Mixer, SDL_Image and the GTK 2.0 libraries.
You will need SDL 2.0, SDL_Mixer 2.0, SDL_Image 2.0. To be able to play movies you also need ffmpeg libraries (some).
You will also need `byacc`
On debian and friends, use `sudo apt install libsdl1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev byacc gtk2.0-dev` to install them all.
On debian and friends, use `sudo apt install libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev libtiff-dev libavcodec-dev libavformat-dev libswscale-dev byacc flex` to install them all.

The build itself is pretty classing and straight forward:

Expand Down
11 changes: 1 addition & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dnl AC_PROG_LIBTOOL

AM_PATH_DIRECTX
AM_PATH_DXMEDIA
AM_PATH_SDL
AM_PATH_SDL2
AM_PATH_SDL_FFMPEG
AC_PATH_X
AC_PATH_XTRA
Expand All @@ -64,15 +64,6 @@ AC_WORDS_BIGENDIAN
AC_OS_DEFINES
AC_OS_PATHNAMES

if test "x$ac_OpSystem" != "xWIN32"
then
PKG_CHECK_MODULES(GTK, gtk+-2.0)
AC_DEFINE(USE_GTK,1,[Use gtk+ for native dialogs])
AC_SUBST(USE_GTK)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
fi

AC_CHECK_HEADERS(limits.h sys/param.h)
case $host in
*-cygwin*)
Expand Down
10 changes: 6 additions & 4 deletions ctp2_code/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SUBDIRS = \
libs \
sound

bin_PROGRAMS = ctp2
bin_PROGRAMS = ctp/ctp2
# This hack shortens include path list,
# but prohibits using a separate build dir
#ctp2_code=..
Expand Down Expand Up @@ -38,7 +38,7 @@ CTP2_ANET_INC=-I$(ctp2_code)/libs/anet/h

include $(ctp2_code)/os/autoconf/Makefile.common

ctp2_LDADD = \
ctp_ctp2_LDADD = \
gfx/gfx_utils/libgfxgfx_utils.la \
gfx/layers/libgfxlayers.la \
gfx/spritesys/libgfxspritesys.la \
Expand All @@ -57,10 +57,10 @@ ctp2_LDADD = \
$(CTP2_LIBOSNOWIN32_LDADD) \
$(CTP2_LIBTTF_LDADD)

ctp2_LDFLAGS = \
ctp_ctp2_LDFLAGS = \
$(CTP2_LDFLAGS)

ctp2_SOURCES = \
ctp_ctp2_SOURCES = \
ctp/ctp2_utils/appstrings.cpp \
ctp/ctp2_utils/c3cmdline.cpp \
ctp/ctp2_utils/c3cpu.cpp \
Expand Down Expand Up @@ -235,6 +235,8 @@ ctp2_SOURCES = \
ui/aui_sdl/aui_sdljoystick.cpp \
ui/aui_sdl/aui_sdlkeyboard.cpp \
ui/aui_sdl/aui_sdlmouse.cpp \
ui/aui_sdl/aui_sdlmovie.cpp \
ui/aui_sdl/aui_sdlmoviemanager.cpp \
ui/aui_sdl/aui_sdlsound.cpp \
ui/aui_sdl/aui_sdlsurface.cpp \
ui/aui_sdl/aui_sdlui.cpp \
Expand Down
2 changes: 1 addition & 1 deletion ctp2_code/ctp/c3.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// - Moved DirectX API-Version to use into "ctp2_config.h"
// - Added struct for automatic debug tool initialization and
// cleanup so that it is the first respective the last thing
// that is done in the program. (Oct 3rd 2005 Martin Gühmann)
// that is done in the program. (Oct 3rd 2005 Martin Gühmann)
//
//----------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 88ba108

Please sign in to comment.