aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-10-06 19:41:32 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-10-06 19:41:32 -0300
commitf3c2d53f1837a7bd8e9e1517579b7354af91ef8c (patch)
treeabc2c97032e96e6fef0470db853dbf47b0efe00b /Makefile
parentfa22d10a9d132ff509cb4b40ced1c6d1c0e98167 (diff)
downloadquerymanager-f3c2d53f1837a7bd8e9e1517579b7354af91ef8c.tar.gz
querymanager-f3c2d53f1837a7bd8e9e1517579b7354af91ef8c.zip
sketch out new query queue/worker for async queries
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile33
1 files changed, 28 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 3a8453d..0ba1f30 100644
--- a/Makefile
+++ b/Makefile
@@ -8,14 +8,29 @@ CFLAGS = -m64 -fno-strict-aliasing -pedantic -Wno-unused-parameter -Wall -Wextra
CXXFLAGS = $(CFLAGS) --std=c++11
LFLAGS = -Wl,-t
+# IMPORTANT(fusion): Using TABS outside recipes may cause errors in some cases.
+# This is because .RECIPEPREFIX defaults to it and any line starting with it is
+# assumed to introduce another recipe command. If indentation is needed before
+# any target is specified, use SPACES.
+
DEBUG ?= 0
ifneq ($(DEBUG), 0)
- CFLAGS += -g -Og
+ CFLAGS += -g -Og -DENABLE_ASSERTIONS=1
+else
+ CFLAGS += -O2
+endif
+
+DATABASE ?= sqlite
+ifeq ($(DATABASE), sqlite)
+ DATABASEOBJ = $(BUILDDIR)/database_sqlite.obj $(BUILDDIR)/sqlite3.obj
+else ifeq ($(DATABASE), postgres)
+ DATABASEOBJ = $(BUILDDIR)/database_pq.obj
+ LFLAGS += -lpq
else
- CFLAGS += -O2
+ $(error Unsupported DATABASE: `$(DATABASE)`. Valid options are `sqlite` or `postgres`)
endif
-$(BUILDDIR)/$(OUTPUTEXE): $(BUILDDIR)/connections.obj $(BUILDDIR)/database.obj $(BUILDDIR)/hostcache.obj $(BUILDDIR)/querymanager.obj $(BUILDDIR)/sha256.obj $(BUILDDIR)/sqlite3.obj
+$(BUILDDIR)/$(OUTPUTEXE): $(BUILDDIR)/connections.obj $(BUILDDIR)/hostcache.obj $(BUILDDIR)/query.obj $(BUILDDIR)/querymanager.obj $(BUILDDIR)/sha256.obj $(DATABASEOBJ)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LFLAGS)
@@ -23,11 +38,11 @@ $(BUILDDIR)/connections.obj: $(SRCDIR)/connections.cc $(SRCDIR)/querymanager.hh
@mkdir -p $(@D)
$(CXX) -c $(CXXFLAGS) -o $@ $<
-$(BUILDDIR)/database.obj: $(SRCDIR)/database.cc $(SRCDIR)/querymanager.hh
+$(BUILDDIR)/hostcache.obj: $(SRCDIR)/hostcache.cc $(SRCDIR)/querymanager.hh
@mkdir -p $(@D)
$(CXX) -c $(CXXFLAGS) -o $@ $<
-$(BUILDDIR)/hostcache.obj: $(SRCDIR)/hostcache.cc $(SRCDIR)/querymanager.hh
+$(BUILDDIR)/query.obj: $(SRCDIR)/query.cc $(SRCDIR)/querymanager.hh
@mkdir -p $(@D)
$(CXX) -c $(CXXFLAGS) -o $@ $<
@@ -39,6 +54,14 @@ $(BUILDDIR)/sha256.obj: $(SRCDIR)/sha256.cc $(SRCDIR)/querymanager.hh
@mkdir -p $(@D)
$(CXX) -c $(CXXFLAGS) -o $@ $<
+$(BUILDDIR)/database_sqlite.obj: $(SRCDIR)/database_sqlite.cc $(SRCDIR)/querymanager.hh
+ @mkdir -p $(@D)
+ $(CXX) -c $(CXXFLAGS) -o $@ $<
+
+$(BUILDDIR)/database_pq.obj: $(SRCDIR)/database_pq.cc $(SRCDIR)/querymanager.hh
+ @mkdir -p $(@D)
+ $(CXX) -c $(CXXFLAGS) -o $@ $<
+
$(BUILDDIR)/sqlite3.obj: $(SRCDIR)/sqlite3.c $(SRCDIR)/sqlite3.h
@mkdir -p $(@D)
$(CC) -c $(CFLAGS) -o $@ $<