/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:26:41 UTC
  • Revision ID: edam@waxworlds.org-20090305132641-42u18q8sg2lx966x
Tags: 1.6
- added cpp build switch
- added static linking switch

Show diffs side-by-side

added added

removed removed

1
 
#                                                       Edam's Makefile v1.9
 
1
#                                                       Edam's Makefile v1.6
2
2
#___________________________________________________________________________
3
3
#                                                            S E T T I N G S
4
4
 
5
 
# Overridable options
6
 
# (better to specify these in environment/command line)
7
 
#export DEBUGMODE       := 1
8
 
#export STATICLIBS      := 1
9
 
 
10
 
# Target binary/library
11
 
#BUILDLIB       := 1
12
 
#BUILDSO        := 1
13
 
TARGET          := tim
 
5
# Target binary
 
6
TARGET          = groups
14
7
 
15
8
# All source files
16
 
CC_SRCS         := tim.cc
17
 
C_SRCS          := 
18
 
S_SRCS          := 
19
 
 
20
 
# Libraries to link
21
 
LIBRARIES       := 
22
 
 
23
 
# Subdirectories to make
24
 
SUBDIRS         := 
 
9
CC_SRCS         =
 
10
C_SRCS          = groups.c xmalloc.c
 
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
#___________________________________________________________________________
 
22
#                                                                    M E A T
25
23
 
26
24
# Software
27
 
AS                      := nasm
28
 
CC                      := gcc
29
 
CXX                     := g++
30
 
 
31
 
# Flags
32
 
CPPFLAGS        :=
33
 
CFLAGS          := $(if $(DEBUGMODE),-g -D DEBUG,-O2)
34
 
CXXFLAGS        := $(if $(DEBUGMODE),-g -D DEBUG,-O2)
35
 
ASFLAGS         := -f elf $(if $(DEBUGMODE),-g -dDEBUG,-O2)
36
 
LDFLAGS         := -Wall $(if $(DEBUGMODE),,-s) $(if $(STATICLIBS), -static)
 
25
AS=nasm
 
26
 
 
27
ifdef DEBUG
 
28
 
 
29
# Debug build flags
 
30
CPPFLAGS        = -g -D DEBUG
 
31
ASFLAGS         = -f elf -g -dDEBUG
 
32
LDFLAGS         = -Wall $(if $(STATICLIBS), -static)
 
33
 
 
34
else
 
35
 
 
36
# Release build flags
 
37
CPPFLAGS        = -O2
 
38
ASFLAGS         = -f elf -O2
 
39
LDFLAGS         = -Wall -s $(if $(STATICLIBS), -static)
 
40
 
 
41
endif
 
42
 
 
43
# More variables...
 
44
DEPFILE         = Depends
 
45
_SRCS           = $(CC_SRCS) $(C_SRCS) $(S_SRCS)
 
46
_OBJS           = $(addsuffix .o,$(basename $(_SRCS)))
 
47
LDLIBS          = $(addprefix -l,$(LIBRARIES))
 
48
 
 
49
# Main rule...
 
50
$(TARGET): $(_OBJS)
 
51
        $(if $(CPPBUILD), g++, gcc) -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)
37
52
 
38
53
#___________________________________________________________________________
39
 
 
40
 
DEPFILE         := depends.mk
41
 
_SRCS           := $(CC_SRCS) $(C_SRCS) $(S_SRCS)
42
 
_OBJS           := $(addsuffix .o,$(basename $(_SRCS)))
43
 
LDLIBS          := $(addprefix -l,$(LIBRARIES))
44
 
 
45
 
.PHONY: all target clean clean_all run depend dep $(SUBDIRS)
46
 
 
47
 
all:    $(SUBDIRS) $(TARGET)
48
 
 
49
 
target: $(TARGET)
 
54
#                                                                  R U L E S
 
55
 
 
56
.PHONY: all clean run depend dep
 
57
 
 
58
all:    clean depend $(TARGET)
50
59
 
51
60
clean:
52
 
ifeq ($(MAKECMDGOALS),clean)
53
 
ifdef SUBDIRS
54
 
        @echo NOT RECURSING: Use \"make clean_all\" to clean recursively..."
55
 
endif
56
 
endif
57
 
        rm -f core $(DEPFILE) $(_OBJS) $(TARGET)
 
61
        rm -f core $(DEPFILE) $(_OBJS)
58
62
        rm -f *~
59
63
 
60
 
clean_all: $(SUBDIRS) clean
61
 
 
62
64
run:    $(TARGET)
63
 
        $(if $(BUILDLIB),@echo Can\'t run a library\!,./$(TARGET))
 
65
        ./$(TARGET)
64
66
 
65
 
#depend dep:
 
67
depend dep:
66
68
#       makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)
67
69
 
68
 
$(SUBDIRS):
69
 
        @$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
70
 
 
71
 
$(TARGET): $(_OBJS)
72
 
ifdef BUILDLIB
73
 
        $(AR) rcs $(TARGET) $(_OBJS)
74
 
else
75
 
        $(CC) $(if $(BUILDSO),-shared) -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)
76
 
endif
77
 
 
78
 
#%.o:   %.c
79
 
#       $(CC) -c $(CPPFLAGS) $(CFLAGS)
80
 
#%.o:   %.cc
81
 
#       $(CXX) -c $(CPPFLAGS) $(CXXFLAGS)
82
 
#%.o:   %.s
83
 
#       $(AS) $(ASFLAGS)
84
 
 
85
 
-include $(DEPFILE)
86
 
 
87
70
#___________________________________________________________________________
 
71
#include $(DEPFILE)