blob: 657cd95b346183d24b8c561e889c57b067774629 [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
Michael Eckel5c531332020-03-02 01:35:30 +010011CFLAGS=-I inc -I test -Os -Wcast-align -Wall -Werror -pedantic-errors -Wextra -Wshadow -Wparentheses -Wno-conversion -xc -std=c99
Laurence Lundblade74d265c2018-09-19 10:21:00 -070012
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080013QCBOR_OBJ=src/UsefulBuf.o src/qcbor_encode.o src/qcbor_decode.o src/ieee754.o
Laurence Lundblade781fd822018-10-01 09:37:52 -070014
Laurence Lundblade4d1ecba2018-10-12 21:22:30 +080015TEST_OBJ=test/UsefulBuf_Tests.o test/qcbor_encode_tests.o test/qcbor_decode_tests.o test/run_tests.o \
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080016 test/float_tests.o test/half_to_double_from_rfc7049.o
Laurence Lundblade781fd822018-10-01 09:37:52 -070017
Laurence Lundblade2c978832018-12-13 01:10:21 -080018qcbortest: libqcbor.a $(TEST_OBJ) cmd_line_main.o
Laurence Lundbladecd532e42018-12-17 13:19:45 -080019 cc -o $@ $^ libqcbor.a
Laurence Lundblade74d265c2018-09-19 10:21:00 -070020
Laurence Lundbladecd532e42018-12-17 13:19:45 -080021qcbormin: libqcbor.a min_use_main.o
22 cc -dead_strip -o $@ $^ libqcbor.a
Laurence Lundblade74d265c2018-09-19 10:21:00 -070023
Laurence Lundbladec9d3dcf2018-12-19 18:11:36 -080024libqcbor.a: $(QCBOR_OBJ)
Laurence Lundblade2c978832018-12-13 01:10:21 -080025 ar -r $@ $^
Laurence Lundbladec2b14572018-11-01 13:07:49 +070026
Laurence Lundblade74d265c2018-09-19 10:21:00 -070027src/UsefulBuf.o: inc/UsefulBuf.h
Laurence Lundblade781fd822018-10-01 09:37:52 -070028src/qcbor_decode.o: inc/UsefulBuf.h inc/qcbor.h src/ieee754.h
29src/qcbor_encode.o: inc/UsefulBuf.h inc/qcbor.h src/ieee754.h
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080030src/iee754.o: src/ieee754.h
Laurence Lundblade781fd822018-10-01 09:37:52 -070031
Laurence Lundblade4d1ecba2018-10-12 21:22:30 +080032test/run_tests.o: test/UsefulBuf_Tests.h test/float_tests.h test/run_tests.h test/qcbor_encode_tests.h\
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080033 test/qcbor_decode_tests.h
Laurence Lundblade4d1ecba2018-10-12 21:22:30 +080034test/UsefulBuf_Tests.o: test/UsefulBuf_Tests.h inc/qcbor.h inc/UsefulBuf.h
35test/qcbor_encode_tests.o: test/qcbor_encode_tests.h inc/qcbor.h inc/UsefulBuf.h
36test/qcbor_decode_tests.o: test/qcbor_decode_tests.h inc/qcbor.h inc/UsefulBuf.h
37test/float_tests.o: inc/qcbor.h inc/UsefulBuf.h test/float_tests.h test/half_to_double_from_rfc7049.h
Laurence Lundblade781fd822018-10-01 09:37:52 -070038test/half_to_double_from_rfc7049.o: test/half_to_double_from_rfc7049.h
39
Laurence Lundblade972e59c2018-11-11 15:57:23 +070040cmd_line_main.o: test/run_tests.h inc/qcbor.h
Laurence Lundblade74d265c2018-09-19 10:21:00 -070041
Laurence Lundbladec2b14572018-11-01 13:07:49 +070042min_use_main.o: inc/qcbor.h inc/UsefulBuf.h
43
Michael Eckel5c531332020-03-02 01:35:30 +010044ifeq ($(PREFIX),)
45 PREFIX := /usr/local
46endif
47
48install: libqcbor.a
49 install -d $(DESTDIR)$(PREFIX)/lib/
50 install -m 644 libqcbor.a $(DESTDIR)$(PREFIX)/lib/
51 install -d $(DESTDIR)$(PREFIX)/include/qcbor
52 install -m 644 inc/qcbor/qcbor.h $(DESTDIR)$(PREFIX)/include/qcbor
53 install -m 644 inc/qcbor/UsefulBuf.h $(DESTDIR)$(PREFIX)/include/qcbor
54
Laurence Lundblade74d265c2018-09-19 10:21:00 -070055clean:
Laurence Lundbladeb26de6f2019-01-10 08:47:40 -080056 rm -f $(QCBOR_OBJ) $(TEST_OBJ) libqcbor.a min_use_main.o cmd_line_main.o