Makefile 2.81 KB
Newer Older
Edward Vigmond's avatar
Edward Vigmond committed
1
HOSTMACHINE := $(shell uname)
Edward Vigmond's avatar
Edward Vigmond committed
2
include make.conf
Edward Vigmond's avatar
Edward Vigmond committed
3

Edward Vigmond's avatar
Edward Vigmond committed
4 5
#VTK_LIBDIR     =/usr/lib64
#VTK_INCDIR     =/usr/include/vtk-8.1
Edward Vigmond's avatar
Edward Vigmond committed
6

Edward Vigmond's avatar
Edward Vigmond committed
7
Cxx           :=$(shell fltk-config --cxx)
8 9
FLTK_INC      := $(shell fltk-config --use-glut --use-gl --cxxflags)
FLTK_LD_FLAGS := $(shell fltk-config --use-images --use-glut --use-gl --ldflags)
Edward Vigmond's avatar
Edward Vigmond committed
10
COMMON_INC    := -I. -DOBJ_CLASS -D_REENTRANT
11

12 13
FLTK_SOURCES  := $(wildcard *.fl)
OBJS = $(FLTK_SOURCES:.fl=.o)\
Edward Vigmond's avatar
Edward Vigmond committed
14 15 16 17
	$(patsubst %.cc,%.o,$(wildcard *.cc))\
	$(patsubst %.c,%.o,$(wildcard *.c))\
	$(patsubst %.C,%.o,$(wildcard *.C))

18
HDF5API_ROOT  := ./hdf5api
19
ifdef HDF5
Edward Vigmond's avatar
Edward Vigmond committed
20
LIB_CH5       := $(HDF5API_ROOT)/lib/libch5.a
Edward Vigmond's avatar
Edward Vigmond committed
21 22
LIB_HDF5      := -L$(HDF5API_ROOT)/lib -L$(HDF5_ROOT)/lib -lch5 -lhdf5_hl -lhdf5
COMMON_INC    += -DUSE_HDF5 -I$(HDF5_ROOT)/include -I$(HDF5API_ROOT)/include 
23 24
else
LIB_CH5       := 
25
LIB_HDF5      :=
Edward Vigmond's avatar
Edward Vigmond committed
26
OBJS          := $(OBJS:HDF5DataBrowser.o=)
27
endif
Edward Vigmond's avatar
Edward Vigmond committed
28

Edward Vigmond's avatar
Edward Vigmond committed
29
# MAC vs Linux differences
Edward Vigmond's avatar
Edward Vigmond committed
30
ifeq ($(HOSTMACHINE), Darwin)
Edward Vigmond's avatar
Edward Vigmond committed
31
  GLUT_LIB  = -framework GLUT 
Edward Vigmond's avatar
Edward Vigmond committed
32
  FLTK_INC += /usr/X11/include
Edward Vigmond's avatar
Edward Vigmond committed
33
  LIB_EXT   = .dylib
Edward Vigmond's avatar
Edward Vigmond committed
34
else
Edward Vigmond's avatar
Edward Vigmond committed
35
  GLUT_LIB  = -lglut
36
  OMP_FLAG := -fopenmp
Edward Vigmond's avatar
Edward Vigmond committed
37
  LDFLAGS  += $(OMP_FLAG)
Edward Vigmond's avatar
Edward Vigmond committed
38 39 40
ifeq (,$(findstring -lGL,$(FLTK_LD_FLAGS)))
  FLTK_LD_FLAGS += -lGL -lGLU
endif
Edward Vigmond's avatar
Edward Vigmond committed
41
  LIB_EXT   = .so
Edward Vigmond's avatar
Edward Vigmond committed
42 43
endif

Edward Vigmond's avatar
Edward Vigmond committed
44
COMMON_LIBS  = -lGLEW -lpng -lpthread -lm -lz $(LIB_HDF5) 
Edward Vigmond's avatar
Edward Vigmond committed
45 46
LIBS         =  $(FLTK_LD_FLAGS) $(COMMON_LIBS) 
CPPFLAGS     =  $(FLTK_INC) $(COMMON_INC)
Edward Vigmond's avatar
Edward Vigmond committed
47 48
CXXFLAGS     = -std=c++11 -g -O$(DEBUG_LEVEL) $(OMP_FLAG) -MMD -DNOMINMAX  

