summaryrefslogtreecommitdiffstats
path: root/libdha/Makefile
blob: 8dce5cd0dcf4b908951312748de1ed725251fbbf (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
# makefile

include ../config.mak

MAJOR_VERSION = 0
MINOR_VERSION = 1
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION) 


ifeq ($(TARGET_OS),CYGWIN)
SHORTNAME = libdha.dll
else
SHORTNAME = libdha.so.$(MAJOR_VERSION)
SONAME_FLAGS = -Wl,-soname,$(SHORTNAME)
#SHORTNAME = libdha.so
VSHORTNAME = libdha.so
endif
LIBNAME = libdha.so.$(VERSION)

SRCS=libdha.c mtrr.c pci.c pci_names.c
OBJS=$(SRCS:.c=.o)

CFLAGS  = $(OPTFLAGS) -fPIC -I. -I..
LIBS = 
ifeq ($(TARGET_OS),OpenBSD)
ifeq ($(TARGET_ARCH_X86),yes)
LIBS += -li386
endif
endif

.SUFFIXES: .c .o

# .PHONY: all clean

.c.o:
	$(CC) -c $(CFLAGS) -o $@ $<

$(LIBNAME):     $(OBJS)
	#$(CC) -shared $(SONAME_FLAGS) -o $(LIBNAME) $(OBJS) $(LIBS)
	$(CC) -shared -Wl,-soname -Wl,$(LIBNAME) -o $(LIBNAME) $(OBJS) $(LIBS)
	ln -sf $(LIBNAME) $(SHORTNAME)
	ln -sf $(LIBNAME) $(VSHORTNAME)

all:    $(LIBNAME) $(SHORTNAME)

pci_names.c:
	$(AWK) -f pci_db2c.awk oth/pci.db

test:
	$(CC) test.c -o test $(SHORTNAME)

clean:
	rm -f *.o *.so *.so.* *~

distclean:
	rm -f Makefile.bak *.o *.so *.so.* test *~ .depend
	rm -f pci_dev_ids.c pci_ids.h pci_names.c pci_names.h pci_vendors.h pci.db

dep:    depend

depend:
	$(CC) -MM $(CFLAGS) $(SRCS) 1>.depend

install:
	mkdir -p $(prefix)/lib
	install -m 755 -s -p $(LIBNAME) $(prefix)/lib/$(LIBNAME)
	rm -f $(prefix)/lib/libdha.so
	ln -sf $(LIBNAME) $(prefix)/lib/$(SHORTNAME)
ifeq ($(TARGET_OS),OpenBSD)
	ldconfig -R
else
	ldconfig
endif

#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif