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