2
#___________________________________________________________________________
1
# Edam's general-purpose makefile v1.10
2
#_______________________________________________________________________________
6
# (better to specify these in environment/command line)
8
#export STATICLIBS := 1
10
# Target binary/library
16
# Override options (better: specify in environment or on cmdline)
21
# Subdirectories to make
27
#___________________________________________________________________________
31
CC := $(if $(CPPBUILD), g++, gcc)
36
CPPFLAGS := -g -D DEBUG $(CPPFLAGS)
37
ASFLAGS := -f elf -g -dDEBUG $(ASFLAGS)
38
LDFLAGS := -Wall $(if $(STATICLIBS), -static) $(LDFLAGS)
43
CPPFLAGS := -O2 $(CPPFLAGS)
44
ASFLAGS := -f elf -O2 $(ASFLAGS)
45
LDFLAGS := -Wall -s $(if $(STATICLIBS), -static) $(LDFLAGS)
51
_SRCS := $(CC_SRCS) $(C_SRCS) $(S_SRCS)
52
_OBJS := $(addsuffix .o,$(basename $(_SRCS)))
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)))
53
40
LDLIBS := $(addprefix -l,$(LIBRARIES))
55
.PHONY: all clean run depend dep
61
$(AR) rcs $(TARGET) $(_OBJS)
63
$(CC) -o $(TARGET) $(LDFLAGS) $(LDLIBS) $(_OBJS)
41
TARGET := $(patsubst %.so,%,$(patsubst %.a,%,$(TARGET)))
42
TARGET := $(TARGET)$(if $(BUILDALIB),.a,)$(if $(BUILDSOLIB),.so,)
44
.PHONY: all subdirs target clean clean_all run depend dep $(SUBDIRS)
67
rm -f core $(DEPFILE) $(_OBJS)
53
ifeq "$(MAKECMDGOALS)" "clean"
55
@echo NOT RECURSING: Use \"make clean_all\" to clean subdirectoried as well...
58
rm -f core $(DEPFILE) $(OBJECTS) $(TARGET)
61
clean_all: subdirs clean
74
# makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)
76
#___________________________________________________________________________
71
# makedepend -f- -- $(CPPFLAGS) -- $(SOURCES) > $(DEPFILE)
74
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
78
$(AR) rcs $(TARGET) $(OBJECTS)
80
$(CXX) $(if $(BUILDSOLIB),-shared) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(LDLIBS)
84
# $(CC) -c $(CPPFLAGS) $(CFLAGS)
86
# $(CXX) -c $(CPPFLAGS) $(CXXFLAGS)
92
#_______________________________________________________________________________