Edward Vigmond's avatar
Edward Vigmond committed
49
# VTK
Edward Vigmond's avatar
Edward Vigmond committed
50
ifdef VTK_LIBDIR
51
COMMON_INC    += -DUSE_VTK -I$(VTK_INCDIR)
Edward Vigmond's avatar
Edward Vigmond committed
52
VTK_LSLIBS     = $(shell ls $(VTK_LIBDIR)/libvtk*$(LIB_EXT) | grep -Ev '(Python)|(Java)|(TCL)|(Parallel)|(MPI)|(Filters)|(Imaging)|(Interaction)|(Rendering)' )
53
a              = $(subst $(VTK_LIBDIR)/lib,-l,$(VTK_LSLIBS) )
Edward Vigmond's avatar
Edward Vigmond committed
54
VTK_LIBS       = $(subst $(LIB_EXT),,$(a) )
Edward Vigmond's avatar
Edward Vigmond committed
55 56 57
LIBS          += $(VTK_LIBS)
endif

Edward Vigmond's avatar
Edward Vigmond committed
58 59 60
ifdef ENABLE_LOGGING
CPPFLAGS += -DLOGGING_ENABLED
endif
Edward Vigmond's avatar
Edward Vigmond committed
61

62
#the files in OS_files contain OSMESA dependent clauses
Edward Vigmond's avatar
Edward Vigmond committed
63
OS_files:=$(patsubst %.cc,%.o,$(shell grep -l OSMESA *.cc))
64 65
OS_OBJS=$(filter-out $(OS_files),$(OBJS)) $(OS_files:.o=_os.o)

66
all: meshalyzer
Edward Vigmond's avatar
Edward Vigmond committed
67

Edward Vigmond's avatar
Edward Vigmond committed
68
meshalyzer: $(LIB_CH5) $(FLTK_SOURCES:.fl=.cc) $(OBJS) 
69
	$(CXX) $(LDFLAGS) -o meshalyzer $(sort $(OBJS)) $(GLUT_LIB) $(LIBS)
Edward Vigmond's avatar
Edward Vigmond committed
70
	fltk-config --post meshalyzer
Edward Vigmond's avatar
Edward Vigmond committed
71

Edward Vigmond's avatar
Edward Vigmond committed
72
mesalyzer: $(LIB_CH5) $(FLTK_SOURCES:.fl=.cc) $(OS_OBJS)
73
	$(CXX) $(LDFLAGS) -o mesalyzer $(sort $(OS_OBJS)) -lOSMesa $(LIBS) -lrt
74 75
	fltk-config --post mesalyzer

76
ifdef HDF5
Edward Vigmond's avatar
Edward Vigmond committed
77
$(LIB_CH5): 
78
	cd hdf5api && make all 
Edward Vigmond's avatar
Edward Vigmond committed
79
	cd hdf5api && make install PREFIX=. 
80
endif
Edward Vigmond's avatar
Edward Vigmond committed
81

82
$(OS_files:.o=_os.o): %_os.o: %.cc
Edward Vigmond's avatar
Edward Vigmond committed
83
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -D OSMESA -c -o $@  $<
84

Edward Vigmond's avatar
Edward Vigmond committed
85
clean:
86
	rm -rf $(FLTK_SOURCES:.fl=.h) $(FLTK_SOURCES:.fl=.cc) *.o *.d meshalyzer mesalyzer meshalyzer.app
Edward Vigmond's avatar
Edward Vigmond committed
87 88 89
ifdef HDF5
	cd hdf5api && make clean
endif
Edward Vigmond's avatar
Edward Vigmond committed
90 91 92

utils: 
	cd utils && make all
Edward Vigmond's avatar
Edward Vigmond committed
93

Edward Vigmond's avatar
Edward Vigmond committed
94 95
docs: 
	doxygen Doxyfile
96
ifdef HDF5
Edward Vigmond's avatar
Edward Vigmond committed
97
	cd hdf5api && doxygen Doxyfile
98
endif
99

100
%.h %.cc: %.fl
101
	fluid -c -o .cc $<
102 103

-include $(OBJS:.o=.d)
Edward Vigmond's avatar
Edward Vigmond committed
104 105 106

.PHONY: utils