Skip to content

Commit

Permalink
Let's compile on Ubuntu 18.04
Browse files Browse the repository at this point in the history
Let's compile on Ubuntu 18.04
  • Loading branch information
SmileYzn committed Jul 4, 2023
1 parent c10cf7e commit 9de8a6f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@ jobs:
build:

runs-on: ubuntu-latest
container: centos:7
container: ubuntu:18.04

steps:
- uses: actions/checkout@v3

- name: Update cache
run: yes | yum -y --assumeyes makecache
- name: Add i386 architecture
run: dpkg --add-architecture i386

- name: Update repository
run: apt-get update

- name: Install build dependencies
run: yes | yum -y --assumeyes install @'Development Tools' libgcc.i686 glibc-devel glibc-devel.i686 libstdc++-devel libstdc++-devel.i686 glibc-static glibc-static.i686 libstdc++-static libstdc++-static.i686 wget
run: apt-get install -qq -y wget unzip build-essential gcc-4.8-multilib g++-4.8-multilib libgcc1:i386

- name: Update alternatives
run: update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

- name: Run build
working-directory: ./AccuracyFix
run: |
# Export compiler include path
export CPATH=$CPATH:/usr/include/c++/4.8.5/i686-redhat-linux
# Make build
make
run: make

- name: Move release file to publish
run: |
Expand Down
25 changes: 16 additions & 9 deletions AccuracyFix/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Include CSSDK and MetaMod SDK
# Include CS SDK
CSSDK = include/cssdk

# Include Metamod SDK
METAMOD = include/metamod

# Release file output name
Expand All @@ -12,14 +14,19 @@ BIN_DIR = Release
COMPILER = g++
OBJECTS = *.cpp

# Static linker
LINK = -static-libstdc++
# Linker Libs
LINKER =

# Compiler version check to static linking
RES_COMPILER_VERSION := $(shell expr "`$(COMPILER) -dumpversion`" ">=" "5")

# Optional flags
OPT_FLAGS = -std=gnu++11 -pipe -g0 -O3 -flto -funroll-loops -fomit-frame-pointer -fno-stack-protector -fPIC
# Link static lib if compiler is newer than minimum version
ifeq "$(RES_COMPILER_VERSION)" "1"
LINKER += -static-libstdc++
endif

# C flags
CFLAGS = $(OPT_FLAGS) -g -DNDEBUG -Dlinux -D__linux__ -D_GLIBCXX_USE_CXX11_ABI=0 -U_FORTIFY_SOURCE -m32 -msse3 -msse4.1 -shared
CFLAGS = -std=gnu++11 -pipe -g0 -O3 -s -flto -funroll-loops -fno-stack-protector -g -DNDEBUG -Dlinux -D__linux__ -D_GLIBCXX_USE_CXX11_ABI=0 -m32 -msse3 -msse4.1 -shared

# Include directory
INCLUDE = -I. -I$(CSSDK)/common -I$(CSSDK)/dlls -I$(CSSDK)/engine -I$(CSSDK)/game_shared -I$(CSSDK)/pm_shared -I$(CSSDK)/public -I$(METAMOD)
Expand All @@ -36,11 +43,11 @@ $(BIN_DIR)/%.o: %.c
all:
mkdir -p $(BIN_DIR)

$(MAKE) $(NAME)
$(MAKE) $(NAME) && strip -x $(BIN_DIR)/$(NAME)_mm.so

$(NAME): $(OBJ_LINUX)

$(COMPILER) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -o$(BIN_DIR)/$(NAME)_mm.so
$(COMPILER) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINKER) -o$(BIN_DIR)/$(NAME)_mm.so

check:
cppcheck $(INCLUDE) --quiet --max-configs=100 --std=gnu++11 -DNDEBUG -Dlinux -D__linux__ -U_FORTIFY_SOURCE .
Expand All @@ -49,4 +56,4 @@ default: all

clean:
rm -rf Release/*.o
rm -rf Release/*.so
rm -rf Release/*.so

0 comments on commit 9de8a6f

Please sign in to comment.