makefile 5.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
################################################################################
# Makefile building all dynamic libraries:
# libTELoss.so, libEvent.so, libDetectors.so, libSimulations.so 
#
#	OBJS - files type *.o (subdir.mk)
#	LIBS - list of the loaded libraries (objects.mk)
#	RM - command "rm -rf"
#	CPP_DEPS - files type *.d (subdir.mk)
#	.PHONY - 
#	.SECONDARY - 
#	
# Vratislav Chudoba
################################################################################

RM := rm -rf

CC := g++

F90 := gfortran

ROOTLIBS = $(shell root-config --libdir)
ROOTINCS = $(shell root-config --incdir)
23
ROOTCFLAGS = $(shell root-config --cflags)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

PWD = $(shell pwd)
INSTALLFOLDER = $(HOME)/AculLib

ACULDATA = $(PWD)/AculData
ELOSS = $(PWD)/ELoss
TELOSS = $(PWD)/TELoss
DETECTORS = $(PWD)/Detectors
BE = $(PWD)/Be
THREADS = $(PWD)/Threads
APPS = $(PWD)/apps

-include $(ACULDATA)/AculData.mk
-include $(ELOSS)/ELOSS.mk
-include $(TELOSS)/TELoss.mk
-include $(DETECTORS)/Detectors.mk
-include $(BE)/Be.mk
#-include $(THREADS)/Threads.mk
-include $(APPS)/apps.mk

all: libAculData.so \
	libTELoss.so \
	libDetectors.so \
	libBe.so
	

#ROOT html documentation, it will be done as a program which will be alsa compiled by this makefile, program will be as a last condition after all of the libraries
htmldoc: libTELoss.so
	-$(RM) htmldoc
	root -l -q html.cxx	

#copy the libraries and includes somewhere into $HOME, copy the ./htmldoc folder into some location in $HOME
install: 
	-mkdir $(INSTALLFOLDER)	
	-mkdir $(INSTALLFOLDER)/lib
	-mkdir $(INSTALLFOLDER)/include
	cp lib* $(INSTALLFOLDER)/lib
	cp $(ACULDATA)/*.h $(INSTALLFOLDER)/include
	cp $(TELOSS)/*.h $(INSTALLFOLDER)/include
	cp $(DETECTORS)/*.h $(INSTALLFOLDER)/include
	cp -r ./htmldoc $(INSTALLFOLDER)/htmldoc

clean:
	-$(RM) $(ACULDATAOBJS) $(ACULDATACPP_DEPS) 
68
	-$(RM) $(ACULDATA)/AculDataCint.* libAculData.so $(ACULDATA)/*.pcm
69 70
	-@echo ' '
	-$(RM) $(TELOSSOBJS) $(TELOSSCPP_DEPS) 
71
	-$(RM) $(TELOSS)/TELossCint.* libTELoss.so $(TELOSS)/*.pcm
72 73
	-@echo ' '
	-$(RM) $(DETECTORSOBJS) $(DETECTORSCPP_DEPS) 
74
	-$(RM) $(DETECTORS)/DetectorsCint.* libDetectors.so $(DETECTORS)/*.pcm 
75 76
	-@echo ' '
	-$(RM) $(BEOBJS) $(BECPP_DEPS) 
77 78 79 80 81
	-$(RM) $(BE)/BeCint.* libBe.so $(BE)/*.pcm
#	-@echo ' '
#	-$(RM) $(THREADSOBJS) 
#	-$(RM) $(THREADS)/ThreadsCint.* libThreads.so $(THREADS)/*.pcm
#	-@echo ' '
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
	-$(RM) htmldoc
	-@echo ' '

# Those *Cint* files below need special treating:
$(ACULDATA)/AculDataCint.cpp:
	-@echo 'Pre-building AculDataCint.cpp and AculDataCint.h files'
	-rootcint -f $(ACULDATA)/AculDataCint.cpp -c -p $(ACULDATA_HEADERS)
	-@echo ' '

$(TELOSS)/TELossCint.cpp:
	-@echo 'Pre-building TELossCint.cpp and TELossCint.h files'
	-rootcint -f $(TELOSS)/TELossCint.cpp -c -p $(TELOSS)/TELoss.h $(TELOSS)/linkdef.h
	-@echo ' '

$(DETECTORS)/DetectorsCint.cpp:
	-@echo 'Pre-building DetectorsCint.cpp and DetectorsCint.h files'
	-rootcint -f $(DETECTORS)/DetectorsCint.cpp -c -p $(DETECTORS_HEADERS)
	-@echo ' '
	
$(BE)/BeCint.cpp:
	-@echo 'Pre-building BeCint.cpp and BeCint.h files'
103
	-rootcint -f $(BE)/BeCint.cpp -m $(BE) $(BE_HEADERS)
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
	-@echo ' '
	

#*.so files
libAculData.so: $(ACULDATAOBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CC) -L $(ROOTLIBS) -shared -o"libAculData.so" $(ACULDATAOBJS) $(ACULDATALIBS)
	@echo 'Finished building target: $@'
	@echo ' '

libTELoss.so: $(TELOSSOBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CC) -L . -L $(ROOTLIBS) -shared -o"libTELoss.so" $(TELOSSOBJS) $(TELOSSLIBS)
	@echo 'Finished building target: $@'
	@echo ' '

libDetectors.so: $(DETECTORSOBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	g++ -L $(ROOTLIBS) -shared -o"libDetectors.so" $(DETECTORSOBJS) $(DETECTORSLIBS)
	@echo 'Finished building target: $@'
	@echo ' '

libBe.so: libAculData.so libDetectors.so libTELoss.so $(BEOBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	g++ -L . -L $(ROOTLIBS) -shared -o"libBe.so" $(BEOBJS) $(BELIBS)
	@echo 'Finished building target: $@'
	@echo ' '
	
fillExpFile: $(APPSOBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	g++ -L . -L $(ROOTLIBS) -o"fillExpFile" $(APPSOBJS) $(APPSLIBS)
	@echo 'Finished building target: $@'
	@echo ' '
	
.PHONY: all clean
#.SECONDARY: AculData_pre-build TELoss_pre-build Detectors_pre-build libAculData.so libTELoss.so libDetectors.so

# Each subdirectory must supply rules for building sources it contributes
%.o: %.cpp
	@echo 'Building file: $@'
	@echo 'Invoking: GCC C++ Compiler'
#	$(CC) -I$(ROOTINCS) -O0 -g3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
#	$(CC) -I$(ROOTINCS) -DTHREADING -I$(BOOSTINCS) -O2 -Wall -mmmx -msse -msse2 -msse3 -mfpmath=sse,387 -march=nocona -mtune=nocona -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
152 153 154
	$(CC) -I$(ROOTINCS) -O2 -std=c++11 -Wall -mmmx -msse -msse2 -msse3 -mfpmath=sse,387 -march=nocona -mtune=nocona -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
#	$(CC) -I$(ROOTINCS) -O2 $(ROOTCFLAGS) -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
#	$(CC) -I$(ROOTINCS) -O2 $(ROOTCFLAGS) -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
155 156 157 158 159 160 161 162 163 164
	@echo 'Finished building: $@'
	@echo ' '

# fortran object files
$(TELOSS)/ELOSS.o:
	@echo 'Building file: $@'
	@echo 'Invoking: gfortran'
	$(F90) -c -fPIC -o"$(TELOSS)/ELOSS.o" $(TELOSS)/ELOSS.f90
	@echo 'Finished building target: $@'
	@echo ' '