diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-02-13 03:07:11 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-02-13 03:07:11 +0100 |
commit | b72e8567723c30f0e5a83675743e9380c48e5d55 (patch) | |
tree | f0dc052508543771fca08c358836507770864249 /common.mk | |
download | pcitool-b72e8567723c30f0e5a83675743e9380c48e5d55.tar.gz pcitool-b72e8567723c30f0e5a83675743e9380c48e5d55.tar.bz2 pcitool-b72e8567723c30f0e5a83675743e9380c48e5d55.tar.xz pcitool-b72e8567723c30f0e5a83675743e9380c48e5d55.zip |
Initial import
Diffstat (limited to 'common.mk')
-rw-r--r-- | common.mk | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..1758acd --- /dev/null +++ b/common.mk @@ -0,0 +1,55 @@ +# Compiler and default flags +CC ?= gcc +CFLAGS ?= -O2 + + +# Defaults for directories +ROOTDIR ?= $(shell pwd) + +INCDIR ?= $(ROOTDIR) +BINDIR ?= $(ROOTDIR) +LIBDIR ?= $(ROOTDIR) +OBJDIR ?= $(ROOTDIR) +DEPENDDIR ?= $(ROOTDIR) + +CXXFLAGS += $(addprefix -I ,$(INCDIR)) +CFLAGS += $(addprefix -I ,$(INCDIR)) + +# Source files in this directory +SRC = $(wildcard *.cpp) +SRCC = $(wildcard *.c) + +# Corresponding object files +OBJ = $(addprefix $(OBJDIR)/,$(SRC:.cpp=.o)) +OBJ += $(addprefix $(OBJDIR)/,$(SRCC:.c=.o)) + +# Corresponding dependency files +DEPEND = $(addprefix $(DEPENDDIR)/,$(SRC:.cpp=.d)) +DEPEND += $(addprefix $(DEPENDDIR)/,$(SRCC:.c=.d)) + +# This makes Verbose easier. Just prefix $(Q) to any command +ifdef VERBOSE + Q ?= +else + Q ?= @ +endif + +############################################################### +# Target definitions + +# Target for automatic dependency generation +depend: $(DEPEND) $(DEPENDC); + +# This rule generates a dependency makefile for each source +$(DEPENDDIR)/%.d: %.c + @echo -e "DEPEND \t$<" + $(Q)$(CC) $(addprefix -I ,$(INCDIR)) -MM -MF $@ \ + -MT $(OBJDIR)/$(<:.c=.o) -MT $@ $< + +# This includes the automatically +# generated dependency files +-include $(DEPEND) + +$(OBJDIR)/%.o: %.c + @echo -e "CC \t$<" + $(Q)@$(CC) $(CFLAGS) -c -o $@ $< |