mirror of
https://github.com/troglobit/libite.git
synced 2026-10-01 05:22:34 +07: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:
@@ -19,10 +19,7 @@
|
||||
# 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
|
||||
# THE SOFTWARE.
|
||||
.PHONY: all install clean
|
||||
|
||||
# Figure out root of library, unless used as submodule
|
||||
ROOTDIR ?= $(shell pwd)
|
||||
.PHONY: install test
|
||||
|
||||
#VERSION = $(shell git tag -l | tail -1)
|
||||
VERSION ?= 1.0.0
|
||||
@@ -42,17 +39,6 @@ CPPFLAGS += -D_GNU_SOURCE
|
||||
CPPFLAGS += -W -Wall
|
||||
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
|
||||
HEADERS = lite.h
|
||||
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
|
||||
|
||||
# Build rules
|
||||
all: $(TARGET)
|
||||
test:
|
||||
$(MAKE) -f rsync.mk
|
||||
|
||||
$(OBJS): Makefile
|
||||
|
||||
@@ -130,12 +116,6 @@ strip: $(TARGET)
|
||||
check: clean
|
||||
$(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
|
||||
distdir:
|
||||
@git archive --format=tar HEAD | (cd $(distdir); tar xf -)
|
||||
|
||||
@@ -1,22 +1,4 @@
|
||||
# Unittest makefile for rsync.c
|
||||
.PHONY: 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)
|
||||
OBJS = dir.o copyfile.o fexist.o fisdir.o fmode.o
|
||||
TARGET = $(OBJS) rsync.test clean
|
||||
|
||||
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
|
||||
%.o: %.c
|
||||
$(PRINT) " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
|
||||
@@ -7,3 +27,18 @@
|
||||
$(PRINT) " LINK $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
|
||||
$(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