Permalink
Browse files

add example Makefile

  • Loading branch information...
1 parent 47055ec commit cdd8bf64669f1c674e5a27ffe037d6fd3a0b27f2 @martinrehfeld committed Apr 8, 2012
Showing with 21 additions and 1 deletion.
  1. +2 −1 README.md
  2. +19 −0 examples/Makefile
View
3 README.md
@@ -26,4 +26,5 @@ Example usage:
f2c myapp.f
gcc -o myapp myapp.c -lf2c
-The buildpack will detect your app as FORTRAN-77 if it has the file `Makefile` in the root. It will then run `make` to compile the app.
+The buildpack will detect your app as FORTRAN-77 if it has the file `Makefile` in the root.
+It will then run `make` to compile the app (see examples/Makefile for a template).
View
19 examples/Makefile
@@ -0,0 +1,19 @@
+CFLAGS=-c
+LDFLAGS=-L$(F2CLIB_DIR) -lf2c -lm
+
+EXECUTABLE=myapp
+SOURCES=myapp.f
+OBJECTS=$(SOURCES:.f=.o)
+INTERMEDIATES=$(SOURCES:.f=.c)
+
+all: $(SOURCES) $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CC) $(OBJECTS) -o $@ $(LDFLAGS)
+
+.f.o:
+ f2c $<
+ $(CC) $(CFLAGS) $(<:.f=.c) -o $@
+
+clean:
+ rm -f $(EXECUTABLE) $(OBJECTS) $(INTERMEDIATES)

0 comments on commit cdd8bf6

Please sign in to comment.