-
Akash Kothari authoredAkash Kothari authored
c.mk 1.98 KiB
# (c) 2007 The Board of Trustees of the University of Illinois.
# Default language wide options
LANG_CFLAGS=-I$(PARBOIL_ROOT)/common/include -I/usr/local/cuda/include
LANG_CXXFLAGS=$(LANG_CFLAGS)
LANG_LDFLAGS=
CFLAGS=$(LANG_CFLAGS) $(PLATFORM_CFLAGS) $(APP_CFLAGS)
CXXFLAGS=$(LANG_CXXFLAGS) $(PLATFORM_CXXFLAGS) $(APP_CXXFLAGS)
LDFLAGS=$(LANG_LDFLAGS) $(PLATFORM_LDFLAGS) $(APP_LDFLAGS)
# Rules common to all makefiles
########################################
# Functions
########################################
# Add BUILDDIR as a prefix to each element of $1
INBUILDDIR=$(addprefix $(BUILDDIR)/,$(1))
# Add SRCDIR as a prefix to each element of $1
INSRCDIR=$(addprefix $(SRCDIR)/,$(1))
########################################
# Environment variable check
########################################
# The second-last directory in the $(BUILDDIR) path
# must have the name "build". This reduces the risk of terrible
# accidents if paths are not set up correctly.
ifeq ("$(notdir $(BUILDDIR))", "")
$(error $$BUILDDIR is not set correctly)
endif
ifneq ("$(notdir $(patsubst %/,%,$(dir $(BUILDDIR))))", "build")
$(error $$BUILDDIR is not set correctly)
endif
.PHONY: run
########################################
# Derived variables
########################################
ifeq ($(DEBUGGER),)
DEBUGGER=gdb
endif
OBJS = $(call INBUILDDIR,$(SRCDIR_OBJS))
########################################
# Rules
########################################
default: $(BUILDDIR) $(BIN)
run:
@$(BIN) $(ARGS)
debug:
@$(DEBUGGER) --args $(BIN) $(ARGS)
clean :
rm -f $(BUILDDIR)/*
if [ -d $(BUILDDIR) ]; then rmdir $(BUILDDIR); fi
$(BIN) : $(OBJS) $(BUILDDIR)/parboil.o
$(CXX) $^ -o $@ $(LDFLAGS)
$(BUILDDIR) :
mkdir -p $(BUILDDIR)
$(BUILDDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(BUILDDIR)/parboil.o: $(PARBOIL_ROOT)/common/src/parboil.c
$(CC) $(CFLAGS) -c $< -o $@
$(BUILDDIR)/%.o : $(SRCDIR)/%.cc
$(CXX) $(CXXFLAGS) -c $< -o $@
$(BUILDDIR)/%.o : $(SRCDIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@