/make/edam-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/edam-mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#                                                       Edam's Makefile v1.9
#___________________________________________________________________________
#                                                            S E T T I N G S

# Overridable options
# (better to specify these in environment/command line)
#export DEBUGMODE	:= 1
#export STATICLIBS	:= 1

# Target binary/library
#BUILDLIB	:= 1
#BUILDSO	:= 1
TARGET		:= tim

# All source files
CC_SRCS		:= tim.cc
C_SRCS		:= 
S_SRCS		:= 

# Libraries to link
LIBRARIES	:= 

# Subdirectories to make
SUBDIRS		:= 

# Software
AS			:= nasm
CC			:= gcc
CXX			:= g++

# Flags
CPPFLAGS	:=
CFLAGS		:= $(if $(DEBUGMODE),-g -D DEBUG,-O2)
CXXFLAGS	:= $(if $(DEBUGMODE),-g -D DEBUG,-O2)
ASFLAGS		:= -f elf $(if $(DEBUGMODE),-g -dDEBUG,-O2)
LDFLAGS		:= -Wall $(if $(DEBUGMODE),,-s) $(if $(STATICLIBS), -static)

#___________________________________________________________________________

DEPFILE		:= depends.mk
_SRCS		:= $(CC_SRCS) $(C_SRCS) $(S_SRCS)
_OBJS		:= $(addsuffix .o,$(basename $(_SRCS)))
LDLIBS		:= $(addprefix -l,$(LIBRARIES))

.PHONY:	all target clean clean_all run depend dep $(SUBDIRS)

all:	$(SUBDIRS) $(TARGET)

target:	$(TARGET)

clean:
ifeq ($(MAKECMDGOALS),clean)
ifdef SUBDIRS
	@echo NOT RECURSING: Use \"make clean_all\" to clean recursively..."
endif
endif
	rm -f core $(DEPFILE) $(_OBJS) $(TARGET)
	rm -f *~

clean_all: $(SUBDIRS) clean

run:	$(TARGET)
	$(if $(BUILDLIB),@echo Can\'t run a library\!,./$(TARGET))

#depend dep:
#	makedepend -f- -- $(CPPFLAGS) -- $(_SRCS) > $(DEPFILE)

$(SUBDIRS):
	@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)

$(TARGET): $(_OBJS)
ifdef BUILDLIB
	$(AR) rcs $(TARGET) $(_OBJS)
else
	$(CC) $(if $(BUILDSO),-shared) -o $(TARGET) $(LDFLAGS) $(_OBJS) $(LDLIBS)
endif

#%.o:	%.c
#	$(CC) -c $(CPPFLAGS) $(CFLAGS)
#%.o:	%.cc
#	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)
#%.o:	%.s
#	$(AS) $(ASFLAGS)

-include $(DEPFILE)

#___________________________________________________________________________