1 | #
|
---|
2 | # Copyright (c) 2013 Vojtech Horky
|
---|
3 | # All rights reserved.
|
---|
4 | #
|
---|
5 | # Redistribution and use in source and binary forms, with or without
|
---|
6 | # modification, are permitted provided that the following conditions
|
---|
7 | # are met:
|
---|
8 | #
|
---|
9 | # - Redistributions of source code must retain the above copyright
|
---|
10 | # notice, this list of conditions and the following disclaimer.
|
---|
11 | # - Redistributions in binary form must reproduce the above copyright
|
---|
12 | # notice, this list of conditions and the following disclaimer in the
|
---|
13 | # documentation and/or other materials provided with the distribution.
|
---|
14 | # - The name of the author may not be used to endorse or promote products
|
---|
15 | # derived from this software without specific prior written permission.
|
---|
16 | #
|
---|
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | #
|
---|
28 |
|
---|
29 | PCUT_TARGET_SOURCES = src/os/stdc.c src/os/unix.c
|
---|
30 | OBJ_EXT = o
|
---|
31 | PCUT_LIB = libpcut.a
|
---|
32 | PCUT_PREPROC = ./pcut.bin
|
---|
33 |
|
---|
34 | # Installation paths
|
---|
35 | PREFIX = /usr/local
|
---|
36 | LIBDIR = $(PREFIX)/lib
|
---|
37 | INCLUDEDIR = $(PREFIX)/include
|
---|
38 |
|
---|
39 | -include pcut.mak
|
---|
40 |
|
---|
41 | PCUT_OBJECTS := $(addsuffix .o,$(basename $(PCUT_SOURCES)))
|
---|
42 | PCUT_PREPROC_OBJECTS := $(addsuffix .o,$(basename $(PCUT_PREPROC_SOURCES)))
|
---|
43 |
|
---|
44 | # Take care of dependencies
|
---|
45 | DEPEND = Makefile.depend
|
---|
46 | -include $(DEPEND)
|
---|
47 | $(DEPEND):
|
---|
48 | makedepend -f - -Iinclude -- $(PCUT_SOURCES) >$@ 2>/dev/null
|
---|
49 |
|
---|
50 |
|
---|
51 | #
|
---|
52 | # Add the check target for running all the tests
|
---|
53 | #
|
---|
54 | TEST_BASE = tests/
|
---|
55 | EXE_EXT = run
|
---|
56 | TEST_CFLAGS = $(PCUT_CFLAGS)
|
---|
57 | TEST_LDFLAGS =
|
---|
58 | -include tests/tests.mak
|
---|
59 | TEST_APPS_BASENAMES := $(basename $(TEST_APPS))
|
---|
60 | DIFF = diff
|
---|
61 | DIFFFLAGS = -du1
|
---|
62 |
|
---|
63 | check: libpcut.a check-build
|
---|
64 | @for i in $(TEST_APPS_BASENAMES); do \
|
---|
65 | echo -n ./$$i; \
|
---|
66 | ./$$i.$(EXE_EXT) | sed 's:$(TEST_BASE)::g' >$$i.got; \
|
---|
67 | if cmp -s $$i.got $$i.expected; then \
|
---|
68 | echo " ok."; \
|
---|
69 | else \
|
---|
70 | echo " failed:"; \
|
---|
71 | $(DIFF) $(DIFFFLAGS) $$i.expected $$i.got; \
|
---|
72 | fi; \
|
---|
73 | done
|
---|
74 |
|
---|
75 | #
|
---|
76 | # Clean-up
|
---|
77 | #
|
---|
78 | platform-clean:
|
---|
79 | rm -f $(DEPEND) $(PCUT_LIB) $(PCUT_PREPROC)
|
---|
80 |
|
---|
81 | #
|
---|
82 | # Actual build rules
|
---|
83 | #
|
---|
84 | $(PCUT_LIB): $(PCUT_OBJECTS)
|
---|
85 | $(AR) rc $@ $(PCUT_OBJECTS)
|
---|
86 | $(RANLIB) $@
|
---|
87 |
|
---|
88 | $(PCUT_PREPROC): $(PCUT_PREPROC_OBJECTS)
|
---|
89 | $(LD) $(LDFLAGS) -o $@ $(PCUT_PREPROC_OBJECTS)
|
---|
90 |
|
---|
91 | %.o: $(DEPEND)
|
---|
92 |
|
---|
93 | #
|
---|
94 | # Installation
|
---|
95 | #
|
---|
96 | install: $(PCUT_LIB)
|
---|
97 | install -d -m 755 $(DESTDIR)$(LIBDIR)
|
---|
98 | install -d -m 755 $(DESTDIR)$(INCLUDEDIR)/pcut
|
---|
99 | install -m 644 $(PCUT_LIB) $(DESTDIR)$(LIBDIR)/$(PCUT_LIB)
|
---|
100 | install -m 644 include/pcut/*.h $(DESTDIR)$(INCLUDEDIR)/pcut/
|
---|