aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile62
1 files changed, 62 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..acfc5b5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,62 @@
+.POSIX:
+
+include config.mk
+
+OBJ =\
+ float.o\
+ double.o\
+ long-double.o
+
+HDR =\
+ libcolour.h
+
+TEMPLATES =\
+ convert-template.c\
+ libcolour-template.c
+
+
+all: libcolour.a libcolour.so.$(VERSION_MAJOR).$(VERSION_MINOR) test
+
+
+float.o: float.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ float.c
+
+double.o: double.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ double.c
+
+long-double.o: long-double.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ long-double.c
+
+
+float.pic.o: float.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ float.c
+
+double.pic.o: double.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ double.c
+
+long-double.pic.o: long-double.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ long-double.c
+
+
+libcolour.a: $(OBJ)
+ $(AR) rc $@ $?
+ $(AR) -s $@
+
+libcolour.so.$(VERSION_MAJOR).$(VERSION_MINOR): $(OBJ:.o=.pic.o)
+ $(CC) -shared -Wl,-soname,libcolour.so.$(VERSION_MAJOR) -o $@ $(LDFLAGS) $^
+
+
+test.o: test.c libcolour.h
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ test.c
+
+test: test.o libcolour.a
+ $(CC) -o $@ $^ $(LDFLAGS)
+
+
+check: test
+ ./test
+
+clean:
+ -rm -- *.o *.a *.so *.so.* test
+
+.PHONY: all clean check