2
#___________________________________________________________________________
1
# Edam's general-purpose makefile v1.11
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
#___________________________________________________________________________
21
# Subdirectories to make
35
CPPFLAGS := $(CPPFLAGS) -g -D DEBUG
36
ASFLAGS := -f elf -g -dDEBUG
37
LDFLAGS := -Wall $(if $(STATICLIBS), -static) $(LDFLAGS)
31
CFLAGS := $(if $(DEBUGMODE),-g -D DEBUG,-O2)
32
CXXFLAGS := $(if $(DEBUGMODE),-g -D DEBUG,-O2)
33
ASFLAGS := -f elf $(if $(DEBUGMODE),-g -dDEBUG,-O2)
34
LDFLAGS := -Wall $(if $(DEBUGMODE),,-s) $(if $(STATICLIBS), -static)
36
#_______________________________________________________________________________
39
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
40
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
42
CPPFLAGS := $(CPPFLAGS) -O2
44
LDFLAGS := -Wall -s $(if $(STATICLIBS), -static) $(LDFLAGS)
62
@echo "NOT RECURSING: use 'make clean_all' to clean subdirectories as well."
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)
58
#___________________________________________________________________________
61
.PHONY: all clean run depend dep
63
all: clean depend $(TARGET)
66
rm -f core $(DEPFILE) $(_OBJS)
64
rm -f $(OBJECTS) $(TARGET) core $(DEPFILE) *~
73
# makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)
75
#___________________________________________________________________________
74
# makedepend -f- -- $(CPPFLAGS) -- $(SOURCES) > $(DEPFILE)
77
@echo ==== Sub directory: $@
78
@$(MAKE) --no-print-directory -C $@ $(filter-out $(SUBDIRS),$(MAKECMDGOALS))
82
$(AR) rcs $(TARGET) $(OBJECTS)
84
$(CXX) $(if $(BUILDSOLIB),-shared) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(LDLIBS)
88
# $(CC) -c $(CPPFLAGS) $(CFLAGS)
90
# $(CXX) -c $(CPPFLAGS) $(CXXFLAGS)
96
#_______________________________________________________________________________