summaryrefslogtreecommitdiffstats
blob: 1b5a5c4170b018736f51d0518f261b13f38430a6 (plain) (blame)
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
#
# makefile for ctoolsprof server
#
# examples:
# make clean debug CC=your-favorite-gcc DESTDIR=your-destination-dir install
# make clean release CC=your-favorite-gcc DESTDIR=your-destination-dir install
# To Use CROSS_COMPILE:
# make clean debug arm DESTDIR=your-destination-dir install
# make clean release arm DESTDIR=your-destination-dir install 
# make arm all DESTDIR=your-destination-dir

ifeq ($(findstring arm, $(MAKECMDGOALS)), arm) 
	CC= $(CROSS_COMPILE)gcc
endif

ifeq ($(findstring debug, $(MAKECMDGOALS)), debug) 
	CFLAGS= -std=c99 -c -g -Wall $(INC_PATH) -D DEBUG -D _GNU_SOURCE
	OBJDIR= ./debug
else 
    CFLAGS= -std=c99 -c -O2 $(INC_PATH) -D SERVER -D _GNU_SOURCE
	OBJDIR= ./release
endif
LFLAGS =
LIBS= 
LIB_PATH=
INCLUDE_PATH = -I ../example_app

.PHONY: clean debug release install arm

all: clean release arm install

#
# Declare.c and .h dependencies
#
ctprof_ex.o: ctprof_ex.c
ctprof_utility.o : ctprof_utility.h ctprof_utility.c 

#
# Add objects
#

OBJECTS = $(addprefix $(OBJDIR)/, ctprof_ex.o ctprof_utility.o)

#.c.o:
#	@echo "Compiling" $<
#	$(CC) $(CFLAGS) $<

$(OBJDIR)/%.o: %.c
	@echo "Compiling" $<
	@mkdir -p $(OBJDIR)
	$(CC) $(CFLAGS) $(INCLUDE_PATH) -o $@ $<

ctprof_ex: $(OBJECTS)
	@echo "Building target" $@
	$(CC) $(LFLAGS) $(LIBS_PATH) -o $(OBJDIR)/$@ $(OBJECTS) $(LIBS)

debug: ctprof_ex
	@echo "debug build complete"

release: ctprof_ex
	@echo "release build complete"

arm: ctprof_ex
	@echo "ARM version built"

install: 
	mv $(OBJDIR)/ctprof_ex $(DESTDIR)

clean:
	-rm $(OBJECTS)