James Dong | 17299ab | 2010-05-14 15:45:22 -0700 | [diff] [blame] | 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 | |
| 17 | VERBOSE:=@ |
| 18 | |
| 19 | |
| 20 | VOMT ?= lib |
| 21 | |
| 22 | ifeq ($(VOMT), lib) |
| 23 | LIB_STATIC=$(VOTARGET).a |
| 24 | LIB_DYNAMIC=$(VOTARGET).so |
| 25 | endif |
| 26 | |
| 27 | ifeq ($(VOMT), exe) |
| 28 | TARGET=$(VOTARGET) |
| 29 | endif |
| 30 | |
| 31 | CFLAGS=$(VOCFLAGS) $(addprefix -I, $(VOSRCDIR)) |
| 32 | CPPFLAGS=$(VOCPPFLAGS) $(addprefix -I, $(VOSRCDIR)) |
| 33 | ifneq ($(VOTT), pc) |
| 34 | ASFLAGS=$(VOASFLAGS) $(addprefix -I, $(VOSRCDIR)) |
| 35 | endif |
| 36 | |
| 37 | LDFLAGS:=$(VOLDFLAGS) |
| 38 | VOTEDEPS+=$(VODEPLIBS) |
| 39 | VOTLDEPS+=$(VODEPLIBS) |
| 40 | VOSTCLIBS ?= |
| 41 | |
| 42 | vpath %.c $(VOSRCDIR) |
| 43 | vpath %.cpp $(VOSRCDIR) |
| 44 | ifneq ($(VOTT), pc) |
| 45 | vpath %.s $(VOSRCDIR) |
| 46 | endif |
| 47 | |
| 48 | ifeq ($(VOTT), pc) |
| 49 | BLTDIRS=$(VORELDIR)/Linux/static |
| 50 | BLTDIRD=$(VORELDIR)/Linux/shared |
| 51 | else |
| 52 | BLTDIRS=$(VORELDIR)/Google/$(VONJ)/lib/$(VOTT) |
| 53 | BLTDIRD=$(VORELDIR)/Google/$(VONJ)/so/$(VOTT) |
| 54 | endif |
| 55 | |
| 56 | |
| 57 | .PRECIOUS: $(OBJDIR)/%.o |
| 58 | |
| 59 | ifeq ($(VOMT), lib) |
| 60 | all: mkdirs $(LIB_STATIC) $(LIB_DYNAMIC) |
| 61 | mkdirs: $(OBJDIR) $(BLTDIRS) $(BLTDIRD) |
| 62 | else |
| 63 | all: mkdirs $(TARGET) |
| 64 | mkdirs: $(OBJDIR) |
| 65 | endif |
| 66 | |
| 67 | $(OBJDIR): |
| 68 | @if test ! -d $@; then \ |
| 69 | mkdir -p $@; \ |
| 70 | fi; |
| 71 | |
| 72 | ifeq ($(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; |
| 81 | endif |
| 82 | |
| 83 | |
| 84 | ifeq ($(VOMT), lib) |
| 85 | $(LIB_STATIC):$(OBJS) |
| 86 | $(AR) cr $@ $(OBJDIR)/*.o $(VOSTCLIBS) |
| 87 | $(RANLIB) $@ |
| 88 | ifneq ($(VODBG), yes) |
| 89 | #$(STRIP) $@ |
| 90 | endif |
| 91 | |
| 92 | $(LIB_DYNAMIC):$(OBJS) |
| 93 | $(GG) $(LDFLAGS) -o $@ $(OBJDIR)/*.o -Wl,--whole-archive $(VOSTCLIBS) -Wl,--no-whole-archive $(VOTLDEPS) |
| 94 | ifneq ($(VODBG), yes) |
| 95 | $(STRIP) $@ |
| 96 | endif |
| 97 | |
| 98 | else |
| 99 | |
| 100 | $(TARGET):$(OBJS) |
| 101 | $(GG) $(LDFLAGS) -o $@ $(OBJDIR)/*.o -Wl,--whole-archive $(VOSTCLIBS) -Wl,--no-whole-archive $(VOTEDEPS) |
| 102 | ifneq ($(VODBG), yes) |
| 103 | $(STRIP) $@ |
| 104 | endif |
| 105 | |
| 106 | endif |
| 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 $< |
| 116 | ifneq ($(VOTT), pc) |
| 117 | .s.o: |
| 118 | $(VERBOSE) $(AS) $(ASFLAGS) -o $(OBJDIR)/$@ $< |
| 119 | endif |
| 120 | |
| 121 | |
| 122 | .PHONY: clean devel |
| 123 | clean: |
| 124 | ifeq ($(VOMT), lib) |
| 125 | -rm -fr $(OBJDIR) .*.sw* $(VOTARGET).* |
| 126 | else |
| 127 | -rm -fr $(OBJDIR) .*.sw* $(VOTARGET) |
| 128 | endif |
| 129 | |
| 130 | devel: |
| 131 | cp -a $(LIB_STATIC) $(BLTDIRS) |
| 132 | cp -a $(LIB_DYNAMIC) $(BLTDIRD) |
| 133 | |