diff --git a/CMakeLists.txt b/CMakeLists.txt index 9529184..62a8ef7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ if (WIN32) # TODO set arch on target instead of generator set(IZ_PLATFORM WINDOWS) set(IZ_CRYPTO_LIBRARIES libcrypto libssl) + set(IZ_GETOPT_DEPENDENCIES dependencies/getopt-for-windows/getopt.h + dependencies/getopt-for-windows/getopt.c) add_definitions( -DIZ_WINDOWS ) @@ -93,6 +95,16 @@ elseif(IZ_PLATFORM STREQUAL "MACOS") /usr/local/include/openssl ) + link_directories( + /usr/local/lib + ) +elseif(IZ_PLATFORM STREQUAL "UNIX") + include_directories( + /usr/local/include + /usr/local/include/SDL2 + /usr/local/include/openssl + ) + link_directories( /usr/local/lib ) @@ -106,8 +118,7 @@ add_executable( ${IZ_EXECUTABLE_TYPE} dependencies/minIni/dev/minIni.h dependencies/minIni/dev/minIni.c - dependencies/getopt-for-windows/getopt.h - dependencies/getopt-for-windows/getopt.c + ${IZ_GETOPT_DEPENDENCIES} src/packages/game/output/video/IZ_video.h src/packages/game/output/video/IZ_video.c src/packages/common/IZ_common.h diff --git a/README.md b/README.md index 8e3d963..253c97f 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,25 @@ A run-and-gun shooter inspired by Metal Slug. 1. Clone this repo. 2. Clone the repositories under `dependencies.txt`, including SDL2. -3. Build the SDL, SDL_image, and SDL_ttf dependencies using the [build instructions for macOS](https://wiki.libsdl.org/SDL2/Installation#macos). - > **Note:** You may need to download other tools to build the libraries. - - > **Note:** Clone the submodules under SDL_ttf to download freetype and harfbuzz -4. Build the following dependencies first: - - `portmidi` - - `libwebsockets` (follow the [instructions on building LWS](https://libwebsockets.org/lws-api-doc-master/html/md_README_8build.html)) -5. Build via CMake. +3. Build the SDL, SDL_image, and SDL_ttf dependencies using the [build instructions for Linux/UNIX](https://wiki.libsdl.org/SDL2/Installation#linuxunix) + or [build instructions for macOS](https://wiki.libsdl.org/SDL2/Installation#macos). + > **Note:** You may need to download other tools to build the libraries: + > - autoconf + > - make + + > **Note:** Clone the submodules under SDL_ttf to download freetype and harfbuzz: + > + > ```shell + > git submodule update --init --recursive + > ``` +4. For OpenSSL, simply run: + ```shell + ./Configure + make + make test + ``` +5. Build the following dependencies first: + - `portmidi` (Linux needs [ALSA libraries](https://www.alsa-project.org/files/pub/lib/) to be compiled) + - ALSA Lib requires `libtool` to be compiled. + - `libwebsockets` (follow the [instructions on building LWS](https://libwebsockets.org/lws-api-doc-master/html/md_README_8build.html)) +6. Build via CMake. diff --git a/dependencies.txt b/dependencies.txt index 2b0ddc8..4abb26a 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -10,3 +10,4 @@ https://libwebsockets.org/repo/libwebsockets https://github.com/openssl/openssl https://www.sqlite.org/download.html (use SQLite amalgamated source code, unpack into `sqlite` directory) https://code.modal.sh/TheoryOfNekomata/bdd-for-c-mocks +git://git.alsa-project.org/alsa-lib.git (linux/unix) \ No newline at end of file diff --git a/src/packages/compat/IZ_windows.h b/src/packages/compat/IZ_windows.h index 4b98140..bba40dd 100644 --- a/src/packages/compat/IZ_windows.h +++ b/src/packages/compat/IZ_windows.h @@ -3,6 +3,7 @@ #ifndef IZ_WINDOWS typedef int errno_t; +typedef unsigned int rsize_t; #else #include #include diff --git a/src/packages/game/IZ_app_input.c b/src/packages/game/IZ_app_input.c index 1e3d4c1..ec8cc00 100644 --- a/src/packages/game/IZ_app_input.c +++ b/src/packages/game/IZ_app_input.c @@ -4,6 +4,10 @@ #define IZ_DEBUG_CONNECT SDLK_PAGEUP #define IZ_DEBUG_DISCONNECT SDLK_PAGEDOWN #define IZ_DEBUG_SEND_MESSAGE SDLK_INSERT +#elif IZ_UNIX + #define IZ_DEBUG_CONNECT SDLK_PAGEUP + #define IZ_DEBUG_DISCONNECT SDLK_PAGEDOWN + #define IZ_DEBUG_SEND_MESSAGE SDLK_INSERT #elif IZ_MACOS #define IZ_DEBUG_CONNECT SDLK_EQUALS #define IZ_DEBUG_DISCONNECT SDLK_MINUS diff --git a/src/packages/game/output/video/IZ_video.c b/src/packages/game/output/video/IZ_video.c index ef37d2c..547f159 100644 --- a/src/packages/game/output/video/IZ_video.c +++ b/src/packages/game/output/video/IZ_video.c @@ -87,6 +87,7 @@ IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, con IZ_LogError("video", "Window could not be created! Reason: %s", SDL_GetError()); return -3; } + SDL_ShowWindow(window); state->window = window; state->renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); return 0; diff --git a/src/packages/io/IZ_io.c b/src/packages/io/IZ_io.c index a5226e0..1afd4db 100644 --- a/src/packages/io/IZ_io.c +++ b/src/packages/io/IZ_io.c @@ -47,13 +47,8 @@ bool IZ_isdir(const char* path) { struct stat s; int err = stat("/path/to/possible_dir", &s); if(-1 == err) { - if(ENOENT == errno) { return false; - } - perror("stat"); - exit(1);\ - return; } - return (S_ISDIR(s.st_mode)) + return (S_ISDIR(s.st_mode)); #endif } diff --git a/src/packages/io/IZ_io.h b/src/packages/io/IZ_io.h index 6db24c2..24d8d6e 100644 --- a/src/packages/io/IZ_io.h +++ b/src/packages/io/IZ_io.h @@ -5,6 +5,9 @@ #include #include #include "../compat/IZ_windows.h" +#ifdef IZ_UNIX +#include +#endif int IZ_sprintf(char*, size_t, const char*, ...); diff --git a/src/packages/log/IZ_log.h b/src/packages/log/IZ_log.h index 4d998db..c34402b 100644 --- a/src/packages/log/IZ_log.h +++ b/src/packages/log/IZ_log.h @@ -21,6 +21,7 @@ #include #include #include +#include #include "../timer/IZ_timer.h" #include "../io/IZ_io.h" #include "../stdinc/IZ_string.h"