summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@shell.devel.redhat.com>2009-09-04 02:29:08 -0400
committerJiri Olsa <jolsa@shell.devel.redhat.com>2009-09-04 02:29:08 -0400
commit04f3fbbfdb3a5dd197dbc25ca18ad244f1fbf6a5 (patch)
tree8e53039a4f5d1a4571000bc06214053261aebf8d /Makefile
downloadlatrace-04f3fbbfdb3a5dd197dbc25ca18ad244f1fbf6a5.tar.gz
latrace-04f3fbbfdb3a5dd197dbc25ca18ad244f1fbf6a5.tar.xz
latrace-04f3fbbfdb3a5dd197dbc25ca18ad244f1fbf6a5.zip
initial commit - 0.5.7
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile218
1 files changed, 218 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..aa48365
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,218 @@
+# Copyright (C) 2008, 2009 Jiri Olsa <olsajiri@gmail.com>
+#
+# This file is part of the latrace.
+#
+# The latrace is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# The latrace is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with the latrace (file COPYING). If not, see
+# <http://www.gnu.org/licenses/>.
+
+
+-include src/autoconf.make
+
+confdir := $(sysconfdir)/latrace.d
+
+# looks like DESTDIR is a standard, but prioritize ROOTDIR anyway
+ifdef DESTDIR
+ifndef ROOTDIR
+ROOTDIR=$(DESTDIR)
+endif
+endif
+
+ifneq ($(findstring $(MAKEFLAGS),w),w)
+PRINT_DIR = --no-print-directory
+else # "make -w"
+NO_SUBDIR = :
+endif
+
+# nice output definition
+# Mostly copied from kernel and git makefiles.
+
+ifndef V
+ QUIET_CC = @echo " CC" $@;
+ QUIET_LD = @echo " LD" $@;
+ QUIET_LEX = @echo " LE" $@;
+ QUIET_YACC = @echo " YA" $@;
+ QUIET_DEP = @echo " DEP" $@;
+ QUIET_GEN = @echo " GEN" $@;
+ QUIET_ASCIIDOC = @echo " ASCIIDOC" $@;
+ QUIET_XMLTO = @echo " XMLTO" $@;
+ QUIET_PKG = @echo -n " PKG ";
+
+# install file quietly, arguments:
+# 1 - file to install
+# 2 - directory to install to
+# 3 - permissions
+# 4 - bool - skip the install if the file does not exist
+define install
+ @if [ -n "$4" -a ! -e $1 ]; then \
+ echo " SKIP $(ROOTDIR)$2/$(notdir $1)"; \
+ else \
+ echo -n " INSTALL " `echo $(ROOTDIR)$2/$(notdir $1) | sed 's:[/]\+:/:g'` ; \
+ mkdir -p $(ROOTDIR)$2; \
+ install -m $3 $1 $(ROOTDIR)$2; echo; \
+ fi
+
+endef
+define remove
+ @echo " CLEAN " $1; $(RM) -rf $1
+endef
+else
+define remove
+ $(RM) -rf $1
+endef
+define install
+ if [ -n "$4" -a ! -e $1 ]; then \
+ echo " SKIP $(ROOTDIR)$2/$(notdir $1)"; \
+ else \
+ mkdir -p $(ROOTDIR)$2; \
+ install -m $3 $1 $(ROOTDIR)$2; echo; \
+ fi
+endef
+endif
+
+
+.PHONY: all clean tags install package .FORCE-LATRACE-CFLAGS
+
+all::
+
+install:: all
+ $(call install,etc/latrace.d/ctype.conf,$(confdir),644)
+ $(call install,etc/latrace.d/inet.conf,$(confdir),644)
+ $(call install,etc/latrace.d/misc.conf,$(confdir),644)
+ $(call install,etc/latrace.d/typedefs.conf,$(confdir),644)
+ $(call install,etc/latrace.d/stdlib.conf,$(confdir),644)
+ $(call install,etc/latrace.d/string.conf,$(confdir),644)
+ $(call install,etc/latrace.d/ctype.conf,$(confdir),644)
+ $(call install,etc/latrace.d/ncurses.conf,$(confdir),644)
+ $(call install,etc/latrace.d/stdio.conf,$(confdir),644)
+ $(call install,etc/latrace.d/dirent.conf,$(confdir),644)
+ $(call install,etc/latrace.d/unistd.conf,$(confdir),644)
+ $(call install,etc/latrace.d/libintl.conf,$(confdir),644)
+ $(call install,etc/latrace.d/dlfcn.conf,$(confdir),644)
+ $(call install,etc/latrace.d/fcntl.conf,$(confdir),644)
+ $(call install,etc/latrace.d/getopt.conf,$(confdir),644)
+ $(call install,etc/latrace.d/signal.conf,$(confdir),644)
+ $(call install,etc/latrace.d/ioctl.conf,$(confdir),644)
+ $(call install,etc/latrace.d/socket.conf,$(confdir),644)
+ $(call install,etc/latrace.d/netdb.conf,$(confdir),644)
+ $(call install,etc/latrace.d/stat.conf,$(confdir),644)
+ $(call install,etc/latrace.d/wait.conf,$(confdir),644)
+ $(call install,etc/latrace.d/utmp.conf,$(confdir),644)
+ $(call install,etc/latrace.d/time.conf,$(confdir),644)
+ $(call install,etc/latrace.d/termios.conf,$(confdir),644)
+ $(call install,etc/latrace.d/term.conf,$(confdir),644)
+ $(call install,etc/latrace.d/syslog.conf,$(confdir),644)
+ $(call install,etc/latrace.d/pwd.conf,$(confdir),644)
+ $(call install,etc/latrace.d/libio.conf,$(confdir),644)
+ $(call install,etc/latrace.d/locale.conf,$(confdir),644)
+ $(call install,etc/latrace.d/pthread.conf,$(confdir),644)
+ $(call install,etc/latrace.d/resource.conf,$(confdir),644)
+ $(call install,etc/latrace.d/mman.conf,$(confdir),644)
+ $(call install,etc/latrace.d/arch-$(CONFIG_SYSDEP_DIR).conf,$(confdir),644)
+ $(call install,etc/latrace.conf,$(sysconfdir),644)
+ifeq ($(CONFIG_SYSDEP_DIR),x86_64)
+ $(call install,etc/sysdeps/$(CONFIG_SYSDEP_DIR)/syscall.conf,$(confdir),644,1)
+endif
+
+
+ifeq (,$(filter clean mrproper,$(MAKECMDGOALS)))
+-include deps.make
+endif
+
+
+# main building schema
+# Module subdir (src,libsf) are supposed to fill PROGRAMS and
+# OBJS variables, and rule to link the module. The top makefile
+# will do the rest.
+
+PROGRAMS=
+OBJS=
+
+include src/Makefile
+include doc/Makefile
+
+INCLUDES= -Isrc -Isrc/sysdeps/$(CONFIG_SYSDEP_DIR)
+ALL_CFLAGS=$(CPPFLAGS) $(CFLAGS) -O2 -fPIC -Wall $(INCLUDES) -D_GNU_SOURCE
+
+
+%.o: %.c LATRACE-CFLAGS
+ $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
+
+.SECONDARY:
+
+%.c: %.l LATRACE-CFLAGS
+ $(QUIET_LEX)$(LEX) -t $< > $(basename $<).c
+
+%.c: %.y LATRACE-CFLAGS
+ $(QUIET_YACC)$(YACC) -v $< -d -o $(basename $<).c
+
+
+all:: $(PROGRAMS) LATRACE-CFLAGS
+
+clean::
+ $(call remove, $(OBJS) $(PROGRAMS))
+ $(call remove, src/args-bison.c src/args-flex.c src/args-bison.h src/args-bison.output)
+ $(call remove, lib bin share deps.make latrace-$(LT_VER))
+
+mrproper::
+ @for i in `find . -type f -o -type d -o -type l | cut -c 3- | grep -v svn`; do \
+ svn info $$i > /dev/null 2>&1; \
+ if [ x"$$?" != x"0" ]; then \
+ echo " CLEAN $$i"; rm -rf $$i; \
+ fi; \
+ done
+
+package:
+ $(QUIET_PKG)rm -f latrace-$(LT_VER); ln -s . latrace-$(LT_VER); \
+ echo "latrace-$(LT_VER)"; \
+ for i in `find . -type f | cut -c 3- | grep -v svn`; do \
+ svn info $$i > /dev/null 2>&1; \
+ if [ x"$$?" == x"0" ]; then \
+ echo "latrace-$(LT_VER)/$$i"; \
+ fi; \
+ done | tar cjvf latrace-$(LT_VER).tar.bz2 -T- > /dev/null 2>&1
+
+
+# dependencies
+# The gcc -M depedencies generation needs to repaired to include
+# subdirectory name within the target.. at least I haven't find any
+# gcc option to do that.
+# - no dependency for flex and bison definitions
+DEPS_OBJS=$(filter-out src/args-flex.o src/args-bison.o,$(OBJS))
+
+deps.make:
+ $(QUIET_DEP)$(RM) -f deps.make; \
+ (for obj in $(DEPS_OBJS); do \
+ src=`echo $$obj | sed "s/\.o/.c/"`; \
+ $(CC) $(ALL_CFLAGS) -M -MT$$obj $$src; \
+ done) > deps.make
+
+# utilities
+tags:
+ $(QUIET_GEN)$(RM) -f tags; \
+ $(FIND) . -name '*.[hc]' -print | xargs ctags -a
+
+cscope:
+ $(QUIET_GEN)$(RM) -f cscope*; \
+ $(FIND) . -name '*.[hc]' -print > cscope.files; \
+ cscope -b -icscope.files
+
+# detect prefix and cflags changes
+TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
+ $(prefix):$(exec_prefix):$(bindir):$(libdir):$(sysconfdir) #'
+
+LATRACE-CFLAGS: .FORCE-LATRACE-CFLAGS
+ @FLAGS='$(TRACK_CFLAGS)'; \
+ if test x"$$FLAGS" != x"`cat LATRACE-CFLAGS 2>/dev/null`" ; then \
+ echo "$$FLAGS" >LATRACE-CFLAGS; \
+ fi