src/vlock.sh: get rid of getopt
[vlock.git] / Makefile
blob3bf26bc4ab29016c83e9045564edbde273aa0d67
1 # vlock makefile
3 include config.mk
5 VPATH = src
7 VLOCK_VERSION = 2.2 beta1
9 PROGRAMS = vlock vlock-main
11 .PHONY: all
12 all: $(PROGRAMS)
14 .PHONY: debug
15 debug:
16 @$(MAKE) DEBUG=y
18 ifeq ($(ENABLE_PLUGINS),yes)
19 all: plugins
20 endif
22 .PHONY: plugins
23 plugins: modules scripts
25 .PHONY: modules
26 modules:
27 @$(MAKE) -C modules
29 .PHONY: scripts
30 scripts:
31 @$(MAKE) -C scripts
33 ### configuration ###
35 config.mk:
36 $(info )
37 $(info ###################################################)
38 $(info # Creating default configuration. #)
39 $(info # Run ./configure or edit config.mk to customize. #)
40 $(info ###################################################)
41 $(info )
42 @./configure --quiet
44 ### installation rules ###
46 .PHONY: install
47 install: install-programs install-man
49 ifeq ($(ENABLE_PLUGINS),yes)
50 install: install-plugins
51 endif
53 .PHONY: install-programs
54 install-programs: $(PROGRAMS)
55 $(MKDIR_P) $(DESTDIR)$(PREFIX)/bin
56 $(INSTALL) -m 755 -o root -g $(ROOT_GROUP) vlock $(DESTDIR)$(BINDIR)/vlock
57 $(MKDIR_P) $(DESTDIR)$(PREFIX)/sbin
58 $(INSTALL) -m 4711 -o root -g $(ROOT_GROUP) vlock-main $(DESTDIR)$(SBINDIR)/vlock-main
60 .PHONY: install-plugins
61 install-plugins: install-modules install-scripts
63 .PHONY: install-modules
64 install-modules:
65 @$(MAKE) -C modules install
67 .PHONY: install-scripts
68 install-scripts:
69 @$(MAKE) -C scripts install
71 .PHONY: install-man
72 install-man:
73 $(MKDIR_P) $(DESTDIR)$(PREFIX)/share/man/man1
74 $(INSTALL) -m 644 -o root -g $(ROOT_GROUP) man/vlock.1 $(DESTDIR)$(MANDIR)/man1/vlock.1
75 $(MKDIR_P) $(DESTDIR)$(PREFIX)/share/man/man8
76 $(INSTALL) -m 644 -o root -g $(ROOT_GROUP) man/vlock-main.8 $(DESTDIR)$(MANDIR)/man8/vlock-main.8
79 ### build rules ###
81 vlock: vlock.sh config.mk Makefile
82 $(BOURNE_SHELL) -n $<
83 sed \
84 -e 's,%BOURNE_SHELL%,$(BOURNE_SHELL),' \
85 -e 's,%PREFIX%,$(PREFIX),' \
86 -e 's,%VLOCK_VERSION%,$(VLOCK_VERSION),' \
87 -e 's,%VLOCK_ENABLE_PLUGINS%,$(ENABLE_PLUGINS),' \
88 $< > $@.tmp
89 mv -f $@.tmp $@
91 override CFLAGS += -Isrc
93 vlock-main: vlock-main.o prompt.o auth-$(AUTH_METHOD).o console_switch.o util.o
95 auth-pam.o: auth-pam.c prompt.h auth.h
96 auth-shadow.o: auth-shadow.c prompt.h auth.h
97 prompt.o: prompt.c prompt.h
98 vlock-main.o: vlock-main.c auth.h prompt.h util.h
99 plugins.o: plugins.c tsort.h plugin.h plugins.h list.h util.h
100 module.o : override CFLAGS += -DVLOCK_MODULE_DIR="\"$(MODULEDIR)\""
101 module.o: module.c plugin.h list.h util.h
102 script.o : override CFLAGS += -DVLOCK_SCRIPT_DIR="\"$(SCRIPTDIR)\""
103 script.o: script.c plugin.h process.h list.h util.h
104 plugin.o: plugin.c plugin.h list.h util.h
105 tsort.o: tsort.c tsort.h list.h
106 list.o: list.c list.h util.h
107 console_switch.o: console_switch.c console_switch.h
108 process.o: process.c process.h
109 util.o: util.c util.h
111 ifneq ($(ENABLE_ROOT_PASSWORD),yes)
112 vlock-main.o : override CFLAGS += -DNO_ROOT_PASS
113 endif
115 ifeq ($(AUTH_METHOD),pam)
116 vlock-main : override LDFLAGS += $(PAM_LIBS)
117 endif
119 ifeq ($(AUTH_METHOD),shadow)
120 vlock-main : override LDFLAGS += $(CRYPT_LIB)
121 endif
123 ifeq ($(ENABLE_PLUGINS),yes)
124 vlock-main: plugins.o plugin.o module.o process.o script.o tsort.o list.o
125 # -rdynamic is needed so that the all plugin can access the symbols from console_switch.o
126 vlock-main : override LDFLAGS += $(DL_LIB) -rdynamic
127 vlock-main.o : override CFLAGS += -DUSE_PLUGINS
128 vlock-main.o: plugins.h
129 endif
131 .PHONY: realclean
132 realclean: clean
133 $(RM) config.mk
135 .PHONY: clean
136 clean:
137 $(RM) $(PROGRAMS) $(wildcard *.o)
138 @$(MAKE) -C modules clean
139 @$(MAKE) -C scripts clean