aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/Makefile
blob: 722d5d33e5e451e947ebb4b953f28a84cfe4ee69 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright (C) 2005 Jan Hutter, Martin Willi
# Hochschule fuer Technik Rapperswil
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#

FREESWANSRCDIR=../..
# include strongswan Makefile, if charon sits in its tree
ifeq ($(shell ls $(FREESWANSRCDIR)/Makefile.inc 2>&1), ../../Makefile.inc)
  include ${FREESWANSRCDIR}/Makefile.inc
else
# Defaults if not using strongswan defines
  USE_LEAK_DETECTIVE?=false
  INSTALL=install
  INSTBINFLAGS=-b --suffix=.old
  LIBEXECDIR=/usr/local/libexec/ipsec
  SHAREDLIBDIR=/usr/local/lib
endif


BUILD_DIR= ./bin/

BINNAMECHARON= $(BUILD_DIR)charon
BINNAMESTROKE= $(BUILD_DIR)stroke
BINNAMETEST= $(BUILD_DIR)run_tests
BINNAMELIB=  $(BUILD_DIR)libstrongswan.so

MAIN_DIR= ./

CFLAGS= -Icharon -Ilib -Istroke -fPIC -Wall -Wcast-qual -Wstrict-prototypes -Wbad-function-cast -g
ifeq ($(USE_LEAK_DETECTIVE),true)
  CFLAGS+= -DLEAK_DETECTIVE
endif

# objects is extended by each included Makefile
CHARON_OBJS=
LIB_OBJS=
TEST_OBJS=

all :						programs

include $(MAIN_DIR)charon/Makefile.charon
include $(MAIN_DIR)lib/Makefile.lib
include $(MAIN_DIR)stroke/Makefile.stroke
include $(MAIN_DIR)testing/Makefile.testcases

programs : 					$(BINNAMECHARON) $(BINNAMESTROKE)

test :						$(BINNAMETEST)
							LD_LIBRARY_PATH=$(BUILD_DIR) $(BINNAMETEST)

run :						$(BINNAMECHARON)
							LD_LIBRARY_PATH=$(BUILD_DIR) $(BINNAMECHARON)

apidoc : 
							doxygen Doxyfile

build_dir:
							mkdir -p $(BUILD_DIR)
							
$(BINNAMELIB) :				build_dir $(LIB_OBJS)
							$(CC) -lpthread -ldl -lgmp -shared $(LIB_OBJS) -o $@

$(BINNAMECHARON) :			build_dir $(CHARON_OBJS) $(BINNAMELIB) $(BUILD_DIR)daemon.o
							$(CC) -L./bin -lstrongswan $(CHARON_OBJS) $(BUILD_DIR)daemon.o -o $@

$(BINNAMETEST) :			build_dir $(CHARON_OBJS) $(TEST_OBJS) $(BINNAMELIB) $(BUILD_DIR)testcases.o
							$(CC) -L./bin -lstrongswan  $(LDFLAGS) $(CHARON_OBJS) $(TEST_OBJS) $(BUILD_DIR)testcases.o -o $@

$(BINNAMESTROKE) :			build_dir $(BINNAMELIB) $(BUILD_DIR)stroke.o
							$(CC) $(LDFLAGS) $(CFLAGS) $(BUILD_DIR)stroke.o -o $@

install :					$(BINNAMECHARON) $(BINNAMESTROKE)
							$(INSTALL) $(INSTBINFLAGS) $(BINNAMECHARON) $(BINNAMESTROKE) $(LIBEXECDIR)
							$(INSTALL) $(INSTBINFLAGS) $(BINNAMELIB) $(SHAREDLIBDIR)
				
install_file_list:
							@echo $(LIBEXECDIR)/charon
							@echo $(LIBEXECDIR)/stroke
							@echo $(SHAREDLIBDIR)/libstrongswan.so

clean : 		
							rm -fR $(BUILD_DIR)
				
cleanall: clean

distclean: clean

mostlyclean: clean

realclean: clean