diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | config.env.default | 1 | ||||
-rw-r--r-- | src/main.c | 6 |
4 files changed, 13 insertions, 4 deletions
@@ -40,8 +40,8 @@ $(BLDDIR)/rename.ld: $(BLDDIR)/endpoints.o $(BLDDIR) @readelf --syms --wide $(BLDDIR)/endpoints.o | awk '/FUNC/ && /GLOBAL/ && /ENDP/ {old = $$8; gsub(/_/, "/", $$8); gsub(/ENDP/, "", $$8); printf "\t%s = %s;\n", $$8, old }' >> $@ echo } >> $@ -endpoints.so: $(BLDDIR)/endpoints.o $(BLDDIR)/common.o $(BLDDIR)/mime.o $(BLDDIR)/sql.o - $(CC) -shared -fPIC -Wl,$(BLDDIR)/rename.ld $(CFLAGS) $^ -lmicrohttpd -lsqlite3 -o $@ +endpoints.so: $(BLDDIR)/endpoints.o $(BLDDIR)/common.o $(BLDDIR)/mime.o $(BLDDIR)/sql.o $(BLDDIR)/rename.ld + $(CC) -shared -fPIC -Wl,$(BLDDIR)/rename.ld $(CFLAGS) $(BLDDIR)/endpoints.o $(BLDDIR)/common.o $(BLDDIR)/mime.o $(BLDDIR)/sql.o -lmicrohttpd -lsqlite3 -o $@ # main @@ -58,7 +58,7 @@ main: $(BLDDIR)/main.o $(BLDDIR)/mime.o $(BLDDIR)/common.o $(CC) $(CFLAGS) $^ -ldl -lmicrohttpd -lsqlite3 -o $@ clean: - $(RM) --recursive $(BLDDIR)/template/* $(BLDDIR)/* main endpoints.o endpoints.so rename.ld include/mime.h.inc + $(RM) --recursive $(BLDDIR)/template/* $(BLDDIR)/* main endpoints.o endpoints.so rename.ld include/mime.c.inc veryclean: clean $(RM) jals.db config.env @@ -28,6 +28,7 @@ Pretty small. See [html docs page](www/docs.html). # Build ## Requirements +0. submodules 0. `make` 0. `gperf` 0. `cc` @@ -38,6 +39,9 @@ Pretty small. See [html docs page](www/docs.html). all of the paths can be configured in [`Makefile`](Makefile) ## Steps `make` +## Os-specific dependency installation: +* debian12: `# apt install libmicrohttpd-dev libsqlite3-dev gperf` +* arch: `# pacman -S libmicrohttpd sqlite gperf` # Run 0. Copy `config.env.default` to `config.env`, change environment variables in diff --git a/config.env.default b/config.env.default index 1af9713..c7a2bb3 100644 --- a/config.env.default +++ b/config.env.default @@ -1 +1,2 @@ HTTPHOSTNAME=http://localhost +HTTPPORT=8080 @@ -21,6 +21,8 @@ # define DEFAULT_DATABASE_PATH "./jals.db" #endif +unsigned short HTTPPORT; + struct connarg { void* dylib; query_func query; @@ -105,7 +107,9 @@ struct MHD_Daemon *init(sigset_t *sigset, const char *dlpath, const char *dbpath sigset_t oldmask; pthread_sigmask(SIG_BLOCK, &newmask, sigset); /* To prevent MHD from recieving the signal */ - struct MHD_Daemon *daemon = MHD_start_daemon(MHD_USE_ERROR_LOG | MHD_USE_POLL | MHD_USE_INTERNAL_POLLING_THREAD, 8080, NULL, NULL, process_connection, &arg, MHD_OPTION_END); + const char* httpport_envp = getenv("HTTPPORT"); + HTTPPORT = httpport_envp ? atoi(httpport_envp) : 8080; + struct MHD_Daemon *daemon = MHD_start_daemon(MHD_USE_ERROR_LOG | MHD_USE_POLL | MHD_USE_INTERNAL_POLLING_THREAD, HTTPPORT, NULL, NULL, process_connection, &arg, MHD_OPTION_END); pthread_sigmask(SIG_UNBLOCK, &newmask, NULL); if (daemon == NULL) LFAILV("could not initialize daemon"); |