1
2#	Define here the relative path from this file to the folder containing the autogen.sh script.
3builddir = ../../..
4
5#	Define here the relative path from the the folder containing the autogen.sh script to the folder containing the sdl.m4 file.
6sdlm4dir = src/Unix/darwin
7
8#	Configure the aranym ppc binary.
9CONFIGURE_OPTIONS_ppc  = --host=powerpc-apple-darwin8.10.0 --enable-fullmmu --enable-opengl --enable-fpe=uae --enable-nfjpeg --enable-nfosmesa --enable-ethernet=yes --enable-vblupdates=yes
10
11#	Configure the aranym x86 binary.
12CONFIGURE_OPTIONS_i386 = --host=i386-apple-darwin8.10.0 --enable-opengl --enable-jit-compiler --enable-nfjpeg --enable-nfosmesa --enable-ethernet=yes --enable-vblupdates=yes
13
14#	This flag is needed to by the autogen.sh script.
15ACLOCAL_FLAGS = "-I $(sdlm4dir)/"
16
17
18.PHONY: universal i386 ppc clean clean_i386 clean_ppc touch
19
20
21#	The universal target builds the x86 executable, then the ppc executable and finally merges both into an universal binary which is then put into the application bundle.
22universal: $(builddir)/depend_i386 $(builddir)/depend_powerpc
23	$(MAKE) -C $(builddir) -f Makefile_i386 aranym_i386
24	$(MAKE) -C $(builddir) -f Makefile_ppc aranym_powerpc
25	#	create the universal binary from the ppc and i386 versions
26	lipo -create $(builddir)/aranym_powerpc $(builddir)/aranym_i386 -output $(builddir)/aranym
27	#	now just build the bundle containing the just build universal binary
28	$(MAKE) -C $(builddir) -f Makefile_ppc
29	rm -rf ARAnyM.app
30	mv $(builddir)/ARAnyM.app .
31
32#	The i386 target builds the x86 executable and puts it into the application bundle.
33i386: $(builddir)/depend_i386
34	$(MAKE) -C $(builddir) -f Makefile_i386 aranym_i386
35	cp -p $(builddir)/aranym_i386 $(builddir)/aranym
36	$(MAKE) -C $(builddir) -f Makefile_i386
37	rm -rf ARAnyM.app
38	mv $(builddir)/ARAnyM.app .
39
40
41#	The ppc target builds the powerpc executable and puts it into the application bundle.
42ppc: $(builddir)/depend_powerpc
43	$(MAKE) -C $(builddir) -f Makefile_ppc aranym_powerpc
44	cp -p $(builddir)/aranym_powerpc $(builddir)/aranym
45	$(MAKE) -C $(builddir) -f Makefile_ppc
46	rm -rf ARAnyM.app
47	mv $(builddir)/ARAnyM.app .
48
49
50#	The depend target builds both dependencies for x86 and powerpc.
51depend: depend_i386 depend_ppc
52
53
54#	The depend_i386 target builds only the dependencies for x86.
55depend_i386: $(builddir)/depend_i386
56
57
58#	The depend_ppc target builds only the dependencies for powerpc.
59depend_ppc: $(builddir)/depend_powerpc
60
61
62#	The clean target removes all build files.
63clean: clean_i386 clean_ppc
64
65
66#	The clean_i386 target removes all build files related to the x86 binary and the application bundle.
67clean_i386:
68	if test -f $(builddir)/Makefile_i386; then \
69		$(MAKE) -C $(builddir) -f Makefile_i386 clean; \
70	fi
71
72
73#	The clean_ppc target removes all build files related to the ppc binary and the application bundle.
74clean_ppc:
75	if test -f $(builddir)/Makefile_ppc; then \
76		$(MAKE) -C $(builddir) -f Makefile_ppc clean; \
77	fi
78
79
80#	The clean target removes all build files.
81distclean: distclean_i386 distclean_ppc
82
83
84#	The clean_i386 target removes all build files related to the x86 binary and the application bundle.
85distclean_i386:
86	if test -f $(builddir)/Makefile_i386; then \
87		$(MAKE) -C $(builddir) -f Makefile_i386 distclean; \
88		rm -f $(builddir)/Makefile_i386; \
89	fi
90	rm -f $(builddir)/configure_i386
91	rm -f $(builddir)/config_i386.h
92	rm -f $(builddir)/config_tmp.h
93
94
95#	The clean_ppc target removes all build files related to the ppc binary and the application bundle.
96distclean_ppc:
97	if test -f $(builddir)/Makefile_ppc; then \
98		$(MAKE) -C $(builddir) -f Makefile_ppc distclean; \
99		rm -f $(builddir)/Makefile_ppc; \
100	fi
101	rm -f $(builddir)/configure_ppc
102	rm -f $(builddir)/config_ppc.h
103	rm -f $(builddir)/config_tmp.h
104
105
106#	This target touches both makefiles to avoid another configure run if something has been changed in the Makefile.in file.
107touch:
108	touch $(builddir)/Makefile_i386
109	touch $(builddir)/Makefile_ppc
110
111
112#	This target combines both configurations into one config_tmp.h file.
113$(builddir)/config_tmp.h:
114	echo "#ifndef CONFIG_H" > $@
115	echo "    #define CONFIG_H" >> $@
116	echo "    #if CPU_powerpc" >> $@
117	echo "        #include \"config_ppc.h\"" >> $@
118	echo "    #elif CPU_i386" >> $@
119	echo "        #include \"config_i386.h\"" >> $@
120	echo "    #else" >> $@
121	echo "        #error Unsupported CPU type" >> $@
122	echo "    #endif" >> $@
123	echo "#endif" >> $@
124
125
126#	This target calls autogen.sh, configure and make depend and renames the generic config* files as config*_i386* to avoid overwriting if configuration for the ppc binary is done.
127$(builddir)/config_i386.h: $(builddir)/configure.ac $(builddir)/autogen.sh $(builddir)/acinclude.m4 sdl.m4 $(builddir)/config.guess
128	cd $(builddir)/; NO_CONFIGURE=yes ACLOCAL_FLAGS=$(ACLOCAL_FLAGS) ./autogen.sh;
129	cd $(builddir)/; ./configure $(CONFIGURE_OPTIONS_i386)
130	mv $(builddir)/configure $(builddir)/configure_i386
131	mv $(builddir)/config.log $(builddir)/config_i386.log
132	mv $(builddir)/config.h $(builddir)/config_i386.h
133
134
135#	This target calls autogen.sh, configure and make depend and renames the generic config* files as config*_ppc* to avoid overwriting if configuration for the x86 binary is done.
136$(builddir)/config_ppc.h: $(builddir)/configure.ac $(builddir)/autogen.sh $(builddir)/acinclude.m4 sdl.m4 $(builddir)/config.guess
137	cd $(builddir)/; NO_CONFIGURE=yes ACLOCAL_FLAGS=$(ACLOCAL_FLAGS) ./autogen.sh;
138	cd $(builddir)/; ./configure $(CONFIGURE_OPTIONS_ppc)
139	mv $(builddir)/configure $(builddir)/configure_ppc
140	mv $(builddir)/config.log $(builddir)/config_ppc.log
141	#mv $(builddir)/config.h $(builddir)/config_ppc.h
142	# 10.3.9 compatibility:
143	cat $(builddir)/config.h | sed 's/#define HAVE_SYS_STATVFS_H 1/\/* #undef HAVE_SYS_STATVFS_H *\//' > $(builddir)/config_ppc.h
144	rm -f $(builddir)/config.h
145
146
147#	This target calls make to buid the dependency file for x86.
148$(builddir)/depend_i386: $(builddir)/Makefile_i386 $(builddir)/config_tmp.h
149	cp $(builddir)/config_tmp.h $(builddir)/config.h
150	$(MAKE) -C $(builddir) -f Makefile_i386 depend
151
152
153#	This target calls make to buid the dependency file for powerpc.
154$(builddir)/depend_powerpc: $(builddir)/Makefile_ppc $(builddir)/config_tmp.h
155	cp $(builddir)/config_tmp.h $(builddir)/config.h
156	$(MAKE) -C $(builddir) -f Makefile_ppc depend
157
158
159#	After a configuration for x86 this target renames the created Makefile to Makefile_i386
160$(builddir)/Makefile_i386: $(builddir)/config_i386.h $(builddir)/Makefile.in
161	mv $(builddir)/Makefile $(builddir)/Makefile_i386
162	touch $(builddir)/Makefile_i386
163
164
165#	After a configuration for ppc this target renames the created Makefile to Makefile_ppc
166$(builddir)/Makefile_ppc: $(builddir)/config_ppc.h $(builddir)/Makefile.in
167	mv $(builddir)/Makefile $(builddir)/Makefile_ppc
168	touch $(builddir)/Makefile_ppc
169
170
171