/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:28:28 UTC
  • Revision ID: edam@waxworlds.org-20090305132828-fbaz7j6st7ualnge
Tags: 1.7
- puled out options to set flags for g++, as and ld

Show diffs side-by-side

added added

removed removed

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