/make/edam-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/edam-mk
7 by edam
- set CC correctly
1
#                                                       Edam's Makefile v1.8
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
7 by edam
- set CC correctly
6
TARGET		:= tim
1 by edam
initial makefile
7
8
# All source files
7 by edam
- set CC correctly
9
CC_SRCS		:= 
10
C_SRCS		:= 
11
S_SRCS		:= 
3 by edam
- added propper header
12
13
# Libraries
7 by edam
- set CC correctly
14
LIBRARIES	:= 
15
16
# Override options (better: specify in environment or on cmdline)
17
#DEBUGMODE	:= 1
18
CPPBUILD	:= 1
19
#STATICLIBS	:= 1
20
BUILDLIB	:= 1
21
22
# Initial flags
23
CPPFLAGS	:= 
24
ASFLAGS		:= 
25
LDFLAGS		:= 
6 by edam
- puled out options to set flags for g++, as and ld
26
3 by edam
- added propper header
27
#___________________________________________________________________________
28
29
# Software
7 by edam
- set CC correctly
30
AS			:= nasm
31
CC			:= $(if $(CPPBUILD), g++, gcc)
1 by edam
initial makefile
32
7 by edam
- set CC correctly
33
ifdef DEBUGMODE
4 by edam
- replaced debug option with debug switch
34
35
# Debug build flags
7 by edam
- set CC correctly
36
CPPFLAGS	:= -g -D DEBUG $(CPPFLAGS)
37
ASFLAGS		:= -f elf -g -dDEBUG $(ASFLAGS)
6 by edam
- puled out options to set flags for g++, as and ld
38
LDFLAGS		:= -Wall $(if $(STATICLIBS), -static) $(LDFLAGS)
4 by edam
- replaced debug option with debug switch
39
40
else
41
42
# Release build flags
7 by edam
- set CC correctly
43
CPPFLAGS	:= -O2 $(CPPFLAGS)
44
ASFLAGS		:= -f elf -O2 $(ASFLAGS)
6 by edam
- puled out options to set flags for g++, as and ld
45
LDFLAGS		:= -Wall -s $(if $(STATICLIBS), -static) $(LDFLAGS)
4 by edam
- replaced debug option with debug switch
46
47
endif
48
1 by edam
initial makefile
49
# More variables...
7 by edam
- set CC correctly
50
DEPFILE		:= Depends
51
_SRCS		:= $(CC_SRCS) $(C_SRCS) $(S_SRCS)
52
_OBJS		:= $(addsuffix .o,$(basename $(_SRCS)))
53
LDLIBS		:= $(addprefix -l,$(LIBRARIES))
54
55
.PHONY:	all clean run depend dep
56
57
all:	depend $(TARGET)
58
3 by edam
- added propper header
59
$(TARGET): $(_OBJS)
7 by edam
- set CC correctly
60
ifdef BUILDLIB
61
	$(AR) rcs $(TARGET) $(_OBJS)
62
else
63
	$(CC) -o $(TARGET) $(LDFLAGS) $(LDLIBS) $(_OBJS)
64
endif
1 by edam
initial makefile
65
66
clean:
3 by edam
- added propper header
67
	rm -f core $(DEPFILE) $(_OBJS)
1 by edam
initial makefile
68
	rm -f *~
69
4 by edam
- replaced debug option with debug switch
70
run:	$(TARGET)
71
	./$(TARGET)
72
1 by edam
initial makefile
73
depend dep:
3 by edam
- added propper header
74
#	makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)
1 by edam
initial makefile
75
3 by edam
- added propper header
76
#___________________________________________________________________________
1 by edam
initial makefile
77
#include $(DEPFILE)