2
2
#___________________________________________________________________________
6
# (better to specify these in environment/command line)
8
#export STATICLIBS := 1
10
# Target binary/library
9
CC_SRCS = helloworld.cc
16
# Options (comment-out to disable)
26
#___________________________________________________________________________
23
# Subdirectories to make
35
CPPFLAGS := $(CPPFLAGS) -g -D DEBUG
36
ASFLAGS := -f elf -g -dDEBUG
37
LDFLAGS := -Wall $(if $(STATICLIBS), -static) $(LDFLAGS)
42
CPPFLAGS := $(CPPFLAGS) -O2
44
LDFLAGS := -Wall -s $(if $(STATICLIBS), -static) $(LDFLAGS)
50
_SRCS = $(CC_SRCS) $(C_SRCS) $(S_SRCS)
51
_OBJS = $(addsuffix .o,$(basename $(_SRCS)))
52
LDLIBS = $(addprefix -l,$(LIBRARIES))
56
$(if $(CPPBUILD), g++, gcc) -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)
33
CFLAGS := $(if $(DEBUGMODE),-g -D DEBUG,-O2)
34
CXXFLAGS := $(if $(DEBUGMODE),-g -D DEBUG,-O2)
35
ASFLAGS := -f elf $(if $(DEBUGMODE),-g -dDEBUG,-O2)
36
LDFLAGS := -Wall $(if $(DEBUGMODE),,-s) $(if $(STATICLIBS), -static)
58
38
#___________________________________________________________________________
61
.PHONY: all clean run depend dep
63
all: clean depend $(TARGET)
41
_SRCS := $(CC_SRCS) $(C_SRCS) $(S_SRCS)
42
_OBJS := $(addsuffix .o,$(basename $(_SRCS)))
43
LDLIBS := $(addprefix -l,$(LIBRARIES))
45
.PHONY: all target clean clean_all run depend dep $(SUBDIRS)
47
all: $(SUBDIRS) $(TARGET)
66
rm -f core $(DEPFILE) $(_OBJS)
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))
73
66
# makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)
69
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
73
$(AR) rcs $(TARGET) $(_OBJS)
75
$(CC) $(if $(BUILDSO),-shared) -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)
79
# $(CC) -c $(CPPFLAGS) $(CFLAGS)
81
# $(CXX) -c $(CPPFLAGS) $(CXXFLAGS)
75
87
#___________________________________________________________________________