From: Matt Birkholz Date: Tue, 6 May 2014 02:23:06 +0000 (-0700) Subject: ffi: Update Makefile for prhello example. X-Git-Tag: release-9.2.0~12 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=4f95017b2e871e6146ddf79ddaa1ff61585a0961;p=mit-scheme.git ffi: Update Makefile for prhello example. Use the generate-shim, compile-shim, link-shim and install-shim procedures. Move to a separate file included via @verbatiminclude, for more convenient testing. --- diff --git a/doc/ffi/ffi.texinfo b/doc/ffi/ffi.texinfo index 8feb6c28f..155487a52 100644 --- a/doc/ffi/ffi.texinfo +++ b/doc/ffi/ffi.texinfo @@ -154,11 +154,11 @@ data types is given in a case sensitive @file{.cdecl} file. The C declarations look like this: @smallexample -(extern (* GtkWidget) @r{; gtk+-2.4.0/gtk/gtkwindow.h} +(extern (* GtkWidget) gtk_window_new (type GtkWindowType)) -(typedef GtkWindowType @r{; gtk+-2.4.0/gtk/gtkenums.h} +(typedef GtkWindowType (enum (GTK_WINDOW_TOPLEVEL) (GTK_WINDOW_POPUP))) @@ -321,7 +321,7 @@ examples in the synopsis might expand as shown here. (alien-byte-increment @verb{"#@43"} (* (C-sizeof "GdkColor") (C-enum "GTK_STATE_NORMAL"))) @expansion{} -(alien-byte-increment @verb{"#@43"} 0) +(alien-byte-increment @verb{"#@43"} (* 12 0)) @myresult{} @verb{"#@44"} (C-array-loc! @verb{"#@43"} "GdkColor" (C-enum "GTK_STATE_PRELIGHT")) @@ -329,7 +329,7 @@ examples in the synopsis might expand as shown here. (alien-byte-increment! @verb{"#@43"} (* (C-sizeof "GdkColor") (C-enum "GTK_STATE_PRELIGHT"))) @expansion{} -(alien-byte-increment! @verb{"#@43"} 24) +(alien-byte-increment! @verb{"#@43"} (* 12 2)) @myresult{} @verb{"#@43"} @end smallexample @@ -650,38 +650,7 @@ The following Makefile rules describe the process of building and installing a shim for the example ``Hello, World!'' program. @example -@verbatim -install-example: build-example - $(INSTALL_DATA) prhello-types.bin ../lib/. - $(INSTALL_DATA) prhello-const.bin ../lib/. - $(INSTALL_DATA) prhello-shim.so ../lib/. - -build-example: prhello-shim.so prhello-types.bin prhello-const.bin - -prhello-shim.so: prhello-shim.o - $(CC) -shared -fPIC -o $@ $^ `pkg-config --libs gtk+-2.0` - -prhello-shim.o: prhello-shim.c - $(CC) -I../lib -Wall -fPIC `pkg-config --cflags gtk+-2.0` -o $@ -c $< - -prhello-shim.c prhello-const.c prhello-types.bin: prhello.cdecl - (echo "(load-option 'FFI)"; \ - echo '(C-generate "prhello" "#include ")') \ - | ../microcode/scheme --library ../lib --batch-mode - -prhello-const.bin: prhello-const.scm - echo '(sf "prhello-const")' | mit-scheme --compiler --batch-mode - -prhello-const.scm: prhello-const - ./prhello-const - -prhello-const: prhello-const.o - @rm -f $@ - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ `pkg-config --libs gtk+-2.0` - -prhello-const.o: prhello-const.c - $(CC) `pkg-config --cflags gtk+-2.0` $(CFLAGS) -o $@ -c $< -@end verbatim +@verbatiminclude prhello-Makefile @end example diff --git a/doc/ffi/prhello-Makefile b/doc/ffi/prhello-Makefile new file mode 100644 index 000000000..7a023a251 --- /dev/null +++ b/doc/ffi/prhello-Makefile @@ -0,0 +1,32 @@ +install: build + echo '(install-shim "$(DESTDIR)" "prhello")' \ + | mit-scheme --batch-mode + +clean: + rm prhello-const* prhello-types* prhello-shim* + +build: prhello-shim.so prhello-types.bin prhello-const.bin + +prhello-shim.so: prhello-shim.o + echo "(link-shim)" \ + | mit-scheme --batch-mode -- -o $@ $^ `pkg-config --libs gtk+-2.0` + +prhello-shim.o: prhello-shim.c + echo '(compile-shim)' \ + | mit-scheme --batch-mode -- `pkg-config --cflags gtk+-2.0` -c $< + +prhello-shim.c prhello-const.c prhello-types.bin: prhello.cdecl + echo '(generate-shim "prhello" "#include ")' \ + | mit-scheme --batch-mode + +prhello-const.bin: prhello-const.scm + echo '(sf "prhello-const")' | mit-scheme --batch-mode + +prhello-const.scm: prhello-const + ./prhello-const + +prhello-const: prhello-const.o + $(CC) -o $@ $^ $(LDFLAGS) `pkg-config --libs gtk+-2.0` + +prhello-const.o: prhello-const.c + $(CC) `pkg-config --cflags gtk+-2.0` $(CFLAGS) -o $@ -c $<