1#
2# Common included Makefile for plug ins
3#
4# Copyright (C) 2011 Vox Lucida
5#
6# The contents of this file are subject to the Mozilla Public License
7# Version 1.0 (the "License"); you may not use this file except in
8# compliance with the License. You may obtain a copy of the License at
9# http://www.mozilla.org/MPL/
10#
11# Software distributed under the License is distributed on an "AS IS"
12# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
13# the License for the specific language governing rights and limitations
14# under the License.
15#
16# The Original Code is OPAL.
17#
18# The Initial Developer of the Original Code is Robert Jongbloed
19#
20# Contributor(s): ______________________________________.
21#
22# $Revision$
23# $Author$
24# $Date$
25#
26
27prefix        := @prefix@
28exec_prefix   := @exec_prefix@
29libdir        := @libdir@
30
31CC            := @CC@
32CXX           := @CXX@
33CFLAGS        += @CFLAGS@ -I@prefix@/include -I$(PLUGINDIR)/../include -I$(PLUGINDIR)
34LDFLAGS       += @LDFLAGS@ @LDSO@
35PLUGINEXT     :=@PLUGINEXT@
36
37ifneq ($(DEBUG),)
38CFLAGS        += -g
39endif
40
41OBJDIR := $(PLUGINDIR)/../lib_@OSTYPE@_@MACHTYPE@/plugins/$(BASENAME)
42
43SONAME	= $(BASENAME)_ptplugin
44
45PLUGIN_NAME = $(SONAME).$(PLUGINEXT)
46PLUGIN_PATH = $(OBJDIR)/$(PLUGIN_NAME)
47
48all: $(PLUGIN_PATH)
49
50
51ifeq ($(VERBOSE),)
52Q_CC = @echo [CC] `echo $< | sed s^$(SRCDIR)/^^` ;
53Q_LD = @echo [LD] `echo $@ | sed s^$(OBJDIR)/^^` ;
54endif
55
56
57vpath	%.o $(OBJDIR)
58vpath	%.c $(SRCDIR)
59vpath	%.cxx $(SRCDIR)
60
61$(OBJDIR)/%.o : %.c
62	@mkdir -p $(OBJDIR) >/dev/null 2>&1
63	$(Q_CC)$(CC) -c $(CFLAGS) -o $@ $<
64
65$(OBJDIR)/%.o : %.cxx
66	@mkdir -p $(OBJDIR) >/dev/null 2>&1
67	$(Q_CC)$(CXX) -c $(CXXFLAGS) $(CFLAGS) -o $@ $<
68
69$(OBJDIR)/%.o : %.cpp
70	@mkdir -p $(OBJDIR) >/dev/null 2>&1
71	$(Q_CC)$(CXX) -c $(CXXFLAGS) $(CFLAGS) -o $@ $<
72
73OBJECTS	= $(addprefix $(OBJDIR)/,$(patsubst %.cxx,%.o,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(notdir $(SRCS))))))
74
75$(PLUGIN_PATH): $(SUBDIRS) $(OBJECTS)
76	$(Q_LD)$(CXX) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
77
78ifneq ($(SUBDIRS),)
79.PHONY: $(SUBDIRS)
80$(SUBDIRS):
81	$(MAKE) -C $@
82endif
83
84install:
85	@$(foreach dir,$(SUBDIRS),if test -d ${dir} ; then $(MAKE) -C $(dir) install; fi ; )
86	mkdir -p $(DESTDIR)$(libdir)/$(INSTALL_DIR)
87	install $(PLUGIN_PATH) $(DESTDIR)$(libdir)/$(INSTALL_DIR)
88
89uninstall:
90	@$(foreach dir,$(SUBDIRS),if test -d ${dir} ; then $(MAKE) -C $(dir) uninstall; fi ; )
91	rm -f $(DESTDIR)$(libdir)/$(INSTALL_DIR)/$(PLUGIN_NAME)
92
93clean:
94	@$(foreach dir,$(SUBDIRS),if test -d ${dir} ; then $(MAKE) -C $(dir) clean; fi ; )
95	rm -rf $(OBJDIR)
96
97###########################################
98