mirror of
https://github.com/sigmasternchen/CShore
synced 2025-03-15 16:18:56 +00:00
project restructure
This commit is contained in:
parent
94647efd6e
commit
69843f16a4
11 changed files with 51 additions and 17 deletions
53
Makefile
53
Makefile
|
@ -3,22 +3,55 @@ LD = gcc
|
||||||
CFLAGS = -Wall -g -std=c99 -ICFloor/src/ -ICson/src/ -D_POSIX_SOURCE
|
CFLAGS = -Wall -g -std=c99 -ICFloor/src/ -ICson/src/ -D_POSIX_SOURCE
|
||||||
LDFLAGS = -lpthread -lrt
|
LDFLAGS = -lpthread -lrt
|
||||||
|
|
||||||
test: main.o router.o request.o test.o CFloor/libcfloor.a Cson/libcson.a
|
CFLOOR_LIB = CFloor/libcfloor.a
|
||||||
|
CSON_LIB = Cson/libcson.a
|
||||||
|
LIBS = $(CFLOOR_LIB) $(CSON_LIB)
|
||||||
|
|
||||||
|
OBJS = obj/router.o obj/request.o obj/base_cfloor.o
|
||||||
|
DEPS = $(OBJS:%.o=%.d)
|
||||||
|
|
||||||
|
DEMO_OBJS = obj/demo.o
|
||||||
|
|
||||||
|
HAS_MAIN =
|
||||||
|
NEEDS_MAIN = \
|
||||||
|
if test "$(HAS_MAIN)" != "yes"; then\
|
||||||
|
echo "ERROR: Trying to build standalone without base.";\
|
||||||
|
echo " Specify target base_cfloor instead.";\
|
||||||
|
exit 1;\
|
||||||
|
fi
|
||||||
|
|
||||||
|
all: base_cfloor clean
|
||||||
|
|
||||||
|
base_cfloor: CFLAGS += -DBASE_CFLOOR
|
||||||
|
base_cfloor: HAS_MAIN = "yes"
|
||||||
|
base_cfloor: standalone
|
||||||
|
|
||||||
|
|
||||||
|
standalone: $(DEMO_OBJS) $(OBJS) $(LIBS)
|
||||||
|
@$(NEEDS_MAIN)
|
||||||
$(LD) $(LDFLAGS) -o $@ $^
|
$(LD) $(LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
CFloor/libcfloor.a:
|
$(CFLOOR_LIB):
|
||||||
$(MAKE) -C CFloor/ libcfloor.a
|
$(MAKE) -C CFloor/ libcfloor.a
|
||||||
|
|
||||||
Cson/libcson.a:
|
$(CSON_LIB):
|
||||||
$(MAKE) -C Cson/ libcson.a
|
$(MAKE) -C Cson/ libcson.a
|
||||||
|
|
||||||
%.o: %.c
|
-include $(DEPS)
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
|
||||||
|
obj/%.o: demo/%.c obj
|
||||||
#main.o: main.c router.h
|
$(CC) $(CFLAGS) -Isrc/ -MMD -c -o $@ $<
|
||||||
#router.o: router.c router.h
|
|
||||||
#test.o: controller.h
|
obj/%.o: src/%.c obj
|
||||||
|
$(CC) $(CFLAGS) -MMD -c -o $@ $<
|
||||||
|
|
||||||
|
obj:
|
||||||
|
@mkdir -p obj
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o test
|
@echo "Cleaning up..."
|
||||||
|
@rm -f obj/*.o
|
||||||
|
@rm -f obj/*.d
|
||||||
|
@rm -f standalone
|
||||||
$(MAKE) -C CFloor/ clean
|
$(MAKE) -C CFloor/ clean
|
||||||
|
$(MAKE) -C Cson/ clean
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "controller.h"
|
#include <controller.h>
|
||||||
|
|
||||||
|
|
||||||
GET("/", hello);
|
GET("/", hello);
|
||||||
|
@ -12,5 +12,5 @@ response_t hello(ctx_t ctx) {
|
||||||
|
|
||||||
GET("/foobar", foobar);
|
GET("/foobar", foobar);
|
||||||
response_t foobar(ctx_t ctx) {
|
response_t foobar(ctx_t ctx) {
|
||||||
return fileResponse("foobar.txt");
|
return fileResponse("demo/foobar.txt");
|
||||||
}
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifdef BASE_CFLOOR
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -80,3 +82,5 @@ int main() {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef MISC_H_
|
#ifndef COMMON_H_
|
||||||
#define MISC_H_
|
#define COMMON_H_
|
||||||
|
|
||||||
#include <misc.h>
|
#include <misc.h>
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#include <json.h>
|
#include <json.h>
|
||||||
|
|
||||||
|
|
||||||
#include "request.h"
|
#include "request.h"
|
||||||
|
|
||||||
response_t emptyResponse() {
|
response_t emptyResponse() {
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef ROUTER_H
|
#ifndef ROUTER_H
|
||||||
#define ROUTER_H
|
#define ROUTER_H
|
||||||
|
|
||||||
#include <misc.h>
|
|
||||||
|
|
||||||
#include "handler.h"
|
#include "handler.h"
|
||||||
|
|
||||||
int registerRoute(method_t method, const char* path, handle_t handle);
|
int registerRoute(method_t method, const char* path, handle_t handle);
|
Loading…
Reference in a new issue