31
33
CFLAGS := $(if $(DEBUGMODE),-g -D DEBUG,-O2)
32
34
CXXFLAGS := $(if $(DEBUGMODE),-g -D DEBUG,-O2)
33
35
ASFLAGS := -f elf $(if $(DEBUGMODE),-g -dDEBUG,-O2)
34
36
LDFLAGS := -Wall $(if $(DEBUGMODE),,-s) $(if $(STATICLIBS), -static)
36
#_______________________________________________________________________________
38
#___________________________________________________________________________
38
40
DEPFILE := depends.mk
39
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
41
_SRCS := $(CC_SRCS) $(C_SRCS) $(S_SRCS)
42
_OBJS := $(addsuffix .o,$(basename $(_SRCS)))
40
43
LDLIBS := $(addprefix -l,$(LIBRARIES))
41
TARGET := $(patsubst %.so,%,$(patsubst %.a,%,$(TARGET)))
42
TARGET := $(TARGET)$(if $(BUILDALIB),.a,)$(if $(BUILDSOLIB),.so,)
44
# Turn clean_all in to a recursive clean
45
ifeq "$(MAKECMDGOALS)" "clean_all"
46
export RECURSIVE_CLEAN := 1
50
.PHONY: all subdirs target clean clean_all run depend dep $(SUBDIRS)
59
clean clean_all: subdirs
62
@echo "NOT RECURSING: use 'make clean_all' to clean subdirectories as well."
64
rm -f $(OBJECTS) $(TARGET) core $(DEPFILE) *~
45
.PHONY: all target clean clean_all run depend dep $(SUBDIRS)
47
all: $(SUBDIRS) $(TARGET)
52
ifeq ($(MAKECMDGOALS),clean)
54
@echo NOT RECURSING: Use \"make clean_all\" to clean recursively..."
57
rm -f core $(DEPFILE) $(_OBJS) $(TARGET)
60
clean_all: $(SUBDIRS) clean
63
$(if $(BUILDLIB),@echo Can\'t run a library\!,./$(TARGET))
74
# makedepend -f- -- $(CPPFLAGS) -- $(SOURCES) > $(DEPFILE)
66
# makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)
77
@echo ==== Sub directory: $@
78
@$(MAKE) --no-print-directory -C $@ $(filter-out $(SUBDIRS),$(MAKECMDGOALS))
69
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
82
$(AR) rcs $(TARGET) $(OBJECTS)
73
$(AR) rcs $(TARGET) $(_OBJS)
84
$(CXX) $(if $(BUILDSOLIB),-shared) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(LDLIBS)
75
$(CC) $(if $(BUILDSO),-shared) -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)