b1da4b18fe592be156e73ae52298343238f7f3a3
[openjpeg.git] / Makefile.nix
1 #top Makefile.nix
2 include  config.nix
3
4 TARGET  = openjpeg
5 COMPILERFLAGS = -Wall -O3 -ffast-math -std=c99 -fPIC
6
7 INCLUDE = -I. -Ilibopenjpeg
8 LIBRARIES = -lstdc++
9
10 SRCS = ./libopenjpeg/bio.c ./libopenjpeg/cio.c ./libopenjpeg/dwt.c \
11  ./libopenjpeg/event.c ./libopenjpeg/image.c ./libopenjpeg/j2k.c \
12  ./libopenjpeg/j2k_lib.c ./libopenjpeg/jp2.c ./libopenjpeg/jpt.c \
13  ./libopenjpeg/mct.c ./libopenjpeg/mqc.c ./libopenjpeg/openjpeg.c \
14  ./libopenjpeg/pi.c ./libopenjpeg/raw.c ./libopenjpeg/t1.c \
15  ./libopenjpeg/t2.c ./libopenjpeg/tcd.c ./libopenjpeg/tgt.c \
16
17 INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h \
18  ./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h \
19  ./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h \
20  ./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h \
21  ./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h \
22  ./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h \
23  ./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_malloc.h \
24  ./libopenjpeg/opj_includes.h
25
26 INSTALL_LIBDIR = $(prefix)/lib
27 headerdir = openjpeg-$(MAJOR).$(MINOR)
28 INSTALL_INCLUDE = $(prefix)/include/$(headerdir)
29
30 # Converts cr/lf to just lf
31 DOS2UNIX = dos2unix
32
33 MODULES = $(SRCS:.c=.o)
34
35 CFLAGS = $(COMPILERFLAGS) $(INCLUDE)
36
37 LIBNAME = lib$(TARGET)
38
39 ifeq ($(ENABLE_SHARED),yes)
40 SHAREDLIB = $(LIBNAME).so.$(MAJOR).$(MINOR).$(BUILD)
41 else
42 STATICLIB = $(LIBNAME).a
43 endif
44
45 default: all
46
47 all: OpenJPEG
48         make -C codec -f Makefile.nix all
49         make -C mj2 -f Makefile.nix all
50 ifeq ($(WITH_JPWL),yes)
51         make -C jpwl -f Makefile.nix all
52 endif
53 ifeq ($(WITH_JP3D),yes)
54         make -C jp3d -f Makefile.nix all
55 endif
56
57 dos2unix:
58         @$(DOS2UNIX) $(SRCS) $(INCLS)
59
60 OpenJPEG: $(STATICLIB) $(SHAREDLIB)
61         install -d bin
62 ifeq ($(ENABLE_SHARED),yes)
63         install -m 755 $(SHAREDLIB) bin
64         (cd bin && ln -sf $(SHAREDLIB) $(LIBNAME).so.$(MAJOR).$(MINOR))
65         (cd bin && ln -sf $(SHAREDLIB) $(LIBNAME).so)
66 else
67         install -m 644 $(STATICLIB) bin
68 endif
69
70 .c.o:
71         $(CC) $(CFLAGS) -c $< -o $@
72
73 ifeq ($(ENABLE_SHARED),yes)
74 $(SHAREDLIB): $(MODULES)
75         $(CC) -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES)
76 else
77 $(STATICLIB): $(MODULES)
78         rm -f $(STATICLIB)
79         $(AR) r $@ $(MODULES)
80 endif
81
82 install: OpenJPEG
83         install -d $(DESTDIR)$(INSTALL_LIBDIR) 
84 ifeq ($(ENABLE_SHARED),yes)
85         install -m 755 -o root -g root $(SHAREDLIB) $(DESTDIR)$(INSTALL_LIBDIR)
86         (cd $(DESTDIR)$(INSTALL_LIBDIR) && \
87         ln -sf $(SHAREDLIB) $(LIBNAME).so.$(MAJOR).$(MINOR) )
88         (cd $(DESTDIR)$(INSTALL_LIBDIR) && \
89         ln -sf $(SHAREDLIB) $(LIBNAME).so )
90 else
91         install -m 644 -o root -g root $(STATICLIB) $(DESTDIR)$(INSTALL_LIBDIR)
92         (cd $(DESTDIR)$(INSTALL_LIBDIR) && ranlib $(STATICLIB) )
93 endif
94         install -d $(DESTDIR)$(INSTALL_INCLUDE)
95         install -m 644 -o root -g root libopenjpeg/openjpeg.h \
96         $(DESTDIR)$(INSTALL_INCLUDE)
97         (cd $(DESTDIR)$(prefix)/include && \
98         ln -sf $(headerdir)/openjpeg.h openjpeg.h)
99         make -C codec -f Makefile.nix install
100         make -C mj2 -f Makefile.nix install
101 ifeq ($(WITH_JPWL),yes)
102         make -C jpwl -f Makefile.nix install
103 endif
104 ifeq ($(WITH_JP3D),yes)
105         make -C jp3d -f Makefile.nix install
106 endif
107         $(LDCONFIG)
108         make -C doc -f Makefile.nix install
109
110 ifeq ($(WITH_JPWL),yes)
111 jpwl-all:
112         make -C jpwl -f Makefile.nix all
113
114 jpwl-install: jpwl-all
115         make -C jpwl -f Makefile.nix install
116         $(LDCONFIG)
117
118 jpwl-clean:
119         make -C jpwl -f Makefile.nix clean
120
121 jpwl-uninstall:
122         make -C jpwl -f Makefile.nix uninstall
123 endif
124
125 ifeq ($(WITH_JP3D),yes)
126 jp3d-all:
127         make -C jp3d -f Makefile.nix all
128
129 jp3d-install: jp3d-all
130         make -C jp3d -f Makefile.nix install
131         $(LDCONFIG)
132
133 jp3d-clean:
134         make -C jp3d -f Makefile.nix clean
135
136 jp3d-uninstall:
137         make -C jp3d -f Makefile.nix uninstall
138 endif
139
140 doc-all:
141         make -C doc -f Makefile.nix all
142
143 doc-install: doc-all
144         make -C doc -f Makefile.nix install
145
146 clean:
147         rm -rf bin
148         rm -f core u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB)
149         make -C codec -f Makefile.nix clean
150         make -C mj2 -f Makefile.nix clean
151         make -C doc -f Makefile.nix clean
152 ifeq ($(WITH_JPWL),yes)
153         make -C jpwl -f Makefile.nix clean
154 endif
155 ifeq ($(WITH_JP3D),yes)
156         make -C jp3d -f Makefile.nix clean
157 endif
158
159 doc-clean:
160         make -C doc -f Makefile.nix clean
161
162 uninstall:
163 ifeq ($(ENABLE_SHARED),yes)
164         (cd $(DESTDIR)$(INSTALL_LIBDIR) && \
165         rm -f $(LIBNAME).so $(LIBNAME).so.$(MAJOR).$(MINOR) $(SHAREDLIB) )
166 else
167         rm -f $(DESTDIR)$(INSTALL_LIBDIR)/$(STATICLIB)
168 endif
169         $(LDCONFIG)
170         rm -f $(DESTDIR)$(prefix)/include/openjpeg.h
171         rm -rf $(DESTDIR)$(INSTALL_INCLUDE)
172         make -C codec -f Makefile.nix uninstall
173         make -C mj2 -f Makefile.nix uninstall
174         make -C doc -f Makefile.nix uninstall
175 ifeq ($(WITH_JPWL),yes)
176         make -C jpwl -f Makefile.nix uninstall
177 endif
178 ifeq ($(WITH_JP3D),yes)
179         make -C jp3d -f Makefile.nix uninstall
180 endif
181
182 distclean: clean
183         rm -rf bin