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 | 7596eef | 2024-12-21 10:08:32 -0700 | [diff] [blame] | 3 | # Copyright (c) 2018-2024, 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 |
Laurence Lundblade | b0e7033 | 2022-09-07 11:55:09 -0700 | [diff] [blame] | 22 | # before pushes to master (though not yet through an automated build |
| 23 | # process). See "warn:" below. |
Laurence Lundblade | b970245 | 2021-03-08 21:02:57 -0800 | [diff] [blame] | 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 | |
Laurence Lundblade | 7596eef | 2024-12-21 10:08:32 -0700 | [diff] [blame] | 27 | QCBOR_OBJ=src/UsefulBuf.o \ |
| 28 | src/qcbor_main_encode.o \ |
| 29 | src/qcbor_number_encode.o \ |
| 30 | src/qcbor_main_decode.o \ |
| 31 | src/qcbor_spiffy_decode.o \ |
| 32 | src/qcbor_number_decode.o \ |
| 33 | src/qcbor_tag_decode.o \ |
| 34 | src/ieee754.o \ |
| 35 | src/qcbor_err_to_str.o |
Laurence Lundblade | 781fd82 | 2018-10-01 09:37:52 -0700 | [diff] [blame] | 36 | |
Laurence Lundblade | 2117bbf | 2024-12-30 22:56:41 -0500 | [diff] [blame] | 37 | TEST_OBJ=test/UsefulBuf_Tests.o \ |
| 38 | test/qcbor_encode_tests.o \ |
| 39 | test/qcbor_decode_tests.o \ |
| 40 | test/run_tests.o \ |
| 41 | test/float_tests.o \ |
| 42 | test/half_to_double_from_rfc7049.o \ |
| 43 | example.o \ |
| 44 | tag-examples.o \ |
| 45 | ub-example.o |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 46 | |
Laurence Lundblade | b0e7033 | 2022-09-07 11:55:09 -0700 | [diff] [blame] | 47 | .PHONY: all so install uninstall clean warn |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 48 | |
Laurence Lundblade | cb31ed3 | 2020-07-26 04:18:37 -0700 | [diff] [blame] | 49 | all: qcbortest libqcbor.a |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 50 | |
| 51 | so: libqcbor.so |
Laurence Lundblade | 781fd82 | 2018-10-01 09:37:52 -0700 | [diff] [blame] | 52 | |
Laurence Lundblade | 2c97883 | 2018-12-13 01:10:21 -0800 | [diff] [blame] | 53 | qcbortest: libqcbor.a $(TEST_OBJ) cmd_line_main.o |
Norbert KamiĆski | 6bbc4ed | 2020-11-27 02:44:04 +0100 | [diff] [blame] | 54 | $(CC) -o $@ $^ libqcbor.a $(LIBS) |
Laurence Lundblade | 74d265c | 2018-09-19 10:21:00 -0700 | [diff] [blame] | 55 | |
Laurence Lundblade | c9d3dcf | 2018-12-19 18:11:36 -0800 | [diff] [blame] | 56 | libqcbor.a: $(QCBOR_OBJ) |
Laurence Lundblade | 2c97883 | 2018-12-13 01:10:21 -0800 | [diff] [blame] | 57 | ar -r $@ $^ |
Laurence Lundblade | c2b1457 | 2018-11-01 13:07:49 +0700 | [diff] [blame] | 58 | |
Laurence Lundblade | b0e7033 | 2022-09-07 11:55:09 -0700 | [diff] [blame] | 59 | # run "make warn" as a handy way to compile with the warning flags |
| 60 | # used in the QCBOR release process. See CFLAGS above. |
| 61 | warn: |
Laurence Lundblade | 5d83b9b | 2024-06-29 11:19:39 -0700 | [diff] [blame] | 62 | make CMD_LINE="$(CMD_LINE) -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wcast-qual" |
Laurence Lundblade | b0e7033 | 2022-09-07 11:55:09 -0700 | [diff] [blame] | 63 | |
Laurence Lundblade | b970245 | 2021-03-08 21:02:57 -0800 | [diff] [blame] | 64 | |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 65 | # The shared library is not made by default because of platform |
| 66 | # variability For example MacOS and Linux behave differently and some |
| 67 | # IoT OS's don't support them at all. |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 68 | libqcbor.so: $(QCBOR_OBJ) |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 69 | $(CC) -shared $^ $(CFLAGS) -o $@ |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 70 | |
Laurence Lundblade | 926ccfc | 2024-12-05 20:34:55 -0800 | [diff] [blame] | 71 | PUBLIC_INTERFACE=inc/qcbor/UsefulBuf.h \ |
| 72 | inc/qcbor/qcbor_private.h \ |
| 73 | inc/qcbor/qcbor_common.h \ |
Laurence Lundblade | 2117bbf | 2024-12-30 22:56:41 -0500 | [diff] [blame] | 74 | inc/qcbor/qcbor_main_encode.h \ |
| 75 | inc/qcbor/qcbor_number_encode.h \ |
| 76 | inc/qcbor/qcbor_tag_encode.h \ |
Laurence Lundblade | cf49acc | 2024-12-08 20:48:31 -0700 | [diff] [blame] | 77 | inc/qcbor/qcbor_decode.h \ |
Laurence Lundblade | 926ccfc | 2024-12-05 20:34:55 -0800 | [diff] [blame] | 78 | inc/qcbor/qcbor_main_decode.h \ |
| 79 | inc/qcbor/qcbor_spiffy_decode.h \ |
| 80 | inc/qcbor/qcbor_tag_decode.h \ |
| 81 | inc/qcbor/qcbor_number_decode.h |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 82 | |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 83 | src/UsefulBuf.o: inc/qcbor/UsefulBuf.h |
Laurence Lundblade | 926ccfc | 2024-12-05 20:34:55 -0800 | [diff] [blame] | 84 | |
Laurence Lundblade | 2117bbf | 2024-12-30 22:56:41 -0500 | [diff] [blame] | 85 | src/qcbor_main_encode.o: inc/qcbor/UsefulBuf.h \ |
| 86 | inc/qcbor/qcbor_private.h \ |
| 87 | inc/qcbor/qcbor_common.h \ |
| 88 | inc/qcbor/qcbor_main_encode.h |
| 89 | |
| 90 | src/qcbor_tag_encode.o: inc/qcbor/UsefulBuf.h \ |
| 91 | inc/qcbor/qcbor_private.h \ |
| 92 | inc/qcbor/qcbor_common.h \ |
| 93 | inc/qcbor/qcbor_main_encode.h \ |
| 94 | inc/qcbor/qcbor_number_encode.h \ |
| 95 | inc/qcbor/qcbor_tag_encode.h \ |
| 96 | src/ieee754.h |
Laurence Lundblade | 926ccfc | 2024-12-05 20:34:55 -0800 | [diff] [blame] | 97 | |
| 98 | src/qcbor_main_decode.o: inc/qcbor/UsefulBuf.h \ |
| 99 | inc/qcbor/qcbor_private.h \ |
| 100 | inc/qcbor/qcbor_common.h \ |
| 101 | inc/qcbor/qcbor_main_decode.h \ |
| 102 | inc/qcbor/qcbor_spiffy_decode.h \ |
Laurence Lundblade | cf49acc | 2024-12-08 20:48:31 -0700 | [diff] [blame] | 103 | inc/qcbor/qcbor_tag_decode.h \ |
Laurence Lundblade | 926ccfc | 2024-12-05 20:34:55 -0800 | [diff] [blame] | 104 | src/decode_nesting.h \ |
| 105 | src/ieee754.h |
| 106 | |
Laurence Lundblade | cf49acc | 2024-12-08 20:48:31 -0700 | [diff] [blame] | 107 | src/qcbor_tag_decode.o: inc/qcbor/UsefulBuf.h \ |
| 108 | inc/qcbor/qcbor_private.h \ |
| 109 | inc/qcbor/qcbor_common.h \ |
| 110 | inc/qcbor/qcbor_main_decode.h \ |
| 111 | inc/qcbor/qcbor_spiffy_decode.h \ |
| 112 | src/decode_nesting.h \ |
| 113 | inc/qcbor/qcbor_tag_decode.h |
| 114 | |
Laurence Lundblade | 2117bbf | 2024-12-30 22:56:41 -0500 | [diff] [blame] | 115 | src/qcbor_spiffy_decode.o: inc/qcbor/UsefulBuf.h \ |
| 116 | inc/qcbor/qcbor_private.h \ |
| 117 | inc/qcbor/qcbor_common.h \ |
| 118 | inc/qcbor/qcbor_main_decode.h \ |
| 119 | inc/qcbor/qcbor_spiffy_decode.h \ |
| 120 | src/decode_nesting.h \ |
| 121 | inc/qcbor/qcbor_tag_decode.h |
| 122 | |
Laurence Lundblade | cf49acc | 2024-12-08 20:48:31 -0700 | [diff] [blame] | 123 | src/qcbor_number_decode.o: inc/qcbor/UsefulBuf.h \ |
| 124 | inc/qcbor/qcbor_private.h \ |
| 125 | inc/qcbor/qcbor_common.h \ |
| 126 | inc/qcbor/qcbor_main_decode.h \ |
| 127 | inc/qcbor/qcbor_tag_decode.h \ |
| 128 | inc/qcbor/qcbor_spiffy_decode.h \ |
| 129 | inc/qcbor/qcbor_number_decode.h \ |
| 130 | src/ieee754.h |
| 131 | |
| 132 | src/iee754.o: src/ieee754.h \ |
| 133 | inc/qcbor/qcbor_common.h |
| 134 | |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 135 | src/qcbor_err_to_str.o: inc/qcbor/qcbor_common.h |
Laurence Lundblade | 781fd82 | 2018-10-01 09:37:52 -0700 | [diff] [blame] | 136 | |
Laurence Lundblade | cb31ed3 | 2020-07-26 04:18:37 -0700 | [diff] [blame] | 137 | example.o: $(PUBLIC_INTERFACE) |
Laurence Lundblade | 41e96ca | 2022-04-09 10:37:39 -0600 | [diff] [blame] | 138 | ub-example.o: $(PUBLIC_INTERFACE) |
Laurence Lundblade | 721b56e | 2024-10-22 03:02:04 -0700 | [diff] [blame] | 139 | tag-examples.o: $(PUBLIC_INTERFACE) |
Laurence Lundblade | cb31ed3 | 2020-07-26 04:18:37 -0700 | [diff] [blame] | 140 | |
Laurence Lundblade | 1d85d52 | 2020-06-22 13:24:59 -0700 | [diff] [blame] | 141 | 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] | 142 | test/UsefulBuf_Tests.o: test/UsefulBuf_Tests.h inc/qcbor/UsefulBuf.h |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 143 | test/qcbor_encode_tests.o: test/qcbor_encode_tests.h $(PUBLIC_INTERFACE) |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 144 | test/qcbor_decode_tests.o: test/qcbor_decode_tests.h $(PUBLIC_INTERFACE) |
| 145 | test/float_tests.o: test/float_tests.h test/half_to_double_from_rfc7049.h $(PUBLIC_INTERFACE) |
| 146 | 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] | 147 | |
Michael Eckel | 9c42c20 | 2020-03-04 18:26:11 +0100 | [diff] [blame] | 148 | cmd_line_main.o: test/run_tests.h $(PUBLIC_INTERFACE) |
Laurence Lundblade | 74d265c | 2018-09-19 10:21:00 -0700 | [diff] [blame] | 149 | |
Laurence Lundblade | c2b1457 | 2018-11-01 13:07:49 +0700 | [diff] [blame] | 150 | |
Michael Eckel | 5c53133 | 2020-03-02 01:35:30 +0100 | [diff] [blame] | 151 | ifeq ($(PREFIX),) |
| 152 | PREFIX := /usr/local |
| 153 | endif |
| 154 | |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 155 | install: libqcbor.a $(PUBLIC_INTERFACE) |
Michael Eckel | 5c53133 | 2020-03-02 01:35:30 +0100 | [diff] [blame] | 156 | install -d $(DESTDIR)$(PREFIX)/lib/ |
| 157 | install -m 644 libqcbor.a $(DESTDIR)$(PREFIX)/lib/ |
| 158 | install -d $(DESTDIR)$(PREFIX)/include/qcbor |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 159 | install -m 644 inc/qcbor/qcbor.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 160 | install -m 644 inc/qcbor/qcbor_private.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 161 | install -m 644 inc/qcbor/qcbor_common.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 2117bbf | 2024-12-30 22:56:41 -0500 | [diff] [blame] | 162 | install -m 644 inc/qcbor/qcbor_main_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 163 | install -m 644 inc/qcbor/qcbor_spiffy_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 164 | install -m 644 inc/qcbor/qcbor_number_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 165 | install -m 644 inc/qcbor/qcbor_tag_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 166 | install -m 644 inc/qcbor/qcbor_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 167 | install -m 644 inc/qcbor/qcbor_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 67257dc | 2020-07-27 03:33:37 -0700 | [diff] [blame] | 168 | install -m 644 inc/qcbor/qcbor_spiffy_decode.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 2117bbf | 2024-12-30 22:56:41 -0500 | [diff] [blame] | 169 | install -m 644 inc/qcbor/qcbor_main_encode.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 170 | install -m 644 inc/qcbor/qcbor_number_encode.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 171 | install -m 644 inc/qcbor/qcbor_tag_encode.h $(DESTDIR)$(PREFIX)/include/qcbor |
Laurence Lundblade | 844bb5c | 2020-03-01 17:27:25 -0800 | [diff] [blame] | 172 | install -m 644 inc/qcbor/qcbor_encode.h $(DESTDIR)$(PREFIX)/include/qcbor |
Michael Eckel | 5c53133 | 2020-03-02 01:35:30 +0100 | [diff] [blame] | 173 | install -m 644 inc/qcbor/UsefulBuf.h $(DESTDIR)$(PREFIX)/include/qcbor |
| 174 | |
Laurence Lundblade | 02990fa | 2020-03-27 09:51:58 -0700 | [diff] [blame] | 175 | install_so: libqcbor.so |
| 176 | install -m 755 libqcbor.so $(DESTDIR)$(PREFIX)/lib/libqcbor.so.1.0.0 |
| 177 | ln -sf libqcbor.so.1 $(DESTDIR)$(PREFIX)/lib/libqcbor.so |
| 178 | ln -sf libqcbor.so.1.0.0 $(DESTDIR)$(PREFIX)/lib/libqcbor.so.1 |
| 179 | |
Michael Eckel | 7e8effa | 2020-03-09 18:19:17 +0100 | [diff] [blame] | 180 | uninstall: libqcbor.a $(PUBLIC_INTERFACE) |
| 181 | $(RM) -d $(DESTDIR)$(PREFIX)/include/qcbor/* |
| 182 | $(RM) -d $(DESTDIR)$(PREFIX)/include/qcbor/ |
| 183 | $(RM) $(addprefix $(DESTDIR)$(PREFIX)/lib/, \ |
| 184 | libqcbor.a libqcbor.so libqcbor.so.1 libqcbor.so.1.0.0) |
| 185 | |
Laurence Lundblade | 74d265c | 2018-09-19 10:21:00 -0700 | [diff] [blame] | 186 | clean: |
Laurence Lundblade | cb31ed3 | 2020-07-26 04:18:37 -0700 | [diff] [blame] | 187 | rm -f $(QCBOR_OBJ) $(TEST_OBJ) libqcbor.a cmd_line_main.o libqcbor.a libqcbor.so qcbormin qcbortest |