blob: 91220aac1ac4e2c5266992da771f152a24ccd9fa [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 Eckel5c531332020-03-02 01:35:30 +010013CFLAGS=-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 -070014
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080015
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080016QCBOR_OBJ=src/UsefulBuf.o src/qcbor_encode.o src/qcbor_decode.o src/ieee754.o
Laurence Lundblade781fd822018-10-01 09:37:52 -070017
Laurence Lundblade4d1ecba2018-10-12 21:22:30 +080018TEST_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 -080019 test/float_tests.o test/half_to_double_from_rfc7049.o
Laurence Lundblade781fd822018-10-01 09:37:52 -070020
Laurence Lundblade2c978832018-12-13 01:10:21 -080021qcbortest: libqcbor.a $(TEST_OBJ) cmd_line_main.o
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080022 $(CC) -o $@ $^ libqcbor.a
Laurence Lundblade74d265c2018-09-19 10:21:00 -070023
Laurence Lundbladecd532e42018-12-17 13:19:45 -080024qcbormin: libqcbor.a min_use_main.o
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080025 $(CC) -dead_strip -o $@ $^ libqcbor.a
Laurence Lundblade74d265c2018-09-19 10:21:00 -070026
Laurence Lundbladec9d3dcf2018-12-19 18:11:36 -080027libqcbor.a: $(QCBOR_OBJ)
Laurence Lundblade2c978832018-12-13 01:10:21 -080028 ar -r $@ $^
Laurence Lundbladec2b14572018-11-01 13:07:49 +070029
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080030PUBLIC_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
31
Laurence Lundblade74d265c2018-09-19 10:21:00 -070032src/UsefulBuf.o: inc/UsefulBuf.h
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080033src/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
34src/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
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080035src/iee754.o: src/ieee754.h
Laurence Lundblade781fd822018-10-01 09:37:52 -070036
Laurence Lundblade4d1ecba2018-10-12 21:22:30 +080037test/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 -080038 test/qcbor_decode_tests.h
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080039test/UsefulBuf_Tests.o: test/UsefulBuf_Tests.h inc/UsefulBuf.h
40test/qcbor_encode_tests.o: test/qcbor_encode_tests.h $(PUBLIC_INTERFACE)
41test/qcbor_decode_tests.o: test/qcbor_decode_tests.h $(PUBIC_INTERFACE)
42test/float_tests.o: test/float_tests.h test/half_to_double_from_rfc7049.h $(PUBLIC_INTERFACE)
Laurence Lundblade781fd822018-10-01 09:37:52 -070043test/half_to_double_from_rfc7049.o: test/half_to_double_from_rfc7049.h
44
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080045cmd_line_main.o: test/run_tests.h $(PUBLIC_INTERFACE)
Laurence Lundblade74d265c2018-09-19 10:21:00 -070046
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080047min_use_main.o: $(PUBLIC_INTERFACE)
Laurence Lundbladec2b14572018-11-01 13:07:49 +070048
Michael Eckel5c531332020-03-02 01:35:30 +010049ifeq ($(PREFIX),)
50 PREFIX := /usr/local
51endif
52
53install: libqcbor.a
54 install -d $(DESTDIR)$(PREFIX)/lib/
55 install -m 644 libqcbor.a $(DESTDIR)$(PREFIX)/lib/
56 install -d $(DESTDIR)$(PREFIX)/include/qcbor
Laurence Lundblade844bb5c2020-03-01 17:27:25 -080057 install -m 644 inc/qcbor.h $(DESTDIR)$(PREFIX)/include/qcbor
58 install -m 644 inc/qcbor/qcbor_private.h $(DESTDIR)$(PREFIX)/include/qcbor
59 install -m 644 inc/qcbor/qcbor_common.h $(DESTDIR)$(PREFIX)/include/qcbor
60 install -m 644 inc/qcbor/qcbor_decode.h $(DESTDIR)$(PREFIX)/include/qcbor
61 install -m 644 inc/qcbor/qcbor_encode.h $(DESTDIR)$(PREFIX)/include/qcbor
Michael Eckel5c531332020-03-02 01:35:30 +010062 install -m 644 inc/qcbor/UsefulBuf.h $(DESTDIR)$(PREFIX)/include/qcbor
63
Laurence Lundblade74d265c2018-09-19 10:21:00 -070064clean:
Laurence Lundbladeb26de6f2019-01-10 08:47:40 -080065 rm -f $(QCBOR_OBJ) $(TEST_OBJ) libqcbor.a min_use_main.o cmd_line_main.o