summaryrefslogtreecommitdiff
blob: d1d5606faab6ce0515cf53e2bdb9e0a29df4931a (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
--- Makefile
+++ Makefile
@@ -5,20 +5,15 @@
 VERPAT		= 7
 VERSION		= $(VERMAJ).$(VERMIN).$(VERPAT)
 
-# Define SHARED as 1 for Linux shared ELF library
-#SHARED		= 1
-
-ifeq ($(SHARED),1)
 LIBTARGET	= lib$(DIST).so.$(VERSION)
 LIBTARGETSO	= lib$(DIST).so
 LIBTARGETSOMAJ	= $(LIBTARGETSO).$(VERMAJ)
 CCSHRD		= -fPIC
-else
-LIBTARGET	= lib$(DIST).a
-endif
+
+LIBTARGETA	= lib$(DIST).a
 
 LIBHEAD		= $(DIST).h
-TARGETS		= $(LIBTARGET)
+TARGETS		= $(LIBTARGET) $(LIBTARGETA)
 
 INSTBASEDIR	= /usr/local
 INSTLIBDIR	= $(INSTBASEDIR)/lib
@@ -27,12 +22,12 @@
 INSTALLPROG	= install -m 755
 MKDIRP		= install -d -m 755
 
-CC		= gcc
-OPTIM		= -O2
-
-INCDIR		= -I.
-
-CCOPT		= -s -Wall $(OPTIM) $(INCDIR)
+CC		?= gcc
+AR		?= ar
+ARFLAGS ?= rc
+RANLIB	?= ranlib
+CPPFLAGS += -I.
+CFLAGS += -Wall
 
 # Object files to store in the library
 LIBOBJS		= shhopt.o
@@ -43,21 +38,19 @@
 # don't worry if you get ranlib not found errors.  This probably means
 # that your ar does an implicit ranlib and you do not need to run ranlib
 # separately.  This error is harmless.
-$(LIBTARGET): $(LIBOBJS)
-ifeq ($(SHARED),1)
-	$(CC) -shared -Wl,-soname,$(LIBTARGETSOMAJ) -o $(LIBTARGET) $(LIBOBJS)
-else
-	ar rc $(LIBTARGET) $(LIBOBJS)
-	ranlib $(LIBTARGET) || true
-endif
+$(LIBTARGET): $(LIBOBJS:.o=.lo)
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$(LIBTARGETSOMAJ) -o $@ $^
+$(LIBTARGETA): $(LIBOBJS)
+	$(AR) $(ARFLAGS) $@ $^
+	$(RANLIB) $@
 
 # Note that you may need GNU's -liberty if your libc lacks strtoul
 example: $(LIBTARGET) example.o
 	$(CC) -o example example.c \
 		-L. -I. -L$(INSTLIBDIR) -I$(INSTINCDIR) -lshhopt
 
-.c.o:
-	$(CC) $(CCSHRD) -o $@ -c $(CCOPT) $<
+%.lo: %.c
+	$(COMPILE.c) $(CCSHRD) $^ -o $@
 
 depend dep:
 	$(CC) $(INCDIR) -MM *.c >depend
@@ -73,7 +66,7 @@
 endif
 
 clean:
-	rm -f *.o core *~ depend
+	rm -f *.o *.lo *.so* *.a core *~ depend
 
 chmod:
 	chmod a+r *