WORKDIR = $(shell pwd -L) CXX = g++ CXXFLAGS = -Wall -fPIC -ansi -O3 CXXFLAGS += -std=c++0x SOFLAGS = -O -shared LDFLAGS = -L$(WORKDIR)/lib LOADLIBES = -lKM3NeTDBClient LIBS = -lssl UNAME_S := $(shell uname -s) # macOS specific ifeq ($(UNAME_S),Darwin) CXXFLAGS += -I/usr/local/opt/openssl/include LDFLAGS += -L/usr/local/opt/openssl/lib LOADLIBES += /usr/local/opt/openssl/lib/*.a endif NATIVE_SRCS = $(wildcard *.cpp) NATIVE_OBJS = $(addprefix $(WORKDIR)/bin/, $(NATIVE_SRCS:.cpp=.o)) PUBLIC_LIBS = $(addprefix $(WORKDIR)/lib/, libKM3NeTDBClient.so) PUBLIC_INCLUDES = $(addprefix $(WORKDIR)/include/, KM3NeTDBClient.h) default: libs libs: $(PUBLIC_LIBS) $(PUBLIC_INCLUDES) $(PUBLIC_LIBS): | $(WORKDIR)/lib $(PUBLIC_INCLUDES): | $(WORKDIR)/include $(NATIVE_OBJS): | $(WORKDIR)/bin $(PUBLIC_LIBS): $(NATIVE_OBJS) $(CXX) $(SOFLAGS) -o $@ $^ $(LIBS) $(PUBLIC_INCLUDES): $(WORKDIR)/include/%: % $(WORKDIR)/lib $(WORKDIR)/bin $(WORKDIR)/include: mkdir -p $@ $(WORKDIR)/bin/%.o: %.cpp %.d $(CXX) $(CXXFLAGS) -c -o $@ $< %.d: %.cpp @/bin/echo -n "$@ " > $@ @$(CXX) $(CXXFLAGS) -MM -MP $< >> $@ $(WORKDIR)/include/%:% cp $^ $(WORKDIR)/include # examples EXAMPLE_SRCS = $(wildcard $(WORKDIR)/examples/*.cpp) EXAMPLE_BINS = $(subst $(WORKDIR)/examples/,$(WORKDIR)/examples/bin/,$(EXAMPLE_SRCS:.cpp=)) examples: libs $(EXAMPLE_BINS) $(EXAMPLE_BINS): | $(WORKDIR)/examples/bin $(WORKDIR)/examples/bin: mkdir -p $@ $(WORKDIR)/examples/bin/%: $(WORKDIR)/examples/%.cpp $(PUBLIC_LIBS) $(PUBLIC_INCLUDES) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -lKM3NeTDBClient -I$(WORKDIR)/include $(LOADLIBES) # clean clean: rm -rf $(WORKDIR)/lib rm -rf $(WORKDIR)/bin rm -rf $(WORKDIR)/include rm -rf $(WORKDIR)/examples/bin