From: Michael D. Lowis Date: Thu, 23 Nov 2017 19:17:53 +0000 (-0500) Subject: overhauled makefile rules X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f6bd21e962c6c24494119639bf978971d9da045a;p=archive%2Ftide-ocaml.git overhauled makefile rules --- diff --git a/.gitignore b/.gitignore index daa65c1..47ad031 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +tags *.o *.cmo *.cmx @@ -5,7 +6,5 @@ *.cmxa *.cmi *.a -edit -dlltide.so -unittests -tags +*.bin +*.byte diff --git a/Makefile b/Makefile index de54c83..21f7437 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,30 @@ # Toolchain Configuration #------------------------------------------------------------------------------- -NATIVE = 1 +OFLAGS = -g +MKLIBFLAGS = -custom +OLDFLAGS = + +# Native Config +BINEXT = bin +OBJEXT = cmx +LIBEXT = cmxa + +# Bytecode Config +#BINEXT = byte +#OBJEXT = cmo +#LIBEXT = cma + +# Include and Lib Paths +#------------------------------------------------------------------------------- INCS = -I . -I lib -I tests \ -I /usr/X11R6/include \ -I /usr/include/freetype2 -I /usr/X11R6/include/freetype2 -LIBS = -L/usr/X11R6/lib -lX11 -lXft -lfontconfig -ifeq ($(NATIVE), 1) - OC = ocamlopt - OCFLAGS = -g - MKLIB = ocamlmklib - MKLIBFLAGS = -custom - OBJEXT = cmx - LIBEXT = cmxa - OLDFLAGS = -compact -ccopt -dead_strip -else - OC = ocamlc - OCFLAGS = -g - MKLIB = ocamlmklib - MKLIBFLAGS = - OBJEXT = cmo - LIBEXT = cma - OLDFLAGS = -g -dllpath . -endif +LIBS = -L/usr/X11R6/lib -lX11 -lXft -lfontconfig # Target Definitions #------------------------------------------------------------------------------- -BINS = edit unittests +BINS = edit.$(BINEXT) unittests.$(BINEXT) BINSRCS = \ edit.ml \ @@ -59,40 +57,51 @@ TESTOBJS = $(TESTSRCS:.ml=.$(OBJEXT)) .PHONY: all clean docs -all: docs/index.html $(BINS) - ./unittests +all: $(BINS) + ./unittests.$(BINEXT) clean: - $(RM) $(BINS) *.cm* *.o *.a *.so lib/*.cm* lib/*.o tests/*.cm* tests/*.o + $(RM) *.byte *.bin *.cm* *.o *.a *.so lib/*.cm* lib/*.o tests/*.cm* tests/*.o # Executable targets -edit: tide.$(LIBEXT) edit.$(OBJEXT) -unittests: tide.$(LIBEXT) $(TESTOBJS) unittests.$(OBJEXT) +edit.$(BINEXT): tide.$(LIBEXT) edit.$(OBJEXT) +unittests.$(BINEXT): tide.$(LIBEXT) $(TESTOBJS) unittests.$(OBJEXT) # Library targets tide.$(LIBEXT): $(LIBOBJS) -docs/index.html: tide.$(LIBEXT) +docs: tide.$(LIBEXT) ocamldoc -d docs -html -I lib $(LIBSRCS) # Dependency generation deps.mk: $(wildcard *.ml* lib/*.ml* tests/*.ml*) - ocamldep -I . -I lib/ -I tests/ -all -native -one-line $^ > deps.mk + ocamldep -I . -I lib/ -I tests/ -all -one-line $^ > deps.mk -include deps.mk # Implicit Rule Definitions #------------------------------------------------------------------------------- -%: - $(OC) $(OLDFLAGS) -o $@ $^ $(INCS) - -%.cmi: %.mli - $(OC) $(OCFLAGS) -c -o $@ $< $(INCS) - -%.$(OBJEXT): %.ml - $(OC) $(OCFLAGS) -c -o $@ $< $(INCS) - -%.$(LIBEXT): - $(MKLIB) $(MKLIBFLAGS) $(OCFLAGS) -o $* -oc $* $^ $(LIBS) - -%.o: %.c - $(OC) $(OCFLAGS) -c $^ $(INCS) +.SUFFIXES: .c .o .ml .mli .cmo .cmx .cmi .cma .cmxa .byte .bin +.c.o: + ocamlc $(OFLAGS) -c $^ $(INCS) mv $(notdir $@) $(dir $@) +.ml.cmo : + ocamlc -c $(OFLAGS) $(INCS) -o $@ $< +.ml.cmx : + ocamlopt -c $(OFLAGS) $(INCS) -o $@ $< +.mli.cmi : + ocamlc -c $(OFLAGS) $(INCS) -o $@ $< +%.cma: + ocamlmklib $(MKLIBFLAGS) $(OFLAGS) -o $* -oc $* $(LIBS) $^ +%.cmxa: + ocamlmklib $(MKLIBFLAGS) $(OFLAGS) -o $* -oc $* $(LIBS) $^ +%.byte: + ocamlc $(OLDFLAGS) $(INCS) -o $@ $^ +%.bin: + ocamlopt $(OLDFLAGS) $(INCS) -o $@ $^ + +# Lexer and parser generation +#.mll.ml : +# ocamllex $(OLEXFLAGS) $< +#.mly.ml : +# ocamlyacc $(OYACCFLAGS) $< +#.mly.mli: +# ocamlyacc $(OYACCFLAGS) $< diff --git a/deps.mk b/deps.mk index e08eb22..c72a8ba 100644 --- a/deps.mk +++ b/deps.mk @@ -1,20 +1,36 @@ +edit.cmo edit.cmi : lib/x11.cmi lib/view.cmi lib/draw.cmi lib/buf.cmi edit.ml edit.cmx edit.o edit.cmi : lib/x11.cmi lib/x11.cmx lib/view.cmi lib/view.cmx lib/draw.cmi lib/draw.cmx lib/buf.cmi lib/buf.cmx edit.ml +lib/buf.cmo : lib/rope.cmi lib/misc.cmi lib/buf.cmi lib/buf.ml lib/buf.cmx lib/buf.o : lib/rope.cmi lib/rope.cmx lib/misc.cmi lib/misc.cmx lib/buf.cmi lib/buf.ml lib/buf.cmi : +lib/cfg.cmo lib/cfg.cmi : lib/x11.cmi lib/cfg.ml lib/cfg.cmx lib/cfg.o lib/cfg.cmi : lib/x11.cmi lib/x11.cmx lib/cfg.ml +lib/draw.cmo : lib/x11.cmi lib/cfg.cmi lib/buf.cmi lib/draw.cmi lib/draw.ml lib/draw.cmx lib/draw.o : lib/x11.cmi lib/x11.cmx lib/cfg.cmi lib/cfg.cmx lib/buf.cmi lib/buf.cmx lib/draw.cmi lib/draw.ml lib/draw.cmi : lib/x11.cmi lib/buf.cmi +lib/misc.cmo lib/misc.cmi : lib/misc.ml lib/misc.cmx lib/misc.o lib/misc.cmi : lib/misc.ml +lib/rope.cmo : lib/rope.cmi lib/rope.ml lib/rope.cmx lib/rope.o : lib/rope.cmi lib/rope.ml lib/rope.cmi : +lib/scrollmap.cmo : lib/draw.cmi lib/buf.cmi lib/scrollmap.cmi lib/scrollmap.ml lib/scrollmap.cmx lib/scrollmap.o : lib/draw.cmi lib/draw.cmx lib/buf.cmi lib/buf.cmx lib/scrollmap.cmi lib/scrollmap.ml lib/scrollmap.cmi : lib/buf.cmi +lib/view.cmo lib/view.cmi : lib/scrollmap.cmi lib/draw.cmi lib/buf.cmi lib/view.ml lib/view.cmx lib/view.o lib/view.cmi : lib/scrollmap.cmi lib/scrollmap.cmx lib/draw.cmi lib/draw.cmx lib/buf.cmi lib/buf.cmx lib/view.ml +lib/view_tests.cmo lib/view_tests.cmi : lib/view_tests.ml lib/view_tests.cmx lib/view_tests.o lib/view_tests.cmi : lib/view_tests.ml +lib/x11.cmo lib/x11.cmi : lib/x11.ml lib/x11.cmx lib/x11.o lib/x11.cmi : lib/x11.ml +tests/buf_tests.cmo tests/buf_tests.cmi : tests/buf_tests.ml tests/buf_tests.cmx tests/buf_tests.o tests/buf_tests.cmi : tests/buf_tests.ml +tests/misc_tests.cmo tests/misc_tests.cmi : tests/misc_tests.ml tests/misc_tests.cmx tests/misc_tests.o tests/misc_tests.cmi : tests/misc_tests.ml +tests/rope_tests.cmo tests/rope_tests.cmi : tests/test.cmi lib/rope.cmi tests/rope_tests.ml tests/rope_tests.cmx tests/rope_tests.o tests/rope_tests.cmi : tests/test.cmi tests/test.cmx lib/rope.cmi lib/rope.cmx tests/rope_tests.ml +tests/scrollmap_tests.cmo tests/scrollmap_tests.cmi : tests/test.cmi lib/scrollmap.cmi tests/scrollmap_tests.ml tests/scrollmap_tests.cmx tests/scrollmap_tests.o tests/scrollmap_tests.cmi : tests/test.cmi tests/test.cmx lib/scrollmap.cmi lib/scrollmap.cmx tests/scrollmap_tests.ml +tests/test.cmo tests/test.cmi : tests/test.ml tests/test.cmx tests/test.o tests/test.cmi : tests/test.ml +unittests.cmo unittests.cmi : tests/test.cmi tests/scrollmap_tests.cmi tests/rope_tests.cmi tests/misc_tests.cmi tests/buf_tests.cmi unittests.ml unittests.cmx unittests.o unittests.cmi : tests/test.cmi tests/test.cmx tests/scrollmap_tests.cmi tests/scrollmap_tests.cmx tests/rope_tests.cmi tests/rope_tests.cmx tests/misc_tests.cmi tests/misc_tests.cmx tests/buf_tests.cmi tests/buf_tests.cmx unittests.ml diff --git a/edit.ml b/edit.ml index 6c41a32..56e54ae 100644 --- a/edit.ml +++ b/edit.ml @@ -3,6 +3,16 @@ open X11 let tags_buf = ref Buf.empty let edit_view = ref (View.empty 640 480) +let scroll_up () = + for i = 1 to 4 do + edit_view := View.scroll_up !edit_view + done + +let scroll_dn () = + for i = 1 to 4 do + edit_view := View.scroll_dn !edit_view + done + (* Event functions ******************************************************************************) let onfocus focused = () @@ -15,8 +25,8 @@ let onmousebtn mods btn x y pressed = | 1 -> () | 2 -> () | 3 -> () - | 4 -> (edit_view := View.scroll_up !edit_view) - | 5 -> (edit_view := View.scroll_dn !edit_view) + | 4 -> scroll_up () + | 5 -> scroll_dn () | _ -> () let onmousemove mods x y = ()