Skip to content

Commit

Permalink
Merge pull request #56 from Sigmanificient/makefile-improvements
Browse files Browse the repository at this point in the history
Makefile portability improvements
  • Loading branch information
cococry authored Sep 20, 2024
2 parents 756b59e + 901b4c4 commit 451e90d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 102 deletions.
45 changes: 30 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
CC = cc
CFLAGS = -O3 -ffast-math -Wall -Wextra -pedantic
LIBS = -lxcb -lxcb-keysyms -lxcb-icccm -lxcb-cursor -lxcb-randr -lxcb-composite -lxcb-ewmh -lX11 -lX11-xcb -lGL -lm -lconfig
SRC = ./src/*.c ./src/ipc/*.c
BIN = ragnar
CC = cc
CFLAGS = -O3 -ffast-math -Wall -Wextra -pedantic
CFLAGS += -isystem api/include

all:
LDLIBS = -lxcb -lxcb-keysyms -lxcb-icccm -lxcb-cursor -lxcb-randr -lxcb-composite -lxcb-ewmh -lX11 -lX11-xcb -lGL -lm -lconfig

SRC = ./src/*.c ./src/ipc/*.c
BIN = ragnar

RAGNAR_API = api/lib/ragnar.a

PREFIX = /usr
BINDIR = $(PREFIX)/bin

.PHONY: all
all: $(RAGNAR_API)
mkdir -p ./bin
${CC} -o bin/${BIN} ${SRC} ${LIBS} ${CFLAGS}
$(CC) -o bin/$(BIN) $(CFLAGS) $(SRC) $(LDLIBS)

$(RAGNAR_API):
$(MAKE) -C api

SOURCE_DIR := ./cfg/
DEST_DIR := $(HOME)/.config/ragnarwm
CONFIG_FILE := $(DEST_DIR)/ragnar.cfg

.PHONY: config
config:
@if [ ! -f "$(CONFIG_FILE)" ]; then \
echo "Config file does not exist. Copying default config..."; \
Expand All @@ -21,16 +34,18 @@ config:
echo "Config file already exists. Skipping copy."; \
fi

.PHONY: install
install:
sudo cp -f bin/${BIN} /usr/bin
sudo cp -f ragnar.desktop /usr/share/xsessions/
sudo cp -f ragnarstart /usr/bin
sudo chmod 755 /usr/bin/ragnar
install -Dm755 bin/$(BIN) -t $(BINDIR)
install -Dm755 ragnarstart -t $(BINDIR)
cp -f ragnar.desktop $(PREFIX)/share/xsessions/

.PHONY: clean
clean:
rm -f bin/*
$(RM) bin/*

.PHONY: uninstall
uninstall:
sudo rm -f /usr/bin/ragnar
sudo rm -f /usr/share/xsessions/ragnar.desktop
sudo rm -f /usr/bin/ragnarstart
$(RM) $(BINDIR)/ragnar
$(RM) $(PREFIX)/share/xsessions/ragnar.desktop
$(RM) $(BINDIR)/ragnarstart
55 changes: 11 additions & 44 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 12 additions & 43 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,34 @@
description = "Ragnar Window Manager";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
...
}:
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};

libs = with pkgs; [
fontconfig
libGL
mesa
libconfig
] ++ (with pkgs.xorg; [
libX11
libXft
libXcursor
libXcomposite
libxcb
xcbutil
xcbutilwm
xorgproto
xcb-util-cursor
xcbutilkeysyms
]);

in {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
gnumake
gcc
glibc
] ++ libs;
};

packages.ragnarwm = pkgs.stdenv.mkDerivation {
name = "ragnarwm";
src = ./.;

makeFlags = [
"CC=${pkgs.stdenv.cc}/bin/cc"
];

buildInputs = libs;
hardeningDisable = [ "format" "fortify" ];

installPhase = ''
runHook preInstall
mkdir -p $out/bin
mkdir -p $out/share/applications
mkdir -p $out/share/xessions
cp -f ragnar $out/bin
cp -f ragnar.desktop $out/share/applications
cp -f ragnar.desktop $out/share/xsessions
cp -f ragnarstart $out/bin
chmod 755 $out/bin/ragnar
runHook postInstall
'';
};

packages.default = self.packages.${system}.ragnarwm;
});
}

0 comments on commit 451e90d

Please sign in to comment.