1#
2# Makefile
3#
4# Copyright (C) 2004 Koji Nakamaru
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software Foundation,
18# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19#
20
21TARGET=fv
22SRCS=\
23	CApp.c \
24	common.c \
25	error.c \
26	CAppFV.c \
27	CFile.c \
28	CReader.c \
29	CReaderHDR.c \
30	CReaderPFM.c \
31	CImage.c \
32
33OBJS=$(subst .c,.o,$(SRCS))
34DEPS=$(subst .c,.d,$(SRCS))
35
36OPTIMIZER=release
37
38ifeq ("$(OPTIMIZER)", "release")
39OPT=\
40-Wall -O3 -march=i686 \
41-fomit-frame-pointer -finline-functions -fstrength-reduce \
42-falign-loops=2 -falign-jumps=2 -falign-functions=2 \
43-DNDEBUG
44else
45OPT=\
46-Wall -g
47endif
48
49ifeq ("$(shell uname -o)", "Cygwin")
50CXX?=g++-3
51CXXFLAGS?=\
52$(OPT) -mno-cygwin -mwindows -Inocygwin/inc -DFREEGLUT_STATIC
53LDFLAGS?=\
54-Lnocygwin/lib -lpng15 -lfreeglut_static -lz -lbz2 -llzma -lpthreadGC2 \
55-lglu32 -lopengl32 -lwinmm
56else
57ifeq ("$(shell uname -o)", "Darwin")
58CXXFLAGS?=\
59$(OPT) -I/opt/local/include
60LDFLAGS?=\
61-framework OpenGL -framework GLUT -framework Foundation \
62-L/opt/local/lib -lpng15 -lz -lbz2 -llzma -lpthread \
63-lm
64else
65CXXXFLAGS=\
66$(OPT)
67LDFLAGS?=\
68-lpng -lz -lbz2 -llzma -lpthread \
69-lfreeglut -lGLU -lGL -L/usr/X11R6/lib -lXi -lXmu -lX11 -lXext -lSM \
70-lm
71endif
72endif
73
74ifeq ("$(shell uname -o)", "Cygwin")
75$(TARGET): $(OBJS)
76	windres -i resource.rc -o resource.o
77	$(CXX) $(CXXFLAGS) -o $@ $(OBJS) resource.o $(LDFLAGS)
78else
79$(TARGET): $(OBJS)
80	$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)
81endif
82
83allclean: clean
84	rm -f $(TARGET) $(TARGET).exe
85
86clean:
87	rm -f $(OBJS) $(DEPS) *~
88
89ifneq "$(MAKECMDGOALS)" "clean"
90  -include $(DEPS)
91endif
92define make-depend
93  $(CXX) -MM -MF $3 -MP -MT $2 $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) $1
94endef
95
96%.o: %.c
97	@$(call make-depend,$<,$@,$(subst .o,.d,$@))
98	$(COMPILE.C) $(OUTPUT_OPTION) $<
99
100archive: allclean $(TARGET)
101	version=`grep '#define k_version' CAppFV.c | sed -e 's/#define k_version	*"//' -e 's/"//'`; \
102	name=fv-src-$$version; \
103	mkdir $$name; \
104	cp AUTHORS COPYING ChangeLog INSTALL NEWS README $$name; \
105	cp -r Makefile *.[ch] $$name; \
106	cp resource.ico resource.rc resource.xpm $$name; \
107	rm -f $$name.zip; \
108	zip -qr9 $$name.zip $$name; \
109	rm -rf $$name; \
110	name=$$name-win32; \
111	mkdir $$name; \
112	cp AUTHORS COPYING ChangeLog INSTALL NEWS README $$name; \
113	cp -r Makefile *.[ch] $$name; \
114	cp resource.ico resource.rc resource.xpm $$name; \
115	mkdir $$name/nocygwin; \
116	cp -r nocygwin/inc nocygwin/lib $$name/nocygwin; \
117	rm -f $$name.zip; \
118	zip -qr9 $$name.zip $$name; \
119	rm -rf $$name; \
120	name=fv-bin-$$version-win32; \
121	mkdir $$name ; \
122	cp fv.exe pthreadGC2.dll README $$name; \
123	rm -f $$name.zip; \
124	zip -qr9 $$name.zip $$name; \
125	rm -rf $$name
126