1SHELL = /bin/sh 2 3# Determine platform 4ifeq (${OS},Windows_NT) 5 PLATFORM = win32 6else 7 PLATFORM = $(shell uname|tr '[:upper:]' '[:lower:]') 8endif 9#include Makefile.$(PLATFORM) 10 11# Compiler options, flags, and libraries 12GCC_FLAGS = -Wall -Wextra -ansi -Wundef -Wconversion -pedantic -Os -std=c++11 13ifdef DEBUG 14 GCC_FLAGS := $(filter-out -Os,$(GCC_FLAGS)) 15 GCC_FLAGS += -g -O0 16endif 17 18GCC_INCL = -I. 19GTK_FLAGS = $(shell pkg-config --cflags gtkmm-3.0) 20XML_FLAGS = $(shell pkg-config --cflags libxml-2.0) 21 22GTK_LIBS = $(shell pkg-config --libs gtkmm-3.0) 23XML_LIBS = $(shell pkg-config --libs libxml-2.0) 24PTH_LIBS = -lpthread 25ZLIB_LIBS = -lz 26CURL_LIBS = $(shell pkg-config --libs libcurl) 27 28# Platform specific configuration 29ifeq (${PLATFORM},darwin) 30 CXX ?= g++ 31 LDFLAGS = ${GTK_LIBS} ${PTH_LIBS} ${XML_LIBS} ${ZLIB_LIBS} ${CURL_LIBS} 32 33 CORES_LINE = $(shell system_profiler SPHardwareDataType | grep Cores) 34 CORES = $(lastword $(CORES_LINE)) 35 SOURCES = util/pipedexec_posix.cc util/os_unix.cc 36 BINARY = gtkevemon 37endif 38 39ifeq (${PLATFORM},$(filter ${PLATFORM}, freebsd dragonfly)) 40 CXX ?= g++ 41 PTH_LIBS = -pthread 42 LDFLAGS = ${GTK_LIBS} ${PTH_LIBS} ${XML_LIBS} ${ZLIB_LIBS} ${CURL_LIBS} 43 44 CORES = $(shell sysctl -n hw.ncpu) 45 SOURCES = util/pipedexec_posix.cc util/os_unix.cc 46 BINARY = gtkevemon 47endif 48 49ifeq (${PLATFORM},linux) 50 CXX ?= g++ 51 LDFLAGS = ${GTK_LIBS} ${PTH_LIBS} ${XML_LIBS} ${ZLIB_LIBS} ${CURL_LIBS} 52 53 CORES = $(shell grep processor /proc/cpuinfo | wc -l) 54 SOURCES = util/pipedexec_posix.cc util/os_unix.cc 55 BINARY = gtkevemon 56endif 57 58ifeq (${PLATFORM},sunos) 59 CXX ?= sunCC 60 GCC_FLAGS = +w +w2 -g 61 SOLARIS_LIBS = -lnsl -lresolv -lsocket 62 LDFLAGS = ${GTK_LIBS} ${PTH_LIBS} ${SOLARIS_LIBS} ${XML_LIBS} ${ZLIB_LIBS} 63 64 CORES = $(shell psrinfo -p) 65 SOURCES = util/pipedexec_posix.cc util/os_unix.cc util/timegm.cc 66 BINARY = gtkevemon 67endif 68 69ifeq (${PLATFORM},win32) 70 CXX ?= i586-mingw32msvc-g++ 71 LDFLAGS = ${GTK_LIBS} ${PTH_LIBS} ${XML_LIBS} 72 CORES = 1 73 74 SOURCES = util/pipedexec_win32.cc util/os_win32.cc util/strptime.cc util/timegm.cc 75 BINARY = gtkevemon.exe 76endif 77 78# Generic compiler flags 79CXXFLAGS ?= ${GCC_FLAGS} 80CXXFLAGS += ${GTK_FLAGS} ${XML_FLAGS} ${GCC_INCL} 81 82# Source and object files 83SOURCES += util/bgprocess.cc util/conf.cc util/helpers.cc \ 84 $(wildcard api/[^_]*.cc) $(wildcard net/[^_]*.cc) \ 85 $(wildcard gui/[^_]*.cc) $(wildcard bits/[^_]*.cc) \ 86 gtkevemon.cc 87OBJECTS = $(foreach file,$(SOURCES),$(subst .cc,.o,$(file))) 88DEPENDENCIES = $(foreach file,$(SOURCES),$(subst .cc,.DEP,$(file))) 89 90#### Building targets #### 91 92all: 93 $(MAKE) -j${CORES} gtkevemon 94 95debug: 96 $(MAKE) -j${CORES} DEBUG=1 gtkevemon 97 98gtkevemon: ${OBJECTS} 99 ${CXX} -o ${BINARY} ${OBJECTS} ${LDFLAGS} 100 101gemcache: 102 ${RM} gemcache 103 ${CXX} -o gemcache gemcache.cc ${CXXFLAGS} 104 105%.o: %.cc 106 ${CXX} -c -o $@ $< ${CXXFLAGS} 107 108#test: ${OBJECTS} 109# ${CXX} -o _test_ssl _test_ssl.cc net/*.o util/helpers.o ${LDFLAGS} ${GCC_INCL} 110 111#### Dependencies target #### 112 113depend: depend-clean ${DEPENDENCIES} 114 115depend-clean: 116 ${RM} Makefile.dep 117 118%.DEP: 119 ${CXX} -MM -MT $(subst .DEP,.o,$@) $(subst .DEP,.cc,$@) ${GCC_INCL} >> Makefile.dep 120 121#### Cleaning target #### 122 123clean: FORCE 124 ${RM} ${BINARY} ${OBJECTS} 125 ${RM} gemcache 126 127FORCE: 128 129#### Compile time dependency information #### 130 131-include Makefile.dep 132