/make/edam-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/edam-mk
6 by edam
- puled out options to set flags for g++, as and ld
1
#                                                       Edam's Makefile v1.7
3 by edam
- added propper header
2
#___________________________________________________________________________
3
#                                                            S E T T I N G S
4
1 by edam
initial makefile
5
# Target binary
6 by edam
- puled out options to set flags for g++, as and ld
6
TARGET		= helloworld
1 by edam
initial makefile
7
8
# All source files
6 by edam
- puled out options to set flags for g++, as and ld
9
CC_SRCS		= helloworld.cc
10
C_SRCS		= 
4 by edam
- replaced debug option with debug switch
11
S_SRCS		= 
3 by edam
- added propper header
12
13
# Libraries
6 by edam
- puled out options to set flags for g++, as and ld
14
LIBRARIES	=
3 by edam
- added propper header
15
5 by edam
- added cpp build switch
16
# Options (comment-out to disable)
4 by edam
- replaced debug option with debug switch
17
DEBUG		= 1
6 by edam
- puled out options to set flags for g++, as and ld
18
CPPBUILD	= 1
5 by edam
- added cpp build switch
19
#STATICLIBS	= 1
3 by edam
- added propper header
20
6 by edam
- puled out options to set flags for g++, as and ld
21
# Other flags
22
CPPFLAGS	= 
23
ASFLAGS		= 
24
LDFLAGS		= 
25
3 by edam
- added propper header
26
#___________________________________________________________________________
27
#                                                                    M E A T
28
29
# Software
30
AS=nasm
1 by edam
initial makefile
31
4 by edam
- replaced debug option with debug switch
32
ifdef DEBUG
33
34
# Debug build flags
6 by edam
- puled out options to set flags for g++, as and ld
35
CPPFLAGS	:= $(CPPFLAGS) -g -D DEBUG
36
ASFLAGS		:= -f elf -g -dDEBUG
37
LDFLAGS		:= -Wall $(if $(STATICLIBS), -static) $(LDFLAGS)
4 by edam
- replaced debug option with debug switch
38
39
else
40
41
# Release build flags
6 by edam
- puled out options to set flags for g++, as and ld
42
CPPFLAGS	:= $(CPPFLAGS) -O2
43
ASFLAGS		:= -f elf -O2
44
LDFLAGS		:= -Wall -s $(if $(STATICLIBS), -static) $(LDFLAGS)
4 by edam
- replaced debug option with debug switch
45
46
endif
47
1 by edam
initial makefile
48
# More variables...
49
DEPFILE		= Depends
3 by edam
- added propper header
50
_SRCS		= $(CC_SRCS) $(C_SRCS) $(S_SRCS)
51
_OBJS		= $(addsuffix .o,$(basename $(_SRCS)))
52
LDLIBS		= $(addprefix -l,$(LIBRARIES))
1 by edam
initial makefile
53
54
# Main rule...
3 by edam
- added propper header
55
$(TARGET): $(_OBJS)
5 by edam
- added cpp build switch
56
	$(if $(CPPBUILD), g++, gcc) -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)
1 by edam
initial makefile
57
3 by edam
- added propper header
58
#___________________________________________________________________________
59
#                                                                  R U L E S
1 by edam
initial makefile
60
4 by edam
- replaced debug option with debug switch
61
.PHONY:	all clean run depend dep
1 by edam
initial makefile
62
63
all:	clean depend $(TARGET)
64
65
clean:
3 by edam
- added propper header
66
	rm -f core $(DEPFILE) $(_OBJS)
1 by edam
initial makefile
67
	rm -f *~
68
4 by edam
- replaced debug option with debug switch
69
run:	$(TARGET)
70
	./$(TARGET)
71
1 by edam
initial makefile
72
depend dep:
3 by edam
- added propper header
73
#	makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)
1 by edam
initial makefile
74
3 by edam
- added propper header
75
#___________________________________________________________________________
1 by edam
initial makefile
76
#include $(DEPFILE)