Laurence Lundblade | 01168ef | 2019-01-21 17:05:47 -0800 | [diff] [blame] | 1 | # Makefile -- UNIX-style make for qcbor as a lib and command line test |
Laurence Lundblade | df1c1cf | 2019-01-17 11:55:05 -0800 | [diff] [blame] | 2 | # |
Laurence Lundblade | b970245 | 2021-03-08 21:02:57 -0800 | [diff] [blame] | 3 | # Copyright (c) 2018-2021, Laurence Lundblade. All rights reserved. |
Laurence Lundblade | df1c1cf | 2019-01-17 11:55:05 -0800 | [diff] [blame] | 4 | # |
Laurence Lundblade | 01168ef | 2019-01-21 17:05:47 -0800 | [diff] [blame] | 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | # See BSD-3-Clause license in README.md |
| 8 | # |
| 9 | |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 10 | |
Laurence Lundblade | b970245 | 2021-03-08 21:02:57 -0800 | [diff] [blame] | 11 | # The math library is needed for floating-point support. To |
| 12 | # avoid need for it #define QCBOR_DISABLE_FLOAT_HW_USE |
akil | 53a6981 | 2020-11-25 05:24:10 +0400 | [diff] [blame] | 13 | LIBS=-lm |
Laurence Lundblade | f19f4da | 2020-03-01 17:41:53 -0800 | [diff] [blame] | 14 | |
Laurence Lundblade | b970245 | 2021-03-08 21:02:57 -0800 | [diff] [blame] | 15 | |
| 16 | # The QCBOR makefile uses a minimum of compiler flags so that it will |
| 17 | # work out-of-the-box with a wide variety of compilers. For example, |
Laurence Lundblade | c5a342f | 2021-05-17 01:17:06 -0700 | [diff] [blame] | 18 | # some compilers error out on some of the warnings flags gcc supports. |
| 19 | # The $(CMD_LINE) variable allows passing in extra flags. This is |
Laurence Lundblade | b970245 | 2021-03-08 21:02:57 -0800 | [diff] [blame] | 20 | # used on the stringent build script that is in |
| 21 | # https://github.com/laurencelundblade/qdv. This script is used |
| 22 | # before pushes to master (though not yet through and automated build |
| 23 | # process) |
| 24 | CFLAGS=$(CMD_LINE) -I inc -I test -Os -fPIC |
Laurence Lundblade | 74d265c | 2018-09-19 10:21:00 -0700 | [diff] [blame] | 25 | |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 26 | |
Michael Eckel | 6e03077 | 2020-03-27 02:20:00 +0100 | [diff] [blame] | 27 | QCBOR_OBJ=src/UsefulBuf.o src/qcbor_encode.o src/qcbor_decode.o src/ieee754.o src/qcbor_err_to_str.o |
Laurence Lundblade | 781fd82 | 2018-10-01 09:37:52 -0700 | [diff] [blame] | 28 | |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 29 | TEST_OBJ=test/UsefulBuf_Tests.o test/qcbor_encode_tests.o \ |
| 30 | test/qcbor_decode_tests.o test/run_tests.o \ |
Laurence Lundblade | 1818e63 | 2020-07-26 04:14:08 -0700 | [diff] [blame] | 31 | test/float_tests.o test/half_to_double_from_rfc7049.o example.o |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 32 | |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 33 | .PHONY: all so install uninstall clean |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 34 | |
Laurence Lundblade | cb31ed3 | 2020-07-26 04:18:37 -0700 | [diff] [blame] | 35 | all: qcbortest libqcbor.a |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 36 | |
| 37 | so: libqcbor.so |
Laurence Lundblade | 781fd82 | 2018-10-01 09:37:52 -0700 | [diff] [blame] | 38 | |
Laurence Lundblade | 2c97883 | 2018-12-13 01:10:21 -0800 | [diff] [blame] | 39 | qcbortest: libqcbor.a $(TEST_OBJ) cmd_line_main.o |
Norbert KamiĆski | 6bbc4ed | 2020-11-27 02:44:04 +0100 | [diff] [blame] | 40 | $(CC) -o $@ $^ libqcbor.a $(LIBS) |
Laurence Lundblade | 74d265c | 2018-09-19 10:21:00 -0700 | [diff] [blame] | 41 | |
Laurence Lundblade | c9d3dcf | 2018-12-19 18:11:36 -0800 | [diff] [blame] | 42 | libqcbor.a: $(QCBOR_OBJ) |
Laurence Lundblade | 2c97883 | 2018-12-13 01:10:21 -0800 | [diff] [blame] | 43 | ar -r $@ $^ |
Laurence Lundblade | c2b1457 | 2018-11-01 13:07:49 +0700 | [diff] [blame] | 44 | |
Laurence Lundblade | b970245 | 2021-03-08 21:02:57 -0800 | [diff] [blame] | 45 | |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 46 | # The shared library is not made by default because of platform |
| 47 | # variability For example MacOS and Linux behave differently and some |
| 48 | # IoT OS's don't support them at all. |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 49 | libqcbor.so: $(QCBOR_OBJ) |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 50 | $(CC) -shared $^ $(CFLAGS) -o $@ |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 51 | |
Laurence Lundblade | 67257dc | 2020-07-27 03:33:37 -0700 | [diff] [blame] | 52 | PUBLIC_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 inc/qcbor/qcbor_spiffy_decode.h |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 53 | |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 54 | src/UsefulBuf.o: inc/qcbor/UsefulBuf.h |
Laurence Lundblade | 67257dc | 2020-07-27 03:33:37 -0700 | [diff] [blame] | 55 | src/qcbor_decode.o: inc/qcbor/UsefulBuf.h inc/qcbor/qcbor_private.h inc/qcbor/qcbor_common.h inc/qcbor/qcbor_decode.h inc/qcbor/qcbor_spiffy_decode.h src/ieee754.h |
| 56 | src/qcbor_encode.o: inc/qcbor/UsefulBuf.h inc/qcbor/qcbor_private.h inc/qcbor/qcbor_common.h inc/qcbor/qcbor_encode.h src/ieee754.h |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 57 | src/iee754.o: src/ieee754.h |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 58 | src/qcbor_err_to_str.o: inc/qcbor/qcbor_common.h |
Laurence Lundblade | 781fd82 | 2018-10-01 09:37:52 -0700 | [diff] [blame] | 59 | |
Laurence Lundblade | cb31ed3 | 2020-07-26 04:18:37 -0700 | [diff] [blame] | 60 | example.o: $(PUBLIC_INTERFACE) |
| 61 | |
Laurence Lundblade | 1d85d52 | 2020-06-22 13:24:59 -0700 | [diff] [blame] | 62 | test/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 inc/qcbor/qcbor_private.h |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 63 | test/UsefulBuf_Tests.o: test/UsefulBuf_Tests.h inc/qcbor/UsefulBuf.h |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 64 | test/qcbor_encode_tests.o: test/qcbor_encode_tests.h $(PUBLIC_INTERFACE) |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 65 | test/qcbor_decode_tests.o: test/qcbor_decode_tests.h $(PUBLIC_INTERFACE) |
| 66 | test/float_tests.o: test/float_tests.h test/half_to_double_from_rfc7049.h $(PUBLIC_INTERFACE) |
| 67 | test/half_to_double_from_rfc7049.o: test/half_to_double_from_rfc7049.h |
Laurence Lundblade | 781fd82 | 2018-10-01 09:37:52 -0700 | [diff] [blame] | 68 | |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 69 | cmd_line_main.o: test/run_tests.h $(PUBLIC_INTERFACE) |
Laurence Lundblade | 74d265c | 2018-09-19 10:21:00 -0700 | [diff] [blame] | 70 | |
Laurence Lundblade | c2b1457 | 2018-11-01 13:07:49 +0700 | [diff] [blame] | 71 | |
Michael Eckel | 5c53133 | 2020-03-02 01:35:30 +0100 | [diff] [blame] | 72 | ifeq ($(PREFIX),) |
| 73 | PREFIX := /usr/local |
| 74 | endif |
| 75 | |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 76 | install: libqcbor.a $(PUBLIC_INTERFACE) |
Michael Eckel | 5c53133 | 2020-03-02 01:35:30 +0100 | [diff] [blame] | 77 | install -d $(DESTDIR)$(PREFIX)/lib/ |
| 78 | install -m 644 libqcbor.a $(DESTDIR)$(PREFIX)/lib/ |
| 79 | install -d $(DESTDIR)$(PREFIX)/include/qcbor |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 80 | install -m 644 inc/qcbor/qcbor.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 81 | install -m 644 inc/qcbor/qcbor_private.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 82 | install -m 644 inc/qcbor/qcbor_common.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 83 | install -m 644 inc/qcbor/qcbor_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 67257dc | 2020-07-27 03:33:37 -0700 | [diff] [blame] | 84 | install -m 644 inc/qcbor/qcbor_spiffy_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 85 | install -m 644 inc/qcbor/qcbor_encode.h $(DESTDIR)$(PREFIX)/include/qcbor |
Michael Eckel | 5c53133 | 2020-03-02 01:35:30 +0100 | [diff] [blame] | 86 | install -m 644 inc/qcbor/UsefulBuf.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 87 | |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 88 | install_so: libqcbor.so |
| 89 | install -m 755 libqcbor.so $(DESTDIR)$(PREFIX)/lib/libqcbor.so.1.0.0 |
| 90 | ln -sf libqcbor.so.1 $(DESTDIR)$(PREFIX)/lib/libqcbor.so |
| 91 | ln -sf libqcbor.so.1.0.0 $(DESTDIR)$(PREFIX)/lib/libqcbor.so.1 |
| 92 | |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 93 | uninstall: libqcbor.a $(PUBLIC_INTERFACE) |
| 94 | $(RM) -d $(DESTDIR)$(PREFIX)/include/qcbor/* |
| 95 | $(RM) -d $(DESTDIR)$(PREFIX)/include/qcbor/ |
| 96 | $(RM) $(addprefix $(DESTDIR)$(PREFIX)/lib/, \ |
| 97 | libqcbor.a libqcbor.so libqcbor.so.1 libqcbor.so.1.0.0) |
| 98 | |
Laurence Lundblade | 74d265c | 2018-09-19 10:21:00 -0700 | [diff] [blame] | 99 | clean: |
Laurence Lundblade | cb31ed3 | 2020-07-26 04:18:37 -0700 | [diff] [blame] | 100 | rm -f $(QCBOR_OBJ) $(TEST_OBJ) libqcbor.a cmd_line_main.o libqcbor.a libqcbor.so qcbormin qcbortest |