lib.mk (1477B)
1 ## Copyright 2013 Brian Swetland <swetland@frotz.net> 2 ## 3 ## Licensed under the Apache License, Version 2.0 (the "License"); 4 ## you may not use this file except in compliance with the License. 5 ## You may obtain a copy of the License at 6 ## 7 ## http://www.apache.org/licenses/LICENSE-2.0 8 ## 9 ## Unless required by applicable law or agreed to in writing, software 10 ## distributed under the License is distributed on an "AS IS" BASIS, 11 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 ## See the License for the specific language governing permissions and 13 ## limitations under the License. 14 15 M_NAME := $(strip $(M_NAME)) 16 M_PATH := $(strip $(M_PATH)) 17 18 # sanity check 19 ifeq "$(M_NAME)" "" 20 $(error No module name specified) 21 endif 22 ifeq "$(M_PATH)" "" 23 $(error No module path specified) 24 endif 25 26 M_OBJS := $(addprefix $(OUT_OBJ)/$(M_PATH)/,$(M_OBJS)) 27 DEPS += $(M_OBJS:%o=%d) 28 29 ALL += $(OUT_LIB)/$(M_NAME).a 30 31 $(OUT_OBJ)/$(M_PATH)/%.o: _CFLAGS := $(M_CFLAGS) 32 33 $(OUT_OBJ)/$(M_PATH)/%.o: $(M_PATH)/%.cc 34 @$(MKDIR) 35 @echo compile $< 36 $(QUIET)g++ $(HOST_CFLAGS) $(_CFLAGS) -c $< -o $@ -MD -MT $@ -MF $(@:%o=%d) 37 38 $(OUT_OBJ)/$(M_PATH)/%.o: $(M_PATH)/%.c 39 @$(MKDIR) 40 @echo compile $< 41 $(QUIET)g++ $(HOST_CFLAGS) $(_CFLAGS) -c $< -o $@ -MD -MT $@ -MF $(@:%o=%d) 42 43 $(OUT_LIB)/$(M_NAME).a: _OBJS := $(M_OBJS) 44 $(OUT_LIB)/$(M_NAME).a: $(M_OBJS) 45 @$(MKDIR) 46 @echo archive $@ 47 @rm -f $@ 48 $(QUIET)ar cr $@ $(_OBJS) 49 50 $(info module $(M_NAME)) 51 52 M_LIBS := 53 M_OBJS := 54 M_NAME := 55 M_CLFAGS :=