Skip to content

Instantly share code, notes, and snippets.

@mgmarino
Created May 20, 2011 13:40
Show Gist options
  • Save mgmarino/982903 to your computer and use it in GitHub Desktop.
Save mgmarino/982903 to your computer and use it in GitHub Desktop.
Makefile example
# Makefile
#
ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs) -lNew
ROOTGLIBS = $(shell root-config --glibs)
MYOS := $(subst -,,$(shell uname))
LIBS = -L$EXOLIB/lib -lEXOUtilities
ifeq ($(MYOS),Linux)
CXX = g++
CXXFLAGS = -g -Wall -fPIC -DEXE
CXXFLAGS += $(ROOTCFLAGS)
OPTIM= -fexpensive-optimizations -funroll-loops
LIBS += $(ROOTLIBS)
GLIBS = $(ROOTGLIBS)
GLIBS += -lSpectrum
endif
ifeq ($(MYOS),Darwin)
CXX = g++
CXXFLAGS = -O2 -Wall -fPIC -DEXE
CXXFLAGS += $(ROOTCFLAGS)
OPTIM= -fexpensive-optimizations -funroll-loops
LIBS += $(ROOTLIBS)
GLIBS = $(ROOTGLIBS)
LDFLAGS = -bind_at_load
endif
CXXFLAGS += -I$EXOLIB/include
%.o : %.C
$(CXX) -c $(CXXFLAGS) $(IFLAGS) $(OPTIM) -o $*.o $(*F).C
%.o : %.c
cc -c $(CFLAGS) $(OPTIM) $(INCPATH) $*.c
%.o : %.f
$(FC) -c $(FFLAGS) $(OPTIM) $(INCPATH) $*.f
%.o : %.F
$(FC) -c $(FFLAGS) $(OPTIM) $(INCPATH) $*.F
EXOScript: EXOScript.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $@.o $(LIBS) $(GLIBS)
EXOScript.o: tree.h tree.C
clean:
@rm -f *.o core
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment