mirror of
https://github.com/troglobit/libite.git
synced 2026-11-06 15:50:57 +00:00
Lay foundation for unit test build framework.
GNU Make double colon rules, rule ;-) Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
b7a8042c87
commit
2ea2357b62
3 files changed
+41
-44
No files matched your search
@@ -19,10 +19,7 @@
|
|||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
.PHONY: all install clean
|
.PHONY: install test
|
||||||
|
|
||||||
# Figure out root of library, unless used as submodule
|
|
||||||
ROOTDIR ?= $(shell pwd)
|
|
||||||
|
|
||||||
#VERSION = $(shell git tag -l | tail -1)
|
#VERSION = $(shell git tag -l | tail -1)
|
||||||
VERSION ?= 1.0.0
|
VERSION ?= 1.0.0
|
||||||
@@ -42,17 +39,6 @@ CPPFLAGS += -D_GNU_SOURCE
|
|||||||
CPPFLAGS += -W -Wall
|
CPPFLAGS += -W -Wall
|
||||||
ARFLAGS = crus
|
ARFLAGS = crus
|
||||||
|
|
||||||
# Default to silent build, use V=1 to get verbose mode.
|
|
||||||
ifeq ($V,1)
|
|
||||||
Q =
|
|
||||||
PRINT = @true
|
|
||||||
MAKEFLAGS =
|
|
||||||
else
|
|
||||||
Q = @
|
|
||||||
PRINT = @printf
|
|
||||||
MAKEFLAGS = --no-print-directory --silent
|
|
||||||
endif
|
|
||||||
|
|
||||||
DISTFILES = README LICENSE
|
DISTFILES = README LICENSE
|
||||||
HEADERS = lite.h
|
HEADERS = lite.h
|
||||||
OBJS := chomp.o copyfile.o dir.o fexist.o fisdir.o fmode.o fsendfile.o
|
OBJS := chomp.o copyfile.o dir.o fexist.o fisdir.o fmode.o fsendfile.o
|
||||||
@@ -78,8 +64,8 @@ incdir ?= $(prefix)/include
|
|||||||
#include <rules.mk>
|
#include <rules.mk>
|
||||||
include rules.mk
|
include rules.mk
|
||||||
|
|
||||||
# Build rules
|
test:
|
||||||
all: $(TARGET)
|
$(MAKE) -f rsync.mk
|
||||||
|
|
||||||
$(OBJS): Makefile
|
$(OBJS): Makefile
|
||||||
|
|
||||||
@@ -130,12 +116,6 @@ strip: $(TARGET)
|
|||||||
check: clean
|
check: clean
|
||||||
$(Q)scan-build $(MAKE) all
|
$(Q)scan-build $(MAKE) all
|
||||||
|
|
||||||
clean:
|
|
||||||
-$(Q)$(RM) $(OBJS) $(DEPS) $(TARGET) $(SOLIB) $(STATICLIB)
|
|
||||||
|
|
||||||
distclean:
|
|
||||||
-$(Q)$(RM) $(JUNK) unittest *.o *.a *.so* *.unittest
|
|
||||||
|
|
||||||
# When called from GNU configure and build system
|
# When called from GNU configure and build system
|
||||||
distdir:
|
distdir:
|
||||||
@git archive --format=tar HEAD | (cd $(distdir); tar xf -)
|
@git archive --format=tar HEAD | (cd $(distdir); tar xf -)
|
||||||
|
|||||||
@@ -1,22 +1,4 @@
|
|||||||
# Unittest makefile for rsync.c
|
OBJS = dir.o copyfile.o fexist.o fisdir.o fmode.o
|
||||||
.PHONY: clean
|
TARGET = $(OBJS) rsync.test clean
|
||||||
|
|
||||||
SRC = rsync.c
|
|
||||||
OBJS = dir.o copyfile.o fexist.o fisdir.o fmode.o
|
|
||||||
UNIT = rsync.unittest
|
|
||||||
#CPPFLAGS = -DDEBUG -I../../.. -I../../include
|
|
||||||
|
|
||||||
all: build run
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -f $(OBJS) $(UNIT)
|
|
||||||
|
|
||||||
# This rule also forces a cleanup of built objects to not leave any object files
|
|
||||||
# lingering in the tree to interfere with cross builds.
|
|
||||||
build: clean $(OBJS)
|
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -o $(UNIT) -DUNITTEST $(SRC) $(OBJS)
|
|
||||||
@rm -f $(OBJS)
|
|
||||||
|
|
||||||
run:
|
|
||||||
@./$(UNIT)
|
|
||||||
|
|
||||||
|
include rules.mk
|
||||||
@@ -1,3 +1,23 @@
|
|||||||
|
.PHONY: all clean distclean
|
||||||
|
|
||||||
|
# Figure out root of library, unless used as submodule
|
||||||
|
ROOTDIR ?= $(shell pwd)
|
||||||
|
|
||||||
|
# Default to silent build, use V=1 to get verbose mode.
|
||||||
|
ifeq ($V,1)
|
||||||
|
Q =
|
||||||
|
PRINT = @true
|
||||||
|
REDIRECT =
|
||||||
|
MAKEFLAGS =
|
||||||
|
else
|
||||||
|
Q = @
|
||||||
|
PRINT = @printf
|
||||||
|
REDIRECT = >/dev/null
|
||||||
|
MAKEFLAGS = --no-print-directory --silent
|
||||||
|
endif
|
||||||
|
|
||||||
|
export ROOTDIR Q PRINT MAKEFLAGS
|
||||||
|
|
||||||
# Pretty printing and GCC -M for auto dep files
|
# Pretty printing and GCC -M for auto dep files
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(PRINT) " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
|
$(PRINT) " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
|
||||||
@@ -7,3 +27,18 @@
|
|||||||
$(PRINT) " LINK $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
|
$(PRINT) " LINK $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
|
||||||
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-Map,$@.map -o $@ $^ $(LDLIBS$(LDLIBS-$(@)))
|
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-Map,$@.map -o $@ $^ $(LDLIBS$(LDLIBS-$(@)))
|
||||||
|
|
||||||
|
%.test: %.c
|
||||||
|
$(PRINT) " TEST $(subst $(ROOTDIR)/,,$(shell pwd)/)$(@:.test=)\n"
|
||||||
|
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -DUNITTEST $< $(OBJS)
|
||||||
|
$(Q)@./$@ $(REDIRECT)
|
||||||
|
|
||||||
|
|
||||||
|
# Default build rules for both main and unit test makefiles
|
||||||
|
all:: $(TARGET)
|
||||||
|
|
||||||
|
clean::
|
||||||
|
-$(Q)$(RM) $(OBJS) $(DEPS) $(TARGET) $(SOLIB) $(STATICLIB)
|
||||||
|
|
||||||
|
distclean::
|
||||||
|
-$(Q)$(RM) $(JUNK) unittest *.o *.a *.so* *.unittest *.test
|
||||||
|
|
||||||
Reference in new issue
Block a user