CC=g++ #wildcard, this finds all *.c file and make *.o files objects = $(patsubst %.c,%.o,$(wildcard *.c)) PYTHIA8=/home/sayan/pythia8235/ fastjet=/home/sayan/fastjet-3.3.1/fastjet-install/ ROOT_DIR = /home/sayan/ROOT_6.12_BUILD/ DELPHES_DIR = /home/sayan/Delphes-3.4.1/ PLATFORM_TYPE := $(shell uname -s) FJFLAGS := $(shell fastjet-config --cxxflags) FJLIBS := $(shell fastjet-config --libs) ROOTFLAGS := $(shell root-config --cflags) ROOTLIBS := $(shell root-config --libs) ROOTINC := $(shell root-config --incdir) #include delphes exroot INC := -I$(DELPHES_DIR) -I$(DELPHES_DIR)/classes -I$(DELPHES_DIR)/external LIB := -L$(DELPHES_DIR) -lDelphes -Wl,-rpath $(DELPHES_DIR) all: Example7 Example7: $(objects) Example7.C $(CXX) -O3 $(objects) Example7.C \ $(ROOTFLAGS) $(INC) \ $(ROOTLIBS) $(LIB) \ -Wl,-rpath,$(DELPHES_DIR) \ -o Example7 $(FJFLAGS) $(FJLIBS) $(ROOTLIBS) %.o: %.C %.h rm lib/*; gcc -fPIC -O2 -c $(FJFLAGS) $< -o $@ clean: rm $(FILES) Example7 lib/*