summaryrefslogtreecommitdiff
blob: 32ac20deb6718bbbf7982e415521d3caed7fb016 (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
--- Makefile
+++ Makefile
@@ -1,75 +1,37 @@
-CC=gcc
-CCFLAGS=-O2 -Wall
-EXTRACCFLAGS=-s -lezV24
-EXPATCCFLAGS=-lexpat
-CFILES=put.c get.c cobex_core.c ls.c cobex_tools.c cobex_serial.c rm.c mkdir.c
-HFILES=cobex_defs.h cobex_core.h capabilities.h cobex_tools.h cobex_serial.h
-O2FILES=cobex_core.o cobex_tools.o cobex_serial.o
-PUTO=put.o
-GETO=get.o
-LSO=ls.o
-RMO=rm.o
-MKDIRO=mkdir.o
-CAPAO=capability.o
-COBEXPUT=cobex_put
-COBEXGET=cobex_get
-COBEXLS=cobex_ls
-COBEXRM=cobex_rm
-COBEXCAPA=cobex_capa
-COBEXMKDIR=cobex_mkdir
+CC ?= gcc
+CFLAGS ?= -O2
+CFLAGS += -Wall
+LDLIBS += -lezV24
+
+PROGS = cobex_put cobex_get cobex_ls cobex_rm cobex_mkdir
+CFILES = $(wildcard *.c)
+HFILES = $(wildcard *.h)
+O2FILES = cobex_core.o cobex_tools.o cobex_serial.o
+
 EXTRAFILES = README Changelog COPYING Makefile cobex_put.pl Things_to_know_T310.txt Hacking_pl2303_driver.txt
 VERSION = 0.2.13
 PROJNAME = cobex-$(VERSION)
 
-all: $(COBEXPUT) $(COBEXGET) $(COBEXLS) $(COBEXRM) $(COBEXMKDIR)
+all: $(PROGS)
 
 model:
 	cd modeldb && make all 
 
-$(COBEXPUT): $(O2FILES) $(PUTO)
-	$(CC) $(CCFLAGS) $(EXTRACCFLAGS) -o $(COBEXPUT) $(PUTO) $(O2FILES)
-
-$(COBEXGET): $(O2FILES) $(GETO)
-	$(CC) $(CCFLAGS) $(EXTRACCFLAGS) -o $(COBEXGET) $(GETO) $(O2FILES)
-
-$(COBEXRM): $(O2FILES) $(RMO)
-	$(CC) $(CCFLAGS) $(EXTRACCFLAGS) -o $(COBEXRM) $(RMO) $(O2FILES)
-
-$(COBEXLS): $(O2FILES) $(LSO)
-	$(CC) $(CCFLAGS) $(EXTRACCFLAGS) $(EXPATCCFLAGS) -o $(COBEXLS) $(LSO) $(O2FILES)
-
-$(COBEXCAPA): $(O2FILES) $(CAPAO)
-	$(CC) $(CCFLAGS) $(EXTRACCFLAGS) -o $(COBEXCAPA) $(CAPAO) $(O2FILES)
-
-$(COBEXMKDIR): $(O2FILES) $(MKDIRO)
-	$(CC) $(CCFLAGS) $(EXTRACCFLAGS) -o $(COBEXMKDIR) $(MKDIRO) $(O2FILES)
-
-
-test2: $(O2FILES) test2.o
-	$(CC) $(CCFLAGS) $(EXTRACCFLAGS) $(EXPATCCFLAGS) -o test2 test2.o $(O2FILES)
-
-.c.o:
-	$(CC) $(CCFLAGS) $(LOCKSERIAL) -c $<
-
-$(PUTO): put.c $(O2FILES)
-
-$(GETO): get.c $(O2FILES)
-
-$(LSO): ls.c $(O2FILES)
-
-$(RMO): rm.c $(O2FILES)
-
-test2.o: test2.c $(O2FILES)
-
-cobex_core.o: cobex_core.c cobex_core.h cobex_defs.h
-
-cobex_tools.o: cobex_tools.c cobex_tools.h cobex_defs.h cobex_core.c cobex_core.h
-
-cobex_serial.o: cobex_serial.c cobex_serial.h cobex_core.c cobex_core.h
+cobex_put:   $(O2FILES)
+cobex_get:   $(O2FILES)
+cobex_ls:    $(O2FILES)
+cobex_rm:    $(O2FILES)
+cobex_mkdir: $(O2FILES)
+cobex_capa:  $(O2FILES)
+
+cobex_ls: LDLIBS += -lexpat
+
+-include .depend
+.depend: $(CFILES) $(HFILES)
+	$(CC) -MM $^ > .depend
 
 clean:
-	rm -f *.o
-	cd modeldb && make clean
+	rm -f *.o $(PROGS)
 
 printfiles: $(CFILES) $(HFILES)
 	@echo $?
@@ -88,3 +50,5 @@
 
 dist-contrib :
 	cd contrib && make dist VERSION=$(VERSION)
+
+.PHONY: all clean dist dist2 dist-modeldb dist-contrib model printfiles