Skip to content

Commit

Permalink
Merge pull request #2 from EECS-NTNU/makefiles
Browse files Browse the repository at this point in the history
makefile: Add help target for printing available make targets
  • Loading branch information
phate authored Jun 20, 2019
2 parents 9436849 + 00d217e commit f7baeb4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@
# Copyright 2011 2012 2013 2014 2015 Nico Reißmann <[email protected]>
# See COPYING for terms of redistribution.

JIVE_ROOT ?= .
define HELP_TEXT
clear
echo "Makefile for the Jive RVSDG API"
echo "Version 1.0 - 2019-06-18"
endef
.PHONY: help
help:
@$(HELP_TEXT)
@$(HELP_TEXT_JIVE)
@echo "all Compiles the Jive library and runs unit tests"

CFLAGS+=-Wall -Wpedantic --std=c++14
CPPFLAGS+=-I$(JIVE_ROOT)/include
JIVE_ROOT ?= .

.PHONY: all
all: check
all: jive check

include Makefile.sub
include tests/Makefile.sub
Expand All @@ -18,7 +26,7 @@ doc:
doxygen doxygen.conf

.PHONY: clean
clean: jive-clean jive-test-clean
clean: jive-clean

%.lo: %.c
$(CXX) -c -DPIC -fPIC $(CFLAGS) $(CPPFLAGS) -o $@ $<
Expand Down
14 changes: 14 additions & 0 deletions Makefile.sub
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
define HELP_TEXT_JIVE
echo ""
echo "Jive Make Targets"
echo "--------------------------------------------------------------------------------"
echo "jive Compiles the Jive library"
echo "jive-clean Cleans all build files and libraries"
endef

# RVSDG core
LIBJIVE_SRC = \
src/common.c \
Expand Down Expand Up @@ -103,14 +111,20 @@ HEADERS = $(shell find $(JIVE_ROOT)/include -name "*.h")
.PHONY: jive
jive: $(JIVE_ROOT)/libjive.a

$(JIVE_ROOT)/libjive.a: CFLAGS+=-Wall -Wpedantic --std=c++14
$(JIVE_ROOT)/libjive.a: CPPFLAGS+=-I$(JIVE_ROOT)/include
$(JIVE_ROOT)/libjive.a: $(patsubst %.c, $(JIVE_ROOT)/%.la, $(LIBJIVE_SRC))

$(JIVE_ROOT)/libjive.so: CFLAGS+=-Wall -Wpedantic --std=c++14
$(JIVE_ROOT)/libjive.so: CPPFLAGS+=-I$(JIVE_ROOT)/include
$(JIVE_ROOT)/libjive.so: $(patsubst %.c, $(JIVE_ROOT)/%.lo, $(LIBJIVE_SRC))

.PHONY: jive-clean
jive-clean: jive-depclean
@find $(JIVE_ROOT)/ -name "*.o" -o -name "*.lo" -o -name "*.la" -o -name "*.so" -o -name "*.a" | xargs rm -rf
@rm -rf $(JIVE_ROOT)/*.log
@rm -rf $(JIVE_ROOT)/a.out
@rm -rf $(JIVE_ROOT)/tests/test-runner

.PHONY: jive-depclean
jive-depclean:
Expand Down
8 changes: 2 additions & 6 deletions tests/Makefile.sub
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ include tests/types/Makefile.sub
include tests/util/Makefile.sub
include tests/rvsdg/Makefile.sub

TESTPROGS=test-runner

TEST_SOURCES = tests/testtypes.c tests/testarch.c tests/testnodes.c tests/test-runner.c tests/test-registry.c $(patsubst %, tests/%.c, $(TESTS))
SOURCES += $(TEST_SOURCES)

Expand All @@ -26,6 +24,8 @@ GREEN='\033[0;32m'
NC='\033[0m' # No Color

.PHONY: check
check: CFLAGS+=-Wall -Wpedantic --std=c++14
check: CPPFLAGS+=-I$(JIVE_ROOT)/include
check: tests/test-runner
@rm -rf check.log passed.log failed.log
@for TEST in `tests/test-runner`; do \
Expand Down Expand Up @@ -68,7 +68,3 @@ valgrind-check: tests/test-runner
fi \
fi
@if [ "x$(EXPECT_FAIL_TESTS)" != x ] ; then echo "Expected failures: $(EXPECT_FAIL_TESTS)" ; fi

.PHONY: jive-test-clean
jive-test-clean:
@rm -rf $(TESTPROGS)

0 comments on commit f7baeb4

Please sign in to comment.