[01579ad] | 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 |
|
---|
| 33 | # Installation paths
|
---|
| 34 | PREFIX = /usr/local
|
---|
| 35 | LIBDIR = $(PREFIX)/lib
|
---|
| 36 | INCLUDEDIR = $(PREFIX)/include
|
---|
| 37 |
|
---|
| 38 | -include pcut.mak
|
---|
| 39 |
|
---|
| 40 | PCUT_OBJECTS := $(addsuffix .o,$(basename $(PCUT_SOURCES)))
|
---|
| 41 |
|
---|
| 42 | # Take care of dependencies
|
---|
| 43 | DEPEND = Makefile.depend
|
---|
| 44 | -include $(DEPEND)
|
---|
| 45 | $(DEPEND):
|
---|
| 46 | makedepend -f - -Iinclude -- $(PCUT_SOURCES) >$@ 2>/dev/null
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | #
|
---|
| 50 | # Add the check target for running all the tests
|
---|
| 51 | #
|
---|
| 52 | TEST_BASE = tests/
|
---|
| 53 | EXE_EXT = run
|
---|
| 54 | TEST_CFLAGS = $(PCUT_CFLAGS)
|
---|
| 55 | TEST_LDFLAGS = -L. -lpcut
|
---|
| 56 | -include tests/tests.mak
|
---|
| 57 | TEST_APPS_BASENAMES := $(basename $(TEST_APPS))
|
---|
| 58 | DIFF = diff
|
---|
| 59 | DIFFFLAGS = -du1
|
---|
| 60 |
|
---|
| 61 | check: libpcut.a check-build
|
---|
| 62 | @for i in $(TEST_APPS_BASENAMES); do \
|
---|
| 63 | echo -n ./$$i; \
|
---|
| 64 | ./$$i.$(EXE_EXT) | sed 's:$(TEST_BASE)::g' >$$i.got; \
|
---|
| 65 | if cmp -s $$i.got $$i.expected; then \
|
---|
| 66 | echo " ok."; \
|
---|
| 67 | else \
|
---|
| 68 | echo " failed:"; \
|
---|
| 69 | $(DIFF) $(DIFFFLAGS) $$i.expected $$i.got; \
|
---|
| 70 | fi; \
|
---|
| 71 | done
|
---|
| 72 |
|
---|
| 73 | #
|
---|
| 74 | # Clean-up
|
---|
| 75 | #
|
---|
| 76 | platform-clean:
|
---|
| 77 | rm -f libpcut.a $(DEPEND)
|
---|
| 78 |
|
---|
| 79 | #
|
---|
| 80 | # Actual build rules
|
---|
| 81 | #
|
---|
| 82 | $(PCUT_LIB): $(PCUT_OBJECTS)
|
---|
| 83 | $(AR) rc $@ $(PCUT_OBJECTS)
|
---|
| 84 | $(RANLIB) $@
|
---|
| 85 |
|
---|
| 86 | %.o: $(DEPEND)
|
---|
| 87 |
|
---|
| 88 | #
|
---|
| 89 | # Installation
|
---|
| 90 | #
|
---|
| 91 | install: $(PCUT_LIB)
|
---|
| 92 | install -d -m 755 $(DESTDIR)$(LIBDIR)
|
---|
| 93 | install -d -m 755 $(DESTDIR)$(INCLUDEDIR)/pcut
|
---|
| 94 | install -m 644 $(PCUT_LIB) $(DESTDIR)$(LIBDIR)/$(PCUT_LIB)
|
---|
| 95 | install -m 644 include/pcut/*.h $(DESTDIR)$(INCLUDEDIR)/pcut/
|
---|