Update makefile with some libraries compiled separately
This commit is contained in:
50
Makefile
50
Makefile
@@ -1,22 +1,50 @@
|
||||
CFLAGS=-Wall -Wextra -ggdb
|
||||
|
||||
LIBWS=./vendor/libmicrohttpd/
|
||||
LIBWS_LIB=$(LIBWS)lib/libmicrohttpd.a
|
||||
|
||||
LIBSHA=./vendor/sha256/
|
||||
LIBSHA_SRC=$(LIBSHA)sha256.c
|
||||
|
||||
LDFLAGS=-lm -luuid
|
||||
INCL_FLAGS=-I$(LIBWS)include -I$(LIBSHA)
|
||||
SHARED_LIB_FILES=output/libpath.a output/libnoh.a output/libsha.a
|
||||
SHARED_LIBS=-L./output -lsha -lpath -lnoh
|
||||
|
||||
server: src/server.c $(LIBSHA_SRC) output
|
||||
gcc $(CFLAGS) $(INCL_FLAGS) -o output/server src/server.c $(LIBSHA_SRC) $(LIBWS_LIB) $(LDFLAGS)
|
||||
################################################################################
|
||||
|
||||
LDFLAGS2=-lm
|
||||
INCL_FLAGS2=-I$(LIBSHA)
|
||||
SERVER_LDFLAGS=-lm -luuid -L $(LIBWS)lib -lmicrohttpd $(SHARED_LIBS)
|
||||
SERVER_INCL_FLAGS=-I$(LIBWS)include -I$(LIBSHA)
|
||||
|
||||
userctl: src/userctl.c $(LIBSHA_SRC) output
|
||||
gcc $(CFLAGS) $(INCL_FLAGS2) -o output/userctl src/userctl.c $(LIBSHA_SRC) $(LDFLAGS2)
|
||||
SERVER_SRC=src/server.c src/users.c \
|
||||
src/id_store.c src/library.c \
|
||||
src/opds_handler.c src/get_handler.c
|
||||
|
||||
server: output/server
|
||||
output/server: $(SERVER_SRC) $(SHARED_LIB_FILES) | output
|
||||
gcc $(CFLAGS) $(SERVER_INCL_FLAGS) -o output/server src/server.c $(SERVER_LDFLAGS)
|
||||
|
||||
################################################################################
|
||||
|
||||
USERCTL_LDFLAGS=-lm $(SHARED_LIBS)
|
||||
USERCTL_INCL_FLAGS=-I$(LIBSHA)
|
||||
|
||||
USERCTL_SRC=src/userctl.c src/users.c
|
||||
|
||||
userctl: output/userctl
|
||||
output/userctl: $(USERCTL_SRC) $(SHARED_LIB_FILES) | output
|
||||
gcc $(CFLAGS) $(USERCTL_INCL_FLAGS) -o output/userctl src/userctl.c $(USERCTL_LDFLAGS)
|
||||
|
||||
################################################################################
|
||||
|
||||
output/libsha.a: $(LIBSHA)sha256.c $(LIBSHA)sha256.h | output
|
||||
gcc $(CFLAGS) -c -o output/sha.o $(LIBSHA)sha256.c
|
||||
ar rcsD output/libsha.a output/sha.o
|
||||
|
||||
output/libpath.a: src/path.c src/path.h | output
|
||||
gcc $(CFLAGS) -x c -c -o output/path.o src/path.c -L ./output -lnoh
|
||||
ar rcsD output/libpath.a output/path.o
|
||||
|
||||
output/libnoh.a: src/noh.h | output
|
||||
gcc $(CFLAGS) -x c -c -o output/noh.o src/noh.h -DNOH_IMPLEMENTATION
|
||||
ar rcsD output/libnoh.a output/noh.o
|
||||
|
||||
################################################################################
|
||||
|
||||
output:
|
||||
mkdir -p output
|
||||
|
||||
4
build.sh
4
build.sh
@@ -5,8 +5,8 @@ clear
|
||||
if [ $1 = "build" ]; then
|
||||
echo "Building"
|
||||
|
||||
make server -B
|
||||
make userctl -B
|
||||
make server
|
||||
make userctl
|
||||
|
||||
elif [ $1 = "run" ]; then
|
||||
echo "Running"
|
||||
|
||||
@@ -440,14 +440,14 @@ bool noh_sv_ends_with(Noh_String_View a, Noh_String_View b);
|
||||
bool noh_sv_ends_with_ci(Noh_String_View a, Noh_String_View b);
|
||||
|
||||
// Checks whether the first string view contains the elements from the second string view.
|
||||
inline bool noh_sv_contains(Noh_String_View a, Noh_String_View b);
|
||||
bool noh_sv_contains(Noh_String_View a, Noh_String_View b);
|
||||
|
||||
// Returns the first index of the second string view in the first string view.
|
||||
// Returns -1 if it is not found.
|
||||
int noh_sv_index_of(Noh_String_View a, Noh_String_View b);
|
||||
|
||||
// Checks whether the first string view contains the elements from the second string view, ignoring the case.
|
||||
inline bool noh_sv_contains_ci(Noh_String_View a, Noh_String_View b);
|
||||
bool noh_sv_contains_ci(Noh_String_View a, Noh_String_View b);
|
||||
|
||||
// Returns the first index of the second string view in the first string view, ignoring the case.
|
||||
// Returns -1 if it is not found.
|
||||
@@ -1113,7 +1113,7 @@ bool noh_sv_ends_with_ci(Noh_String_View a, Noh_String_View b) {
|
||||
return noh_sv_eq_ci(a, b);
|
||||
}
|
||||
|
||||
inline bool noh_sv_contains(Noh_String_View a, Noh_String_View b) {
|
||||
bool noh_sv_contains(Noh_String_View a, Noh_String_View b) {
|
||||
return noh_sv_index_of(a, b) >= 0;
|
||||
}
|
||||
|
||||
@@ -1128,7 +1128,7 @@ int noh_sv_index_of(Noh_String_View a, Noh_String_View b) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline bool noh_sv_contains_ci(Noh_String_View a, Noh_String_View b) {
|
||||
bool noh_sv_contains_ci(Noh_String_View a, Noh_String_View b) {
|
||||
return noh_sv_index_of_ci(a, b) >= 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "path.h"
|
||||
|
||||
static inline bool byte_is_url_safe(char c) {
|
||||
return (c >= 'A' && c <= 'Z')
|
||||
|| (c >= 'a' && c <= 'z')
|
||||
@@ -99,7 +101,7 @@ void url_decode(Noh_String *string) {
|
||||
}
|
||||
|
||||
#define build_path(url, first, ...) build_path_((url), (first), __VA_ARGS__, NULL)
|
||||
static Noh_String build_path_(bool url, bool go_up, Noh_String_View *first, ...) {
|
||||
Noh_String build_path_(bool url, bool go_up, Noh_String_View *first, ...) {
|
||||
va_list args;
|
||||
Noh_String_View *elem_ = first;
|
||||
va_start(args, first);
|
||||
|
||||
13
src/path.h
Normal file
13
src/path.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef PATH_H_
|
||||
#define PATH_H_
|
||||
|
||||
#include "noh.h"
|
||||
|
||||
#define build_path(url, first, ...) build_path_((url), (first), __VA_ARGS__, NULL)
|
||||
Noh_String build_path_(bool url, bool go_up, Noh_String_View *first, ...);
|
||||
|
||||
void url_encode(Noh_String *string);
|
||||
|
||||
void url_decode(Noh_String *string);
|
||||
|
||||
#endif // PATH_H_
|
||||
@@ -2,12 +2,12 @@
|
||||
#include <sha256.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <dirent.h>
|
||||
#define NOH_IMPLEMENTATION
|
||||
|
||||
#include "path.h"
|
||||
#include "noh.h"
|
||||
|
||||
Noh_Arena temp;
|
||||
|
||||
#include "path.c"
|
||||
#include "users.c"
|
||||
|
||||
#define SV Noh_String_View
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#define NOH_IMPLEMENTATION
|
||||
|
||||
#include "path.h"
|
||||
#include "noh.h"
|
||||
|
||||
Noh_Arena temp;
|
||||
|
||||
#include "path.c"
|
||||
#include "users.c"
|
||||
|
||||
#define SV Noh_String_View
|
||||
|
||||
Reference in New Issue
Block a user