app.mk (1876B)
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 ASSETS := $(wildcard $(M_PATH)/assets/*) 30 ASSETS += $(patsubst common/%,$(M_PATH)/%,$(wildcard common/assets/*)) 31 ASSETS := $(addprefix $(OUT)/,$(ASSETS)) 32 33 $(OUT)/$(M_PATH)/assets/%: $(M_PATH)/assets/% 34 @$(MKDIR) 35 ln -sf "../../../$<" "$@" 36 # cp $< $@ 37 38 $(OUT)/$(M_PATH)/assets/%: common/assets/% 39 @$(MKDIR) 40 ln -sf "../../../$<" "$@" 41 # cp $< $@ 42 43 M_LIBS := $(addprefix $(OUT_LIB)/,$(M_LIBS)) 44 M_LIBS := $(addsuffix .a,$(M_LIBS)) 45 46 ALL += $(OUT)/$(M_PATH)/$(M_NAME) 47 48 $(OUT_OBJ)/$(M_PATH)/%.o: _CFLAGS := $(M_CFLAGS) 49 50 $(OUT_OBJ)/$(M_PATH)/%.o: $(M_PATH)/%.cc 51 @$(MKDIR) 52 @echo compile $< 53 $(QUIET)g++ $(HOST_CFLAGS) $(_CFLAGS) -c $< -o $@ -MD -MT $@ -MF $(@:%o=%d) 54 55 $(OUT)/$(M_PATH)/$(M_NAME): _OBJS := $(M_OBJS) 56 $(OUT)/$(M_PATH)/$(M_NAME): _LIBS := $(M_LIBS) 57 $(OUT)/$(M_PATH)/$(M_NAME): $(M_OBJS) $(M_LIBS) $(ASSETS) 58 @$(MKDIR) 59 @echo link $@ 60 $(QUIET)g++ $(HOST_CFLAGS) $(HOST_LFLAGS) -o $@ $(_OBJS) $(_LIBS) $(HOST_LIBS) 61 62 $(info module $(M_NAME)) 63 64 M_LIBS := 65 M_OBJS := 66 M_NAME := 67 M_CFLAGS :=