aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--CMakeLists.txt11
-rw-r--r--Makefile15
-rw-r--r--build/Makefile238
-rw-r--r--flake.lock26
-rw-r--r--flake.nix61
-rw-r--r--include/config.h10
7 files changed, 115 insertions, 249 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8ae570b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.o
+/yetihack
+/result
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 43e5163..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (yetihack)
-add_executable (yetihack ${PROJECT_SOURCE_DIR}/src/yetihack.cpp ${PROJECT_SOURCE_DIR}/src/yeti.cpp)
-find_package(Curses)
-target_link_libraries(yetihack ${CURSES_LIBRARIES})
-include (CheckIncludeFile)
-check_include_file(unistd.h HAVE_UNISTD_H)
-check_include_file(windows.h HAVE_WINDOWS_H)
-configure_file("${PROJECT_SOURCE_DIR}/include/config.h.in" "${PROJECT_SOURCE_DIR}/include/config.h")
-include_directories("include")
-install (TARGETS yetihack DESTINATION bin)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2316ece
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,15 @@
+CFLAGS=-O2 -Wall -Wextra -Iinclude `pkg-config --cflags ncurses`
+LDFLAGS=`pkg-config --libs ncurses`
+
+yetihack: yetihack.o yeti.o
+ g++ $(LDFLAGS) -o $@ $^
+
+yetihack.o: src/yetihack.cpp include/yeti.h
+ g++ -c $(CFLAGS) -o $@ $<
+
+yeti.o: src/yeti.cpp include/yeti.h
+ g++ -c $(CFLAGS) -o $@ $<
+
+.PHONY: clean
+clean:
+ rm *.o yetihack
diff --git a/build/Makefile b/build/Makefile
deleted file mode 100644
index 42437d0..0000000
--- a/build/Makefile
+++ /dev/null
@@ -1,238 +0,0 @@
-# CMAKE generated file: DO NOT EDIT!
-# Generated by "Unix Makefiles" Generator, CMake Version 2.8
-
-# Default target executed when no arguments are given to make.
-default_target: all
-.PHONY : default_target
-
-#=============================================================================
-# Special targets provided by cmake.
-
-# Disable implicit rules so canonical targets will work.
-.SUFFIXES:
-
-# Remove some rules from gmake that .SUFFIXES does not remove.
-SUFFIXES =
-
-.SUFFIXES: .hpux_make_needs_suffix_list
-
-# Suppress display of executed commands.
-$(VERBOSE).SILENT:
-
-# A target that is always out of date.
-cmake_force:
-.PHONY : cmake_force
-
-#=============================================================================
-# Set environment variables for the build.
-
-# The shell in which to execute make rules.
-SHELL = /bin/sh
-
-# The CMake executable.
-CMAKE_COMMAND = /usr/bin/cmake
-
-# The command to remove a file.
-RM = /usr/bin/cmake -E remove -f
-
-# Escaping for special characters.
-EQUALS = =
-
-# The program to use to edit the cache.
-CMAKE_EDIT_COMMAND = /usr/bin/ccmake
-
-# The top-level source directory on which CMake was run.
-CMAKE_SOURCE_DIR = /home/ray/Documents/programs/yetihack
-
-# The top-level build directory on which CMake was run.
-CMAKE_BINARY_DIR = /home/ray/Documents/programs/yetihack/build
-
-#=============================================================================
-# Targets provided globally by CMake.
-
-# Special rule for the target edit_cache
-edit_cache:
- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
- /usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
-.PHONY : edit_cache
-
-# Special rule for the target edit_cache
-edit_cache/fast: edit_cache
-.PHONY : edit_cache/fast
-
-# Special rule for the target install
-install: preinstall
- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
- /usr/bin/cmake -P cmake_install.cmake
-.PHONY : install
-
-# Special rule for the target install
-install/fast: preinstall/fast
- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
- /usr/bin/cmake -P cmake_install.cmake
-.PHONY : install/fast
-
-# Special rule for the target install/local
-install/local: preinstall
- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
- /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
-.PHONY : install/local
-
-# Special rule for the target install/local
-install/local/fast: install/local
-.PHONY : install/local/fast
-
-# Special rule for the target install/strip
-install/strip: preinstall
- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
- /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
-.PHONY : install/strip
-
-# Special rule for the target install/strip
-install/strip/fast: install/strip
-.PHONY : install/strip/fast
-
-# Special rule for the target list_install_components
-list_install_components:
- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
-.PHONY : list_install_components
-
-# Special rule for the target list_install_components
-list_install_components/fast: list_install_components
-.PHONY : list_install_components/fast
-
-# Special rule for the target rebuild_cache
-rebuild_cache:
- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
- /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
-.PHONY : rebuild_cache
-
-# Special rule for the target rebuild_cache
-rebuild_cache/fast: rebuild_cache
-.PHONY : rebuild_cache/fast
-
-# The main all target
-all: cmake_check_build_system
- $(CMAKE_COMMAND) -E cmake_progress_start /home/ray/Documents/programs/yetihack/build/CMakeFiles /home/ray/Documents/programs/yetihack/build/CMakeFiles/progress.marks
- $(MAKE) -f CMakeFiles/Makefile2 all
- $(CMAKE_COMMAND) -E cmake_progress_start /home/ray/Documents/programs/yetihack/build/CMakeFiles 0
-.PHONY : all
-
-# The main clean target
-clean:
- $(MAKE) -f CMakeFiles/Makefile2 clean
-.PHONY : clean
-
-# The main clean target
-clean/fast: clean
-.PHONY : clean/fast
-
-# Prepare targets for installation.
-preinstall: all
- $(MAKE) -f CMakeFiles/Makefile2 preinstall
-.PHONY : preinstall
-
-# Prepare targets for installation.
-preinstall/fast:
- $(MAKE) -f CMakeFiles/Makefile2 preinstall
-.PHONY : preinstall/fast
-
-# clear depends
-depend:
- $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
-.PHONY : depend
-
-#=============================================================================
-# Target rules for targets named yetihack
-
-# Build rule for target.
-yetihack: cmake_check_build_system
- $(MAKE) -f CMakeFiles/Makefile2 yetihack
-.PHONY : yetihack
-
-# fast build rule for target.
-yetihack/fast:
- $(MAKE) -f CMakeFiles/yetihack.dir/build.make CMakeFiles/yetihack.dir/build
-.PHONY : yetihack/fast
-
-src/yeti.o: src/yeti.cpp.o
-.PHONY : src/yeti.o
-
-# target to build an object file
-src/yeti.cpp.o:
- $(MAKE) -f CMakeFiles/yetihack.dir/build.make CMakeFiles/yetihack.dir/src/yeti.cpp.o
-.PHONY : src/yeti.cpp.o
-
-src/yeti.i: src/yeti.cpp.i
-.PHONY : src/yeti.i
-
-# target to preprocess a source file
-src/yeti.cpp.i:
- $(MAKE) -f CMakeFiles/yetihack.dir/build.make CMakeFiles/yetihack.dir/src/yeti.cpp.i
-.PHONY : src/yeti.cpp.i
-
-src/yeti.s: src/yeti.cpp.s
-.PHONY : src/yeti.s
-
-# target to generate assembly for a file
-src/yeti.cpp.s:
- $(MAKE) -f CMakeFiles/yetihack.dir/build.make CMakeFiles/yetihack.dir/src/yeti.cpp.s
-.PHONY : src/yeti.cpp.s
-
-src/yetihack.o: src/yetihack.cpp.o
-.PHONY : src/yetihack.o
-
-# target to build an object file
-src/yetihack.cpp.o:
- $(MAKE) -f CMakeFiles/yetihack.dir/build.make CMakeFiles/yetihack.dir/src/yetihack.cpp.o
-.PHONY : src/yetihack.cpp.o
-
-src/yetihack.i: src/yetihack.cpp.i
-.PHONY : src/yetihack.i
-
-# target to preprocess a source file
-src/yetihack.cpp.i:
- $(MAKE) -f CMakeFiles/yetihack.dir/build.make CMakeFiles/yetihack.dir/src/yetihack.cpp.i
-.PHONY : src/yetihack.cpp.i
-
-src/yetihack.s: src/yetihack.cpp.s
-.PHONY : src/yetihack.s
-
-# target to generate assembly for a file
-src/yetihack.cpp.s:
- $(MAKE) -f CMakeFiles/yetihack.dir/build.make CMakeFiles/yetihack.dir/src/yetihack.cpp.s
-.PHONY : src/yetihack.cpp.s
-
-# Help Target
-help:
- @echo "The following are some of the valid targets for this Makefile:"
- @echo "... all (the default if no target is provided)"
- @echo "... clean"
- @echo "... depend"
- @echo "... edit_cache"
- @echo "... install"
- @echo "... install/local"
- @echo "... install/strip"
- @echo "... list_install_components"
- @echo "... rebuild_cache"
- @echo "... yetihack"
- @echo "... src/yeti.o"
- @echo "... src/yeti.i"
- @echo "... src/yeti.s"
- @echo "... src/yetihack.o"
- @echo "... src/yetihack.i"
- @echo "... src/yetihack.s"
-.PHONY : help
-
-
-
-#=============================================================================
-# Special targets to cleanup operation of make.
-
-# Special rule to run CMake to check the build system integrity.
-# No rule that depends on this can have commands that come from listfiles
-# because they might be regenerated.
-cmake_check_build_system:
- $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
-.PHONY : cmake_check_build_system
-
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..ab7d67a
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,26 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1744463964,
+ "narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "ref": "nixos-unstable",
+ "type": "indirect"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..08deb06
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,61 @@
+{
+ description = "A shitty game I wrote a long time ago";
+
+ # Nixpkgs / NixOS version to use.
+ inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
+
+ outputs = { self, nixpkgs }:
+ let
+
+ # to work with older version of flakes
+ lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
+
+ # Generate a user-friendly version number.
+ version = builtins.substring 0 8 lastModifiedDate;
+
+ # System types to support.
+ supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
+
+ # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
+ forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
+
+ # Nixpkgs instantiated for supported system types.
+ nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
+
+ in
+
+ {
+
+ # A Nixpkgs overlay.
+ overlay = final: prev: {
+
+ yetihack = with final; stdenv.mkDerivation rec {
+ pname = "yetihack";
+ inherit version;
+
+ src = ./.;
+
+ nativeBuildInputs = [ pkg-config ];
+ buildInputs = [ ncurses ];
+
+ installPhase = ''
+ mkdir -p $out/bin
+ cp yetihack $out/bin
+ '';
+ };
+
+ };
+
+ # Provide some binary packages for selected system types.
+ packages = forAllSystems (system:
+ {
+ inherit (nixpkgsFor.${system}) yetihack;
+ });
+
+ # The default package for 'nix build'. This makes sense if the
+ # flake provides only one package or there is a clear "main"
+ # package.
+ defaultPackage = forAllSystems (system: self.packages.${system}.yetihack);
+
+ };
+}
diff --git a/include/config.h b/include/config.h
new file mode 100644
index 0000000..0544e65
--- /dev/null
+++ b/include/config.h
@@ -0,0 +1,10 @@
+#ifndef YETIHACK_CONFIG_H_
+#define YETIHACK_CONFIG_H_
+
+#define HAVE_UNISTD_H
+
+#ifdef HAVE_WINDOWS_H
+#undef HAVE_WINDOWS_H
+#endif
+
+#endif // YETIHACK_CONFIG_H_