1#/* 2# ** Copyright 2003-2010, VisualOn, Inc. 3# ** 4# ** Licensed under the Apache License, Version 2.0 (the "License"); 5# ** you may not use this file except in compliance with the License. 6# ** You may obtain a copy of the License at 7# ** 8# ** http://www.apache.org/licenses/LICENSE-2.0 9# ** 10# ** Unless required by applicable law or agreed to in writing, software 11# ** distributed under the License is distributed on an "AS IS" BASIS, 12# ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# ** See the License for the specific language governing permissions and 14# ** limitations under the License. 15# */ 16 17VERBOSE:=@ 18 19 20VOMT ?= lib 21 22ifeq ($(VOMT), lib) 23LIB_STATIC=$(VOTARGET).a 24LIB_DYNAMIC=$(VOTARGET).so 25endif 26 27ifeq ($(VOMT), exe) 28TARGET=$(VOTARGET) 29endif 30 31CFLAGS=$(VOCFLAGS) $(addprefix -I, $(VOSRCDIR)) 32CPPFLAGS=$(VOCPPFLAGS) $(addprefix -I, $(VOSRCDIR)) 33ifneq ($(VOTT), pc) 34ASFLAGS=$(VOASFLAGS) $(addprefix -I, $(VOSRCDIR)) 35endif 36 37LDFLAGS:=$(VOLDFLAGS) 38VOTEDEPS+=$(VODEPLIBS) 39VOTLDEPS+=$(VODEPLIBS) 40VOSTCLIBS ?= 41 42vpath %.c $(VOSRCDIR) 43vpath %.cpp $(VOSRCDIR) 44ifneq ($(VOTT), pc) 45vpath %.s $(VOSRCDIR) 46endif 47 48ifeq ($(VOTT), pc) 49BLTDIRS=$(VORELDIR)/Linux/static 50BLTDIRD=$(VORELDIR)/Linux/shared 51else 52BLTDIRS=$(VORELDIR)/Google/$(VONJ)/lib/$(VOTT) 53BLTDIRD=$(VORELDIR)/Google/$(VONJ)/so/$(VOTT) 54endif 55 56 57.PRECIOUS: $(OBJDIR)/%.o 58 59ifeq ($(VOMT), lib) 60all: mkdirs $(LIB_STATIC) $(LIB_DYNAMIC) 61mkdirs: $(OBJDIR) $(BLTDIRS) $(BLTDIRD) 62else 63all: mkdirs $(TARGET) 64mkdirs: $(OBJDIR) 65endif 66 67$(OBJDIR): 68 @if test ! -d $@; then \ 69 mkdir -p $@; \ 70 fi; 71 72ifeq ($(VOMT), lib) 73$(BLTDIRS): 74 @if test ! -d $@; then \ 75 mkdir -p $@; \ 76 fi; 77$(BLTDIRD): 78 @if test ! -d $@; then \ 79 mkdir -p $@; \ 80 fi; 81endif 82 83 84ifeq ($(VOMT), lib) 85$(LIB_STATIC):$(OBJS) 86 $(AR) cr $@ $(OBJDIR)/*.o $(VOSTCLIBS) 87 $(RANLIB) $@ 88ifneq ($(VODBG), yes) 89 #$(STRIP) $@ 90endif 91 92$(LIB_DYNAMIC):$(OBJS) 93 $(GG) $(LDFLAGS) -o $@ $(OBJDIR)/*.o -Wl,--whole-archive $(VOSTCLIBS) -Wl,--no-whole-archive $(VOTLDEPS) 94ifneq ($(VODBG), yes) 95 $(STRIP) $@ 96endif 97 98else 99 100$(TARGET):$(OBJS) 101 $(GG) $(LDFLAGS) -o $@ $(OBJDIR)/*.o -Wl,--whole-archive $(VOSTCLIBS) -Wl,--no-whole-archive $(VOTEDEPS) 102ifneq ($(VODBG), yes) 103 $(STRIP) $@ 104endif 105 106endif 107 108 109.SUFFIXES: .c .cpp .s .o 110.c.o: 111 $(VERBOSE) $(CC) $(CFLAGS) -o $(OBJDIR)/$@ -c $< 112#%.c:$(OBJDIR)/%.o 113# $(VERBOSE) $(CC) $(CFLAGS) -o $@ -c $< 114.cpp.o: 115 $(VERBOSE) $(GG) $(CPPFLAGS) -o $(OBJDIR)/$@ -c $< 116ifneq ($(VOTT), pc) 117.s.o: 118 $(VERBOSE) $(AS) $(ASFLAGS) -o $(OBJDIR)/$@ $< 119endif 120 121 122.PHONY: clean devel 123clean: 124ifeq ($(VOMT), lib) 125 -rm -fr $(OBJDIR) .*.sw* $(VOTARGET).* 126else 127 -rm -fr $(OBJDIR) .*.sw* $(VOTARGET) 128endif 129 130devel: 131 cp -a $(LIB_STATIC) $(BLTDIRS) 132 cp -a $(LIB_DYNAMIC) $(BLTDIRD) 133 134