Skip to content

Commit

Permalink
Merge pull request #31 from elementc/dev/linux-x64
Browse files Browse the repository at this point in the history
Support 64-bit linux builds
  • Loading branch information
greenfire27 authored Oct 11, 2021
2 parents 7c55f40 + 9399642 commit 4ed8811
Show file tree
Hide file tree
Showing 23 changed files with 663 additions and 26 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ Torque2D.exe
Torque2D_DEBUG.exe
Torque2DGame.app
Torque2DGame_Debug.app
Torque2D
Torque2D_DEBUG
linkmap.txt
**/.vs/**
.vscode/

# Compiled source #
###################
Expand Down Expand Up @@ -80,5 +83,7 @@ engine/compilers/android-studio/app/.externalNativeBuild/

# Linux build files #
#####################
engine/compilers/Make/Debug/
engine/compilers/Make/Release/
engine/compilers/Make-32bit/Debug/
engine/compilers/Make-32bit/Release/
engine/compilers/Make-64bit/Debug/
engine/compilers/Make-64bit/Release/
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ APP_TARGETS_DEBUG :=
build-in-docker: docker-buildenv
docker run \
--rm \
--user $(shell id -u):$(shell id -g) \
-v $(shell readlink -e ../../../ ):/torque2d-engine-build/ \
-w /torque2d-engine-build/engine/compilers/Make/ \
-w /torque2d-engine-build/engine/compilers/Make-32bit/ \
torque2d-linux32-build-env \
make -j all

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions engine/compilers/Make-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install \
build-essential \
gcc-multilib \
g++-multilib \
nasm \
libsdl-dev \
libxft-dev \
libopenal-dev && \
rm -rf /var/lib/{apt,dpkg,cache,log}/
RUN mkdir /torque2d-engine-build/
45 changes: 45 additions & 0 deletions engine/compilers/Make-64bit/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
DEPS :=
LIB_TARGETS :=
LIB_TARGETS_DEBUG :=
SHARED_LIB_TARGETS :=
SHARED_LIB_TARGETS_DEBUG :=
APP_TARGETS :=
APP_TARGETS_DEBUG :=

build-in-docker: docker-buildenv
docker run \
--rm \
--user $(shell id -u):$(shell id -g) \
-v $(shell readlink -e ../../../ ):/torque2d-engine-build/ \
-w /torque2d-engine-build/engine/compilers/Make-64bit/ \
torque2d-linux64-build-env \
make -j all

all: debug release

docker-buildenv: Dockerfile
docker build -t torque2d-linux64-build-env .

clean:
rm -rf Debug
rm -rf Release
rm -rf lib

.PHONY: all debug release clean

-include x Torque2D
-include x zlib
-include x lpng
-include x ljpeg
-include x vorbis
-include x ogg

release: $(LIB_TARGETS) $(SHARED_LIB_TARGETS) $(APP_TARGETS)
@echo Built libraries: $(LIB_TARGETS)
@echo Built shared libraries: $(SHARED_LIB_TARGETS)
@echo Built apps: $(APP_TARGETS)

debug: $(LIB_TARGETS_DEBUG) $(SHARED_LIB_TARGETS_DEBUG) $(APP_TARGETS_DEBUG)
@echo Built libraries: $(LIB_TARGETS_DEBUG)
@echo Built shared libraries: $(SHARED_LIB_TARGETS_DEBUG)
@echo Built apps: $(APP_TARGETS_DEBUG)
143 changes: 143 additions & 0 deletions engine/compilers/Make-64bit/Torque2D
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
APPNAME := ../../../Torque2D

2D_SOURCES := $(shell find ../../source/2d/ -name "*.cc") + \
$(shell find ../../source/2d/ -name "*.cpp")
ALGORITHM_SOURCES := $(shell find ../../source/algorithm/ -name "*.cc")
ASSETS_SOURCES := $(shell find ../../source/assets/ -name "*.cc")
AUDIO_SOURCES := $(shell find ../../source/audio/ -name "*.cc")
BITMAPFONT_SOURCES := $(shell find ../../source/bitmapFont/ -name "*.cc")
BOX2D_SOURCES := $(shell find ../../source/Box2D/ -name "*.cpp")
COLLECTION_SOURCES := $(shell find ../../source/collection/ -name "*.cc")
COMPONENT_SOURCES := $(shell find ../../source/component/ -name "*.cpp")
CONSOLE_SOURCES := $(shell find ../../source/console/ -name "*.cc")
DEBUG_SOURCES := $(shell find ../../source/debug/ -name "*.cc")
DELEGATES_SOURCES := $(shell find ../../source/delegates/ -name "*.cc")
GAME_SOURCES := $(shell find ../../source/game/ -name "*.cc")
GRAPHICS_SOURCES := $(shell find ../../source/graphics/ -name "*.cc")
GUI_SOURCES := $(shell find ../../source/gui/ -name "*.cc")
INPUT_SOURCES := $(shell find ../../source/input/ -name "*.cc")
IO_SOURCES := $(shell find ../../source/io/ -name "*.cc")
MATH_SOURCES := $(shell find ../../source/math/ -name "*.cc") + \
$(shell find ../../source/math/ -name "*.cpp")
MEMORY_SOURCES := $(shell find ../../source/memory/ -name "*.cc")
MESSAGING_SOURCES := $(shell find ../../source/messaging/ -name "*.cc")
MODULE_SOURCES := $(shell find ../../source/module/ -name "*.cc")
NETWORK_SOURCES := $(shell find ../../source/network/ -name "*.cc")
PERSISTENCE_SOURCES := $(shell find ../../source/persistence/ -name "*.cc") + \
$(shell find ../../source/persistence/ -name "*.cpp")
PLATFORM_SOURCES := $(shell find ../../source/platform/ -name "*.cc") + \
$(shell find ../../source/platform/ -name "*.cpp")
PLATFORM_UNIX_SOURCES := $(shell find ../../source/platformX86UNIX/ -name "*.cc")
SIM_SOURCES := $(shell find ../../source/sim/ -name "*.cc") + \
$(shell find ../../source/sim/ -name "*.cpp")
STRING_SOURCES := $(shell find ../../source/string/ -name "*.cc") + \
$(shell find ../../source/string/ -name "*.cpp")

SOURCES := $(2D_SOURCES) + \
$(ALGORITHM_SOURCES) + \
$(ASSETS_SOURCES) + \
$(AUDIO_SOURCES) + \
$(BITMAPFONT_SOURCES) + \
$(BOX2D_SOURCES) + \
$(COLLECTION_SOURCES) + \
$(COMPONENT_SOURCES) + \
$(CONSOLE_SOURCES) + \
$(DEBUG_SOURCES) + \
$(DELEGATES_SOURCES) + \
$(GAME_SOURCES) + \
$(GRAPHICS_SOURCES) + \
$(GUI_SOURCES) + \
$(INPUT_SOURCES) + \
$(IO_SOURCES) + \
$(MATH_SOURCES) + \
$(MEMORY_SOURCES) + \
$(MESSAGING_SOURCES) + \
$(MODULE_SOURCES) + \
$(NETWORK_SOURCES) + \
$(PERSISTENCE_SOURCES) + \
$(PLATFORM_SOURCES) + \
$(PLATFORM_UNIX_SOURCES) + \
$(SIM_SOURCES) + \
$(STRING_SOURCES)

LDFLAGS := -g -m64
LDLIBS := -lstdc++ -lm -ldl -lpthread -lrt -lX11 -lXft -lSDL -lopenal

CFLAGS := -std=gnu++11 -MMD -I. -Wfatal-errors -Wunused -m64 -msse -march=x86-64 -pipe

CFLAGS += -I/usr/include
CFLAGS += -I/usr/include/freetype2
CFLAGS += -I../../source
CFLAGS += -I../../source/persistence/rapidjson/include
CFLAGS += -I../../lib/ljpeg
CFLAGS += -I../../lib/zlib
CFLAGS += -I../../lib/lpng
CFLAGS += -I../../lib/freetype
CFLAGS += -I../../lib/libvorbis/include
CFLAGS += -I../../lib/libogg/include
CFLAGS += -I../../lib/openal/LINUX/

CFLAGS += -DLINUX
CFLAGS += -D__amd64__
CFLAGS += -DTORQUE_64


CFLAGS_DEBUG := $(CFLAGS) -ggdb
CFLAGS_DEBUG += -DTORQUE_DEBUG
CFLAGS_DEBUG += -DTORQUE_DEBUG_GUARD
CFLAGS_DEBUG += -DTORQUE_NET_STATS

CFLAGS += -O0

NASMFLAGS := -f elf64 -D LINUX

CC := gcc
LD := gcc

APP_TARGETS += $(APPNAME)
APP_TARGETS_DEBUG += $(APPNAME)_DEBUG

OBJS := $(patsubst ../../source/%,Release/%.o,$(SOURCES))
OBJS := $(filter %.o, $(OBJS))

OBJS_DEBUG := $(patsubst ../../source/%,Debug/%.o,$(SOURCES))
OBJS_DEBUG := $(filter %.o,$(OBJS_DEBUG))

$(APP_TARGETS): $(OBJS) $(LIB_TARGETS)
@echo Linking release
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIB_TARGETS) $(LDLIBS)

$(APP_TARGETS_DEBUG): $(OBJS_DEBUG) $(LIB_TARGETS_DEBUG)
@echo Linking debug
$(LD) $(LDFLAGS) -o $@ $(OBJS_DEBUG) $(LIB_TARGETS_DEBUG) $(LDLIBS)

Release/%.asm.o: ../../source/%.asm
@echo Building release asm $@
@mkdir -p $(dir $@)
nasm $(NASMFLAGS) $< -o $@

Release/%.o: ../../source/%
@echo Building release object $@
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) $< -o $@

Debug/%.asm.o: ../../source/%.asm
@echo Building debug asm $@
@mkdir -p $(dir $@)
nasm $(NASMFLAGS) $< -o $@

Debug/%.o: ../../source/%
@echo Building debug object $@
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS_DEBUG) $< -o $@

release: $(APP_TARGETS)
debug: $(APP_TARGETS_DEBUG)

.PHONY: $(APP_TARGETS) $(APP_TARGETS_DEBUG)

DEPS += $(patsubst %.o,%.d,$(OBJS))
DEPS += $(patsubst %.o,%.d,$(OBJS_DEBUG))

APPNAME :=
SOURCES :=
109 changes: 109 additions & 0 deletions engine/compilers/Make-64bit/ljpeg
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# I release this sample under the MIT license: free for any use, provided
# you hold me harmless from any such use you make, and you retain my
# copyright on the actual sources.
# Copyright 2005 Jon Watte.

LIBNAME := ljpeg
SOURCES := ../../lib/ljpeg/jidctint.c \
../../lib/ljpeg/jcmainct.c \
../../lib/ljpeg/jfdctfst.c \
../../lib/ljpeg/jdatadst.c \
../../lib/ljpeg/jdsample.c \
../../lib/ljpeg/jmemmgr.c \
../../lib/ljpeg/jidctred.c \
../../lib/ljpeg/jcphuff.c \
../../lib/ljpeg/jchuff.c \
../../lib/ljpeg/jdapistd.c \
../../lib/ljpeg/jdpostct.c \
../../lib/ljpeg/jquant2.c \
../../lib/ljpeg/jdmerge.c \
../../lib/ljpeg/jfdctflt.c \
../../lib/ljpeg/jcprepct.c \
../../lib/ljpeg/jccolor.c \
../../lib/ljpeg/jfdctint.c \
../../lib/ljpeg/jdhuff.c \
../../lib/ljpeg/jcomapi.c \
../../lib/ljpeg/jcinit.c \
../../lib/ljpeg/jccoefct.c \
../../lib/ljpeg/jdinput.c \
../../lib/ljpeg/jutils.c \
../../lib/ljpeg/jcapimin.c \
../../lib/ljpeg/jdcoefct.c \
../../lib/ljpeg/jidctflt.c \
../../lib/ljpeg/jcmaster.c \
../../lib/ljpeg/jddctmgr.c \
../../lib/ljpeg/jidctfst.c \
../../lib/ljpeg/jcparam.c \
../../lib/ljpeg/jcapistd.c \
../../lib/ljpeg/jdmaster.c \
../../lib/ljpeg/jcdctmgr.c \
../../lib/ljpeg/jctrans.c \
../../lib/ljpeg/jdmainct.c \
../../lib/ljpeg/jdtrans.c \
../../lib/ljpeg/jcsample.c \
../../lib/ljpeg/jdmarker.c \
../../lib/ljpeg/jdatasrc.c \
../../lib/ljpeg/jerror.c \
../../lib/ljpeg/jquant1.c \
../../lib/ljpeg/jdphuff.c \
../../lib/ljpeg/jcmarker.c \
../../lib/ljpeg/jdapimin.c \
../../lib/ljpeg/jdcolor.c \
../../lib/ljpeg/jmemnobs.c \

LDFLAGS_ljpeg := -g -m64

CFLAGS_ljpeg := -MMD -I. -m64 -msse -mmmx -march=x86-64

CFLAGS_ljpeg += -I../../lib/ljpeg

CFLAGS_ljpeg += -DUNICODE
CFLAGS_ljpeg += -DLINUX

CFLAGS_DEBUG_ljpeg := $(CFLAGS_ljpeg) -ggdb
CFLAGS_DEBUG_ljpeg += -DTORQUE_DEBUG
CFLAGS_DEBUG_ljpeg += -DTORQUE_DEBUG_GUARD
CFLAGS_DEBUG_ljpeg += -DTORQUE_NET_STATS

CFLAGS_ljpeg += -O3

CC := gcc
LD := gcc

TARGET_ljpeg := lib/ljpeg.a
TARGET_ljpeg_DEBUG := lib/ljpeg_DEBUG.a

LIB_TARGETS += $(TARGET_ljpeg)
LIB_TARGETS_DEBUG += $(TARGET_ljpeg_DEBUG)

OBJS_ljpeg := $(patsubst ../../lib/ljpeg/%,Release/ljpeg/%.o,$(SOURCES))
OBJS_ljpeg_DEBUG := $(patsubst ../../lib/ljpeg/%,Debug/ljpeg/%.o,$(SOURCES))

# Deriving the variable name from the target name is the secret sauce
# of the build system.
#
$(TARGET_ljpeg): $(OBJS_ljpeg)
@echo Linking library ljpng
@mkdir -p $(dir $@)
ar cr $@ $(OBJS_ljpeg)

$(TARGET_ljpeg_DEBUG): $(OBJS_ljpeg_DEBUG)
@echo Linking debug library ljpng
@mkdir -p $(dir $@)
ar cr $@ $(OBJS_ljpeg_DEBUG)

Release/ljpeg/%.o: ../../lib/ljpeg/%
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS_ljpeg) $< -o $@

Debug/ljpeg/%.o: ../../lib/ljpeg/%
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS_DEBUG_ljpeg) $< -o $@

release_ljpeg: $(TARGET_ljpeg)
debug_ljpeg: $(TARGET_ljpeg_DEBUG)

.PHONY: debug_ljpeg release_ljpeg

DEPS += $(patsubst %.o,%.d,$(OBJS_ljpeg))
DEPS += $(patsubst %.o,%.d,$(OBJS_ljpeg_DEBUG))
Loading

0 comments on commit 4ed8811

Please sign in to comment.