(no commit message)
[strongswan.git] / src / charon / Makefile
1 # Copyright (C) 2005 Jan Hutter, Martin Willi
2 # Hochschule fuer Technik Rapperswil
3 #
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the
6 # Free Software Foundation; either version 2 of the License, or (at your
7 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # for more details.
13 #
14
15 FREESWANSRCDIR=../..
16 # include strongswan Makefile, if charon sits in its tree
17 ifeq ($(shell ls $(FREESWANSRCDIR)/Makefile.inc 2>&1), ../../Makefile.inc)
18 include ${FREESWANSRCDIR}/Makefile.inc
19 else
20 # Defaults if not using strongswan defines
21 USE_LEAK_DETECTIVE?=false
22 INSTALL=install
23 INSTBINFLAGS=-b --suffix=.old
24 LIBEXECDIR=/usr/local/libexec/ipsec
25 SHAREDLIBDIR=/usr/local/lib
26 endif
27
28
29 BUILD_DIR= ./bin/
30
31 BINNAMECHARON= $(BUILD_DIR)charon
32 BINNAMESTROKE= $(BUILD_DIR)stroke
33 BINNAMETEST= $(BUILD_DIR)run_tests
34 BINNAMELIB= $(BUILD_DIR)libstrongswan.so
35
36 MAIN_DIR= ./
37
38 CFLAGS= -Icharon -Ilib -Istroke -fPIC -Wall -g
39 ifeq ($(USE_LEAK_DETECTIVE),true)
40 CFLAGS+= -DLEAK_DETECTIVE
41 endif
42
43 # objects is extended by each included Makefile
44 CHARON_OBJS=
45 LIB_OBJS=
46 TEST_OBJS=
47
48 all : programs
49
50 include $(MAIN_DIR)charon/Makefile.charon
51 include $(MAIN_DIR)lib/Makefile.lib
52 include $(MAIN_DIR)stroke/Makefile.stroke
53 include $(MAIN_DIR)testing/Makefile.testcases
54
55 programs : $(BINNAMECHARON) $(BINNAMESTROKE)
56
57 test : $(BINNAMETEST)
58 LD_LIBRARY_PATH=$(BUILD_DIR) $(BINNAMETEST)
59
60 run : $(BINNAMECHARON)
61 LD_LIBRARY_PATH=$(BUILD_DIR) $(BINNAMECHARON)
62
63 apidoc :
64 doxygen Doxyfile
65
66 build_dir:
67 mkdir -p $(BUILD_DIR)
68
69 $(BINNAMELIB) : build_dir $(LIB_OBJS)
70 $(CC) -lpthread -ldl -lgmp -shared $(LIB_OBJS) -o $@
71
72 $(BINNAMECHARON) : build_dir $(CHARON_OBJS) $(BINNAMELIB) $(BUILD_DIR)daemon.o
73 $(CC) -L./bin -lstrongswan $(CHARON_OBJS) $(BUILD_DIR)daemon.o -o $@
74
75 $(BINNAMETEST) : build_dir $(CHARON_OBJS) $(TEST_OBJS) $(BINNAMELIB) $(BUILD_DIR)testcases.o
76 $(CC) -L./bin -lstrongswan $(LDFLAGS) $(CHARON_OBJS) $(TEST_OBJS) $(BUILD_DIR)testcases.o -o $@
77
78 $(BINNAMESTROKE) : build_dir $(BINNAMELIB) $(BUILD_DIR)stroke.o
79 $(CC) $(LDFLAGS) $(CFLAGS) $(BUILD_DIR)stroke.o -o $@
80
81 install : $(BINNAMECHARON) $(BINNAMESTROKE)
82 $(INSTALL) $(INSTBINFLAGS) $(BINNAMECHARON) $(BINNAMESTROKE) $(LIBEXECDIR)
83 $(INSTALL) $(INSTBINFLAGS) $(BINNAMELIB) $(SHAREDLIBDIR)
84
85 install_file_list:
86 @echo $(LIBEXECDIR)/charon
87 @echo $(LIBEXECDIR)/stroke
88 @echo $(SHAREDLIBDIR)/libstrongswan.so
89
90 clean :
91 rm -fR $(BUILD_DIR)
92
93 cleanall: clean
94
95 distclean: clean
96
97 mostlyclean: clean
98
99 realclean: clean