/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:53:15 UTC
  • Revision ID: edam@waxworlds.org-20090305135315-6vqbac8z1n6861w5
Tags: 2.1
- compiler/linker gives all wornings when building in debug
- renamed dependency files .dep so they don't clash with D source
- try to echo a blank line when recursing

Show diffs side-by-side

added added

removed removed

40
40
CPPFLAGS        := 
41
41
CFLAGS          := 
42
42
CXXFLAGS        := 
43
 
DFLAGS          := 
44
43
ASFLAGS         := 
45
44
LDFLAGS         := 
46
45
LDPOSTFLAGS     := 
54
53
endif
55
54
 
56
55
# software
 
56
AS                      := nasm
57
57
CC                      := gcc
58
58
CXX                     := g++
59
 
GDC                     := gdc
60
 
AS                      := nasm
61
59
LD                      := g++
62
60
AR                      := ar
63
61
MAKE            := make
64
62
 
65
 
# debug/profile build flags
 
63
# build flags
66
64
CPPFLAGS        := $(if $(PROFILEMODE),-pg -D PROFILE) $(CPPFLAGS)
67
65
CPPFLAGS        := $(if $(DEBUGMODE),-g -D DEBUG -Wall,-O2) $(CPPFLAGS)
68
 
DFLAGS          := $(if $(DEBUGMODE),,-frelease)
 
66
CPPFLAGS        := $(if $(MKSHAREDLIB),-fPIC) $(CPPFLAGS)
69
67
ASFLAGS         := -f elf $(if $(DEBUGMODE),-g -dDEBUG,-O2) $(ASFLAGS)
70
68
LDFLAGS         := $(if $(PROFILEMODE),-pg) $(LDFLAGS)
71
 
LDFLAGS         := $(if $(or $(PROFILEMODE), $(DEBUGMODE)),,-Wl,-S) $(LDFLAGS)
72
 
 
73
 
# setup options for shared/static libs
74
 
CPPFLAGS        := $(if $(MKSHAREDLIB),-fPIC) $(CPPFLAGS)
 
69
LDFLAGS         := $(if $(or $(PROFILEMODE),$(DEBUGMODE)),,-Wl,-S) $(LDFLAGS)
75
70
LDFLAGS         := $(if $(LINKSTATIC),-static) $(LDFLAGS)
76
 
 
77
 
# add libraries for d
78
 
LIBRARIES       := $(LIBRARIES) $(if $(filter %.d, $(SOURCES)), gphobos pthread m)
79
 
 
80
 
# build flags for libraries
81
71
LDPOSTFLAGS := $(addprefix -l,$(LIBRARIES)) $(LDPOSTFLAGS)
82
72
 
83
73
#_______________________________________________________________________________
86
76
# object debug/profile suffix
87
77
BUILDSUFFIX     := $(if $(PROFILEMODE),_p,$(if $(DEBUGMODE),_d))
88
78
 
89
 
# work out object and dependency files
 
79
# files
90
80
OBJECTS         := $(addsuffix $(BUILDSUFFIX).o,$(basename $(SOURCES)))
91
81
DEPFILES        := $(addsuffix .dep,$(basename $(SOURCES)))
92
82
 
93
 
# fixup target name
 
83
# fixup target
94
84
ifdef TARGET
95
 
TARGET          := $(basename $(TARGET))$(BUILDSUFFIX)$(suffix $(TARGET))
96
 
TARGET          := $(patsubst %.so,%,$(patsubst %.a,%,$(TARGET)))
 
85
TARGET          := $(basename $(TARGET))$(BUILDSUFFIX)$(suffix $(TARGET))
 
86
TARGET          := $(patsubst %.so,%,$(patsubst %.a,%,$(TARGET)))
97
87
ifneq ($(strip $(MKSHAREDLIB) $(MKSTATICLIB)),)
98
 
TARGET          := $(TARGET)$(if $(MKSHAREDLIB),.so,$(if $(MKSTATICLIB),.a))
99
 
TARGET          := lib$(patsubst lib%,%,$(TARGET))
 
88
TARGET          := $(TARGET)$(if $(MKSHAREDLIB),.so,$(if $(MKSTATICLIB),.a))
 
89
TARGET          := lib$(patsubst lib%,%,$(TARGET))
100
90
endif
101
91
endif
102
92
 
142
132
        @echo "NOT RECURSING: use 'make clean_all' to clean subdirectories as well."
143
133
endif
144
134
endif
145
 
        rm -f $(OBJECTS) $(TARGET) *.dep core
 
135
        rm -f $(OBJECTS) $(TARGET) core
146
136
 
147
137
clean_all: subdirs clean
148
138
 
179
169
        $(CXX) -c $(CPPFLAGS) $(DEPFLAGS) $(CXXFLAGS) -o $@ $<
180
170
        $(FIXUP_DEPENDANCY_FILES)
181
171
 
182
 
%.o %_d.o %_p.o: %.d
183
 
        $(GDC) -c $(CPPFLAGS) $(DFLAGS) -o $@ $<
184
 
 
185
172
%.o %_d.o %_p.o: %.s
186
173
        $(AS) $(ASFLAGS) -o $@ $<
187
174
%.o %_d.o %_p.o: %.S