aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-07-21 16:09:40 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-07-21 16:11:16 +0200
commitfa5bc4d0b8c68d488c3b288362bbff88ad104db1 (patch)
tree55fb779b3b880468e1bd442e674f0485947f0c8e
parentReword terminal output to better modularization. (diff)
downloadcalp-fa5bc4d0b8c68d488c3b288362bbff88ad104db1.tar.gz
calp-fa5bc4d0b8c68d488c3b288362bbff88ad104db1.tar.xz
Rewrote build and main execution.
-rw-r--r--Makefile47
-rwxr-xr-xmodule/main.scm17
-rw-r--r--module/vcomponent/primitive.scm3
-rw-r--r--module/vulgar/termios.scm2
4 files changed, 38 insertions, 31 deletions
diff --git a/Makefile b/Makefile
index e7dae809..2b22c86d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: all clean tests guild-stuff guile-none
+.PHONY: all clean tests
CC := gcc
@@ -6,10 +6,10 @@ OBJDIR = obj
SRCDIR = src
LIBDIR = lib
-CFLAGS = -std=gnu11 -Wall -Wextra \
- -ggdb -fPIC \
- $(shell guile-config compile)
-LDFLAGS = -fPIC $(shell guile-config link)
+export LD_LIBRARY_PATH=$(PWD)/$(LIBDIR)
+
+CFLAGS = -std=gnu11 -Wall -Wextra -ggdb -fPIC $(shell guile-config compile)
+LDFLAGS = $(shell guile-config link)
LIBS = libguile-calendar.so
SO_FILES = $(addprefix $(LIBDIR)/, $(LIBS))
@@ -24,39 +24,41 @@ X_FILES = $(SCM_C_FILES:.scm.c=.x)
O_FILES = $(C_FILES:src/%.c=obj/%.o)
-all: parse $(SO_FILES) guild-stuff guile-none
+SCM_FILES = $(shell find module/ -type f -name \*.scm)
+GO_FILES = $(addprefix obj/,$(addsuffix .go,$(SCM_FILES)))
+
+GUILE_C_FLAGS = -Lmodule \
+ -Wunused-variable -Wunused-toplevel \
+ -Wshadowed-toplevel -Wunbound-variable \
+ -Wmacro-use-before-definition -Warity-mismatch \
+ -Wduplicate-case-datum -Wbad-case-datum
-guild-stuff:
- guild compile module/vcomponent/primitive.scm
-guile-none:
- module/main.scm none
+all: $(SO_FILES) $(GO_FILES)
+# Old C main
parse: $(O_FILES)
$(CC) -o $@ $^ $(LDFLAGS)
-$(O_FILES): | $(OBJDIR)
-
-$(SO_FILES): | $(LIBDIR)
-
src/%.x : src/%.scm.c
guile-snarf -o $@ $< $(CFLAGS)
$(OBJDIR)/%.scm.o : src/%.scm.c src/%.x
+ @mkdir -p $(OBJDIR)
$(CC) -c $(CFLAGS) -o $@ $<
$(OBJDIR)/%.o : src/%.c # $(H_FILES) $(X_FILES)
+ @mkdir -p $(OBJDIR)
$(CC) -c $(CFLAGS) -o $@ $<
-$(OBJDIR):
- mkdir -p $(OBJDIR)
-
-$(LIBDIR):
- mkdir -p $(LIBDIR)
-
$(LIBDIR)/%.so: $(O_FILES)
+ @mkdir -p $(LIBDIR)
$(CC) -shared -o $@ $^ $(LDFLAGS)
+$(OBJDIR)/%.scm.go: %.scm $(SO_FILES)
+ @mkdir -p $(OBJDIR)
+ guild compile $(GUILE_C_FLAGS) -o $@ $<
+
.SECONDARY += %.dot
%.dot: testcal/%.ics parse
./parse $< -g $@
@@ -70,11 +72,10 @@ tags: $(C_FILES) $(H_FILES)
clean:
-rm parse
- -rm $(OBJDIR)/*.o
- -rmdir $(OBJDIR)
+ -rm -r $(OBJDIR)/*
-rm $(LIBDIR)/*.so
-rm $(SRCDIR)/*.x
- -rm -r $$HOME/.cache/guile/ccache/2.2-LE-8-3.A/$$PWD
+
tests:
tests/run-tests.scm
diff --git a/module/main.scm b/module/main.scm
index 6fb878a0..c991f78b 100755
--- a/module/main.scm
+++ b/module/main.scm
@@ -1,8 +1,17 @@
-#!/usr/bin/guile \
--e main -s
-!#
+#!/bin/bash
+# -*- mode: scheme -*-
+
+root=$(dirname $(dirname $(realpath $0)))
+
+GUILE_LOAD_PATH="$root/module:$GUILE_LOAD_PATH"
+GUILE_LOAD_COMPILED_PATH="root/obj/module:$GUILE_LOAD_COMPILED_PATH"
+LD_LIBRARY_PATH="$root/lib:$LD_LIBRARY_PATH"
-(add-to-load-path (dirname (current-filename)))
+export GUILE_LOAD_PATH GUILE_LOAD_COMPILED_PATH LD_LIBRARY_PATH
+export GUILE_AUTO_COMPILE=0
+
+exec guile -e main -s $0 "$@"
+!#
(use-modules (srfi srfi-1)
(srfi srfi-19)
diff --git a/module/vcomponent/primitive.scm b/module/vcomponent/primitive.scm
index b583d454..ad33a3be 100644
--- a/module/vcomponent/primitive.scm
+++ b/module/vcomponent/primitive.scm
@@ -16,7 +16,4 @@
%vcomponent-shallow-copy))
-(setenv "LD_LIBRARY_PATH"
- (string-append (dirname (dirname (dirname (current-filename))))
- "/lib"))
(load-extension "libguile-calendar" "init_lib")
diff --git a/module/vulgar/termios.scm b/module/vulgar/termios.scm
index aa40b6e7..6bebda2a 100644
--- a/module/vulgar/termios.scm
+++ b/module/vulgar/termios.scm
@@ -36,7 +36,7 @@
;; int, * → int, and bind it to a scheme procedure of the same name.
;;
;; Currently only links to the library stored in the variable lib, when called.
-(eval-when (compile)
+(eval-when (compile expand)
(read-hash-extend
#\$ (lambda (c port)
(let* ((name (string-trim-both (read-delimited ":" port)))