/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:23:20 UTC
  • Revision ID: edam@waxworlds.org-20090305132320-hjmtab4k0hr9i147
Tags: 1.3
- added propper header
- added debug options
- added libraries option
- added (currently unused) dependencies

Show diffs side-by-side

added added

removed removed

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