From c47cf8ab9278f48ee1aeb31310d69310c537177c Mon Sep 17 00:00:00 2001 From: duhow Date: Sat, 19 Apr 2025 14:23:24 +0200 Subject: [PATCH 1/4] add makefile --- Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4233be4 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +CC ?= gcc + +HAS_FLAC ?= 1 +DEFINES ?= + +CFLAGS ?= \ + -O3 -march=native -mtune=native \ + -Wall -Wextra \ + -Wshadow -Winit-self -Wunused -Wunreachable-code \ + -Wno-missing-field-initializers -Wno-unused-result \ + -Wno-strict-aliasing -Wno-stringop-overflow + +LDFLAGS ?= -lSDL2 -lm + +SRC = $(wildcard \ + src/gfx/*.c \ + src/modloaders/*.c \ + src/smploaders/*.c \ +) + +ifeq ($(HAS_FLAC), 1) + DEFINES += -DHAS_LIBFLAC + SRC += $(wildcard src/libflac/*.c) +endif + +SRC += $(wildcard src/*.c) + +ifndef DEBUG + DEFINES += -DNDEBUG +endif + +OUT_DIR = release/other +OUT_FILE = $(OUT_DIR)/pt2-clone + +.PHONY: all clean + +all: $(OUT_FILE) + +OBJ = $(SRC:%.c=%.o) + +$(OUT_FILE): $(OBJ) + @mkdir -p $(OUT_DIR) + $(CC) $(OBJ) $(LDFLAGS) -o $(OUT_FILE) + @echo "Done. The executable can be found in '$(OUT_DIR)' if everything went well." + +%.o: %.c + @echo "CC $<" + @$(CC) $(DEFINES) $(CFLAGS) -c $< -o $@ + +clean: + -rm -f $(OUT_FILE) + -rm -f $(SRC:%.c=%.o) From aa8625783e7fafc9a73272b218b2ea8e579bf532 Mon Sep 17 00:00:00 2001 From: duhow Date: Sat, 19 Apr 2025 14:23:38 +0200 Subject: [PATCH 2/4] update gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index d7b7bd6..1da4968 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,10 @@ vs2019_project/pt2-clone/Debug/pt2-clone.vcxproj.FileListAbsolute.txt *.enc release/macos/pt2-clone-macos.app/Contents/MacOS/pt2-clone-macos pt_pal_editor/vs2019_project/pt_pal_editor/x64/Debug/pt_pal_editor.vcxproj.FileListAbsolute.txt + +/CMakeCache.txt +/CMakeFiles/ +/build/ +/cmake_install.cmake +release/other/pt2-clone +/src/**/*.o From e502185a35b71dd861f36aab40da75b73e6fb6a8 Mon Sep 17 00:00:00 2001 From: duhow Date: Sat, 19 Apr 2025 14:48:12 +0200 Subject: [PATCH 3/4] update scripts and documentation --- HOW-TO-COMPILE.txt | 4 +--- make-linux-noflac.sh | 9 --------- make-linux.sh | 9 --------- make-macos.sh | 0 4 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 make-linux-noflac.sh delete mode 100644 make-linux.sh mode change 100644 => 100755 make-macos.sh diff --git a/HOW-TO-COMPILE.txt b/HOW-TO-COMPILE.txt index d6e05f3..aa81dee 100644 --- a/HOW-TO-COMPILE.txt +++ b/HOW-TO-COMPILE.txt @@ -10,8 +10,7 @@ Compiled Windows/macOS binaries are always available at 16-bits.org/pt2.php Fedora: gcc gcc-c++ alsa-lib-devel SDL2-devel Others: www.google.com (you want gcc, g++ (or c++), alsa dev and SDL2 dev) 2. Compile the PT2 clone: (folder: "pt2-clone") - chmod +x make-linux.sh (only needed once) - ./make-linux.sh + make -j2 3. Copy pt2-clone/release/other/protracker.ini to ~/.config/protracker/ (or ~/.protracker/). Make sure there are no config files in the same path as the @@ -33,7 +32,6 @@ Compiled Windows/macOS binaries are always available at 16-bits.org/pt2.php 2. Download the SDL 2 framework at https://www.libsdl.org 3. Inside the package, copy SDL2.framework to /Library/Frameworks/ 4. Compile the PT2 clone: (folder: "pt2-clone") - chmod +x make-macos.sh (only needed once) ./make-macos.sh 5. If you have more than one user in your OS, copy pt2-clone/release/macos/protracker.ini to ~/.config/protracker/ diff --git a/make-linux-noflac.sh b/make-linux-noflac.sh deleted file mode 100644 index ae325bb..0000000 --- a/make-linux-noflac.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -rm release/other/pt2-clone &> /dev/null - -echo Compiling, please wait... -gcc -DNDEBUG src/gfx/*.c src/modloaders/*.c src/smploaders/*.c src/*.c -lSDL2 -lm -Wshadow -Winit-self -Wall -Wno-missing-field-initializers -Wno-unused-result -Wno-strict-aliasing -Wextra -Wunused -Wunreachable-code -Wno-stringop-overflow -march=native -mtune=native -O3 -o release/other/pt2-clone -rm src/gfx/*.o src/*.o &> /dev/null - -echo Done. The executable can be found in \'release/other\' if everything went well. diff --git a/make-linux.sh b/make-linux.sh deleted file mode 100644 index e7fdfb1..0000000 --- a/make-linux.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -rm release/other/pt2-clone &> /dev/null - -echo Compiling, please wait... -gcc -DNDEBUG -DHAS_LIBFLAC src/gfx/*.c src/modloaders/*.c src/libflac/*.c src/smploaders/*.c src/*.c -lSDL2 -lm -Wshadow -Winit-self -Wall -Wno-missing-field-initializers -Wno-unused-result -Wno-strict-aliasing -Wextra -Wunused -Wunreachable-code -Wno-stringop-overflow -march=native -mtune=native -O3 -o release/other/pt2-clone -rm src/gfx/*.o src/*.o &> /dev/null - -echo Done. The executable can be found in \'release/other\' if everything went well. diff --git a/make-macos.sh b/make-macos.sh old mode 100644 new mode 100755 From 8997d8a891143e58962c38c2c78175a662362293 Mon Sep 17 00:00:00 2001 From: duhow Date: Sat, 19 Apr 2025 15:05:25 +0200 Subject: [PATCH 4/4] set install target --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 4233be4..6c751b0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ CC ?= gcc +DESTDIR ?= /usr/local HAS_FLAC ?= 1 DEFINES ?= @@ -50,3 +51,10 @@ $(OUT_FILE): $(OBJ) clean: -rm -f $(OUT_FILE) -rm -f $(SRC:%.c=%.o) + +USER_HOME ?= $(shell getent passwd $(SUDO_USER) | cut -d: -f6) +USER_HOME := $(if $(USER_HOME),$(USER_HOME),$(HOME)) + +install: $(OUT_FILE) + @install -v $(OUT_FILE) $(DESTDIR)/bin/ + @install -vD $(OUT_DIR)/protracker.ini $(USER_HOME)/.config/protracker/protracker.ini