big refactor of pretty much everything

I still need to make the Makefile better as it's pretty shit right now
but it's alright for now I think
This commit is contained in:
jacekpoz 2024-02-11 23:23:50 +01:00
parent 5601945db1
commit d24c1d3767
No known key found for this signature in database
GPG key ID: 94E812A8B12AAE3C
16 changed files with 32 additions and 20 deletions

View file

@ -6,16 +6,20 @@ CFLAGS += -Wcast-qual -Wswitch-default -Wswitch-enum
CFLAGS += -Wconversion -Wunreachable-code CFLAGS += -Wconversion -Wunreachable-code
# for asprintf() and getline() # for asprintf() and getline()
CFLAGS += -D_GNU_SOURCE CFLAGS += -D_GNU_SOURCE
CFLAGS += -Iinclude
LDFLAGS = LDFLAGS =
NAME = modfetch NAME = modfetch
PROG = modfetch.c SRC = src
LIB = config.c semver.c util.c _PROG = modfetch.c
OBJ = $(PROG:.c=.o) $(LIB:.c=.o) PROG = $(addprefix $(SRC)/, $(_PROG))
_LIB = config.c semver.c util.c
LIB = $(addprefix $(SRC)/, $(_LIB))
OBJ = $(_PROG:.c=.o) $(_LIB:.c=.o)
BIN = target BIN = target
TEMPMOD = $(wildcard modules/*.c) _MOD = $(wildcard modules/*.c)
MOD = $(TEMPMOD:modules/%=%) MOD = $(_MOD:modules/%=%)
.PHONY: all clean .PHONY: all clean
@ -32,7 +36,7 @@ $(NAME): $(OBJ)
%.so: modules/%.c $(LIB) %.so: modules/%.c $(LIB)
$(CC) $^ -shared -fPIC $(CFLAGS) $(LDFLAGS) -o $(BIN)/$@ $(CC) $^ -shared -fPIC $(CFLAGS) $(LDFLAGS) -o $(BIN)/$@
%.o: %.c %.o: src/%.c
$(CC) -c $< $(CFLAGS) -o $(BIN)/$@ $(CC) -c $< $(CFLAGS) -o $(BIN)/$@
clean: clean_modules clean: clean_modules

View file

@ -16,7 +16,7 @@ typedef struct {
Module *modules; Module *modules;
} Config; } Config;
char *default_config_path(); char *default_config_path(void);
void parsing_error(size_t line); void parsing_error(size_t line);

View file

@ -1,7 +1,8 @@
#ifndef _MODFETCH_MOD_H #ifndef _MODFETCH_MOD_H
#define _MODFETCH_MOD_H #define _MODFETCH_MOD_H
#include "semver.h" #include <semver.h>
#include <stdint.h> #include <stdint.h>
static const semver API_VERSION = { static const semver API_VERSION = {

View file

@ -4,7 +4,8 @@
* 09 Feb 2024 * 09 Feb 2024
*/ */
#include "../mod.h" #include <mod.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -4,7 +4,8 @@
* 09 Feb 2024 * 09 Feb 2024
*/ */
#include "../mod.h" #include <mod.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View file

@ -8,7 +8,8 @@
* 09 Feb 2024 * 09 Feb 2024
*/ */
#include "../mod.h" #include <mod.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -1,5 +1,7 @@
#include "config.h" #include <config.h>
#include "util.h"
#include <util.h>
#include <errno.h> #include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
@ -7,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
char *default_config_path() { char *default_config_path(void) {
char *config_path = NULL; char *config_path = NULL;
char *config_dir = getenv("XDG_CONFIG_HOME"); char *config_dir = getenv("XDG_CONFIG_HOME");

BIN
src/config.o Normal file

Binary file not shown.

View file

@ -1,7 +1,7 @@
#include "config.h" #include <config.h>
#include "mod.h" #include <mod.h>
#include "semver.h" #include <semver.h>
#include "util.h" #include <util.h>
#include <ctype.h> #include <ctype.h>
#include <dlfcn.h> #include <dlfcn.h>

BIN
src/modfetch.o Normal file

Binary file not shown.

View file

@ -1,4 +1,5 @@
#include "semver.h" #include <semver.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

BIN
src/semver.o Normal file

Binary file not shown.

View file

@ -1,4 +1,5 @@
#include "util.h" #include <util.h>
#include <ctype.h> #include <ctype.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>

BIN
src/util.o Normal file

Binary file not shown.