/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:55:34 UTC
  • Revision ID: edam@waxworlds.org-20090305135534-omg3htccymsu5ki4
Tags: 2.2
- added support for D!
- also cleanup dependency files

Show diffs side-by-side

added added

removed removed

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