$OpenBSD: patch-Makefile,v 1.4 2009/07/14 15:35:24 sthen Exp $ --- Makefile.orig Fri Dec 21 10:39:41 2007 +++ Makefile Tue Jul 14 13:51:57 2009 @@ -11,7 +11,7 @@ INCLUDE = -Ilibopenjpeg CC = gcc AR = ar -PREFIX = /usr +PREFIX ?= /usr INSTALL_LIBDIR = $(PREFIX)/lib INSTALL_INCLUDE = $(PREFIX)/include @@ -19,14 +19,15 @@ INSTALL_INCLUDE = $(PREFIX)/include DOS2UNIX = dos2unix COMPILERFLAGS = -Wall -O3 -ffast-math -std=c99 -fPIC -LIBRARIES = -lstdc++ +LIBRARIES = MODULES = $(SRCS:.c=.o) +SOMODULES = $(SRCS:.c=.so) CFLAGS = $(COMPILERFLAGS) $(INCLUDE) TARGET = openjpeg STATICLIB = lib$(TARGET).a -SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so +SHAREDLIB = lib$(TARGET).so.$(LIBopenjpeg_VERSION) LIBNAME = lib$(TARGET).so.$(VER_MAJOR) @@ -47,23 +48,26 @@ dos2unix: OpenJPEG: $(STATICLIB) $(SHAREDLIB) +.SUFFIXES: .c .o .so + .c.o: $(CC) $(CFLAGS) -c $< -o $@ +.c.so: + $(CC) $(CFLAGS) -fPIC -c $< -o $@ + $(STATICLIB): $(MODULES) $(AR) r $@ $(MODULES) -$(SHAREDLIB): $(MODULES) - $(CC) -s -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES) +$(SHAREDLIB): $(SOMODULES) + $(CC) -shared -fPIC -o $@ $(SOMODULES) $(LIBRARIES) install: OpenJPEG - install -d '$(DESTDIR)$(INSTALL_LIBDIR)' '$(DESTDIR)$(INSTALL_INCLUDE)' - install -m 644 -o root -g root $(STATICLIB) '$(DESTDIR)$(INSTALL_LIBDIR)' - ranlib '$(DESTDIR)$(INSTALL_LIBDIR)/$(STATICLIB)' - install -m 755 -o root -g root $(SHAREDLIB) '$(DESTDIR)$(INSTALL_LIBDIR)' - ln -sf $(SHAREDLIB) '$(DESTDIR)$(INSTALL_LIBDIR)/$(LIBNAME)' - install -m 644 -o root -g root libopenjpeg/openjpeg.h '$(DESTDIR)$(INSTALL_INCLUDE)' - -ldconfig + ${BSD_INSTALL_DATA_DIR} '$(INSTALL_LIBDIR)' '$(INSTALL_INCLUDE)' + ${BSD_INSTALL_DATA} $(STATICLIB) '$(INSTALL_LIBDIR)' + ranlib '$(INSTALL_LIBDIR)/$(STATICLIB)' + ${BSD_INSTALL_DATA} $(SHAREDLIB) '$(INSTALL_LIBDIR)' + ${BSD_INSTALL_DATA} libopenjpeg/openjpeg.h '$(INSTALL_INCLUDE)' clean: rm -rf core dist/ u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)