(no commit message)
[strongswan.git] / src / Makefile.program
1
2 include ${FREESWANSRCDIR}/Makefile.ver
3
4 CFLAGS+=$(USERCOMPILE) -I${KLIPSINC}
5
6 CFLAGS+= -Wall
7 CFLAGS+= -Wpointer-arith
8 CFLAGS+= -Wcast-qual
9 CFLAGS+= -Wstrict-prototypes
10 CFLAGS+= -Wbad-function-cast 
11
12 # die if there are any warnings
13 ifndef WERROR
14 WERROR:= -Werror
15 endif
16
17 #CFLAGS+= ${WERROR}
18
19 ifneq ($(LD_LIBRARY_PATH),)
20 LDFLAGS=-L$(LD_LIBRARY_PATH)
21 endif
22
23 MANDIR8=$(MANTREE)/man8
24 MANDIR5=$(MANTREE)/man5
25
26 ifndef PROGRAMDIR
27 PROGRAMDIR=${LIBEXECDIR}
28 endif
29
30 ifndef MANPROGPREFIX
31 MANPROGPREFIX=ipsec_
32 endif
33
34 ifndef CONFDSUBDIR
35 CONFDSUBDIR=.
36 endif
37
38 all: $(PROGRAM)
39
40 programs: all
41
42 ifneq ($(PROGRAM),check)
43 check: $(PROGRAM)
44 endif
45
46
47 ifneq ($(NOINSTALL),true)
48
49 install:: $(PROGRAM) $(CONFFILES) $(EXTRA8MAN) $(EXTRA5MAN) $(EXTRA5PROC) $(LIBFILES) $(CONFDFILES)
50         @mkdir -p $(PROGRAMDIR) $(MANDIR8) $(MANDIR5) $(LIBDIR) $(CONFDIR) $(CONFDDIR) $(CONFDDIR)/$(CONFDSUBDIR) $(EXAMPLECONFDIR)
51         @if [ -n "$(PROGRAM)" ]; then $(INSTALL) $(INSTBINFLAGS) $(PROGRAM) $(PROGRAMDIR); fi
52         @$(foreach f, $(addsuffix .8, $(PROGRAM)), \
53                 $(INSTALL) $(INSTMANFLAGS) $f $(MANDIR8)/$(MANPROGPREFIX)$f || exit 1; \
54         )
55         @$(foreach f, $(EXTRA8MAN), \
56                 $(INSTALL) $(INSTMANFLAGS) $f $(MANDIR8)/ipsec_$f || exit 1; \
57         )
58         @$(foreach f, $(EXTRA5MAN), \
59                 $(INSTALL) $(INSTMANFLAGS) $f $(MANDIR5)/$f || exit 1 ;\
60         )
61         @$(foreach f, $(EXTRA5PROC), \
62                 $(INSTALL) $(INSTMANFLAGS) $f $(MANDIR5)/ipsec_$f || exit 1 ;\
63         )
64         @$(foreach f, $(LIBFILES), \
65                 $(INSTALL) $(INSTCONFFLAGS) $f $(LIBDIR)/$f || exit 1 ;\
66         )
67         @$(foreach f, $(CONFFILES), \
68                 if [ ! -f $(CONFDIR)/$f ]; then $(INSTALL) $(INSTCONFFLAGS) $f $(CONFDIR)/$f || exit 1; fi;\
69                 $(INSTALL) $(INSTCONFFLAGS) $f $(EXAMPLECONFDIR)/$f-sample || exit 1; \
70         )
71         @$(foreach f, $(CONFDFILES), \
72                 if [ ! -f $(CONFDDIR)/$(CONFDSUBDIR)/$f ]; then $(INSTALL) $(INSTCONFFLAGS) $f $(CONFDDIR)/$(CONFDSUBDIR)/$f || exit 1; fi;\
73         )
74
75 install_file_list::
76         @if [ -n "$(PROGRAM)" ]; then echo $(PROGRAMDIR)/$(PROGRAM); fi
77         @$(foreach f, $(addsuffix .8, $(PROGRAM)), \
78                 echo $(MANDIR8)/${MANPROGPREFIX}$f; \
79         )
80         @$(foreach f, $(EXTRA8MAN), \
81                 echo $(MANDIR8)/ipsec_$f; \
82         )
83         @$(foreach f, $(EXTRA5MAN), \
84                 echo $(MANDIR5)/$f;\
85         )
86         @$(foreach f, $(EXTRA5PROC), \
87                 echo $(MANDIR5)/ipsec_$f; \
88         )
89         @$(foreach f, $(LIBFILES), \
90                 echo $(LIBDIR)/$f;\
91         )
92         @$(foreach f, $(CONFFILES), \
93                 echo $(CONFDIR)/$f;\
94                 echo $(EXAMPLECONFDIR)/$f-sample;\
95         )
96         @$(foreach f, $(CONFDFILES), \
97                 echo $(CONFDDIR)/${CONFDSUBDIR}/$f;\
98         )
99
100 endif
101
102 # cancel the rule that compiles directly
103 %: %.c 
104
105 %: %.o $(OBJS)
106         $(CC) $(CFLAGS) -o $@ $@.o ${OBJS} $(LDFLAGS) $(LIBS)
107
108 %: %.in ${FREESWANSRCDIR}/Makefile.inc ${FREESWANSRCDIR}/Makefile.ver
109         cat $< | sed -e "s/xxx/$(IPSECVERSION)/" \
110                         -e "s:@IPSEC_DIR@:$(FINALBINDIR):" \
111                         -e "s:@IPSEC_EXECDIR@:$(FINALLIBEXECDIR):" \
112                         -e "s:@IPSEC_SBINDIR@:$(FINALSBINDIR):" \
113                         -e "s:@IPSEC_LIBDIR@:$(FINALLIBDIR):" \
114                         -e "s:@FINALCONFDIR@:$(FINALCONFDIR):" \
115                         -e "s:@EXAMPLECONFDIR@:$(EXAMPLECONFDIR):" \
116                         -e "s:@FINALDOCDIR@:$(FINALDOCDIR):" \
117                         -e "s:@FINALEXAMPLECONFDIR@:$(FINALEXAMPLECONFDIR):" \
118                         -e "s:@MODULE_GOO_LIST@:$(MODULE_GOO_LIST):" \
119                         -e "s:@IPSEC_CONFS@:$(FINALCONFDIR):" \
120                         -e "s:@IPSEC_CONFDDIR@:$(FINALCONFDDIR):" \
121                         -e "s:@USE_IPROUTE2@:$(USE_IPROUTE2):" \
122                         -e "s:@IPSEC_FIREWALLTYPE@:$(IPSEC_FIREWALLTYPE):" \
123         | cat >$@
124         if [ -x $< ]; then chmod +x $@; fi
125         if [ "${PROGRAM}.in" = $< ]; then chmod +x $@; fi
126
127 cleanall: clean
128
129 distclean: clean
130
131 mostlyclean: clean
132
133 realclean: clean
134
135 clean::
136 ifneq ($(strip $(PROGRAM)),)
137         @if [ -r $(PROGRAM).in ]; then rm -f $(PROGRAM); fi
138         @if [ -r $(PROGRAM).c ];  then rm -f $(PROGRAM); fi
139         @if [ -n "$(OBJS)" ];     then rm -f $(PROGRAM); fi
140 endif
141         @rm -f *.o
142
143 checkprograms:
144