bzr branch
http://bzr.ed.am/make/edam-mk
8
by edam
- added SUBDIRS for recursing |
1 |
# Edam's Makefile v1.9 |
3
by edam
- added propper header |
2 |
#___________________________________________________________________________ |
3 |
# S E T T I N G S |
|
4 |
||
8
by edam
- added SUBDIRS for recursing |
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 |
|
7
by edam
- set CC correctly |
13 |
TARGET := tim |
1
by edam
initial makefile |
14 |
|
15 |
# All source files |
|
8
by edam
- added SUBDIRS for recursing |
16 |
CC_SRCS := tim.cc |
7
by edam
- set CC correctly |
17 |
C_SRCS := |
18 |
S_SRCS := |
|
3
by edam
- added propper header |
19 |
|
8
by edam
- added SUBDIRS for recursing |
20 |
# Libraries to link |
7
by edam
- set CC correctly |
21 |
LIBRARIES := |
22 |
||
8
by edam
- added SUBDIRS for recursing |
23 |
# Subdirectories to make |
24 |
SUBDIRS := |
|
3
by edam
- added propper header |
25 |
|
26 |
# Software |
|
7
by edam
- set CC correctly |
27 |
AS := nasm |
8
by edam
- added SUBDIRS for recursing |
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) |
|
37 |
||
38 |
#___________________________________________________________________________ |
|
39 |
||
40 |
DEPFILE := depends.mk |
|
7
by edam
- set CC correctly |
41 |
_SRCS := $(CC_SRCS) $(C_SRCS) $(S_SRCS) |
42 |
_OBJS := $(addsuffix .o,$(basename $(_SRCS))) |
|
43 |
LDLIBS := $(addprefix -l,$(LIBRARIES)) |
|
44 |
||
8
by edam
- added SUBDIRS for recursing |
45 |
.PHONY: all target clean clean_all run depend dep $(SUBDIRS) |
46 |
||
47 |
all: $(SUBDIRS) $(TARGET) |
|
48 |
||
49 |
target: $(TARGET) |
|
1
by edam
initial makefile |
50 |
|
51 |
clean: |
|
8
by edam
- added SUBDIRS for recursing |
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) |
|
1
by edam
initial makefile |
58 |
rm -f *~ |
59 |
||
8
by edam
- added SUBDIRS for recursing |
60 |
clean_all: $(SUBDIRS) clean |
61 |
||
4
by edam
- replaced debug option with debug switch |
62 |
run: $(TARGET) |
8
by edam
- added SUBDIRS for recursing |
63 |
$(if $(BUILDLIB),@echo Can\'t run a library\!,./$(TARGET)) |
4
by edam
- replaced debug option with debug switch |
64 |
|
8
by edam
- added SUBDIRS for recursing |
65 |
#depend dep: |
3
by edam
- added propper header |
66 |
# makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE) |
1
by edam
initial makefile |
67 |
|
8
by edam
- added SUBDIRS for recursing |
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 |
||
3
by edam
- added propper header |
87 |
#___________________________________________________________________________ |