blob: 5d02a99a889ce07c2edba269e17dbea15c8b915d [file] [log] [blame]
Laurence Lundblade01168ef2019-01-21 17:05:47 -08001# Makefile -- UNIX-style make for qcbor as a lib and command line test
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -08002#
Laurence Lundblade06350ea2020-01-27 19:32:40 -08003# Copyright (c) 2018-2020, Laurence Lundblade. All rights reserved.
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -08004#
Laurence Lundblade01168ef2019-01-21 17:05:47 -08005# SPDX-License-Identifier: BSD-3-Clause
6#
7# See BSD-3-Clause license in README.md
8#
9
Laurence Lundbladec2b14572018-11-01 13:07:49 +070010
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080011CC=cc
12
Michael Eckel7e8effa2020-03-09 18:19:17 +010013CFLAGS=-I inc -I test -Os -fPIC
Laurence Lundbladef19f4da2020-03-01 17:41:53 -080014
Laurence Lundblade74d265c2018-09-19 10:21:00 -070015
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080016
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080017QCBOR_OBJ=src/UsefulBuf.o src/qcbor_encode.o src/qcbor_decode.o src/ieee754.o
Laurence Lundblade781fd822018-10-01 09:37:52 -070018
Michael Eckel9c42c202020-03-04 18:26:11 +010019TEST_OBJ=test/UsefulBuf_Tests.o test/qcbor_encode_tests.o \
20 test/qcbor_decode_tests.o test/run_tests.o \
21 test/float_tests.o test/half_to_double_from_rfc7049.o
22
23.PHONY: all install clean
24
Michael Eckel7e8effa2020-03-09 18:19:17 +010025all: qcbortest qcbormin libqcbor.a libqcbor.so
Laurence Lundblade781fd822018-10-01 09:37:52 -070026
Laurence Lundblade2c978832018-12-13 01:10:21 -080027qcbortest: libqcbor.a $(TEST_OBJ) cmd_line_main.o
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080028 $(CC) -o $@ $^ libqcbor.a
Laurence Lundblade74d265c2018-09-19 10:21:00 -070029
Laurence Lundbladecd532e42018-12-17 13:19:45 -080030qcbormin: libqcbor.a min_use_main.o
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080031 $(CC) -dead_strip -o $@ $^ libqcbor.a
Laurence Lundblade74d265c2018-09-19 10:21:00 -070032
Laurence Lundbladec9d3dcf2018-12-19 18:11:36 -080033libqcbor.a: $(QCBOR_OBJ)
Laurence Lundblade2c978832018-12-13 01:10:21 -080034 ar -r $@ $^
Laurence Lundbladec2b14572018-11-01 13:07:49 +070035
Michael Eckel7e8effa2020-03-09 18:19:17 +010036libqcbor.so: $(QCBOR_OBJ)
37 $(CC) $^ $(CFLAGS) -dead_strip -o $@ -shared
38
Michael Eckel9c42c202020-03-04 18:26:11 +010039PUBLIC_INTERFACE=inc/qcbor/UsefulBuf.h inc/qcbor/qcbor_private.h inc/qcbor/qcbor_common.h inc/qcbor/qcbor_encode.h inc/qcbor/qcbor_decode.h
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080040
Michael Eckel9c42c202020-03-04 18:26:11 +010041src/UsefulBuf.o: inc/qcbor/UsefulBuf.h
42src/qcbor_decode.o: inc/qcbor/UsefulBuf.h inc/qcbor/qcbor_private.h inc/qcbor/qcbor_common.h inc/qcbor/qcbor_encode.h src/ieee754.h
43src/qcbor_encode.o: inc/qcbor/UsefulBuf.h inc/qcbor/qcbor_private.h inc/qcbor/qcbor_common.h inc/qcbor/qcbor_decode.h src/ieee754.h
44src/iee754.o: src/ieee754.h
Laurence Lundblade781fd822018-10-01 09:37:52 -070045
Michael Eckel7e8effa2020-03-09 18:19:17 +010046test/run_tests.o: test/UsefulBuf_Tests.h test/float_tests.h test/run_tests.h test/qcbor_encode_tests.h test/qcbor_decode_tests.h
Michael Eckel9c42c202020-03-04 18:26:11 +010047test/UsefulBuf_Tests.o: test/UsefulBuf_Tests.h inc/qcbor/UsefulBuf.h
Michael Eckel7e8effa2020-03-09 18:19:17 +010048test/qcbor_encode_tests.o: test/qcbor_encode_tests.h $(PUBLIC_INTERFACE)
Michael Eckel9c42c202020-03-04 18:26:11 +010049test/qcbor_decode_tests.o: test/qcbor_decode_tests.h $(PUBLIC_INTERFACE)
50test/float_tests.o: test/float_tests.h test/half_to_double_from_rfc7049.h $(PUBLIC_INTERFACE)
51test/half_to_double_from_rfc7049.o: test/half_to_double_from_rfc7049.h
Laurence Lundblade781fd822018-10-01 09:37:52 -070052
Michael Eckel9c42c202020-03-04 18:26:11 +010053cmd_line_main.o: test/run_tests.h $(PUBLIC_INTERFACE)
Laurence Lundblade74d265c2018-09-19 10:21:00 -070054
Michael Eckel9c42c202020-03-04 18:26:11 +010055min_use_main.o: $(PUBLIC_INTERFACE)
Laurence Lundbladec2b14572018-11-01 13:07:49 +070056
Michael Eckel5c531332020-03-02 01:35:30 +010057ifeq ($(PREFIX),)
58 PREFIX := /usr/local
59endif
60
Michael Eckel7e8effa2020-03-09 18:19:17 +010061install: libqcbor.a libqcbor.so $(PUBLIC_INTERFACE)
Michael Eckel5c531332020-03-02 01:35:30 +010062 install -d $(DESTDIR)$(PREFIX)/lib/
63 install -m 644 libqcbor.a $(DESTDIR)$(PREFIX)/lib/
Michael Eckel7e8effa2020-03-09 18:19:17 +010064 install -m 755 libqcbor.so $(DESTDIR)$(PREFIX)/lib/libqcbor.so.1.0.0
65 ln -sf libqcbor.so.1 $(DESTDIR)$(PREFIX)/lib/libqcbor.so
66 ln -sf libqcbor.so.1.0.0 $(DESTDIR)$(PREFIX)/lib/libqcbor.so.1
Michael Eckel5c531332020-03-02 01:35:30 +010067 install -d $(DESTDIR)$(PREFIX)/include/qcbor
Michael Eckel7e8effa2020-03-09 18:19:17 +010068 install -m 644 inc/qcbor/qcbor.h $(DESTDIR)$(PREFIX)/include/qcbor
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080069 install -m 644 inc/qcbor/qcbor_private.h $(DESTDIR)$(PREFIX)/include/qcbor
70 install -m 644 inc/qcbor/qcbor_common.h $(DESTDIR)$(PREFIX)/include/qcbor
71 install -m 644 inc/qcbor/qcbor_decode.h $(DESTDIR)$(PREFIX)/include/qcbor
72 install -m 644 inc/qcbor/qcbor_encode.h $(DESTDIR)$(PREFIX)/include/qcbor
Michael Eckel5c531332020-03-02 01:35:30 +010073 install -m 644 inc/qcbor/UsefulBuf.h $(DESTDIR)$(PREFIX)/include/qcbor
74
Michael Eckel7e8effa2020-03-09 18:19:17 +010075uninstall: libqcbor.a $(PUBLIC_INTERFACE)
76 $(RM) -d $(DESTDIR)$(PREFIX)/include/qcbor/*
77 $(RM) -d $(DESTDIR)$(PREFIX)/include/qcbor/
78 $(RM) $(addprefix $(DESTDIR)$(PREFIX)/lib/, \
79 libqcbor.a libqcbor.so libqcbor.so.1 libqcbor.so.1.0.0)
80
Laurence Lundblade74d265c2018-09-19 10:21:00 -070081clean:
Laurence Lundbladeb26de6f2019-01-10 08:47:40 -080082 rm -f $(QCBOR_OBJ) $(TEST_OBJ) libqcbor.a min_use_main.o cmd_line_main.o