summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2025-04-10 18:58:30 -0500
committer@syxhe <https://t.me/syxhe>2025-04-10 18:58:30 -0500
commitd9d142a7ad0bade65b6f8b777259e203dc6d5301 (patch)
tree51e174696bb4397e97b10748a21d67ca5e4f971e
parente5454e63a086e549f54c23a686ff300b99a83b58 (diff)
Overhaul makefile
-rw-r--r--.gitignore3
-rw-r--r--src/Makefile19
-rwxr-xr-xsrc/depend.sh14
-rw-r--r--src/encryption.c3
-rw-r--r--src/encryption.h2
-rw-r--r--src/shared.c4
6 files changed, 29 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index 2bba462..72dbe73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@ bin/
6*.o 6*.o
7*test* 7*test*
8*.enc 8*.enc
9.vscode/ \ No newline at end of file 9.vscode/
10*.dep \ No newline at end of file
diff --git a/src/Makefile b/src/Makefile
index 53cd9fd..88c5344 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,5 +1,5 @@
1CC = gcc 1CC = gcc
2SHELL = /usr/bin/env -S bash 2SHELL := bash
3 3
4# I need to get better at makefiles so I can write this in a way that isn't absolutely insane/stupid 4# I need to get better at makefiles so I can write this in a way that isn't absolutely insane/stupid
5# RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto 5# RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto
@@ -9,24 +9,23 @@ CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyze
9LDLIBS += $$(pkg-config --libs-only-l libsodium) 9LDLIBS += $$(pkg-config --libs-only-l libsodium)
10LDFLAGS += $$(pkg-config --libs-only-L libsodium) 10LDFLAGS += $$(pkg-config --libs-only-L libsodium)
11 11
12OBJECTS := $(patsubst %.c,%.o, $(wildcard *.c)) 12SOURCES := $(wildcard *.c)
13OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
14DEPS := $(patsubst %.c,%.dep,$(SOURCES))
13 15
14.PHONY: all c clean val 16.PHONY: all c clean val
15.DELETE_ON_ERROR: 17.DELETE_ON_ERROR:
18.ONESHELL:
16 19
17all: main 20all: main
18main: main.o encryption.o shared.o ll.o arena.o 21main: main.o encryption.o shared.o ll.o arena.o
19 22
20 23$(OBJECTS): %.o: %.dep
21$(OBJECTS): shared.h 24%.dep: %.c
22ll.o: ll.c ll.h 25 ./depend.sh `dirname $*` $(CFLAGS) $*.c > $@
23main.o: main.c
24arena.o: arena.c arena.h
25shared.o: shared.c shared.h # Might as well put shared.h in here explicitly
26encryption.o: encryption.c encryption.h
27 26
28c clean: 27c clean:
29 -rm -rv main $(OBJECTS) $(wildcard *.test*) $(wildcard *.enc) 28 @-rm -rv main $(OBJECTS) $(DEPS) $(wildcard *.test*) $(wildcard *.enc)
30 29
31val: 30val:
32 $(MAKE) all 31 $(MAKE) all
diff --git a/src/depend.sh b/src/depend.sh
new file mode 100755
index 0000000..b6084b1
--- /dev/null
+++ b/src/depend.sh
@@ -0,0 +1,14 @@
1#!/bin/bash
2DIR="$1"
3shift 1
4case "$DIR" in
5 "" | ".")
6 gcc -MM -MG "$@" | sed -e "s@^\(.*\)\.o:@\1.d \1.o:@"
7 ;;
8 *)
9 gcc -MM -MG "$@" | sed -e "s@^\(.*\)\.o:@$DIR/\1.d $DIR/\1.o:@"
10 ;;
11esac
12
13# Shamelessly stolen from Peter Miller's "Recursive Make Considered Harmful"
14 # https://web.archive.org/web/20250404190928/https://aegis.sourceforge.net/auug97.pdf \ No newline at end of file
diff --git a/src/encryption.c b/src/encryption.c
index 4ff37cc..3530eed 100644
--- a/src/encryption.c
+++ b/src/encryption.c
@@ -255,8 +255,7 @@ int decrypttofile(FILE *src, FILE *dst, const unsigned char key[crypto_secretstr
255 255
256int genpassword(char **str, unsigned int words) { 256int genpassword(char **str, unsigned int words) {
257 // Early returns 257 // Early returns
258 if(words < 1) 258 if(words < 1) {return 0;}
259 return 0;
260 #if ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0 259 #if ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0
261 checksodium(); 260 checksodium();
262 #endif 261 #endif
diff --git a/src/encryption.h b/src/encryption.h
index b02216f..f6c018c 100644
--- a/src/encryption.h
+++ b/src/encryption.h
@@ -32,7 +32,7 @@ void vxgg_setsodiumfailcb(const vxgg_naclfailcb cb, void *data);
32 32
33// Fuck reading from a file. Even if someone ran strings on the binary and got this they wouldn't be able to regenerate the key 33// Fuck reading from a file. Even if someone ran strings on the binary and got this they wouldn't be able to regenerate the key
34#define PASSWORD_WORDS (\ 34#define PASSWORD_WORDS (\
35 (const char *[]){\ 35 (const char * const []){\
36 "the", "of", "to", "and", "for", "our", "their", "has", "in", "he", "a", "them", "that", "these", "by", "have", "we", \ 36 "the", "of", "to", "and", "for", "our", "their", "has", "in", "he", "a", "them", "that", "these", "by", "have", "we", \
37 "us", "people", "which", "all", "is", "with", "laws", "be", "are", "his", "states", "on", "they", "right", "it", "from", \ 37 "us", "people", "which", "all", "is", "with", "laws", "be", "are", "his", "states", "on", "they", "right", "it", "from", \
38 "government", "such", "among", "powers", "most", "an", "time", "should", "new", "as", "been", "colonies", "assent", \ 38 "government", "such", "among", "powers", "most", "an", "time", "should", "new", "as", "been", "colonies", "assent", \
diff --git a/src/shared.c b/src/shared.c
index 093e766..bec0354 100644
--- a/src/shared.c
+++ b/src/shared.c
@@ -6,7 +6,7 @@
6#include <errno.h> 6#include <errno.h>
7#include <error.h> 7#include <error.h>
8 8
9static enum XALLOC_TYPE { 9enum XALLOC_TYPE {
10 XALLOC_INVAL, // Default when unset 10 XALLOC_INVAL, // Default when unset
11 11
12 XALLOC_MALLOC, 12 XALLOC_MALLOC,
@@ -120,7 +120,7 @@ int rwbuf(char **str, unsigned long int initsize, int fd) {
120int wwbuf(int fd, const unsigned char *buf, int len) { 120int wwbuf(int fd, const unsigned char *buf, int len) {
121 int total = 0; 121 int total = 0;
122 int left = len; 122 int left = len;
123 int n; 123 int n = -1;
124 124
125 while(total < len) { 125 while(total < len) {
126 if((n = write(fd, buf + total, left)) < 0) 126 if((n = write(fd, buf + total, left)) < 0)