Static linking
Check changes in README.md
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
include/*
|
||||
lib/*
|
||||
obj/*
|
||||
Game
|
||||
Release
|
||||
|
||||
33
README.md
33
README.md
@@ -1,3 +1,34 @@
|
||||
# Sandbox
|
||||
|
||||
Gamedev Experiments
|
||||
Gamedev Experiments
|
||||
|
||||
## How to Build
|
||||
|
||||
> [!NOTE]
|
||||
> The makefile is configured for Linux only. Cross-compilation for Windows is planned.
|
||||
|
||||
> [!NOTE]
|
||||
> This project uses external libraries SDL2, GLEW, and cglm. To avoid depending on any Linux distro's package system, these libraries are built from source and linked statically, not dynamically. This makes the executable a few MB larger but also very portable.
|
||||
> A few other small libraries are included directly in the `src/` directory of this git repo.
|
||||
|
||||
1. Build external libraries.
|
||||
- SDL2:
|
||||
1. Download source code: I am using [Release 2.32.10](https://github.com/libsdl-org/SDL/releases/tag/release-2.32.10).
|
||||
2. If this project is located at `~/Code/Sandbox`, place the source code for SDL2 at `~/Code/SDL2` .
|
||||
3. Open a terminal in the SDL2 directory. Enter `./configure` and then `make` .
|
||||
- GLEW:
|
||||
1. Download source code [here](https://glew.sourceforge.net/).
|
||||
2. Extract to `~/Code/glew` .
|
||||
3. Just enter `make` to build GLEW.
|
||||
- cglm:
|
||||
1. Download source code: I am using [Release 0.9.6](https://github.com/recp/cglm/releases/tag/v0.9.6)
|
||||
2. Extract to `~/Code/cglm` .
|
||||
3. In a terminal, `./autogen.sh` then `./configure` and finally `make` .
|
||||
2. Build the project.
|
||||
- In the Sandbox directory, enter `make` to build the executable.
|
||||
- Symbolic links in `lib/` and `include/` are used to find the header files and static archives of the external libraries that were prepared in the previous step.
|
||||
- Other commands are available:
|
||||
- `make clean` to delete the executable and object files.
|
||||
- `make rebuild` to clean and build in one step.
|
||||
- `make run` to build and run in one step.
|
||||
- `make release` to make a smaller executable suitable for distribution.
|
||||
|
||||
40
makefile
40
makefile
@@ -1,13 +1,13 @@
|
||||
INC = include
|
||||
OBJ = obj
|
||||
SRC = src
|
||||
EXE = Game
|
||||
REL = Release
|
||||
INC := include
|
||||
LIB := lib
|
||||
OBJ := obj
|
||||
SRC := src
|
||||
EXE := Game
|
||||
REL := Release
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -w -ggdb -I$(INC)
|
||||
LIBS = -lGLEW -lGLU -lGL -lSDL2 -lcglm -lz -lm
|
||||
RELFLAGS = -O3 -s
|
||||
CC := gcc
|
||||
CFLAGS := -w -I$(INC) -L$(LIB)/SDL2 -L$(LIB)/glew -DGLEW_STATIC -L$(LIB)/cglm
|
||||
LIBS := -Wl,-Bstatic -lSDL2 -lGLEW -lcglm -Wl,-Bdynamic -lGLU -lGL -lm
|
||||
|
||||
OBJFILES := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(shell find $(SRC) -name '*.c'))
|
||||
OBJDIRS := $(patsubst $(SRC)%, $(OBJ)%, $(shell find $(SRC) -type d))
|
||||
@@ -18,21 +18,33 @@ CLEANDIRS := $(addsuffix /.clean, $(OBJDIRS));
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
# Build executable
|
||||
all: CFLAGS += -ggdb -O0
|
||||
all: $(EXE)
|
||||
$(EXE): $(OBJFILES) | $(OBJDIRS)
|
||||
$(EXE): $(OBJFILES) | $(OBJDIRS) $(INC) $(LIB)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
# Compile object files
|
||||
$(OBJ)/%.o: $(SRC)/%.c | $(OBJDIRS)
|
||||
$(OBJ)/%.o: $(SRC)/%.c | $(OBJDIRS) $(INC) $(LIB)
|
||||
$(CC) -c -o $@ $(SRC)/$*.c $(CFLAGS)
|
||||
|
||||
# Create obj directory tree if it doesn't exist
|
||||
# Create directory tree
|
||||
$(OBJDIRS):
|
||||
mkdir -p $@
|
||||
$(INC):
|
||||
mkdir -p $@
|
||||
ln -rs ../SDL2/include $(INC)/SDL2
|
||||
ln -rs ../glew/include/GL $(INC)/GL
|
||||
ln -rs ../cglm/include/cglm $(INC)/cglm
|
||||
$(LIB):
|
||||
mkdir -p $@
|
||||
ln -rs ../SDL2/build/.libs $(LIB)/SDL2
|
||||
ln -rs ../glew/lib $(LIB)/glew
|
||||
ln -rs ../cglm/.libs $(LIB)/cglm
|
||||
|
||||
release: CFLAGS += -O3 -s
|
||||
release: $(REL)
|
||||
$(REL): $(OBJFILES) | $(OBJDIRS)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) $(RELFLAGS)
|
||||
$(REL): $(OBJFILES) | $(OBJDIRS) $(INC) $(LIB)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
# Delete previously built files
|
||||
clean: $(CLEANDIRS)
|
||||
|
||||
37
src/stb/LICENSE
Normal file
37
src/stb/LICENSE
Normal file
@@ -0,0 +1,37 @@
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
7988
src/stb/stb_image.h
Normal file
7988
src/stb/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user