changeset 20:669f7080a8dc

reworked Makefile so that shared object would be built
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 25 Feb 2009 22:54:07 +0900
parents 5cd8212bea78
children b63f5c100e5a
files arib25v023/arib25/src/Makefile
diffstat 1 files changed, 44 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/arib25v023/arib25/src/Makefile	Wed Feb 25 19:36:17 2009 +0900
+++ b/arib25v023/arib25/src/Makefile	Wed Feb 25 22:54:07 2009 +0900
@@ -1,25 +1,52 @@
-# PC/SC Lite libraries and headers.
-PCSC_CFLAGS ?= `pkg-config libpcsclite --cflags`
-PCSC_LDLIBS ?= `pkg-config libpcsclite --libs`
+PREFIX = /usr/local
+MAJOR = 0
+MINOR = 2
+REVISION = 3
+VER = $(MAJOR).$(MINOR).$(REVISION)
+
+DEST_HEADER = $(PREFIX)/include/arib25
 
 CC     = gcc
-CFLAGS = -Wall -O2 -g $(PCSC_CFLAGS) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-LDLIBS = $(PCSC_LDLIBS) -lm
- 
-TARGET = b25
-OBJS   = arib_std_b25.o b_cas_card.o multi2.o td.o ts_section_parser.o
+PCSC_CFLAGS ?= `pkg-config libpcsclite --cflags`
+CPPFLAGS = -Wall $(PCSC_CFLAGS) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+CFLAGS = -O2 -g -fPIC
 
-all: $(TARGET)
+PCSC_LIBS ?= `pkg-config libpcsclite --libs`
+LIBS = $(PCSC_LIBS) -lm
+LDFLAGS ?=
 
-arib_std_b25.o: arib_std_b25.c arib_std_b25.h portable.h b_cas_card.h arib_std_b25_error_code.h multi2.h ts_section_parser.h ts_common_types.h
-b_cas_card.o: b_cas_card.c b_cas_card.h portable.h b_cas_card_error_code.h 
-multi2.o: multi2.c multi2.h portable.h multi2_error_code.h 
-td.o: td.c arib_std_b25.h portable.h b_cas_card.h 
-ts_section_parser.o: ts_section_parser.c ts_section_parser.h ts_common_types.h portable.h ts_section_parser_error_code.h
+OBJS   = arib_std_b25.o b_cas_card.o multi2.o td.o ts_section_parser.o
+HEADERS = arib_std_b25.h b_cas_card.h portable.h
+TARGET_APP = b25
+TARGET_LIB = libarib25.so
+TARGETS = $(TARGET_APP) $(TARGET_LIB)
+DEPEND = Makefile.dep
+SONAME = $(TARGET_LIB).$(MAJOR)
 
-$(TARGET): $(OBJS)
-	$(CC) $(LDLIBS) -o $(TARGET) $(OBJS)
+all: $(TARGETS)
 
 clean:
 	rm -f *.o
-	rm -f $(TARGET)
+	rm -f $(TARGETS)
+
+$(TARGET_APP): $(OBJS)
+	$(CC) $(LDFLAGS) -o $(TARGET_APP) $(OBJS) $(LIBS)
+
+$(TARGET_LIB): $(OBJS)
+	$(CC) $(LDFLAGS) -shared -o $(TARGET_LIB) $(OBJS) $(LIBS) -Wl,-soname,$(SONAME)
+
+$(DEPEND):
+	$(CC) -MM $(OBJS:.o=.c) $(CPPFLAGS) > $@
+
+install: $(TARGET) install-headers
+	install -m755 b25 $(PREFIX)/bin
+	install -m755 $(TARGET_LIB) $(PREFIX)/lib/$(TARGET_LIB).$(VER)
+	ln -sf $(PREFIX)/lib/$(TARGET_LIB).$(VER) $(PREFIX)/lib/$(TARGET_LIB).$(MAJOR)
+	ln -sf $(PREFIX)/lib/$(TARGET_LIB).$(MAJOR) $(PREFIX)/lib/$(TARGET_LIB)
+	ldconfig
+
+install-headers:
+	mkdir -p $(DEST_HEADER)
+	install -m644 $(HEADERS) $(DEST_HEADER)
+
+-include Makefile.dep