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 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/Makefile b/Makefile new file mode 100644 index 0000000..6c751b0 --- /dev/null +++ b/Makefile @@ -0,0 +1,60 @@ +CC ?= gcc +DESTDIR ?= /usr/local + +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) + +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 diff --git a/make-linux-noflac.sh b/make-linux-noflac.sh deleted file mode 100644 index 8ac805b..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/modloaders/*.o src/smploaders/*.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 c9df087..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/modloaders/*.o src/libflac/*.o src/smploaders/*.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