/make/edam-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/edam-mk

« back to all changes in this revision

Viewing changes to Makefile

  • Committer: edam
  • Date: 2009-03-05 13:25:26 UTC
  • Revision ID: edam@waxworlds.org-20090305132526-n50e3cqq1rhs3zfo
Tags: 1.5
- replaced debug option with debug switch
- added run goal

Show diffs side-by-side

added added

removed removed

1
 
#                                                       Edam's Makefile v1.8
 
1
#                                                       Edam's Makefile v1.5
2
2
#___________________________________________________________________________
3
3
#                                                            S E T T I N G S
4
4
 
5
5
# Target binary
6
 
TARGET          := tim
 
6
TARGET          = helloworld
7
7
 
8
8
# All source files
9
 
CC_SRCS         := 
10
 
C_SRCS          := 
11
 
S_SRCS          := 
 
9
CC_SRCS         = helloworld.cc
 
10
C_SRCS          = 
 
11
S_SRCS          = 
12
12
 
13
13
# Libraries
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         := 
 
14
LIBRARIES       = 
 
15
 
 
16
# Uncomment for debug-build
 
17
DEBUG           = 1
26
18
 
27
19
#___________________________________________________________________________
 
20
#                                                                    M E A T
28
21
 
29
22
# Software
30
 
AS                      := nasm
31
 
CC                      := $(if $(CPPBUILD), g++, gcc)
 
23
AS=nasm
32
24
 
33
 
ifdef DEBUGMODE
 
25
ifdef DEBUG
34
26
 
35
27
# Debug build flags
36
 
CPPFLAGS        := -g -D DEBUG $(CPPFLAGS)
37
 
ASFLAGS         := -f elf -g -dDEBUG $(ASFLAGS)
38
 
LDFLAGS         := -Wall $(if $(STATICLIBS), -static) $(LDFLAGS)
 
28
CPPFLAGS        = -g -D DEBUG
 
29
ASFLAGS         = -f elf -g -dDEBUG
 
30
LDFLAGS         = -Wall
39
31
 
40
32
else
41
33
 
42
34
# Release build flags
43
 
CPPFLAGS        := -O2 $(CPPFLAGS)
44
 
ASFLAGS         := -f elf -O2 $(ASFLAGS)
45
 
LDFLAGS         := -Wall -s $(if $(STATICLIBS), -static) $(LDFLAGS)
 
35
CPPFLAGS        = -O2
 
36
ASFLAGS         = -f elf -O2
 
37
LDFLAGS         = -Wall -s
46
38
 
47
39
endif
48
40
 
49
41
# More variables...
50
 
DEPFILE         := Depends
51
 
_SRCS           := $(CC_SRCS) $(C_SRCS) $(S_SRCS)
52
 
_OBJS           := $(addsuffix .o,$(basename $(_SRCS)))
53
 
LDLIBS          := $(addprefix -l,$(LIBRARIES))
 
42
DEPFILE         = Depends
 
43
_SRCS           = $(CC_SRCS) $(C_SRCS) $(S_SRCS)
 
44
_OBJS           = $(addsuffix .o,$(basename $(_SRCS)))
 
45
LDLIBS          = $(addprefix -l,$(LIBRARIES))
 
46
 
 
47
# Main rule...
 
48
$(TARGET): $(_OBJS)
 
49
        g++ -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)
 
50
 
 
51
#___________________________________________________________________________
 
52
#                                                                  R U L E S
54
53
 
55
54
.PHONY: all clean run depend dep
56
55
 
57
 
all:    depend $(TARGET)
58
 
 
59
 
$(TARGET): $(_OBJS)
60
 
ifdef BUILDLIB
61
 
        $(AR) rcs $(TARGET) $(_OBJS)
62
 
else
63
 
        $(CC) -o $(TARGET) $(LDFLAGS) $(LDLIBS) $(_OBJS)
64
 
endif
 
56
all:    clean depend $(TARGET)
65
57
 
66
58
clean:
67
59
        rm -f core $(DEPFILE) $(_OBJS)