#===========================================================
#
## The Standard Makefile
#
#(Usage)
# make U=<program_name>; for compiling a single program
# <program_name> = bar for bar.cpp
# make ; for compiling all (listed below all:)
#
#(Default Library) ROOT
#
#(History)
# 130813 updated
#===========================================================
main:
make library
make compile PROGRAM=$(U)
all:
make compile_all PROGRAM=testReadAData
make compile_all PROGRAM=testA2RT
make compile_all PROGRAM=testReadTTree
make compile_all PROGRAM=testSetDoPrm
WRKDIR = tmp
ULIBOBJS = ReadAData-v03.2.o \
A2RT-v03.5.o \
ReadTTree-v03.3.o \
SetDoPrm-v01.8.o
LIBRARY_NAME = mycpplib
LIBRARY = lib${LIBRARY_NAME}.a
ULIBDIR = /My/cpplib/is/here
#====================================================
### INCLUDES ###
include /opt/local/etc/root/Makefile.arch
INCLUDE = -I/opt/local/include
#------ include user headers
ULIBINC = -I$(ULIBDIR)/include -Iinclude -I.
INCLUDE := $(INCLUDE) $(ULIBINC)
### LIBS ###
LIBS := -L./ -l${LIBRARY_NAME} $(ROOTGLIBS) -L/opt/local/lib -lgsl
UOBJS = <list your objects to be linked>
UOBJS =
LANGSFX=cpp
COMPILER = g++
LINKER = g++
COMPOPT = $(ROOTCFLAGS)
LINKOPT =
GOPTION = -DDEBUG
#====================================================
SRC = $(PROGRAM).$(LANGSFX)
OBJ = $(PROGRAM).o
TARGET = $(PROGRAM)_cxx
LDFLAGS = $(LIBS)
COMPOPT := $(COMPOPT) $(GOPTION)
LINKOPT := $(LINKOPT) $(GOPTION)
LIBSRCS = $(addprefix $(WRKDIR)/,$(ULIBOBJS))
ULIBSRC = $(ULIBDIR)/src
UOBJDIR = $(WRKDIR)
UOBJS := $(addprefix $(UOBJDIR)/,$(UOBJS))
#----------------------------------------------------
library:
@if [ ! -d $(WRKDIR) ]; then mkdir $(WRKDIR); \
echo "## --> tmp/ created...";fi
rm -f ${LIBRARY}
rm -f ${LIBSRCS}
make ${LIBRARY}
${LIBRARY}: ${LIBSRCS}
ar cru $@ ${LIBSRCS}
ranlib $@
compile:
@if [ -f $(SRC) ]; \
then make $(TARGET); \
rm $(OBJ); \
else make all; fi
compile_all:
rm -f $(TARGET)
make $(TARGET)
rm $(OBJ)
#----------------------------------------------------
.SUFFIXES: .exe .f .c .o .a .cpp .cxx .cc
#=================================================
$(TARGET): $(OBJ) $(UOBJS)
$(LINKER) $(LINKOPT) $(OBJ) $(UOBJS) -o $@ $(LDFLAGS)
$(ROOTLINKSRC)Dist.cpp: $(ROOTGUIHDRS).h $(ROOTLINKSRC)LinkDef.h
rootcint -f $(WRKDIR)/$(ROOTLINKSRC)Dist.cpp -c $(INCLUDE) $(ROOTGUIHDRS).h $(ROOTLINKSRC)LinkDef.h
#The following line must be the first one
$(UOBJDIR)/%.o : $(UOBJDIR)/%.cpp
$(COMPILER) -c $(COMPOPT) $< $(INCLUDE) -o $@
$(UOBJDIR)/%.o : $(ULIBSRC)/%.cpp
$(COMPILER) -c $(COMPOPT) $< $(INCLUDE) -o $@
$(UOBJDIR)/%.o : src/%.cpp
$(COMPILER) -c $(COMPOPT) $< $(INCLUDE) -o $@
$(UOBJDIR)/%.o : %.cpp
$(COMPILER) -c $(COMPOPT) $< $(INCLUDE) -o $@
.f.o:
$(FCOMPILE) -c $(FCMPOPT) $(FINCLUDE) $<
.c.o:
$(CCOMPILE) -c $(CCMPOPT) $(CINCLUDE) $<
No comments:
Post a Comment