Makefile cleanup

This commit is contained in:
Charlie Curtsinger 2019-08-18 16:28:54 -05:00
parent 9b0cc348c6
commit 3e2f144b30
6 changed files with 42 additions and 49 deletions

View File

@ -26,4 +26,4 @@ install:
# Run the make check target (add tests later)
script:
- make check
- make check USE_SYSTEM_COZ=1

View File

@ -3,22 +3,16 @@ DIRS := libcoz viewer
include $(ROOT)/common.mk
bench::
@for dir in benchmarks ; do make -C $$dir $@; done
update-gh-pages:: all
@echo $(LOG_PREFIX) Pushing profiler viewer to gh-pages branch $(LOG_SUFFIX)
@git push origin `git subtree split --prefix viewer master 2> /dev/null`:gh-pages
check::
make -C libcoz $@
install:: all
@echo $(LOG_PREFIX) Installing coz to prefix $(prefix) $(LOG_SUFFIX)
@$(INSTALL) -D coz $(DESTDIR)$(bindir)/coz
@$(INSTALL) -D libcoz/libcoz.so $(DESTDIR)$(pkglibdir)/libcoz.so
@$(INSTALL) -D include/coz.h $(DESTDIR)$(incdir)/coz.h
@$(RST2MAN) docs/coz.rst $(DESTDIR)$(man1dir)/coz.1
update-gh-pages::
$(MAKE) -C viewer
git push origin `git subtree split --prefix viewer master 2> /dev/null`:gh-pages
install::
$(INSTALL) -D coz $(DESTDIR)$(bindir)/coz
$(INSTALL) -D include/coz.h $(DESTDIR)$(incdir)/coz.h
$(RST2MAN) docs/coz.rst $(DESTDIR)$(man1dir)/coz.1
distclean::
@for dir in deps/libelfin ; do \
if [ -d $$dir ] ; then make -C $$dir distclean || make -C $$dir clean; fi; \
done
bench:: all
@$(MAKE) -C benchmarks bench

View File

@ -21,7 +21,7 @@ pbzip2: bzip2-1.0.6/libbz2.a
bzip2-1.0.6/libbz2.a:
@echo $(LOG_PREFIX) Downloading libbz2 $(LOG_SUFFIX)
@wget -c https://fossies.org/linux/misc/bzip2-1.0.6.tar.gz
@wget -c https://sourceware.org/pub/bzip2/bzip2-1.0.6.tar.gz
@echo $(LOG_PREFIX) Unpacking libbz2 $(LOG_SUFFIX)
@tar xzf bzip2-1.0.6.tar.gz
@echo $(LOG_PREFIX) Building libbz2 $(LOG_SUFFIX)

View File

@ -1,10 +1,10 @@
DESTDIR =
prefix = /usr
bindir = $(prefix)/bin
pkglibdir = $(prefix)/lib/coz-profiler
incdir = $(prefix)/include
mandir = $(prefix)/share/man
man1dir = $(mandir)/man1
DESTDIR ?=
prefix ?= /usr
bindir := $(prefix)/bin
pkglibdir := $(prefix)/lib/coz-profiler
incdir := $(prefix)/include
mandir := $(prefix)/share/man
man1dir := $(mandir)/man1
INSTALL = install
RST2MAN = rst2man
@ -15,9 +15,9 @@ CXX ?= clang++
# Set coz and include path for coz
ifeq ($(USE_SYSTEM_COZ),1)
COZ = $(shell which coz)
COZ := $(shell which coz)
else
COZ = $(ROOT)/coz
COZ := $(ROOT)/coz
endif
# Default flags
@ -26,11 +26,14 @@ CXXFLAGS ?= $(CFLAGS)
LDLIBS += $(addprefix -l,$(LIBS))
# Default source and object files
SRCS ?= $(wildcard *.cpp) $(wildcard *.c)
OBJS ?= $(addprefix obj/,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRCS))))
SRCS ?= $(wildcard *.cpp) $(wildcard *.c)
OBJS ?= $(addprefix obj/,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRCS))))
# Prevent errors if files named all, clean, distclean, bench, or test exist
.PHONY: all clean distclean bench test
# Targets to build recirsively into $(DIRS)
RECURSIVE_TARGETS ?= all clean distclean bench test install
RECURSIVE_TARGETS ?= all clean bench test install check
# Targets separated by type
SHARED_LIB_TARGETS := $(filter %.so, $(TARGETS))
@ -38,12 +41,15 @@ STATIC_LIB_TARGETS := $(filter %.a, $(TARGETS))
OTHER_TARGETS := $(filter-out %.so, $(filter-out %.a, $(TARGETS)))
# If not set, the build path is just the current directory name
MAKEPATH ?= `basename $(PWD)`
MAKEPATH ?= $(shell basename $(shell pwd))
# Log the build path in gray, following by a log message in bold green
LOG_PREFIX := "$(shell tput setaf 7)[$(MAKEPATH)]$(shell tput sgr0)$(shell tput setaf 2)"
LOG_SUFFIX := "$(shell tput sgr0)"
# Build in parallel
MAKEFLAGS += -j
# Build all targets by default
all:: $(TARGETS)
@ -56,11 +62,7 @@ clean::
# Bring source back to pristine state
distclean:: clean
test::
# Prevent errors if files named all, clean, distclean, bench, or test exist
.PHONY: all clean distclean bench test
@$(MAKE) -C benchmarks clean
# Compile a C++ source file (and generate its dependency rules)
obj/%.o: %.cpp $(PREREQS)
@ -95,9 +97,11 @@ bench_inputs:
test_inputs:
bench:: $(OTHER_TARGETS) bench_inputs
@echo $(LOG_PREFIX) Running benchmark on full input $(LOG_SUFFIX)
$(COZ) run $(COZ_ARGS) --- ./$< $(BENCH_ARGS)
test:: $(OTHER_TARGETS) test_inputs
@echo $(LOG_PREFIX) Running benchmark on test input $(LOG_SUFFIX)
$(COZ) run $(COZ_ARGS) --- ./$< $(TEST_ARGS)
endif

View File

@ -1,7 +1,7 @@
ROOT := ..
TARGETS := libcoz.so
LIBS := dl rt pthread elf++ dwarf++
CXXFLAGS := --std=c++14 -g -O2 -fPIC -I$(ROOT)/include -I.
CXXFLAGS := --std=c++0x -g -O2 -fPIC -I$(ROOT)/include -I.
include $(ROOT)/common.mk
@ -11,6 +11,3 @@ check:: libcoz.so
../coz run --- ./x
if grep -q time= profile.coz; then echo success: coz profiler ran as it should.; fi
$(RM) -f x.c x profile.coz
install::
$(INSTALL) -D $(ROOT)/libcoz/libcoz.so $(DESTDIR)$(pkglibdir)/libcoz.so

View File

@ -1,11 +1,9 @@
all: js/ui.js js/profile.js
ROOT := ..
js/%.js: ts/%.ts tsconfig.json
npm install
include $(ROOT)/common.mk
clean:
rm -f js/*
all:: js/ui.js
# Do nothing for install target
install::
js/ui.js: $(wildcard ts/*.ts) tsconfig.json
@echo $(LOG_PREFIX) Building profile viewer $(LOG_SUFFIX)
@npm install > /dev/null