Makefile improvements
authorClinton Ebadi <clinton@unknownlamer.org>
Wed, 16 Apr 2014 07:59:05 +0000 (03:59 -0400)
committerClinton Ebadi <clinton@unknownlamer.org>
Wed, 16 Apr 2014 07:59:05 +0000 (03:59 -0400)
* Respect CFLAGS
* Require DEBUG=1 instead of just DEBUG being set
* Add TC=1 to instruct mlton to only type check
* BUILD32, in theory, could be used to build 32-bit binaries with
  mlton on a 32-bit host, but is not working currently

Makefile

index 118c5de..e23ac72 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,29 @@
+# Supported flags
+#  BUILD32=1 Target 32-bit x86 (Doesn't Work)
+#  TC=1      Stop after typchecking when building using mlton
+#  DEBUG=1   Keep debugging information when building using mlton
+
 all: mlton bin/vmailpasswd elisp/domtool-tables.el
 
 bin/vmailpasswd: src/mail/vmailpasswd.c
-       $(CC) -lcrypt -o $@ $<
+       $(CC) $(CFLAGS) -lcrypt -o $@ $<
+
+ifeq ($(BUILD32), 1)
+       CFLAGS += -m32
+endif
 
 COMMON_DEPS := configDefault/config.sig configDefault/configDefault.sml \
        openssl/openssl_sml.so pcre/pcre_sml.so config.sml
 
 EMACS_DIR := /usr/local/share/emacs/site-lisp/domtool-mode
 
+clean:
+       rm -f bin/*
+       rm -f openssl/openssl_sml.so
+       rm -f openssl/openssl_sml.o
+       rm -f pcre/pcre_sml.so
+       rm -f pcre/pcre_sml.o
+
 config.sml:
        /bin/echo -e 'structure Config :> CONFIG = struct\nopen ConfigDefault\nend' > $@
 
@@ -39,18 +55,18 @@ configDefault/configDefault.sml: config/core/core.sml src/configDefault.sml.head
                >configDefault/configDefault.sml
 
 openssl/openssl_sml.o: openssl/openssl_sml.c
-       gcc -fPIC -c openssl/openssl_sml.c -o openssl/openssl_sml.o
+       gcc $(CFLAGS) -fPIC -c openssl/openssl_sml.c -o openssl/openssl_sml.o
 
 openssl/openssl_sml.so: openssl/openssl_sml.o
-       gcc -shared -Wl,-soname,openssl_sml.so \
+       gcc $(CFLAGS) -shared -Wl,-soname,openssl_sml.so \
                -o openssl/openssl_sml.so \
                openssl/openssl_sml.o -lssl
 
 pcre/pcre_sml.o: pcre/pcre_sml.c
-       gcc -fPIC -c pcre/pcre_sml.c -o pcre/pcre_sml.o
+       gcc $(CFLAGS) -fPIC -c pcre/pcre_sml.c -o pcre/pcre_sml.o
 
 pcre/pcre_sml.so: pcre/pcre_sml.o
-       gcc -shared -Wl,-soname,pcre_sml.so \
+       gcc $(CFLAGS) -shared -Wl,-soname,pcre_sml.so \
                -o pcre/pcre_sml.so \
                pcre/pcre_sml.o -lpcre
 
@@ -141,10 +157,18 @@ COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
 
 MLTON := mlton -link-opt -ldl
 
-ifdef DEBUG
+ifeq ($(BUILD32),1)
+       MLTON += -codegen c -target i386 -cc-opt -m32
+endif
+
+ifeq ($(DEBUG), 1)
        MLTON += -const 'Exn.keepHistory true'
 endif
 
+ifeq ($(TC), 1)
+       MLTON += -stop tc
+endif
+
 bin/domtool-server: $(COMMON_MLTON_DEPS) src/domtool-server.mlb 
        $(MLTON) -output bin/domtool-server src/domtool-server.mlb