summaryrefslogtreecommitdiff
path: root/Makefile
blob: 7516248b703e17d71dedd1e0a1023f79d58c4003 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
VERSION=0.12.5

INSTALLED_X = $(DESTDIR)/usr/X11R6
LOCAL_X = Xincludes/usr/X11R6
BINDIR = $(DESTDIR)/usr/local/bin
MANDIR = $(DESTDIR)/usr/local/man/man1

# This hack attempts to check if the needed XFree86 header files are installed.
# It checks for a needed XFree86 4.3.00 SDK header file that is not installed by
# default. If it is present, then it assumes that all header files are present.
# If it is not present, then it assumes that all header files are not present
# and uses the local copy of the XFree86 4.2.0 header files.
X_INCLUDES_ROOT = $(shell \
  if [ -f $(INSTALLED_X)/lib/Server/include/xisb.h ] ; then \
    echo -n $(INSTALLED_X) ; \
  else \
    echo -n $(LOCAL_X) ; \
  fi )

ALLINCLUDES = -I. -I$(X_INCLUDES_ROOT)/include/X11 -I$(X_INCLUDES_ROOT)/include/X11/extensions -I$(X_INCLUDES_ROOT)/lib/Server/include

MODULE_DEFINES = -DIN_MODULE -DXFree86Module
PROTO_DEFINES = -DFUNCPROTO=15 -DNARROWPROTO

STD_DEFINES = -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE  -D_GNU_SOURCE  -DSHAPE -DXINPUT -DXKB -DLBX -DXAPPGROUP -DXCSECURITY -DTOGCUP   -DDPMSExtension  -DPIXPRIV -DPANORAMIX  -DRENDER -DGCCUSESGAS -DAVOID_GLYPHBLT -DPIXPRIV -DSINGLEDEPTH -DXFreeXDGA -DXvExtension -DXFree86LOADER  -DXFree86Server -DXF86VIDMODE  -DSMART_SCHEDULE -DBUILDDEBUG -DX_BYTE_ORDER=X_LITTLE_ENDIAN -DNDEBUG
ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(MODULE_DEFINES)

check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)

CCOPTIONS = -pedantic -Wall -Wpointer-arith
CCOPTIONS += $(call check_gcc,-fno-merge-constants,)
CDEBUGFLAGS = -O2
CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) -DVERSION="\"$(VERSION)\""
CFLAGSCLIENT = $(CDEBUGFLAGS) $(CCOPTIONS) -I$(X_INCLUDES_ROOT)/include

CC = gcc

LDCOMBINEFLAGS = -r

SRCS = synaptics.c ps2comm.c
OBJS = synaptics.o ps2comm.o

.c.o:
	$(RM) $@
	$(CC) -c $(CFLAGS) $(_NOOP_) $*.c

all:: synaptics_drv.o synclient syndaemon

install: $(BINDIR)/synclient $(BINDIR)/syndaemon $(INSTALLED_X)/lib/modules/input/synaptics_drv.o install-man

install-man: $(MANDIR)/synclient.1 $(MANDIR)/syndaemon.1

$(MANDIR)/synclient.1: manpages/synclient.1
	install -D $< $@

$(MANDIR)/syndaemon.1: manpages/syndaemon.1
	install -D $< $@

$(BINDIR)/synclient : synclient
	install -D $< $@

$(BINDIR)/syndaemon : syndaemon
	install -D $< $@

$(INSTALLED_X)/lib/modules/input/synaptics_drv.o : synaptics_drv.o
	install -D $< $@

synaptics_drv.o: $(OBJS)
	$(RM) $@
	$(LD) $(LDCOMBINEFLAGS)  $(OBJS) -o $@

synclient.o	: synclient.c
	$(CC) $(CFLAGSCLIENT) -c -o $@ $<

synclient	: synclient.o
	$(CC) -o $@ $< -lm

syndaemon.o	: syndaemon.c
	$(CC) $(CFLAGSCLIENT) -c -o $@ $<

syndaemon	: syndaemon.o
	$(CC) -o $@ $< -lm -L$(INSTALLED_X)/lib -lXext -lX11

testprotokoll: testprotokoll.c
	$(CC) -o testprotokoll testprotokoll.c

synaptics.o : synaptics.h ps2comm.h linux_input.h Makefile
ps2comm.o   : ps2comm.h
synclient.o : synaptics.h
syndeamon.o : synaptics.h

clean::
	$(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut synclient syndaemon "#"* manpages/*~ synaptics-$(VERSION).tar.bz2

tags::
	etags -o TAGS *.c *.h

uninstall::
	$(RM) $(BINDIR)/synclient $(BINDIR)/syndaemon $(INSTALLED_X)/lib/modules/input/synaptics_drv.o $(MANDIR)/synclient.1 $(MANDIR)/syndaemon.1

distribution : synaptics-$(VERSION).tar.bz2

ALLFILES = COMPATIBILITY FILES INSTALL INSTALL.DE INSTALL.FR LICENSE Makefile \
	NEWS README README.alps TODO Xincludes/ alps.patch linux_input.h \
	pc_keyb.c.diff.2.4.3 \
	ps2comm.c ps2comm.h synaptics.c synaptics.h synaptics.spec \
	synclient.c syndaemon.c testprotokoll.c

DST=synaptics-$(VERSION)

synaptics-$(VERSION).tar.bz2 : $(ALLFILES)
	rm -f $(DST).tar.bz2
	rm -rf $(DST)
	mkdir $(DST) $(DST)/manpages $(DST)/script $(DST)/test
	cp -a $(ALLFILES) $(DST)
	cp -a manpages/{synclient.1,syndaemon.1} $(DST)/manpages/
	cp -a script/usbmouse $(DST)/script/
	cp -a test/test-pad.c $(DST)/test/
	chmod u+w $(DST)/*
	tar cf $(DST).tar $(DST)
	rm -rf $(DST)
	bzip2 $(DST).tar