/make/edam-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/edam-mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#                                                       Edam's Makefile v1.7
#___________________________________________________________________________
#                                                            S E T T I N G S

# Target binary
TARGET		= helloworld

# All source files
CC_SRCS		= helloworld.cc
C_SRCS		= 
S_SRCS		= 

# Libraries
LIBRARIES	=

# Options (comment-out to disable)
DEBUG		= 1
CPPBUILD	= 1
#STATICLIBS	= 1

# Other flags
CPPFLAGS	= 
ASFLAGS		= 
LDFLAGS		= 

#___________________________________________________________________________
#                                                                    M E A T

# Software
AS=nasm

ifdef DEBUG

# Debug build flags
CPPFLAGS	:= $(CPPFLAGS) -g -D DEBUG
ASFLAGS		:= -f elf -g -dDEBUG
LDFLAGS		:= -Wall $(if $(STATICLIBS), -static) $(LDFLAGS)

else

# Release build flags
CPPFLAGS	:= $(CPPFLAGS) -O2
ASFLAGS		:= -f elf -O2
LDFLAGS		:= -Wall -s $(if $(STATICLIBS), -static) $(LDFLAGS)

endif

# More variables...
DEPFILE		= Depends
_SRCS		= $(CC_SRCS) $(C_SRCS) $(S_SRCS)
_OBJS		= $(addsuffix .o,$(basename $(_SRCS)))
LDLIBS		= $(addprefix -l,$(LIBRARIES))

# Main rule...
$(TARGET): $(_OBJS)
	$(if $(CPPBUILD), g++, gcc) -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)

#___________________________________________________________________________
#                                                                  R U L E S

.PHONY:	all clean run depend dep

all:	clean depend $(TARGET)

clean:
	rm -f core $(DEPFILE) $(_OBJS)
	rm -f *~

run:	$(TARGET)
	./$(TARGET)

depend dep:
#	makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)

#___________________________________________________________________________
#include $(DEPFILE)